4.2 KiB
4.2 KiB
Workspace Source-Of-Truth Cleanup Plan
Scope
Only this worktree:
/Users/moboudra/.paseo/worktrees/1luy0po7/workspace-sot-hard-cut
Objectives
- One server-owned source of truth for workspace identity.
- Header and sidebar render the same workspace name field.
- Remove client-side workspace construction from agent data.
- Hard cut legacy paths (no dual-read compatibility layer).
Non-Objectives
- No UI-only taxonomy in canonical model (
subtitle,titleKind). - No React derivation from branch/path basename for workspace naming.
- No silent fallbacks masking missing state (
?? "", cwd fallback label).
Phase 0: Audit Existing Worktree Changes
- Inventory all modified files in this worktree.
- For each hunk, classify as
keep,delete, orrewrite. - Build a bad-pattern list and remove all of these:
- Workspace naming fallback in React.
- Canonical payload fields that are presentation-only.
- Any primary label logic equivalent to
Unknown branch. - Any sidebar workspace list constructed from live agent rows.
Acceptance
- Full inventory exists before further refactor work.
- Every bad pattern has a mapped removal location.
Phase 1: Canonical Model Simplification
Define a minimal server canonical workspace entity:
id: normalized cwd (single identity field)projectId: stable grouping keyname: canonical workspace name (server computed)status: dominant state bucketactivityAt: nullable ISO timestamp
Do not include UI/presentation fields in canonical payload.
Acceptance
- No duplicate identity fields (
workspaceId+cwd) in canonical contract. - No subtitle/title-kind fields in canonical contract.
Phase 2: Server Aggregation and RPC
- Build workspace aggregation in
session.tsfrom authoritative server state. - Compute workspace
nameonce in server policy code. - Provide:
fetch_workspaces_request/responsesnapshot RPCworkspace_updateincremental upsert/remove stream
- Keep update semantics aligned with existing directory subscription behavior.
Acceptance
- Non-git and git workspaces both resolve deterministic
name. - No
Unknown branchemitted by server. - Workspace update stream reflects agent lifecycle/state changes.
Phase 3: Client Store Wiring
- Add workspace map in session store keyed by canonical
id. - Hydrate only from
fetch_workspaces. - Apply only
workspace_updateevents for incremental updates. - Keep workspace state channel separate from agent-list derivation.
Acceptance
- Workspace map is populated strictly from workspace RPCs.
- No workspace assembly logic from agent lists in runtime/store.
Phase 4: UI Hard Cut
- Sidebar row label reads only
workspace.name. - Header title reads only
workspace.name. - Remove all local workspace naming helpers based on cwd/branch.
- Missing descriptor after hydration must render explicit missing-state UI, not fallback text.
Acceptance
- Header and sidebar names are guaranteed identical source field.
- No
?? ""/cwd/branch fallback paths for workspace name.
Phase 5: Legacy Deletion
- Delete prior client sidebar workspace-building path(s).
- Remove
Unknown branchprimary naming logic. - Remove any query/helper used only for old workspace naming.
- Delete dead types/helpers from failed intermediate designs.
Acceptance
- No app code path builds workspace rows from agent lists.
- Legacy naming/building code fully removed in same change set.
Phase 6: Verification
- Protocol/schema tests for workspace request/response/update.
- Server aggregation tests:
- non-git workspace
- git branch workspace
- detached/headless workspace
- removal/update behavior
- UI tests:
- selected workspace header name equals sidebar workspace name
- explicit missing-state rendering when descriptor absent post-hydration
- Run
npm run typecheck. - Manual validation in this worktree daemon+expo stack.
Acceptance
- Tests pass.
- Typecheck passes.
- Manual verification confirms name parity and status correctness.
Execution Guardrails
- Work only in
workspace-sot-hard-cut. - No destructive git operations.
- No fallback naming logic in React.
- One naming policy and source of truth: server.
- Hard cut means old code removed, not left dormant.