Merge main into macos-self-update
This commit is contained in:
@@ -0,0 +1,373 @@
|
||||
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/application/open_in_chat.dart';
|
||||
import 'package:pipelines_app/application/open_in_chat_preferences.dart';
|
||||
import 'package:pipelines_app/features/chat/chat_runtime.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_create_fields.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_models.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_archive_action.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_list_panel.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_list_row.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
|
||||
import '../features/chat/ui/sessions/fake_chat_gateway.dart';
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import '../features/pipelines/test_helpers.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() => SharedPreferences.setMockInitialValues({}));
|
||||
|
||||
testWidgets('the harness and model chosen in Settings start the chat', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = FakeChatGateway()
|
||||
..backendsHandler = () async => const {
|
||||
'chat_backends': ['opencode', 'claude'],
|
||||
};
|
||||
await const OpenInChatPreferences(
|
||||
harness: 'claude',
|
||||
provider: 'anthropic',
|
||||
model: 'claude-opus-5-5',
|
||||
).save(gateway);
|
||||
final runtime = ChatRuntime(gateway: gateway);
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
|
||||
await openReferenceInChat(
|
||||
context: tester.element(find.byType(Scaffold)),
|
||||
runtime: runtime,
|
||||
selectChat: (_) {},
|
||||
directory: '/work/run',
|
||||
title: 'Run #42: Build',
|
||||
draft: 'About Pipelines run #42.',
|
||||
);
|
||||
|
||||
final create = gateway.lastFields('chat_create')!['chat_create'] as Map;
|
||||
expect(create['backend'], 'claude');
|
||||
final model = gateway.lastFields('chat_model')!['chat_model'] as Map;
|
||||
expect(model['session_id'], 'created');
|
||||
expect(model['provider'], 'anthropic');
|
||||
expect(model['model'], 'claude-opus-5-5');
|
||||
// Opened for work: beside the active chat, with the keyboard in it.
|
||||
expect(runtime.openedForWork, contains('created'));
|
||||
runtime.dispose();
|
||||
});
|
||||
|
||||
testWidgets('a harness the server no longer offers falls back to the '
|
||||
'default, without the saved model', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = FakeChatGateway()
|
||||
..backendsHandler = () async => const {
|
||||
'chat_backends': ['opencode', 'codex'],
|
||||
};
|
||||
await const OpenInChatPreferences(
|
||||
harness: 'claude',
|
||||
provider: 'anthropic',
|
||||
model: 'claude-opus-5-5',
|
||||
).save(gateway);
|
||||
final runtime = ChatRuntime(gateway: gateway);
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
|
||||
await openReferenceInChat(
|
||||
context: tester.element(find.byType(Scaffold)),
|
||||
runtime: runtime,
|
||||
selectChat: (_) {},
|
||||
directory: '/work/run',
|
||||
title: 'Run #42: Build',
|
||||
draft: 'About Pipelines run #42.',
|
||||
);
|
||||
|
||||
final create = gateway.lastFields('chat_create')!['chat_create'] as Map;
|
||||
// The default harness (OpenCode) is the request's default: not claude.
|
||||
expect(create['backend'], anyOf(isNull, 'opencode'));
|
||||
expect(gateway.lastFields('chat_model'), isNull);
|
||||
runtime.dispose();
|
||||
});
|
||||
|
||||
test('a run summary names its pipeline in name', () {
|
||||
final draft = runChatReference({
|
||||
'id': 7,
|
||||
'name': 'release',
|
||||
'title': 'Ship notes',
|
||||
'version': 3,
|
||||
'status': 'failed',
|
||||
});
|
||||
expect(
|
||||
draft,
|
||||
'About Pipelines run #7 "Ship notes" (pipeline "release" v3, '
|
||||
'status failed). Inspect it with `pipelines inspect 7`.',
|
||||
);
|
||||
final untitled = runChatReference({
|
||||
'id': 8,
|
||||
'name': 'release',
|
||||
'version': 3,
|
||||
'status': 'succeeded',
|
||||
});
|
||||
expect(untitled, contains('run #8 "Run 8" (pipeline "release" v3'));
|
||||
final unversioned = runChatReference({
|
||||
'id': 9,
|
||||
'name': 'release',
|
||||
'status': 'running',
|
||||
});
|
||||
expect(unversioned, contains('(pipeline "release", status running)'));
|
||||
});
|
||||
|
||||
test('run references contain the exact inspect command', () {
|
||||
expect(
|
||||
runChatReference({
|
||||
'id': 42,
|
||||
'title': 'Nightly build',
|
||||
'pipeline_name': 'Deploy',
|
||||
'pipeline_version': 3,
|
||||
'status': 'failed',
|
||||
}),
|
||||
'About Pipelines run #42 "Nightly build" (pipeline "Deploy" v3, '
|
||||
'status failed). Inspect it with `pipelines inspect 42`.',
|
||||
);
|
||||
});
|
||||
|
||||
test('pipeline references contain show and edit guidance', () {
|
||||
expect(
|
||||
pipelineChatReference(7, 'Deploy', 4),
|
||||
'About pipeline "Deploy" (id 7, version 4). Show it with '
|
||||
'`pipelines show "Deploy"`; to change it, draft with `pipelines edit` '
|
||||
'and publish with `pipelines submit`.',
|
||||
);
|
||||
});
|
||||
|
||||
test('open in chat keeps the more menu available', () {
|
||||
expect(showRunMoreMenu({'id': 42}, canOpenInChat: true), isTrue);
|
||||
});
|
||||
|
||||
test('pipeline latest run retains its workspace', () {
|
||||
final run = PipelineRun.fromJson({
|
||||
'id': 9,
|
||||
'pipeline_id': 7,
|
||||
'workspace': '/work/deploy',
|
||||
});
|
||||
expect(run.workspace, '/work/deploy');
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'open in chat uses the catalog backend, draft, route, and focus',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..backendsHandler = () async => const {
|
||||
'chat_backends': ['codex', 'claude'],
|
||||
};
|
||||
final runtime = ChatRuntime(gateway: gateway);
|
||||
String? selected;
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
|
||||
await openReferenceInChat(
|
||||
context: tester.element(find.byType(Scaffold)),
|
||||
runtime: runtime,
|
||||
selectChat: (id) => selected = id,
|
||||
directory: '/work/run',
|
||||
title: 'Run #42: Build',
|
||||
draft: 'About Pipelines run #42.',
|
||||
);
|
||||
|
||||
final create = gateway.lastFields('chat_create')!['chat_create'] as Map;
|
||||
expect(create['backend'], 'codex');
|
||||
expect(create['directory'], '/work/run');
|
||||
expect(selected, 'created');
|
||||
expect(runtime.pendingDrafts['created'], 'About Pipelines run #42.');
|
||||
expect(runtime.composerFocus.take('created'), isTrue);
|
||||
runtime.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('open in chat falls back to the default folder', (tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
final runtime = ChatRuntime(gateway: gateway);
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
|
||||
await openReferenceInChat(
|
||||
context: tester.element(find.byType(Scaffold)),
|
||||
runtime: runtime,
|
||||
selectChat: (_) {},
|
||||
directory: '',
|
||||
title: 'Pipeline: Deploy',
|
||||
draft: 'About pipeline "Deploy".',
|
||||
);
|
||||
|
||||
final create = gateway.lastFields('chat_create')!['chat_create'] as Map;
|
||||
expect(create['directory'], chatHomeDirectory);
|
||||
runtime.dispose();
|
||||
});
|
||||
|
||||
testWidgets('create failure leaves navigation and chat state unchanged', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway()..failures['chat_create'] = 'refused';
|
||||
final runtime = ChatRuntime(gateway: gateway);
|
||||
String? selected;
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
|
||||
await openReferenceInChat(
|
||||
context: tester.element(find.byType(Scaffold)),
|
||||
runtime: runtime,
|
||||
selectChat: (id) => selected = id,
|
||||
directory: '/work/run',
|
||||
title: 'Run #42: Build',
|
||||
draft: 'About Pipelines run #42.',
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(selected, isNull);
|
||||
expect(runtime.opened, isEmpty);
|
||||
expect(find.textContaining('Could not open in chat'), findsOneWidget);
|
||||
runtime.dispose();
|
||||
});
|
||||
|
||||
testWidgets('run list More selects Open in chat on desktop', (tester) async {
|
||||
final run = <String, dynamic>{
|
||||
'id': 42,
|
||||
'title': 'Build',
|
||||
'status': 'failed',
|
||||
'created_at': '2026-10-17T19:00:00',
|
||||
};
|
||||
JsonMap? selected;
|
||||
final gateway = FakeChatGateway();
|
||||
|
||||
tester.view.physicalSize = const Size(900, 700);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunListRow(
|
||||
run: run,
|
||||
now: DateTime(2026, 10, 18),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
onOpenInChat: (context, value) async => selected = value,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('run-list-more-menu-42')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Open in chat'), findsOneWidget);
|
||||
await tester.tap(find.text('Open in chat'));
|
||||
expect(selected, same(run));
|
||||
});
|
||||
|
||||
testWidgets('run detail More selects Open in chat from the phone sheet', (
|
||||
tester,
|
||||
) async {
|
||||
final run = <String, dynamic>{'id': 42, 'title': 'Build'};
|
||||
JsonMap? selected;
|
||||
final gateway = FakeChatGateway();
|
||||
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
onOpenInChat: (context, value) async => selected = value,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byTooltip('More actions'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Open in chat'), findsOneWidget);
|
||||
await tester.tap(find.text('Open in chat'));
|
||||
expect(selected, same(run));
|
||||
});
|
||||
|
||||
testWidgets('pipeline list row More selects Open in chat with latest run', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = gatewayFor(fixture);
|
||||
final controller = PipelinesController(PipelinesRepository(gateway));
|
||||
addTearDown(controller.dispose);
|
||||
await controller.load();
|
||||
PipelineSummary? selected;
|
||||
PipelineRun? selectedRun;
|
||||
|
||||
tester.view.physicalSize = const Size(900, 700);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: PipelineListPanel(
|
||||
controller: controller,
|
||||
onOpenInChat: (context, pipeline, run) async {
|
||||
selected = pipeline;
|
||||
selectedRun = run;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-more-menu-1')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Open in chat'), findsOneWidget);
|
||||
await tester.tap(find.text('Open in chat'));
|
||||
expect(selected?.id, 1);
|
||||
expect(selectedRun?.id, 42);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'pipeline detail actions select Open in chat from phone overflow',
|
||||
(tester) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = gatewayFor(fixture);
|
||||
final controller = PipelinesController(PipelinesRepository(gateway));
|
||||
addTearDown(controller.dispose);
|
||||
final detail = PipelineDetail.fromJson(fixture.details.first);
|
||||
PipelineDetail? selected;
|
||||
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => pipelineActionsMenu(
|
||||
context,
|
||||
controller,
|
||||
detail,
|
||||
onOpenInChat: (context, value, run) async => selected = value,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byTooltip('Pipeline actions'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Open in chat'), findsOneWidget);
|
||||
await tester.tap(find.text('Open in chat'));
|
||||
expect(selected?.id, detail.id);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
|
||||
|
||||
void _size(WidgetTester tester, double width) {
|
||||
tester.view.physicalSize = Size(width, 700);
|
||||
@@ -142,6 +143,54 @@ void main() {
|
||||
expect(find.bySemanticsLabel('More actions'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host: a lone More action is centred in its separate island', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 180);
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
SegmentedBar(
|
||||
title: 'Runs',
|
||||
separateActionIslands: true,
|
||||
actions: [
|
||||
for (final name in ['Filter', 'Sort', 'Select', 'Usage', 'View'])
|
||||
SegmentedOverflowAction(
|
||||
overflowEntry: SegmentedOverflowEntry(
|
||||
label: name,
|
||||
icon: Icons.filter_list,
|
||||
),
|
||||
child: _icon(name, () {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final more = find.byKey(segmentedMoreKey).hitTestable();
|
||||
expect(more, findsOneWidget);
|
||||
final pill = tester.getRect(find.byType(SegmentedPill).last);
|
||||
final button = tester.getRect(more);
|
||||
expect(pill.height, segmentedPieceHeight());
|
||||
expect(button.left - pill.left, closeTo(pill.right - button.right, 0.1));
|
||||
expect(button.top - pill.top, closeTo(pill.bottom - button.bottom, 0.1));
|
||||
|
||||
await tester.pumpWidget(
|
||||
_app(
|
||||
SegmentedBar(
|
||||
title: 'Runs',
|
||||
separateActionIslands: true,
|
||||
actions: [_icon('Needs you', () {}), _icon('Usage', () {})],
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getRect(find.byType(SegmentedPill).last).height,
|
||||
pill.height,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$host: a longer title keeps a readable share at 240px', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user