fix: full chat history, picked model/agent, usage sheet, image previews
- The chat loaded only one page of history: a desc page's older side is cursor.next, not previous, and the server rejects a cursor combined with order (InvalidCursorError). The first page stores `next`, later pages pass only `cursor`. tool/history_probe.dart walks a 1698-message session down to the oldest message with no gaps. - The message list is now reversed (newest at offset 0), so older pages grow above and the viewport stays put; near the top it loads by itself and a "load earlier" row remains as a fallback. - The agent picker filtered only on mode, so Compaction/Title/Summary (primary but hidden) showed up. Filter `hidden` too, and mark the current model or agent with a check. - The usage ring's sheet was guarded by a flag nothing ever set; the ring now opens the context detail sheet. - Tool image previews use a self-loading dialog and Image.memory: no temp file and no path_provider, whose Android implementation throws ClassNotFoundException: Landroid/content/Context; on the emulator. - "Add server" in the connected server sheet now opens the form and returns to the session list once connected. - Add a Linux desktop target for fast local UI checks, plus the probe that pages history. - Version 0.3.2 (code 302).
This commit is contained in:
1 parent
2f5aad3814
commit
61977d2b14
24 files changed
+834
-130
No files matched your search
@@ -0,0 +1,65 @@
|
||||
// Pages a session's history exactly as ChatState does, and reports whether
|
||||
// every message is reached. Run against a live server:
|
||||
// dart run tool/history_probe.dart <sessionId> [directory]
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:openchamber/api/client.dart';
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
final id = args.isEmpty ? '' : args[0];
|
||||
final dir = args.length > 1
|
||||
? args[1]
|
||||
: Directory.current.path;
|
||||
if (id.isEmpty) {
|
||||
print('usage: dart run tool/history_probe.dart <sessionId> [directory]');
|
||||
exit(2);
|
||||
}
|
||||
final client = Client(Uri.parse('http://127.0.0.1:3000'));
|
||||
|
||||
// 1. What ChatState loads first, then each "load earlier" page.
|
||||
final first = await client.listMessages(id, limit: 30, directory: dir);
|
||||
final seen = <String>{for (final m in first.data) m.id};
|
||||
print('page 1: ${first.data.length} msgs next=${first.next != null}');
|
||||
var cursor = first.next;
|
||||
var page = 2;
|
||||
var oldest = 0;
|
||||
while (cursor != null && page <= 200) {
|
||||
final p = await client.listMessages(id,
|
||||
limit: 30, cursor: cursor, directory: dir);
|
||||
if (p.data.isEmpty) {
|
||||
print('page $page: empty (cursor exhausted)');
|
||||
break;
|
||||
}
|
||||
final added = p.data.where((m) => seen.add(m.id)).length;
|
||||
oldest = p.data
|
||||
.map((m) => m.created)
|
||||
.reduce((a, b) => a < b ? a : b);
|
||||
print('page $page: ${p.data.length} msgs (+$added new, '
|
||||
'oldest=${DateTime.fromMillisecondsSinceEpoch(oldest)})');
|
||||
cursor = p.next;
|
||||
page++;
|
||||
if (added == 0) {
|
||||
print('no progress at page $page: stopping');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. The full list, for comparison.
|
||||
final all = <String>{};
|
||||
var c = null as String?;
|
||||
do {
|
||||
final p = await client.listMessages(id,
|
||||
limit: 200, cursor: c, directory: dir);
|
||||
all.addAll(p.data.map((m) => m.id));
|
||||
c = p.next;
|
||||
} while (c != null);
|
||||
|
||||
print('----');
|
||||
print('paged: ${seen.length} unique messages');
|
||||
print('total: ${all.length} messages');
|
||||
print('missing: ${all.difference(seen).length}');
|
||||
final missing = all.difference(seen);
|
||||
if (missing.isNotEmpty) print('first missing: ${missing.take(3).join(', ')}');
|
||||
client.close();
|
||||
exit(0);
|
||||
}
|
||||
@@ -24,6 +24,24 @@ Future<void> probe(String? proxy) async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> probeRaw(String? proxy) async {
|
||||
final label = proxy ?? 'direct';
|
||||
final client = Client(Uri.parse('http://127.0.0.1:3000'), proxy: proxy);
|
||||
try {
|
||||
final bytes = await client
|
||||
.rawFile(
|
||||
'/home/blumia/Sources/openchamber-android-native/resources/icon.png',
|
||||
directory: '/home/blumia/Sources/openchamber-android-native',
|
||||
)
|
||||
.timeout(const Duration(seconds: 15));
|
||||
print('OK raw $label bytes=${bytes.length}');
|
||||
} on Object catch (e) {
|
||||
print('FAIL raw $label ${e.toString().split('\n').first}');
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> probeStream(String? proxy) async {
|
||||
final label = proxy ?? 'direct';
|
||||
final client = Client(Uri.parse('http://127.0.0.1:3000'), proxy: proxy);
|
||||
@@ -48,5 +66,8 @@ Future<void> main() async {
|
||||
await probe('socks5://127.0.0.1:1');
|
||||
await probeStream('socks5://127.0.0.1:1080');
|
||||
await probeStream('http://127.0.0.1:8081');
|
||||
await probeRaw(null);
|
||||
await probeRaw('socks5://127.0.0.1:1080');
|
||||
await probeRaw('http://127.0.0.1:8081');
|
||||
exit(0);
|
||||
}
|
||||
Reference in new issue
Block a user