Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,23 @@ class _MyAppState extends State<MyApp> with WindowListener {
final auth = context.read<AuthProvider>();
if (auth.isAuthenticated) {
context.read<ShortcutRegistry>().dispatch(
AppShortcutAction.newSession,
);
AppShortcutAction.newSession,
);
}
},
onRefresh: () {
final auth = context.read<AuthProvider>();
if (auth.isAuthenticated) {
context.read<SessionProvider>().fetchSessions(
auth.client,
authToken: auth.token,
force: true,
);
auth.client,
authToken: auth.token,
force: true,
);
context.read<SourceProvider>().fetchSources(
auth.client,
authToken: auth.token,
force: true,
);
auth.client,
authToken: auth.token,
force: true,
);
}
},
);
Expand Down
46 changes: 23 additions & 23 deletions lib/models/activity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class PlanStep {
}

Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'description': description,
'index': index,
};
'id': id,
'title': title,
'description': description,
'index': index,
};
}

class Plan {
Expand All @@ -52,10 +52,10 @@ class Plan {
}

Map<String, dynamic> toJson() => {
'id': id,
'steps': steps.map((e) => e.toJson()).toList(),
'createTime': createTime,
};
'id': id,
'steps': steps.map((e) => e.toJson()).toList(),
'createTime': createTime,
};
}

class AgentMessaged {
Expand All @@ -78,8 +78,8 @@ class PlanGenerated {
final Plan plan;
PlanGenerated({required this.plan});
factory PlanGenerated.fromJson(Map<String, dynamic> json) => PlanGenerated(
plan: getObjectFunctionPropOrThrow(json, 'plan', Plan.fromJson),
);
plan: getObjectFunctionPropOrThrow(json, 'plan', Plan.fromJson),
);
Map<String, dynamic> toJson() => {'plan': plan.toJson()};
}

Expand Down Expand Up @@ -144,10 +144,10 @@ class GitPatch {
}

Map<String, dynamic> toJson() => {
'unidiffPatch': unidiffPatch,
'baseCommitId': baseCommitId,
'suggestedCommitMessage': suggestedCommitMessage,
};
'unidiffPatch': unidiffPatch,
'baseCommitId': baseCommitId,
'suggestedCommitMessage': suggestedCommitMessage,
};
}

class ChangeSet {
Expand Down Expand Up @@ -185,15 +185,15 @@ class BashOutput {
required this.exitCode,
});
factory BashOutput.fromJson(Map<String, dynamic> json) => BashOutput(
command: getStringPropOrThrow(json, 'command'),
output: getStringPropOrThrow(json, 'output'),
exitCode: getNumberPropOrThrow(json, 'exitCode')!.toInt(),
);
command: getStringPropOrThrow(json, 'command'),
output: getStringPropOrThrow(json, 'output'),
exitCode: getNumberPropOrThrow(json, 'exitCode')!.toInt(),
);
Map<String, dynamic> toJson() => {
'command': command,
'output': output,
'exitCode': exitCode,
};
'command': command,
'output': output,
'exitCode': exitCode,
};
}

class Artifact {
Expand Down
8 changes: 4 additions & 4 deletions lib/models/bulk_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class BulkActionStep {
Map<String, dynamic> toJson() => {'type': type.index, 'message': message};

factory BulkActionStep.fromJson(Map<String, dynamic> json) => BulkActionStep(
type: BulkActionType
.values[(getNumberPropOrThrow(json, 'type') as num).toInt()],
message: getStringPropOrDefault(json, 'message', null),
);
type: BulkActionType
.values[(getNumberPropOrThrow(json, 'type') as num).toInt()],
message: getStringPropOrDefault(json, 'message', null),
);
}

