Complete chat file previews downloads and explorer actions

This commit is contained in:
2026-11-07 01:44:42 +00:00
parent 81955059de
commit 84a03bea8d
32 changed files with 1349 additions and 140 deletions
+17
View File
@@ -132,3 +132,20 @@ content kind and expects the offset to move:
node tool/capture/capture.mjs --build build/probe-app --out /tmp/review/chat-wheel \
--script tool/capture/examples/chat-wheel-scroll.json
```
## Chat file explorer
Use `--params 'chats=2&files=1' open=/chat/bench-0 click=Files` to open a
populated explorer (the fixture always answers `list_directory`). `files=1`
redirects view/download URLs to same-origin static fixture files; production
continues to use `/files`. After building the probe, copy the fixtures:
```sh
mkdir -p build/probe-app/capture-files
cp tool/capture/fixtures/files/* build/probe-app/capture-files/
```
The tree has an assets subfolder, a hidden folder, PNG/JPEG miniatures, text,
JSON, CSV, PDF, archive, log and video entries. Image/text/table/archive files
have bundled bytes; PDF and video entries demonstrate type labels and menus
only. Use the real server for their external handlers and playback acceptance.
Binary file not shown.
@@ -0,0 +1 @@
{"release":"1.0","ready":true}
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

@@ -0,0 +1,3 @@
section,files
Images,2
Documents,4
1 section files
2 Images 2
3 Documents 4
@@ -0,0 +1,6 @@
# Release notes
The explorer now previews files and saves downloads.
- Open a file to inspect it.
- Use the file menu to download it.
+63
View File
@@ -0,0 +1,63 @@
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/files/files_urls.dart';
/// A static, two-level explorer fixture. Its files live in capture/fixtures/files.
JsonMap probeFilesReply(JsonMap request) {
final fields = request['list_directory'] as Map?;
final path = '${fields?['path'] ?? '/srv/probe/release'}';
final nested = path.endsWith('/assets');
final entries = nested
? <(String, int)>[('design.png', 18432), ('icon.jpg', 23000)]
: <(String, int)>[
('design.png', 18432),
('icon.jpg', 23000),
('release.md', 640),
('config.json', 220),
('metrics.csv', 88),
('report.pdf', 45000),
('archive.zip', 85000),
('server.log', 12582912),
('demo.mp4', 8000000),
];
return {
'id': request['id'],
'type': 'directory_listing',
'directory_listing': {
'path': path,
'home': '/workspace',
'parent': nested
? path.substring(0, path.lastIndexOf('/'))
: '/workspace',
'entries': [
if (!nested) ...[
{'name': 'assets', 'path': '$path/assets', 'is_dir': true},
{
'name': '.config',
'path': '$path/.config',
'is_dir': true,
'hidden': true,
},
],
for (final (name, size) in entries)
{
'name': name,
'path': '$path/$name',
'is_dir': false,
'size': size,
'modified': '2026-11-07T00:00:00Z',
},
],
},
};
}
void installFilesFixture() {
resolveFileUrls = (_, path) {
final name = Uri.encodeComponent(path.split('/').last);
final view = Uri.base.resolve('/capture-files/$name');
return FileUrls(
view: view,
download: view.replace(queryParameters: {'download': '1'}),
);
};
}
@@ -34,6 +34,7 @@ import 'perf/chat_question_fixture.dart';
import 'perf/chat_scroll_fixture.dart';
import 'perf/perf_fixture.dart';
import 'probe_folder_fixture.dart';
import 'probe_files_fixture.dart';
import 'probe_usage_fixture.dart';
/// The run every run-scoped hit names. Its recorded sequences are deliberately
@@ -469,6 +470,8 @@ JsonMap? probeReply(JsonMap request) {
final perf = perfChatReply(request);
if (perf != null) return perf;
switch (type) {
case 'list_directory':
return probeFilesReply(request);
case 'subscribe':
case 'unsubscribe':
return null;
@@ -726,6 +729,7 @@ void main() {
return;
}
configurePerfFixture(params);
if (params['files'] == '1') installFilesFixture();
// `?font=inter` chooses a font as Settings would; otherwise the stored one.
final font = params['font'];
unawaited(