Files
pipelines/app/tool/probe_files_fixture.dart
T
alan d56a76c9a7 Keep Files breadcrumbs aligned to the current folder
Pin the horizontally scrolling breadcrumb to its trailing edge so deep paths keep the current folder visible. Preserve tappable navigation, middle-ellipsize long labels, and cover the behavior with focused widget tests and the rendered fixture.
2026-11-12 23:08:03 +00:00

74 lines
2.3 KiB
Dart

import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/files/files_urls.dart';
/// A static explorer fixture with a deep starting path and a long folder name.
/// Its files live in capture/fixtures/files.
JsonMap probeFilesReply(JsonMap request) {
final fields = request['list_directory'] as Map?;
final requestedPath = '${fields?['path'] ?? '/srv/probe/release'}';
final path = requestedPath == '/srv/probe/release'
? '/srv/probe/release/operations/2026/quarterly/release-candidate'
: requestedPath;
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': 'a-folder-name-that-is-long-enough-to-ellipsize-in-the-middle',
'path':
'$path/a-folder-name-that-is-long-enough-to-ellipsize-in-the-middle',
'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'}),
);
};
}