enum BulkTargetType { visible, filtered }
Expand Down
2 changes: 1 addition & 1 deletion lib/models/cache_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CacheMetadata {
final bool isWatched;
final bool isHidden;
final bool
hasPendingUpdates; // True if message sent but not yet fully refreshed/synced response
hasPendingUpdates; // True if message sent but not yet fully refreshed/synced response
final List<PendingMessage> pendingMessages;
final String? reasonForLastUnread;
final List<String> recentErrors;
Expand Down
97 changes: 51 additions & 46 deletions lib/models/filter_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class FilterContext {
final Session session;
final CacheMetadata metadata;
final dynamic
queueProvider; // Using dynamic to avoid hard dependency on provider
queueProvider; // Using dynamic to avoid hard dependency on provider

FilterContext({
required this.session,
Expand Down Expand Up @@ -200,9 +200,9 @@ class AndElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'and',
'children': children.map((c) => c.toJson()).toList(),
};
'type': 'and',
'children': children.map((c) => c.toJson()).toList(),
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -288,9 +288,9 @@ class TimeFilterElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'time',
'timeFilter': timeFilter.toJson(),
};
'type': 'time',
'timeFilter': timeFilter.toJson(),
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -332,9 +332,9 @@ class OrElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'or',
'children': children.map((c) => c.toJson()).toList(),
};
'type': 'or',
'children': children.map((c) => c.toJson()).toList(),
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -416,9 +416,9 @@ class DisabledElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'disabled',
'child': child.toJson(),
};
'type': 'disabled',
'child': child.toJson(),
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -462,7 +462,8 @@ class TextElement extends FilterElement {
FilterState evaluate(FilterContext context) {
final query = text.toLowerCase();
final session = context.session;
final matches = (session.title?.toLowerCase().contains(query) ?? false) ||
final matches =
(session.title?.toLowerCase().contains(query) ?? false) ||
(session.name.toLowerCase().contains(query)) ||
(session.id.toLowerCase().contains(query)) ||
(session.state.toString().toLowerCase().contains(query)) ||
Expand Down Expand Up @@ -500,10 +501,10 @@ class PrStatusElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'pr_status',
'label': label,
'value': value,
};
'type': 'pr_status',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -541,10 +542,10 @@ class CiStatusElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'ci_status',
'label': label,
'value': value,
};
'type': 'ci_status',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -614,10 +615,10 @@ class LabelElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'label',
'label': label,
'value': value,
};
'type': 'label',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -710,10 +711,10 @@ class StatusElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'status',
'label': label,
'value': value,
};
'type': 'status',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
Expand All @@ -730,7 +731,8 @@ class StatusElement extends FilterElement {
return FilterState.explicitOut;
}

final matches = state.toString().toLowerCase() == query ||
final matches =
state.toString().toLowerCase() == query ||
state.name.toLowerCase() == query ||
state.displayName.toLowerCase() == query;

Expand Down Expand Up @@ -768,14 +770,15 @@ class SourceElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'source',
'label': label,
'value': value,
};
'type': 'source',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
final matches = context.session.sourceContext?.source.toLowerCase() ==
final matches =
context.session.sourceContext?.source.toLowerCase() ==
value.toLowerCase();
if (context.metadata.isHidden) {
return matches ? FilterState.implicitOut : FilterState.explicitOut;
Expand Down Expand Up @@ -878,10 +881,10 @@ class BranchElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'branch',
'label': label,
'value': value,
};
'type': 'branch',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
Expand Down Expand Up @@ -923,14 +926,15 @@ class TagElement extends FilterElement {

@override
Map<String, dynamic> toJson() => {
'type': 'tag',
'label': label,
'value': value,
};
'type': 'tag',
'label': label,
'value': value,
};

@override
FilterState evaluate(FilterContext context) {
final matches = context.session.tags?.any(
final matches =
context.session.tags?.any(
(t) => t.toLowerCase() == value.toLowerCase(),
) ??
false;
Expand Down Expand Up @@ -1052,7 +1056,8 @@ class HasCreatePrElement extends FilterElement {
@override
FilterState evaluate(FilterContext context) {
final session = context.session;
final matches = (session.prStatus == null || session.prStatus!.isEmpty) &&
final matches =
(session.prStatus == null || session.prStatus!.isEmpty) &&
(session.diffUrl != null ||
(session.changedFiles != null && session.changedFiles! > 0));

Expand Down
16 changes: 10 additions & 6 deletions lib/models/filter_element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,15 @@ class FilterElementBuilder {

if (root is AndElement || root is OrElement) {
final isAnd = root is AndElement;
final children =
root is AndElement ? root.children : (root as OrElement).children;
final children = root is AndElement
? root.children
: (root as OrElement).children;

// Simplify all children first
final simplifiedChildren =
children.map((c) => simplify(c)).whereType<FilterElement>().toList();
final simplifiedChildren = children
.map((c) => simplify(c))
.whereType<FilterElement>()
.toList();

if (simplifiedChildren.isEmpty) return null;
if (simplifiedChildren.length == 1) return simplifiedChildren.first;
Expand Down Expand Up @@ -455,8 +458,9 @@ class FilterElementBuilder {
}) {
if (root == null) return root;

final group =
isAnd ? AndElement([target, source]) : OrElement([target, source]);
final group = isAnd
? AndElement([target, source])
: OrElement([target, source]);

// If source is already in the tree (Move operation), remove it first
// Note: This logic assumes we handle 'move' by removing source first at the UI level or prior to calling this if needed.
Expand Down
Loading
Loading