feat(daemon): collapse workspace noise into a "show hidden" section

Discovery returns every pi session directory ever seen, so the console opened on
47 rows on this machine: 20 ghosts (cwd deleted) and 21 scratch dirs under /tmp
next to the real projects. Every row now carries a derived, non-persisted
`visibility`/`visibilityReason`; nothing is filtered server-side, so
`/workspace/<id>` deep links and the chat page's id lookup still resolve.

Precedence: explicit `hidden` wins; a live instance, `pinned` or `trusted`
rescues a row; then temp paths (`PI2_WORKSPACE_HIDE_TEMP`, on), ghosts
(`PI2_WORKSPACE_HIDE_GHOSTS`, on), outside roots (`PI2_WORKSPACE_HIDE_OUTSIDE_ROOTS`,
off) and staleness (`PI2_WORKSPACE_STALE_DAYS`, off). Measured on real data:
47 → 26 default rows, 0 openable rows lost.

The browser collapses the secondary rows behind a persisted toggle and dims them
with a reason badge; `workspace.add` now clears `hidden`.
This commit is contained in:
yuez committed 2026-10-23 10:08:15 +08:00
1 parent 58e247644d
commit 64a1a98c1f
12 files changed
+888 -38

No files matched your search

+13
View File
@@ -278,8 +278,21 @@ export interface WorkspaceInfo {
liveCount: number;
lastActiveAt: number | null;
instance: InstanceState | null;
/**
* Derived, non-persisted noise classification (see docs/protocol.md).
* `secondary` rows are still served and addressable — a client decides
* whether to list them behind a "show hidden" toggle. Older daemons omit
* the field; treat a missing value as `default`.
*/
visibility?: WorkspaceVisibility;
/** Why a row is `secondary`; absent for `default` rows. */
visibilityReason?: WorkspaceVisibilityReason;
}
export type WorkspaceVisibility = "default" | "secondary";
export type WorkspaceVisibilityReason = "hidden" | "ghost" | "temp" | "outside-roots" | "stale";
export type DaemonCommandMethod =
| "instance.ensure"
| "instance.shutdown"