Populate selector catalogs for desktop UI review

This commit is contained in:
2026-11-11 21:23:02 +00:00
parent 16f4e43ddc
commit b556e76778
4 changed files with 180 additions and 3 deletions
+13
View File
@@ -0,0 +1,13 @@
# Populated desktop review fixtures
The full-app fake gateway's `chats=2&header=1` scenario now supplies model and
permission-mode catalogs as well as thinking levels. Selections are validated
and retained per chat, without contacting providers or changing real settings.
This closes the earlier selector review's unsupported-catalog limitation.
- Fixture tests: 2 passed; explicit tool-file analysis: clean.
- Full-app web probe build: passed.
- Inspected populated model, permission, and thinking menus at 1600×1000, dark
theme. All use the shared anchored Material choice surface and checked rows.
- Final broad desktop review still follows integrated cleanup; these captures
are focused fixture verification, not a claim of completed overall review.
+61
View File
@@ -0,0 +1,61 @@
import 'package:flutter_test/flutter_test.dart';
import '../../tool/perf/chat_catalog_fixture.dart';
void main() {
test('catalogs are populated and selection is isolated per chat', () {
final fixture = ChatCatalogFixture();
expect(
fixture.reply({'type': 'chat_models'})!['chat_models'],
hasLength(2),
);
expect(fixture.reply({'type': 'chat_modes'})!['chat_modes'], hasLength(3));
expect(
fixture.reply({
'type': 'chat_model',
'chat_model': {
'session_id': 'a',
'provider': 'openai',
'model': 'openai/gpt-5.6-luna',
},
})!['type'],
'chat_model',
);
expect(
fixture.reply({
'type': 'chat_mode',
'chat_mode': {'session_id': 'a', 'mode': 'plan'},
})!['type'],
'chat_mode',
);
expect(fixture.rowFields('a')['model'], 'openai/gpt-5.6-luna');
expect(fixture.rowFields('a')['mode_name'], 'Plan only');
expect(fixture.rowFields('b')['model'], 'openai/gpt-6.1');
expect(fixture.rowFields('b')['mode'], 'default');
});
test('invalid selections do not mutate catalog state', () {
final fixture = ChatCatalogFixture();
final before = fixture.rowFields('a');
expect(
fixture.reply({
'type': 'chat_mode',
'chat_mode': {'session_id': 'a', 'mode': 'not-a-mode'},
})!['type'],
'error',
);
expect(
fixture.reply({
'type': 'chat_model',
'chat_model': {
'session_id': 'a',
'provider': 'unknown',
'model': 'unknown',
},
})!['type'],
'error',
);
expect(fixture.rowFields('a'), before);
expect(fixture.reply({'type': 'chat_messages'}), isNull);
});
}
+99
View File
@@ -0,0 +1,99 @@
import 'package:pipelines_app/core/api_gateway.dart';
/// Local-only catalogs for exercising all three header menus with `header=1`.
/// No provider or production permission setting is read or changed.
class ChatCatalogFixture {
static const models = <JsonMap>[
{'id': 'openai/gpt-6.1', 'provider': 'openai', 'name': 'GPT 6.1'},
{'id': 'openai/gpt-5.6-luna', 'provider': 'openai', 'name': 'Luna'},
];
static const modes = <JsonMap>[
{
'id': 'default',
'name': 'Ask for permission',
'description': 'Ask before actions that require approval.',
},
{
'id': 'plan',
'name': 'Plan only',
'description': 'Inspect and plan without applying changes.',
},
{
'id': 'auto',
'name': 'Auto approve',
'description': 'Fixture-only automatic approval mode.',
},
];
final Map<String, JsonMap> _model = {};
final Map<String, String> _mode = {};
JsonMap rowFields(String sessionId) {
final model = _model[sessionId] ?? models.first;
final mode = _mode[sessionId] ?? 'default';
return {
'model': model['id'],
'model_provider': model['provider'],
if (_model.containsKey(sessionId)) 'model_selection': 'next_turn',
'mode': mode,
'mode_name': modes.firstWhere((item) => item['id'] == mode)['name'],
};
}
JsonMap? reply(JsonMap request) {
switch (request['type']) {
case 'chat_models':
return {'type': 'chat_models', 'chat_models': models};
case 'chat_modes':
final body = request['chat_query'];
final session = body is Map ? '${body['session_id'] ?? ''}' : '';
return {
'type': 'chat_modes',
'chat_modes': modes,
'chat_mode': {'mode': rowFields(session)['mode']},
};
case 'chat_model':
final body = request['chat_model'];
if (body is! Map) return _invalid;
final session = '${body['session_id'] ?? ''}';
final model = models
.where(
(item) =>
item['id'] == body['model'] &&
item['provider'] == body['provider'],
)
.firstOrNull;
if (session.isEmpty || model == null) return _invalid;
_model[session] = model;
return {
'type': 'chat_model',
'chat_model': {
'session_id': session,
'provider': model['provider'],
'model': model['id'],
'selection': 'next_turn',
},
};
case 'chat_mode':
final body = request['chat_mode'];
if (body is! Map) return _invalid;
final session = '${body['session_id'] ?? ''}';
final mode = '${body['mode'] ?? ''}';
if (session.isEmpty || !modes.any((item) => item['id'] == mode)) {
return _invalid;
}
_mode[session] = mode;
return {
'type': 'chat_mode',
'chat_mode': {'session_id': session, 'mode': mode},
};
default:
return null;
}
}
static const _invalid = <String, dynamic>{
'type': 'error',
'error': 'Unknown chat catalog fixture selection.',
};
}
+7 -3
View File
@@ -23,6 +23,7 @@
import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_effort_fixture.dart';
import 'chat_catalog_fixture.dart';
import 'chat_new_session_fixture.dart';
import 'chat_turn_diff_fixture.dart';
import 'chat_question_fixture.dart';
@@ -77,6 +78,7 @@ const _colorTitles = [
const _colorStarred = {0, 1, 3};
const _colorNames = ['teal', 'purple', null, 'amber', 'red', null, 'blue'];
final Map<String, String?> _pickedColors = {};
final _chatCatalog = ChatCatalogFixture();
JsonMap _chatRow(int i) {
final id = perfChatId(i);
@@ -86,9 +88,7 @@ JsonMap _chatRow(int i) {
'title': 'Fixture chat ${i + 1}',
'directory': '/workspace/demo',
if (_params['header'] == '1') ...{
'model': 'openai/gpt-6.1',
'mode': 'default',
'mode_name': 'Ask for permission',
..._chatCatalog.rowFields(id),
...chatEffortRowFields(id),
},
// Server-shaped handoff facts (chat_sessions rows carry them).
@@ -245,6 +245,10 @@ JsonMap? perfChatReply(JsonMap request) {
final shell = chatShellReply(request);
if (shell != null) return shell;
final id = request['id'];
if (_params['header'] == '1') {
final catalog = _chatCatalog.reply(request);
if (catalog != null) return {'id': id, ...catalog};
}
switch ('${request['type']}') {
case 'chat_effort':
return {'id': id, ...chatEffortReply(request)};