Skip to content

feat: archive consistency across the phone and the desktop - #1636

Merged
jiangzhuqing000 merged 14 commits into
mainfrom
pr/dev-jiangzhuqing000
Nov 17, 2026
Merged

jiangzhuqing000 merged 14 commits into
mainfrom
pr/dev-jiangzhuqing000

Conversation

@jiangzhuqing000

Copy link
Copy Markdown
Collaborator

概述

本 PR 由 dev-jiangzhuqing000 冻结在 pr/dev-jiangzhuqing000(提交 48db12a1e),共 12 个提交,全部为本分支的工作。

主题是归档(archive)在手机端与桌面端的一致性:手机上归档/恢复/删除后的每一条路径,桌面端的列表与归档货架都要跟着正确变化;反过来,已归档的对象不应再出现在任何"可新建/可写入"的位置。

包含的改动

移动端

  • fix(mobile) 已归档工作区不再出现在新建会话的候选列表里。宿主端 read_workspaces() 故意保留 shelved 行(归档视图复用同一份数据),过滤责任在调用方;此前 workspaceOptions 直接读了未过滤的目录,且 [0] 预选可能选中界面上压根没画出来的归档工作区。分享入口的目的地列表同类问题一并修复。当列表因过滤而空时用新文案 noActiveWorkspaces 区分"都归档了"与"还没有工作区"。
  • feat(mobile) 手机端归档设置页与运行日志提示。
  • fix(mobile) 归档货架上的文件夹提供"恢复"操作。

桌面端 + 宿主

  • fix(desktop,host) 手机端移动归档货架后,桌面端货架重新读取。归档货架持有自己的分页流(archived、workspace-archived:<id>),refreshStore() 够不到它;此前远程命令只发 threads-updated,而货架只监听本地的 archive-changed。于是手机恢复工作区后,桌面端货架仍画着那个标题、下面却空空如也。新增 Event::ArchiveChanged 与 threads-updated 平行发出,Tauri 层映射为 archive-changed,复用本地归档已有的重读路径。
  • fix(desktop,mobile) 归档后货架上的树仍保持为一棵树。
  • fix(desktop) 两个 rail 视图共用一个"加载更多"控件。

测试

  • test(host) 断言手机端的归档设置确实写进了桌面端 store。

验证

  • 桌面端 src/components/layout 全量:1095 个测试通过;tsc --noEmit 干净。
  • 移动端 src/screens/__tests__、src/share、ChatScreen.test.ts:519 个测试通过;tsc --noEmit、eslint 干净。
  • cargo clippy -p future-host --all-targets -D warnings、cargo fmt --check、cargo check -p futureos 均干净。

新加的桌面端测试做了变异验证:临时禁用修复后该测试确实失败,恢复后通过,确认它不是空转。

备注

dev-<username> 会在本 PR 打开期间继续前进(后续任务照常并入),那部分不属于本 PR,属于下一个。CI 若因 main 前进而 BEHIND,会在冻结分支上合入 main 解决,元分支不动。

Reported as "the 「再显示 N 个」 under 工作区 and under 最近 are styled
differently — unify them, aligned with the conversation titles". They were two
different implementations:

- workspace/tree lists: `RailLoadMoreRow` — left-aligned on the rows' own column,
  muted ink, no border
- recent list: an inline button in `MergedRows` — centred, bordered,
  `bg-accent-soft` with accent ink and `font-medium`

So the same sentence read as two different kinds of control a tab apart, and the
recent one did not start where the titles above it start.

The recent list now renders `RailLoadMoreRow` like every other list. Its rows are
top-level, so it takes the 16px column rather than the in-group 28px one. The
component gained a `testId` prop so a view with several lists stays assertable
without a second appearance.

A regression test mounts both views and asserts the two controls carry the same
classes and the same 16px inset, and that neither is centred or accent-tinted.
Reported as "two conversations with a parent and child, I archived the parent,
and the archive list showed them as two separate conversations — I want the tree
structure in the archive too, and mobile has the same problem".

Archiving is a tree operation: `archive_thread_tree` shelves a conversation *and
every descendant*. Both archive views then drew the result flat, one equal row
per conversation, so a fork read as an unrelated conversation that happened to be
shelved at the same time — and the one fact the shelf exists to show (this
conversation and the work it started were put away together, and come back
together) was gone.

- Desktop: `ArchivedThreadRow` gained `depth`/`hasChildren`/`expanded` and the
  shared `+`/`−` tree toggle, and the loose shelf and the workspace groups now
  come from `visibleArchivedThreadRows` — the same `buildThreadTree` the active
  list uses, narrowed to the page's own rows. Archiving clears the pin, so the
  archived tree keeps every edge the store has.
- Mobile: `archivedRows` builds each shelf with `buildSessionTree` instead of
  stamping `depth: 1, hasChildren: false`, and takes the fold set so a fork is
  drawn inside its parent. `archivedCatalogRows` passes it through.
