Open a run or pipeline in a new chat

The run and pipeline More menus offer Open in chat: a new chat in the
run's (or the pipeline's latest run's) workspace opens on the Chat tab
with a draft naming the run or pipeline and how to inspect or change it.
This commit is contained in:
2026-11-13 12:38:27 +00:00
parent df0614e2f7
commit e5403ae257
20 changed files with 680 additions and 15 deletions
@@ -170,6 +170,12 @@ bool _warnings = false;
/// visit (group `debug`) to run 7's build visit, so the Artifacts tab's hidden
/// Debugging files group can be reviewed.
bool _turnFiles = false;
/// Chats created during a rendered probe. Keeping these in the fixture makes
/// the real Open in chat flow observable instead of turning the create request
/// into the same "unsupported request" error as an incomplete server.
final _probeChats = <String, JsonMap>{};
int _probeChatSequence = 0;
const List<String> _turnFileNames = [
'input.md',
'memory.md',
@@ -549,6 +555,78 @@ JsonMap? probeReply(JsonMap request) {
'type': 'pipeline',
'detail': probePipelineDetail(pipelineId, version is int ? version : 0),
};
case 'chat_backends':
return {
'id': id,
'type': 'chat_backends',
'chat_backends': ['opencode'],
};
case 'chat_directories':
return {
'id': id,
'type': 'chat_directories',
'chat_directories': ['/Users/fixture/workspace'],
};
case 'chat_sessions':
return {
'id': id,
'type': 'chat_sessions',
'chat_sessions': _probeChats.values.toList(),
};
case 'chat_create':
final body = request['chat_create'];
if (body is! Map) {
return error('Fixture refused a malformed chat create.');
}
final chatId = 'probe-chat-${++_probeChatSequence}';
final session = <String, dynamic>{
'id': chatId,
'title': '${body['title'] ?? ''}',
'directory': '${body['directory'] ?? ''}',
'backend': '${body['backend'] ?? 'opencode'}',
'model': 'fixture-model',
'created_at': '2026-10-20T09:00:00Z',
'closed_at': null,
};
_probeChats[chatId] = session;
return {'id': id, 'type': 'chat_created', 'chat_session': session};
case 'chat_models':
return {
'id': id,
'type': 'chat_models',
'chat_models': [
{'provider': 'fixture', 'model': 'fixture-model'},
],
};
case 'chat_modes':
return {
'id': id,
'type': 'chat_modes',
'chat_modes': const [
{'mode': 'default', 'name': 'Default'},
],
'chat_mode': const {'mode': 'default'},
};
case 'chat_messages':
return {
'id': id,
'type': 'chat_messages',
'chat_history': const {
'messages': <JsonMap>[],
'next_cursor': '',
'has_more': false,
},
};
case 'chat_subscribe':
return {'id': id, 'type': 'chat_subscribed'};
case 'chat_shells':
return {'id': id, 'type': 'chat_shells', 'chat_shells': const []};
case 'chat_automations':
return {
'id': id,
'type': 'chat_automations',
'chat_automations': const [],
};
case 'archive_pipeline':
case 'unarchive_pipeline':
// Mirrors the server: an enabled schedule blocks archiving.