Merge main into macos-self-update

This commit is contained in:
2026-11-13 14:34:21 +00:00
56 changed files with 1972 additions and 130 deletions
@@ -12,12 +12,17 @@ import 'package:pipelines_app/shell/destination.dart';
import 'conversation/chat_thread_fixtures.dart';
class _Gateway extends FakeChatGateway {
_Gateway({this.rows = const ['a', 'b', 'c']});
final List<String> rows;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'},
for (final id in rows)
{'id': id, 'title': 'Chat $id', if (id == 'closed') 'closed_at': 1},
],
});
}
@@ -57,12 +62,16 @@ Future<void> _chord(
await tester.pumpAndSettle();
}
Future<void> _setup(WidgetTester tester, {bool open = true}) async {
Future<void> _setup(
WidgetTester tester, {
bool open = true,
List<String> rows = const ['a', 'b', 'c'],
}) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = const Size(1800, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
final gateway = _Gateway(rows: rows)..history = (_) async => chatPage([]);
addTearDown(gateway.close);
await tester.pumpWidget(
MaterialApp(
@@ -133,20 +142,44 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('single pane with no shown window does nothing; empty workspace '
'does not consume', (tester) async {
await _setup(tester, open: false);
await _chord(tester);
expect(find.byType(ChatWorkspace), findsNothing);
testWidgets(
'single pane cycles list chats; empty workspace does not consume',
(tester) async {
await _setup(tester, open: false);
await _chord(tester);
expect(find.byType(ChatWorkspace), findsNothing);
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
_focusSidebar(tester);
await tester.pumpAndSettle();
await _chord(tester);
expect(find.byType(ChatWorkspace), findsOneWidget);
expect(_workspace(tester).paneCount, 1);
expect(_workspace(tester).activePane?.sessionId, 'b');
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isTrue);
await tester.pumpWidget(const SizedBox.shrink());
},
);
testWidgets('single pane skips closed and hidden-on-this-device chats', (
tester,
) async {
await _setup(tester, open: false, rows: ['a', 'hidden', 'c', 'closed']);
await tester.tap(_actions('hidden'));
await tester.pumpAndSettle();
await tester.tap(find.text('Hide on this device'));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
_focusSidebar(tester);
await tester.pumpAndSettle();
await _chord(tester);
expect(find.byType(ChatWorkspace), findsOneWidget);
expect(_workspace(tester).paneCount, 1);
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
expect(_editable(tester, 'a').controller.text, isEmpty);
expect(_workspace(tester).activePane?.sessionId, 'c');
await _chord(tester);
expect(_workspace(tester).activePane?.sessionId, 'a');
await _chord(tester, reverse: true);
expect(_workspace(tester).activePane?.sessionId, 'c');
await tester.pumpWidget(const SizedBox.shrink());
});
@@ -592,10 +592,8 @@ void main() {
await app.stop(tester);
});
testWidgets('with the tiling focused Ctrl+Tab goes to the top-most shown '
'window, and cycles the panes only when no window is shown', (
tester,
) async {
testWidgets('with the tiling focused Ctrl+Tab cycles the single pane chat '
'list and cycles panes when there are multiple panes', (tester) async {
await _saved('a', 'b', 'c');
final app = _App(_Store());
await app.start(tester);
@@ -603,20 +601,20 @@ void main() {
expect(app.floating, ['c']);
final controller = _workspace(tester);
// A window is shown: from the tiling, Ctrl+Tab takes the keyboard to it
// and the panes stay where they are.
// A shown floating chat is skipped while the single tiled pane cycles the
// remaining open chats.
await tester.tapAt(tester.getCenter(_input('a')));
await tester.pump();
expect(controller.activePane?.sessionId, 'a');
await _tab(tester);
expect(controller.activePane?.sessionId, 'a');
expect(_composerFocused(tester, 'c'), isTrue);
expect(controller.activePane?.sessionId, 'b');
expect(_composerFocused(tester, 'b'), isTrue);
expect(app.floating, ['c']);
// A single shown window has nothing to cycle to.
// It wraps back to the other non-floating chat.
await _tab(tester);
expect(controller.activePane?.sessionId, 'a');
expect(_composerFocused(tester, 'c'), isTrue);
expect(_composerFocused(tester, 'a'), isTrue);
expect(app.floating, ['c']);
// No window shown: the panes cycle and the hidden window stays hidden.
@@ -150,28 +150,25 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('Control Tab over one pane does nothing: it never brings up '
'another chat', (tester) async {
testWidgets('Control Tab over one pane cycles the sidebar chats in both '
'directions', (tester) async {
await _setup(tester);
await _openRow(tester, 'a');
final workspace = _workspace(tester);
await _controlTab(tester);
expect(workspace.activePane?.sessionId, 'a');
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
// Opening b replaces the lone pane; a is no longer shown anywhere.
await _openRow(tester, 'b');
await tester.enterText(_input('b'), 'Draft B');
await _focusSidebar(tester);
for (final shift in [false, true]) {
await _controlTab(tester, shift: shift);
expect(workspace.paneCount, 1);
expect(workspace.activePane?.sessionId, 'b');
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isFalse);
expect(_editable(tester, 'b').controller.text, 'Draft B');
for (final id in ['b', 'c', 'a']) {
await _controlTab(tester);
expect(workspace.activePane?.sessionId, id);
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
}
await _focusSidebar(tester);
for (final id in ['c', 'b', 'a']) {
await _controlTab(tester, shift: true);
expect(workspace.activePane?.sessionId, id);
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
}
// Two panes cycle the panes, not the history.
// Two panes still cycle panes, not the chat list.
await _openRow(tester, 'c');
await tester.tap(_actions('a'));
await tester.pumpAndSettle();
@@ -0,0 +1,115 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/chat_runtime.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
import 'conversation/chat_thread_fixtures.dart';
class _Gateway extends FakeChatGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
for (final id in ['a', 'b', 'new'])
{'id': id, 'title': 'Chat $id', 'directory': '/home/$id'},
],
});
}
if (type == 'chat_shells') return Future.value({'chat_shells': []});
return super.call(type, fields);
}
}
ChatWorkspaceController _workspace(WidgetTester tester) => tester
.widget<ChatWorkspace>(find.byType(ChatWorkspace, skipOffstage: false))
.controller;
void main() {
testWidgets('a chat opened for work goes beside the active chat, becomes '
'active and takes the keyboard', (tester) async {
final layout = ChatWorkspaceController()..open('a');
SharedPreferences.setMockInitialValues({
chatWorkspacePreferenceKey: layout.snapshot()!.encode(),
});
tester.view.physicalSize = const Size(1600, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
addTearDown(gateway.close);
final runtime = ChatRuntime(gateway: gateway);
addTearDown(runtime.dispose);
Widget screen(String? routed) => MaterialApp(
home: Scaffold(
body: ChatScreen(
gateway: gateway,
runtime: runtime,
persistWorkspace: true,
initialSessionId: routed,
onSessionSelected: (_) {},
onBack: () {},
),
),
);
await tester.pumpWidget(screen('a'));
await tester.pumpAndSettle();
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']);
runtime.openedForWork.add('new');
await tester.pumpWidget(screen('new'));
await tester.pumpAndSettle();
final workspace = _workspace(tester);
expect(workspace.panes.map((p) => p.sessionId), ['a', 'new']);
expect(workspace.activePane?.sessionId, 'new');
expect(runtime.openedForWork, isEmpty);
final composer = tester
.widgetList<EditableText>(
find.descendant(
of: find.byKey(const ValueKey('chat-composer-new')),
matching: find.byType(EditableText),
),
)
.first;
expect(composer.focusNode.hasFocus, isTrue);
});
testWidgets('an ordinary routed chat still opens in the active pane', (
tester,
) async {
final layout = ChatWorkspaceController()..open('a');
SharedPreferences.setMockInitialValues({
chatWorkspacePreferenceKey: layout.snapshot()!.encode(),
});
tester.view.physicalSize = const Size(1600, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
addTearDown(gateway.close);
final runtime = ChatRuntime(gateway: gateway);
addTearDown(runtime.dispose);
Widget screen(String? routed) => MaterialApp(
home: Scaffold(
body: ChatScreen(
gateway: gateway,
runtime: runtime,
persistWorkspace: true,
initialSessionId: routed,
onSessionSelected: (_) {},
onBack: () {},
),
),
);
await tester.pumpWidget(screen('a'));
await tester.pumpAndSettle();
await tester.pumpWidget(screen('b'));
await tester.pumpAndSettle();
expect(_workspace(tester).panes.map((p) => p.sessionId), ['b']);
});
}
@@ -150,12 +150,12 @@ void main() {
);
final header = find.byKey(const Key('chat-thread-header'));
expect(find.byKey(const Key('chat-mode')), findsNothing);
// The round Back, the title pill and the actions pill, which always
// carries the More menu, so it is never drawn empty. A narrow bar moves
// The round Back, the title pill, and the two action pills (including the
// More menu), so the More control is never drawn empty. A narrow bar moves
// the Files toggle into that menu.
expect(
find.descendant(of: header, matching: find.byType(SegmentedPill)),
findsNWidgets(3),
findsNWidgets(4),
);
expect(
find.descendant(
@@ -85,6 +85,7 @@ void main() {
activeSessionId: null,
visibleSessionIds: const {'a'},
onOpen: (_) {},
onNewChat: () {},
onExpand: () {},
navigation: const Text('Destinations'),
),
@@ -139,6 +140,7 @@ void main() {
activeSessionId: 'a',
visibleSessionIds: const {'a', 'b'},
onOpen: (_) {},
onNewChat: () {},
onExpand: () {},
),
),
@@ -107,6 +107,7 @@ void main() {
await controller.refresh();
final folds = ChatSectionFolds();
addTearDown(folds.dispose);
var newChatPressed = false;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
@@ -116,12 +117,16 @@ void main() {
activeSessionId: 'a',
visibleSessionIds: const {'a', 'b'},
onOpen: (_) {},
onNewChat: () => newChatPressed = true,
onExpand: () {},
),
),
),
);
await tester.pumpAndSettle();
expect(find.byTooltip('New chat'), findsOneWidget);
await tester.tap(find.byTooltip('New chat'));
expect(newChatPressed, isTrue);
expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(edge(tester, 'a').width, 10);
expect(edge(tester, 'b').width, 3);
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_drop.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_nodes.dart';
void main() {
Future<List<ChatWorkspaceDropZone>> pumpPane(WidgetTester tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final drops = <ChatWorkspaceDropZone>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Row(
children: [
const SizedBox(
width: 200,
child: Draggable<String>(
data: 'b',
// As the chat list does: the feedback sits at the pointer.
dragAnchorStrategy: pointerDragAnchorStrategy,
feedback: Text('chat b'),
child: Text('source'),
),
),
SizedBox(
width: 800,
height: 600,
child: ChatWorkspaceDropTarget(
pane: const ChatWorkspacePane('pane-a', 'a'),
rect: const Rect.fromLTWH(0, 0, 800, 600),
onDrop: (_, _, zone) => drops.add(zone),
),
),
],
),
),
),
);
return drops;
}
// The pane occupies x 200..1000, y 0..600.
for (final (name, point, zone) in [
('centre', const Offset(500, 250), ChatWorkspaceDropZone.replace),
('right edge', const Offset(950, 250), ChatWorkspaceDropZone.right),
('bottom edge', const Offset(500, 560), ChatWorkspaceDropZone.bottom),
]) {
testWidgets('a mouse drag over the $name marks only that zone and drops '
'there', (tester) async {
final drops = await pumpPane(tester);
final gesture = await tester.startGesture(
tester.getCenter(find.text('source')),
);
// No long press: a plain drag starts at once.
await gesture.moveBy(const Offset(20, 0));
await gesture.moveTo(point);
await tester.pump();
await tester.pump();
expect(
find.byKey(ValueKey('chat-drop-zone-${zone.name}')),
findsOneWidget,
);
for (final other in ChatWorkspaceDropZone.values) {
if (other == zone) continue;
expect(
find.byKey(ValueKey('chat-drop-zone-${other.name}')),
findsNothing,
);
}
await gesture.up();
await tester.pump();
expect(drops, [zone]);
expect(find.byKey(ValueKey('chat-drop-zone-${zone.name}')), findsNothing);
});
}
}
@@ -84,6 +84,37 @@ void main() {
expect(controller.panes.last.sessionId, 'new-two');
});
test('drop replaces, splits and moves without duplicating a chat', () {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
final first = controller.panes.first;
final second = controller.panes.last;
controller.dropSession('three', first.id, ChatWorkspaceDropZone.replace);
expect(controller.panes.map((pane) => pane.sessionId), ['three', 'two']);
controller.dropSession('four', second.id, ChatWorkspaceDropZone.right);
expect(controller.panes.map((pane) => pane.sessionId), [
'three',
'two',
'four',
]);
expect(
controller.panes.where((pane) => pane.sessionId == 'three'),
hasLength(1),
);
final four = controller.panes.last;
controller.dropSession('three', four.id, ChatWorkspaceDropZone.bottom);
expect(
controller.panes.where((pane) => pane.sessionId == 'three'),
hasLength(1),
);
expect(controller.activePane?.sessionId, 'three');
});
test(
'geometry clamps visible sizes but retains ratios and spatial neighbors',
() {
@@ -18,7 +18,7 @@ const _implemented = [
'Stop a running chat',
'Focus the neighbouring chat pane',
'Move the active chat pane',
'Cycle chat panes and floating chats',
'Cycle chats and floating chat panes',
'Resize panes with a focused divider',
'Scroll a wide transcript block',
'Show or hide floating chats',
@@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/application/open_in_chat_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/settings/settings_open_in_chat_section.dart';
import '../chat/ui/sessions/fake_chat_gateway.dart';
class _Gateway extends FakeChatGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
switch (type) {
case 'chat_backends':
return {
'chat_backends': ['opencode', 'claude'],
};
case 'chat_sessions':
return {
'chat_sessions': [
{'id': 'old', 'backend': 'claude', 'updated_at': '2026-01-01'},
{'id': 'new', 'backend': 'claude', 'updated_at': '2026-02-01'},
],
};
case 'chat_models':
final session = (fields['chat_query'] as Map)['session_id'];
return {
'chat_models': [
{
'id': 'claude-opus-5-5',
'provider': 'anthropic',
'name': 'Opus from $session',
},
],
};
}
return super.call(type, fields);
}
}
void main() {
testWidgets('choosing a harness and model saves them for Open in chat', (
tester,
) async {
SharedPreferences.setMockInitialValues({});
final gateway = _Gateway();
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: SettingsOpenInChatSection(gateway: gateway),
),
),
),
);
await tester.pumpAndSettle();
expect(find.text('Open in chat'), findsOneWidget);
await tester.tap(find.byKey(const Key('open-in-chat-harness')));
await tester.pumpAndSettle();
await tester.tap(find.text('claude').last);
await tester.pumpAndSettle();
expect((await OpenInChatPreferences.load(gateway)).harness, 'claude');
// Models come from the harness's most recent chat.
await tester.tap(find.byKey(const ValueKey('open-in-chat-model-claude')));
await tester.pumpAndSettle();
expect(find.text('Opus from new'), findsWidgets);
await tester.tap(find.text('Opus from new').last);
await tester.pumpAndSettle();
final saved = await OpenInChatPreferences.load(gateway);
expect(saved.provider, 'anthropic');
expect(saved.model, 'claude-opus-5-5');
});
}