- `filterArchivedRows` and `pageArchivedRows` no longer assume a shelf is one
  level deep: a match keeps the subtree it roots, and the block boundary reads
  the row depths instead of the constant 1.

A fork whose parent is not on the page — behind the cursor, restored on its own,
or filed under another workspace — stays a root on both platforms, the rule every
other tree here follows and the only one that never loses a row.

Tests: desktop mounts a shelved parent plus fork and asserts the folded shelf
draws one row, then two after the toggle; mobile asserts a parent+fork nest one
level in, a workspace shelf nests one deeper still, an orphan fork is a root, and
a search keeps a match's subtree.
Archiving a workspace hides it from every list on the desktop, and its
conversations leave with it; the phone's own pages already agree, since
`activeWorkspaces` filters the shelf out of the workspace tree. The
new-conversation dialog was the one place a shelved workspace came back:
`workspaceOptions` read the catalogue straight, and that read keeps the
shelved rows on purpose — the archived view draws them without a second
round trip, so the filter belongs to the caller, not to the read.

The picker, its pre-selection and the share sheet's destination list now
all go through `activeWorkspaces`, so a conversation can no longer be
started inside a workspace the reader had cleared.

The pre-selection needed the same filter rather than only the drawn list:
`selectDeviceWorkspaces` and `openNew` took `[0]` of the unfiltered array,
so a shelved workspace at the head of a machine's list became the chosen
workspace of a dialog that never drew it — invisible, and still what the
footer would have created in.

When the filter empties the list, the dialog says which fact it is:
`noActiveWorkspaces` ("everything there is shelved") instead of
`noWorkspaces` ("nothing there yet"), because the two send the reader to
different places.
The archiving settings only existed on the desktop, so a reader who archived from the phone cleared run logs silently: the paired machine applied its own setting and nothing on the phone said so.

Expose the run-log cleanup switch, the automatic-archive switch and the idle period in the phone's preferences page, and have them read and write the paired desktop's settings. Before an archive from the phone, show the same one-time notice the desktop shows, keyed on the desktop's own acknowledged flag so the reader is told once between the two surfaces rather than once each. Cancelling leaves the flag alone; a running conversation folds the notice into its existing stop-and-archive question.
The phone's settings page writes through update_app_settings, which is also what publishes app_settings_changed for the desktop to reload. Reading the store back after a remote update pins the first half of that path, so a later handler that wrote elsewhere would fail here instead of silently leaving the desktop showing stale values.
Restoring a workspace on the phone left its heading on the desktop's
archived shelf, with no conversations under it, until some local archive
action refreshed the view. The row was already gone from the store; the
shelf was drawing a page nobody had re-read.

The shelf holds its own streams — `archived` and `workspace-archived:<id>`
— which `refreshStore` does not touch. What a remote archive/restore did
raise was `threads-updated`, a re-list of the *live* conversations, and
the archived view only re-reads on `archive-changed`, which nothing
outside the shell's own dialogs ever raised. So the two halves of the
catalogue went out of step exactly when another client moved one of them.

`ArchiveChanged` is now its own host event, raised beside
`ThreadsUpdated` — not instead of it, because the shelf and the live list
are different streams and a client drawing both re-reads both. The desktop
window presents it as `archive-changed`, the event the shelf already
listens to, so the remote path re-reads through the same route a local
archive dialog uses rather than a second one invented for the phone.

Raised on every remote command that can move the shelf: `archive_session`,
`restore_session`, `delete_session` (a deleted row leaves a heading behind
it too), `archive_workspace`, `restore_workspace` and `delete_workspace`.
Shelving one conversation leaves its workspace in use, so that folder keeps archived=false while still being drawn as a heading on the shelf. The folder menu read only that flag, so it offered 'archive' on a row the reader was already looking at on the shelf.

Treat being drawn on the shelf as the whole condition, as the desktop's shelf menu does: every folder there offers restore, because the folder is what brings back everything inside it.
@jiangzhuqing000
jiangzhuqing000 enabled auto-merge (squash) November 17, 2026 08:40
…w carries

The phone's archive settings page added four writable fields
(archiveRunLogCleanup, archiveRunLogNoticeSeen, autoArchiveEnabled,
autoArchiveIdleDays) to the desktop settings snapshot, but this test's patch
still named only the original five. Its whole point is to name every writable
field so that `assert_eq!(updated["data"], patch)` notices one the reply drops;
with four fields absent from the patch, the comparison went from exact to a
subset check, and the test failed instead.

The fields are added to the patch, and the stored-settings assertions beside it
pin what each one wrote — the repair the test was written for, not a relaxation
of it.
@jiangzhuqing000
jiangzhuqing000 merged commit 6b34d34 into main Nov 17, 2026
27 checks passed
@jiangzhuqing000
jiangzhuqing000 deleted the pr/dev-jiangzhuqing000 branch November 17, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant