Open in chat opens beside the active chat and uses a chosen harness

A chat opened from a run or pipeline now goes in a new pane beside the
active chat instead of replacing it, becomes active and takes the
keyboard once built. Settings > Open in chat chooses its harness and
model (models listed from that harness's most recent chat).
This commit is contained in:
2026-11-13 13:34:26 +00:00
parent f7f2504a30
commit 6cd7774811
10 changed files with 561 additions and 3 deletions
@@ -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');
});
}