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:
@@ -1,8 +1,10 @@
|
||||
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';
|
||||
@@ -18,6 +20,75 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user