feat: the archive picker offers only projects that hold archived sessions

- the archive page passes its project set to the shared picker, built from
  the archived sessions' directories (deduped and sorted by name), so the
  sheet no longer lists every server project
- the restricted picker hides the add-project action: the archive page never
  archives anything, so adding a project there would be pointless
- the picker gained an optional onlyProjects argument; chat archives remain
  reachable through the Chat row
- version 0.6.2+602
This commit is contained in:
blumia committed 2026-11-27 13:36:11 +08:00
1 parent 83e09e8e25
commit 8ac36b1fb1
6 files changed
+56 -12

No files matched your search

+19
View File
@@ -76,12 +76,31 @@ class _ArchivedSessionsScreenState extends State<ArchivedSessionsScreen> {
Future<void> _refresh() => _app.refreshArchived();
/// The projects the picker offers here: only checkouts that actually hold
/// archived sessions. This page never archives anything, so a project
/// without an archive would only get in the way.
List<ProjectInfo> _archiveProjects() {
final byPath = <String, ProjectInfo>{};
for (final session in _app.archivedSessions) {
final directory = session.directory;
if (directory.isEmpty || _app.isChatDirectory(directory)) continue;
final project = _app.projectFor(directory) ??
ProjectInfo(id: '', canonical: directory, name: pathLeaf(directory));
final key = slashPath(project.canonical).toLowerCase();
byPath.putIfAbsent(key, () => project);
}
final projects = byPath.values.toList()
..sort((a, b) => a.label.toLowerCase().compareTo(b.label.toLowerCase()));
return projects;
}
Future<void> _pickProject() async {
final choice = await showProjectPicker(
context,
app: _app,
selected: _bucket ?? allProjectsTarget,
includeAll: true,
onlyProjects: _archiveProjects(),
);
if (choice == null || !mounted) return;
setState(() => _bucket = choice.isAll ? null : choice.canonical);