Add a home-restricted folder picker to the new-chat dialog

Server: list_directory returns a directory_listing (path, home, parent,
entries with is_dir/is_git_repo/hidden, truncated) confined to the server
user's home subtree after cleaning and resolving symlinks, refusing pseudo
filesystems and capping entries at 2000. Documented in docs/cli.md.

App: "Choose folder…" in the create dialog opens a picker (full-screen page
on phones, large dialog on wide windows, Material and Cupertino) with
breadcrumbs, filter, Show hidden, git badges, dimmed files, recent folders,
inline errors and "Start chat here". The probe app gains a folder fixture
for captures.
This commit is contained in:
2026-11-01 21:51:48 +00:00
parent eadd017bdc
commit eed3806efb
25 changed files with 2333 additions and 9 deletions
@@ -0,0 +1,52 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/data/directory_listing.dart';
void main() {
test('parses the directory_listing reply, null parent at home', () {
final listing = DirectoryListing.fromReply({
'type': 'directory_listing',
'directory_listing': {
'path': '/home/op',
'home': '/home/op',
'parent': null,
'entries': [
{
'name': 'src',
'path': '/home/op/src',
'is_dir': true,
'is_git_repo': true,
'hidden': false,
},
{'name': '.zshrc', 'path': '/home/op/.zshrc', 'hidden': true},
],
'truncated': true,
},
});
expect(listing.parent, isNull);
expect(listing.truncated, isTrue);
expect(listing.entries.first.isGitRepo, isTrue);
expect(listing.entries.last.isDir, isFalse);
expect(listing.entries.last.hidden, isTrue);
});
test('a reply without a listing is an error, not an empty folder', () {
expect(
() => DirectoryListing.fromReply({'type': 'pong'}),
throwsStateError,
);
});
test('crumbs run from ~ to the folder', () {
expect(folderCrumbs('/home/op', '/home/op/a/b'), [
(label: '~', path: '/home/op'),
(label: 'a', path: '/home/op/a'),
(label: 'b', path: '/home/op/a/b'),
]);
expect(folderCrumbs('/home/op', '/home/opal'), [
(label: '~', path: '/home/op'),
]);
expect(isInsideHome('/home/op', '/home/opal'), isFalse);
expect(homeRelativeLabel('/home/op', '/home/op/a'), '~/a');
expect(homeRelativeLabel('/home/op', '/srv'), '/srv');
});
}