rank the panel defects against the objective, not against severity

The re-rank the north star deferred, done now that the MVP is built and
running — so it is ranked against what the mechanism turned out to need.

The finding is that most of the list is not on this path. The mechanism is
server-side and a panel is a pointer to it, so a remount, a re-render or a
drag costs a replay, not a session. Section 5.2 and 5.3 are large downgrades;
5.3 was on the critical path when the north star was written and is disarmed
by resolving identity by name.

What is left is small and mostly one defect wearing four hats: a write that
silently does not land. Panel identity lives in the layout jsonb now, so the
swallowed persist catch, the dispatcher's missing else and the two debounce
lost-updates each become a panel that forgets which agent it is — invisibly,
for exactly as long as nobody is looking.

Also corrects two items the MVP made stale, and promotes layout-utils tests:
e588524 put agent identity inside those mutators and shipped them untested.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-07 08:40:33 +00:00
co-authored by Claude Opus 5
parent 678d29b574
commit ecc7fb90d8
2 changed files with 212 additions and 8 deletions
+132 -1
View File
@@ -708,4 +708,135 @@ handoff *visible and its failure loud* (§2), not a history feature.
## 6. How the found defects map onto the path
*(deferred — this is the re-rank, and it is explicitly not to be started yet)*
*(the re-rank. Written 2026-08-07 after the MVP was built and proven running, so it is ranked against
what the mechanism turned out to need, not against what it was predicted to need. `workspace-panel-todo.md`
is ordered by defect severity; this section says which of those defects the **objective** actually cares
about. Where the two disagree, this section wins for prioritisation and the todo keeps the severity note.)*
### 6.1 The headline: most of the panel defect list is not on this path
That is the finding, and it follows directly from Q1 and §1.16. **The mechanism is server-side; the
panels are a window onto it.** An agent's identity, its session, its transcript and its inbox all live in
Postgres and on the sidecar's disk. So a panel can remount, re-render, lose its React state, be dragged
across the dashboard, or not be rendered at all — and the work continues. Whole sections of the todo that
rank high on severity rank near-zero here.
The corollary, and it is the useful half: the defects that *do* matter are almost all the same defect
wearing four hats — **a write that silently does not persist.** Panel identity is the one piece of
coordination state that lives in the layout jsonb rather than in a table of its own, so every silent
persistence failure in this list is now a path by which a panel forgets which agent it is.
### 6.2 Tier A — on the critical path
**A1. Stop swallowing persist failures.** (§1, third item — `state/src/useDashboardState.ts:46`,
`.catch(() => {})`.) *The single highest-value item in the whole list against this objective.* The
panel's agent name is written through this path. A swallowed 500 leaves the optimistic cache correct, so
the panel shows its name, answers to its name, and **forgets it on the next reload** — the failure is
invisible for exactly as long as the human is not looking, which is the entire window this project
exists to serve. §2 requires *loud failure*; this is the loudest silence in the codebase.
**A2. The PATCH dispatcher's missing `else`.** (§2, first item.) The server half of A1. `ws-layout-*` is
matched today so panel `config` does persist — verified, the demo dashboard round-tripped with
`config: {agentName: …}` intact — but a chain of `if (…) continue` with no fallback means the *next* key
family added for coordination is a silent no-op that returns 200. Add the 400.
**A3. Validate the layout on read, and fix the `'[]'` default.** (§4, items 2 and 3.) Panel `config` is
new unvalidated jsonb inside an already-unvalidated tree. `normalizeLayout` calling `.children.map` on a
stored `[]` throws, and with no error boundary (A4) that is a white screen where the dashboard should be.
**A4. Add an error boundary around `WorkspaceRenderer`.** (§4, item 1 — the repo has none, anywhere.)
Ranked here for one specific reason: this is the **last mile of the whole objective.** Work proceeds
overnight; the owner opens the dashboard at 07:00 to see it. A malformed row turning that into a white
screen loses the result at the only moment it is consumed. The work itself is safe — it is in
`chat_session_events` — which is exactly why the recovery path must offer "restore default layout"
rather than requiring SQL.
**A5. The resize-debounce items.** (§5.5, first two.) Both are lost-update bugs against the layout, and
the layout is now where a panel's identity lives. The 500 ms timer closing over a pre-drag tree does not
merely resurrect a deleted panel — it **re-writes an older `config`**, so a panel that was just named
reverts to anonymous. Concurrent same-key writes clobbering has the same effect from a window resize.
The prescribed fix (an updater-form `setValue` + cleanup) fixes identity loss as a consequence.
**A6. Test `layout-utils.ts`.** (§9.) Promoted from "cheapest high-value target" to critical path, and
the reason is mine to own: `e588524` put agent identity inside those pure functions —
`setContents`, `swapPanels`, `movePanel`, `setPanelConfig`, `collectPanelConfigs`, `newPanelFrom` — and
shipped them with **no tests**. A regression in `swapPanels` now silently swaps two agents' identities
between panels, which is worse than any layout glitch it could previously cause. 214 lines of pure
functions over a serialisable tree; there is no excuse.
**A7. Two windows must not disagree about the roster.** (§5.5, "the cache is never invalidated" —
`staleTime: Infinity`, no `invalidateQueries` anywhere, and every PATCH already returns a fresh state
blob the client throws away.) Q1 makes the dashboard *a window onto server-side work*. Two windows onto
the same work that permanently diverge, and neither told, is a direct contradiction of that. Cheap:
consume the response that is already being computed.
### 6.3 Tier B — needed for the surface, not for the mechanism
**B1. `dashboardId` is a bag whose format is parsed by its consumers.** (§5.9, third item.) Promote —
and note a hazard this document's own MVP introduced. The agent address book is keyed on `dashboardId`,
which is literally `workspace.key` (`WorkspaceView.tsx:163`) — so the demo dashboard's agents are stored
under `ws-layout-agent-mvp`. **Renaming a screen key, or changing that derivation, silently orphans
every agent row on that dashboard.** The rows survive, the sessions survive, and the panels can no longer
find them. The prescribed fix — give the context `{kind, id}` instead of the raw key — is now load-bearing
rather than tidy. Not Tier A only because it is stable today and the failure requires someone to change
the derivation.
**B2. Panel lifecycle — but the ranking inverts.** (§5.1.) Against the terminal-orphan objective this was
"the highest-value change here." Against *this* objective the priority is the opposite one: **closing a
chat panel must never destroy the agent.** §5 Q2 records the hazard precisely — the explicit `disconnect`
path calls `clearClaudeSession`, which destroys the `sessionKey → claudeSessionId` pointer and orphans the
transcript, whereas idle reaping deliberately does not. So what is wanted from `onClose` here is a
*guarantee that nothing rides that path*, not an eager cleanup hook. Build the hook for the terminal by
all means; do not let a chat panel be wired into it without deciding that question first. A panel is a
pointer, and closing a window should not delete what it points at.
**B3. `normalizeLayout` as framework, not convention.** (§5.4.) Matters for one consequence: a panel
whose appType is allow-listed but no longer in the registry renders, on a `locked` screen, as an
unrecoverable empty box. A chat panel in that state is a *visible* agent the human cannot reach — though
note its peers still can, because the mechanism does not go through the browser. Real, but a display
failure over a live agent rather than a lost one.
**B4. The mobile collapse decision.** (§6 of the todo, first item.) Genuinely undecided against this
objective, and worth putting to the owner rather than guessing: *"I want to be able to sleep at night"*
raises the obvious question of whether the 03:00 check-in happens on a phone. If yes, a user-created
dashboard rendering only its left column forever is a Tier A problem wearing a mobile hat. If the answer
is "I check on the laptop, and mobile web is being retired for the native app" — which is what
`CLAUDE.md` currently says — it stays Tier C. **One question, one answer, large ranking swing.**
### 6.4 Tier C — orthogonal to this objective, keep them ranked by severity
Not dismissals. These are real defects and several are severe; they simply do not touch agents
coordinating with each other, and should be scheduled on their own merits rather than pulled forward by
this project.
- **§1's Running Shells items and §5.1's pty follow-ups.** The terminal orphan leak is its own worthwhile
problem. It is not this one.
- **§3, multi-user correctness.** Ranks on its own timer (a second member creating a dashboard), which is
unrelated to this path.
- **§5.2, the remount table.** *The largest downgrade in this re-rank.* A remount used to threaten
whatever the panel was holding; a panel now holds nothing. A chat panel that remounts re-runs
`resume-cursor` from its stored cursor and replays the durable log — it costs latency, and §2 declares
latency free. Fix these for the interaction quality they are actually about; do not fix them for this.
- **§5.3, drag-to-move.** *The second-largest downgrade, and it was on the critical path when the north
star was written* (§1.5, P3: "dragging a panel would silently sever its session binding"). Two things
disarmed it. Q3 made the **name** the address and the panel id merely where it currently lives; and
`e588524` made `swapPanels`/`movePanel` carry `{appType, config}` as one unit, so the name travels with
the panel. `useAgentPanel` resolves by name and re-anchors the row's `panelId` afterwards. The
finish-or-delete decision is still open and still worth taking — it is ~180 lines of dead code — but it
is no longer gating anything.
- **§5.6 registry, §5.7 effect hygiene, §5.8 navigation, §5.10 channel hygiene, §8 dead code.** All
orthogonal. Two notes in passing: §5.10's observation that `preview:refresh` and `chat:active-session`
are written by `ChatPanelWrapper` and read by nobody survives the MVP rewrite unchanged — I kept both
writes rather than widen the diff. And §5.8 is not a prerequisite here; the mechanism never goes
through a channel, because it never goes through the browser at all.
### 6.5 What the re-rank did *not* find, and that is the result
No defect in `workspace-panel-todo.md` blocked building the MVP. It was built, and it ran unattended, on
the framework as it stands. The framework needed exactly one addition — per-panel config that survives a
move — and that is now `e588524`.
So the honest summary is: **this list is not the bottleneck, and it should stop being treated as the
prerequisite queue for the objective.** Tier A is seven items, five of which are the same "a write
silently did not land" defect, and all seven are small. Everything else in the list should be scheduled
for its own reasons, on its own timetable, by severity — which is what the file was already ordered by.