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

+9
View File
@@ -5,6 +5,15 @@
---
## 0.6.2 归档选择器只列有归档的项目(分支 `flutter`)
| 项 | 结果 |
| --- | --- |
| 筛选范围 | 归档页打开的项目选择器只列出**实际有已归档会话**的项目(按名字排序),不再显示全部项目;同时隐藏「添加项目」按钮(归档页不会新增归档,添加项目在此无意义)。聊天归档仍通过「聊天」行进入 |
| 版本 | **0.6.2(code 602)** |
---
## 0.6.1 归档筛选改用共享项目选择器(分支 `flutter`)
| 项 | 结果 |
+1 -1
View File
@@ -6,7 +6,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
Flutter to compare mobile UI maturity.
Status: 0.6.1 — servers (passwordless / password login, HTTP/HTTPS and
Status: 0.6.2 — servers (passwordless / password login, HTTP/HTTPS and
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
over the OpenChamber private relay with end-to-end encryption; the pairing
link is pasted or scanned with the camera), session list with search and live
+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);
+20 -10
View File
@@ -36,13 +36,16 @@ class ProjectChoice {
/// Opens the project sheet and returns the chosen target, or null when the
/// person dismissed it. [selected] is a checkout path, or [AppState.chatTarget]
/// for the Chat row.
/// for the Chat row. [onlyProjects] limits the list to exactly those projects
/// (the archive page offers only projects that hold archived sessions, since
/// it never archives anything itself); null lists every selectable checkout.
Future<ProjectChoice?> showProjectPicker(
BuildContext context, {
required AppState app,
required String selected,
bool includeAll = false,
bool includeChat = true,
List<ProjectInfo>? onlyProjects,
}) {
return showModalBottomSheet<ProjectChoice>(
context: context,
@@ -56,6 +59,7 @@ Future<ProjectChoice?> showProjectPicker(
selected: selected,
includeAll: includeAll,
includeChat: includeChat,
projects: onlyProjects,
controller: controller,
),
),
@@ -84,6 +88,10 @@ class _ProjectPickerSheet extends StatefulWidget {
final String selected;
final bool includeAll;
final bool includeChat;
/// Null offers every selectable checkout; a list limits the picker to it
/// (the archive page) and hides the add-project action.
final List<ProjectInfo>? projects;
final ScrollController controller;
const _ProjectPickerSheet({
@@ -91,6 +99,7 @@ class _ProjectPickerSheet extends StatefulWidget {
required this.selected,
required this.includeAll,
required this.includeChat,
required this.projects,
required this.controller,
});
@@ -140,7 +149,7 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
Widget build(BuildContext context) {
final chat = widget.selected == AppState.chatTarget;
// A cached list is shown at once; the refresh updates it in place.
final projects = selectableProjects(widget.app);
final projects = widget.projects ?? selectableProjects(widget.app);
final query = _filter.trim().toLowerCase();
final visible = query.isEmpty
? projects
@@ -162,14 +171,15 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
style:
TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
),
TextButton.icon(
onPressed: _addProject,
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8)),
icon: const Icon(Icons.create_new_folder_outlined, size: 18),
label: const AppText('Add project'),
),
if (widget.projects == null)
TextButton.icon(
onPressed: _addProject,
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8)),
icon: const Icon(Icons.create_new_folder_outlined, size: 18),
label: const AppText('Add project'),
),
],
),
),
+1 -1
View File
@@ -2,7 +2,7 @@ name: openchamber
description: "A lightweight OpenChamber client for phones."
publish_to: 'none'
version: 0.6.1+601
version: 0.6.2+602
environment:
sdk: ^3.14.0
+6
View File
@@ -23,6 +23,8 @@ class _FakeTransport implements Transport {
body = [
{'id': 'p1', 'canonical': '/home/me/alpha', 'vcs': 'git'},
{'id': 'p2', 'canonical': '/home/me/beta', 'vcs': 'git'},
// A project with no archived sessions must not be offered.
{'id': 'p3', 'canonical': '/home/me/gamma', 'vcs': 'git'},
];
} else if (r.path == '/api/config/settings') {
body = {'projects': <dynamic>[]};
@@ -92,6 +94,9 @@ void main() {
// back.
await tester.tap(find.text('All projects'));
await tester.pumpAndSettle();
// Only projects with archived sessions are offered; no add-project here.
expect(find.text('Add project'), findsNothing);
expect(find.text('/home/me/gamma'), findsNothing);
await tester.tap(find.text('/home/me/alpha'));
await tester.pumpAndSettle();
expect(find.text('Old alpha'), findsOneWidget);
@@ -132,6 +137,7 @@ void main() {
await tester.tap(find.text('All projects'));
await tester.pumpAndSettle();
expect(find.text('/home/me/gamma'), findsNothing);
await tester.tap(find.text('/home/me/beta'));
await tester.pumpAndSettle();
expect(find.text('Old beta'), findsOneWidget);