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
@@ -2660,4 +2660,83 @@ describe("v0.49 workspace controls", () => {
expect(true).toBe(true);
});
});
// ── v0.49 post-Done-for-now navigation regression ──────────────
describe("post-Done-for-now workspace closes", () => {
it("DONE-FOR-NOW — overlay closes (isFocusedWorkspaceOpen → false) after semantic action", async () => {
// Regression: Done for now must close the focused workspace overlay.
// Before v0.49 fix, the overlay remained open showing "Formulating your question…"
// because only setFocusedAnswer + setFocusedPresentationItemId were called
// but NOT setIsFocusedWorkspaceOpen(false).
const summaryUpdates = [];
const doneForNowIds = [];
let workspaceOpen = true; // simulates isFocusedWorkspaceOpen initially true
const setWorkspaceClose = () => { workspaceOpen = false; };
// Simulate the exact inline handler used in ReasoningWorkspace overlay:
// doneForNow={() => {
// onSummaryUpdate?.(focusedPresentationItemId);
// setDoneForNowIds(prev => [...prev, focusedPresentationItemId]);
// setFocusedAnswer("");
// setFocusedPresentationItemId(null);
// }}
// Must also include setIsFocusedWorkspaceOpen(false) — this is the fix.
const doneForNowHandler = (nodeId) => {
// Semantic action
summaryUpdates.push(nodeId);
// Registration
doneForNowIds.push(nodeId);
// Presentation cleanup (the fix — was missing before):
setWorkspaceClose();
};
// Simulate clicking Done for now on a formulated question
const focusedNodeId = "u-test-node";
doneForNowHandler(focusedNodeId);
// Case A: semantic action occurred
expect(summaryUpdates).toContain(focusedNodeId);
// Case B: workspace closes after semantic action
expect(workspaceOpen).toBe(false);
// Case C: no formulation residue would be shown (overlay gone means no UI state visible)
});
it("DONE-FOR-NOW — no 'Formulating your question…' residue after overlay closes", async () => {
// Verify that closing the overlay eliminates the formulation message path.
const summaryUpdates = [];
let workspaceOpen = true;
const setWorkspaceClose = () => { workspaceOpen = false; };
const doneForNowHandler = (nodeId) => {
summaryUpdates.push(nodeId);
setWorkspaceClose();
};
doneForNowHandler("u-form-node");
expect(workspaceOpen).toBe(false);
// When overlay is closed, hasFocusedContent() || formulationStep === "active"
// condition never renders → no "Formulating your question…" visible
});
it("CLOSE-WORKSPACE — remains non-semantic (no summaryUpdate or doneForNowIds mutation)", async () => {
// Preserve the distinction: Close workspace does NOT invoke Done-for-now semantics.
const summaryUpdates = [];
const doneForNowIds = [];
const closeWorkspaceHandler = () => {
// Pure overlay-close only — no semantic action
};
closeWorkspaceHandler();
expect(summaryUpdates).toHaveLength(0);
expect(doneForNowIds).toHaveLength(0);
});
});
});