From 873ccae32a0208395a6db6510fd05a746e3cd70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Fri, 7 Aug 2026 14:23:41 +0000 Subject: [PATCH] record the defect the useDashboardState tests found section 9 now carries a concrete instance of its own argument: a test found a bug that two careful readings of the file had not, in code written three days earlier to prevent exactly that failure. also records the two bun/testing-library harness facts that cost more than the fix did, since both present as an unrelated file breaking for no reason. Co-Authored-By: Claude Opus 5 --- docs/workspace-panel-todo.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/workspace-panel-todo.md b/docs/workspace-panel-todo.md index d58522fd..ea9651e0 100644 --- a/docs/workspace-panel-todo.md +++ b/docs/workspace-panel-todo.md @@ -988,6 +988,28 @@ they are marked below, because a dead-code list that is itself wrong is the wors as an *updater*, never as a computed tree, which is the structural fix; a test there would be guarding the fix rather than finding the bug. Checked, not assumed — `bun test src/workspaces/officerdev/src/components/Workspace/`. +- [x] **`useDashboardState`, and the strongest argument this section has for itself.** _(`4f8046d`, + branch `agent-coordination-mvp`)_ — 14 tests over the store every layout and every + `config.agentName` is persisted through. They found a live Tier-A-class defect on the first run, + in code written three days earlier to *stop* silent write loss: `revert` decided whether to roll + back by asking "does the cache still hold exactly what I wrote?" **by reference**, and + `setQueryData` runs React Query's structural sharing, which rebuilds the object it stores rather + than keeping the one it was handed. Measured against @tanstack/react-query 5.101.4 — an object + value comes back `!==`, a string comes back `===`. So the guard was false for every *container* + the store exists to hold, and a refused write kept its optimistic value in the cache while the + toast said it had been rolled back; the change then vanished at the next reload. Only primitives + ever reverted, which is exactly why nobody saw it. Replaced with a per-key write sequence, which + asks the question the identity check meant to ask and does not depend on identity at all. The + regression pin is the test named "a refused OBJECT write is rolled back too". + Two things worth carrying forward. **A test found a bug that review had not**, in a file that had + been read carefully twice — which is the case for §9 stated better than any argument. And + `mock.module` is **process-wide and permanent** in Bun: a stub that does not spread the real + module deletes exports out from under files that never heard of it. Likewise + `@testing-library/react` auto-registers `afterEach(cleanup)` at *import* time, so it lands in + whichever test file imports the library first and every later file silently gets none — that is + now registered in `test-setup.ts`, where preload's lack of a file scope makes it global. Adding + one test file broke fourteen assertions in `DataTable.test.tsx` before both were understood. + - [x] **A panel is told where it is, instead of being handed a key to reverse-engineer.** _(`dbe585f` + `717580f` + `585f234`, branch `agent-coordination-mvp`)_ — the first three items of §5.9. The context field `dashboardId: string` — which was never an id, always the whole `workspace.key` —