Files
openchamber-android-native/tool/event_probe.dart
T
blumia 32277564f9 fix: dark markdown, steadier folds, readable tool details, live refresh
- 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).
2026-11-19 20:18:04 +08:00

38 lines
1.6 KiB
Dart

// Prints live SSE events for a few seconds: their type, session id and the
// keys of their payload. Run against a live server:
// dart run tool/event_probe.dart [seconds]
import 'dart:async';
import 'dart:io';
import 'package:openchamber/api/client.dart';
Future<void> main(List<String> args) async {
final seconds = args.isEmpty ? 20 : int.tryParse(args[0]) ?? 20;
final client = Client(Uri.parse('http://127.0.0.1:3000'));
final seen = <String, int>{};
final sub = client.streamEvents(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',
]).listen((ev) {
final type = ev['type'] as String? ?? '';
final data = ev['data'] as Map<String, dynamic>? ?? {};
seen[type] = (seen[type] ?? 0) + 1;
final sid = data['sessionID'] ?? data['sessionId'];
print('$type session=$sid message=${data['assistantMessageID'] ?? data['messageID']} '
'keys=${data.keys.take(6).join(',')}');
}, onError: (Object e) => print('stream error: $e'));
await Future.delayed(Duration(seconds: seconds));
await sub.cancel();
print('----');
print(seen);
client.close();
exit(0);
}