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:
1 parent
58e247644d
commit
64a1a98c1f
12 files changed
+888
-38
No files matched your search
@@ -10,6 +10,7 @@ import { plural } from "@/lib/i18n";
|
||||
import type { WorkspaceInfo } from "@/lib/protocol";
|
||||
|
||||
import { workspaceName } from "./commands";
|
||||
import { isSecondary, reasonLabelKey } from "./visibility";
|
||||
|
||||
function serverDot(status: ServerIdentity["status"]): DotStatus {
|
||||
if (status === "online") return "ok";
|
||||
@@ -78,9 +79,20 @@ export function WorkspaceRow({ workspace }: WorkspaceRowProps) {
|
||||
const { t } = useTranslation();
|
||||
const dot = instanceDot(workspace);
|
||||
const count = Math.max(workspace.liveCount || 0, workspace.sessionCount || 0);
|
||||
// Secondary rows are dimmed and carry the policy reason; the page decides
|
||||
// *whether* they render (see features/workspaces/visibility.ts).
|
||||
const secondary = isSecondary(workspace);
|
||||
const reasonKey = secondary ? reasonLabelKey(workspace) : null;
|
||||
|
||||
return (
|
||||
<div className="list-row" data-workspace-id={workspace.workspaceId} data-testid="workspace-row">
|
||||
<div
|
||||
className={secondary ? "list-row list-row--secondary" : "list-row"}
|
||||
style={secondary ? { opacity: 0.55 } : undefined}
|
||||
data-workspace-id={workspace.workspaceId}
|
||||
data-testid="workspace-row"
|
||||
data-visibility={secondary ? "secondary" : "default"}
|
||||
data-visibility-reason={reasonKey ? workspace.visibilityReason ?? "hidden" : undefined}
|
||||
>
|
||||
<span className="ico list-row__icon">
|
||||
<Icon name="folder" />
|
||||
</span>
|
||||
@@ -88,6 +100,11 @@ export function WorkspaceRow({ workspace }: WorkspaceRowProps) {
|
||||
<div className="list-row__name">{workspaceName(workspace, t("workspaces.unnamed"))}</div>
|
||||
<div className="list-row__cwd mono muted truncate">{workspace.cwd}</div>
|
||||
</div>
|
||||
{reasonKey ? (
|
||||
<Badge className="list-row__count" data-testid="workspace-reason">
|
||||
{t(reasonKey)}
|
||||
</Badge>
|
||||
) : null}
|
||||
<Badge tone="info" className="list-row__count">
|
||||
{plural("workspaces.sessionCount", count)}
|
||||
</Badge>
|
||||
|
||||
Reference in new issue
Block a user