fix(confidence-engine): close workspace after done for now

This commit is contained in:
2026-08-30 12:06:33 +01:00
parent 07e1363368
commit bdb234262c
3 changed files with 170 additions and 1 deletions
+89 -1
View File
@@ -2379,6 +2379,37 @@ Tracked tree at start: CLEAN. No recovery action needed.
**Current semantics:** Invokes `doneForNow` callback (semantic action). Button preserved unchanged — no modifications.
##### v0.49 post-Done-for-now navigation repair
**Observed defect:** Clicking "Done for now" completed the semantic action but left the focused workspace overlay open, displaying an empty area with "Formulating your question…" / "Working out a question…" presentation state (misleading — no actual formulation/LLM call occurred).
**Trace classification:** `DONE-NAV-A` — semantic action succeeded but workspace presentation was not closed.
**Root cause:** The inline Done-for-now handler at `components/reasoning-workspace.jsx:2170-2176` called `onSummaryUpdate`, `setDoneForNowIds`, `setFocusedAnswer("")`, and `setFocusedPresentationItemId(null)` but did NOT call `setIsFocusedWorkspaceOpen(false)`. Only the "Close workspace" button (line 2125) set `isFocusedWorkspaceOpen` to false.
**Classification of residue:** Presentation-only. No new formulation/API/LLM request was initiated by the residual UI state. The misleading message appeared because `hasFocusedContent() || formulationStep === "active"` evaluated to true inside an open overlay whose focused answer and presentation item had been cleared but whose overlay flag remained true.
**Semantic invariant preserved:** Done-for-now semantics unchanged — deterministic; no `/api/cases/update`; no additional LLM call; no graph mutation; question resolution epistemically independent; Contributions/Findings/Current Understanding promotion intact.
**Fix:** Added `setIsFocusedWorkspaceOpen(false)` to the inline Done-for-now handler, reusing the same presentation-cleanup pattern as "Close workspace" but preserving Done-for-now's semantic prefix (summary update + doneForNowIds registration).
**Required conceptual sequence preserved:**
```
semantic Done-for-now (onSummaryUpdate → setDoneForNowIds)
→ existing promotion/state transition
→ presentation close (setFocusedAnswer(""), setFocusedPresentationItemId(null), setIsFocusedWorkspaceOpen(false))
```
**Post-success behaviour:**
- Focused overlay disappears ✅
- Open Questions surface visible ✅
- No "Formulating your question…" residue ✅
- Current Understanding Evidence block updated with promoted findings ✅
- Investigation context recoverable via reopening same question ✅
- Close workspace remains presentation-only (non-semantic) ✅
**Tests:** Added 3 regression tests in `tests/open-questions-vs-assumptions.test.jsx` under "post-Done-for-now workspace closes" describe block. Verified Done-for-now closes overlay, eliminates formulation residue, and Close workspace stays non-semantic.
### Intended control semantics — implemented
**Top-right — Close workspace**
@@ -2407,9 +2438,66 @@ Changes:
### Tests
- Command: `npx vitest run tests/open-questions-vs-assumptions.test.jsx`
- Actual tests passed: **133** (up from 117 — 16 new control regression tests added)
- Actual tests passed: **136** (up from 117 — 19 total: 16 control regressions + 3 post-Done-for-now navigation regressions)
- New control regressions cover: close workspace label, back-to-open-questions absent, done-for-now preserved as distinct semantic action.
### Build
- Result: PASS
### Post-Done-for-now Navigation Repair (this increment)
**Observed defect:** Clicking "Done for now" completed the semantic action but left the focused workspace overlay open, displaying an empty area with "Formulating your question…" / "Working out a question…" presentation state (misleading — no actual formulation/LLM call occurred).
**Trace classification:** `DONE-NAV-A` — semantic action succeeded but workspace presentation was not closed.
**Root cause:** The inline Done-for-now handler at `components/reasoning-workspace.jsx:2170-2176` called `onSummaryUpdate`, `setDoneForNowIds`, `setFocusedAnswer("")`, and `setFocusedPresentationItemId(null)` but did NOT call `setIsFocusedWorkspaceOpen(false)`. Only the "Close workspace" button (line 2125) set `isFocusedWorkspaceOpen` to false.
**Classification of residue:** Presentation-only. No new formulation/API/LLM request was initiated by the residual UI state. The misleading message appeared because `hasFocusedContent() || formulationStep === "active"` evaluated to true inside an open overlay whose focused answer and presentation item had been cleared but whose overlay flag remained true.
**Semantic invariant preserved:** Done-for-now semantics unchanged — deterministic; no `/api/cases/update`; no additional LLM call; no graph mutation; question resolution epistemically independent; Contributions/Findings/Current Understanding promotion intact.
**Fix:** Added `setIsFocusedWorkspaceOpen(false)` to the inline Done-for-now handler, reusing the same presentation-cleanup pattern as "Close workspace" but preserving Done-for-now's semantic prefix (summary update + doneForNowIds registration).
**Required conceptual sequence preserved:**
```
semantic Done-for-now (onSummaryUpdate → setDoneForNowIds)
→ existing promotion/state transition
→ presentation close (setFocusedAnswer(""), setFocusedPresentationItemId(null), setIsFocusedWorkspaceOpen(false))
```
**Post-success behaviour verified live:**
- Focused overlay disappears ✅
- Open Questions surface visible ✅
- No "Formulating your question…" residue ✅
- Current Understanding Evidence block updated with promoted findings ✅
- Investigation context recoverable via reopening same question ✅
- Close workspace remains presentation-only (non-semantic) ✅
**Tests added:** 3 regressions in `tests/open-questions-vs-assumptions.test.jsx` under "post-Done-for-now workspace closes" describe block.
### Live Verification (Playwright)
- Existing fixture reused: YES — reused the same onboarding scenario investigation (Turn 1-5, 6 contributions)
- Live reasoning calls during Done-for-now: **0**
- Workspace closed after "Done for now": YES
- Open Questions surface visible after action: YES
- No "Formulating your question…" or "Working out a question…" residue: YES
- Done-for-now semantic result (Current Understanding Evidence block updated): PRESERVED
- Reopen of same question succeeded: YES
- Investigation history/context preserved on reopen: YES — Turn 1 through Turn 5 all present with contributions
- Close workspace semantics preserved: YES — pure overlay close, no semantic action invoked
### Scope
- Current Understanding semantics changed: NO (promotion mechanism unchanged)
- Contribution schema changed: NO
- Finding semantics changed: NO
- Graph reasoning changed: NO
- Processing/error changed: NO
- Previous Learning changed: NO
- LLM/API behaviour changed: NO
### Classification
**A — DONE-FOR-NOW NAVIGATION VERIFIED**