- gpt_markdown renders through its own Material port, whose Theme.of falls back to a light theme: code panels stayed light and their text black in the dark theme. The chat now wraps markdown in a matching `mui.Theme`. - Folding a run changed the height below its header and threw the header out of view. The toggle remembers the header's screen position, corrects the scroll offset, and parks the header at the top when the run is longer than the viewport. - Step details show what a tool actually did: the command and its output for shell steps, the remaining inputs and the result for the rest, in monospace; toolOutput falls back to metadata. A read/write/edit of an image is no longer foldable — its path opens the preview. - The event stream now times out without a heartbeat, so a half-open connection is noticed and reopened; returning to the foreground restarts the stream, refreshes the session list and the open chat, and reloadTail merges the newest page instead of dropping loaded history. - A page shorter than the limit means there is nothing older, so short sessions no longer offer "load earlier". - Version 0.3.4 (code 304).
59 lines
2.3 KiB
Dart
59 lines
2.3 KiB
Dart
// Creates a throwaway session, prompts it, and prints the live events for it:
|
|
// type, session id, assistant message id and payload keys. This is how the
|
|
// chat's streaming path is checked against a real server.
|
|
// dart run tool/live_probe.dart [seconds]
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:openchamber/api/client.dart';
|
|
|
|
const types = [
|
|
'session.created', 'session.renamed', 'session.execution.started',
|
|
'session.execution.succeeded', 'session.execution.failed',
|
|
'session.execution.interrupted', 'session.step.started',
|
|
'session.step.ended', 'session.step.failed', 'session.text.started',
|
|
'session.text.delta', 'session.text.ended', 'session.reasoning.started',
|
|
'session.reasoning.delta', 'session.reasoning.ended',
|
|
'session.tool.called', 'session.tool.success', 'session.tool.failed',
|
|
'permission.asked', 'permission.replied',
|
|
];
|
|
|
|
Future<void> main(List<String> args) async {
|
|
final seconds = args.isEmpty ? 40 : int.tryParse(args[0]) ?? 40;
|
|
final dir = Directory.current.path;
|
|
final client = Client(Uri.parse('http://127.0.0.1:3000'));
|
|
|
|
final session = await client.createSession(title: 'event probe', directory: dir);
|
|
print('session ${session.id}');
|
|
|
|
final counts = <String, int>{};
|
|
final sub = client.streamEvents(types: types).listen((ev) {
|
|
final type = ev['type'] as String? ?? '';
|
|
final data = ev['data'] as Map<String, dynamic>? ?? {};
|
|
final sid = data['sessionID'];
|
|
if (sid != session.id) return;
|
|
counts[type] = (counts[type] ?? 0) + 1;
|
|
print('$type msg=${data['assistantMessageID'] ?? data['messageID']} '
|
|
'part=${data['partID']} keys=${data.keys.join(',')}');
|
|
}, onError: (Object e) => print('stream error: $e'));
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
await client.prompt(session.id,
|
|
text: 'Reply with the single word: pong', directory: dir);
|
|
print('prompted');
|
|
|
|
await Future.delayed(Duration(seconds: seconds));
|
|
await sub.cancel();
|
|
|
|
final page = await client.listMessages(session.id, limit: 50, directory: dir);
|
|
print('---- messages: ${page.data.length}');
|
|
for (final m in page.data.reversed) {
|
|
final parts = m.content.map((p) => '${p.type}${p.name == null ? '' : '(${p.name})'}').join(',');
|
|
print('${m.id} ${m.type} parts=[$parts]');
|
|
}
|
|
print('---- event counts: $counts');
|
|
await client.deleteSession(session.id);
|
|
client.close();
|
|
exit(0);
|
|
}
|