Repository navigation
fix(app): keep an unsent new-task prompt reachable after opening another session - #4796
Conversation
…her session The workspace "+" (and the sidebar New session button) open the workspace's empty composer, which only creates its session on send. Until then the typed prompt lived in the hero's component state: it had no session id, so it was invisible to the persisted draft store, the workbench tabs, and conversation history. Clicking any existing session unmounted the hero and the text was gone, with nothing in the UI to return to. Persist the new-task prompt under a reserved per-workspace slot of the existing draft store (same account/organization scoping as session drafts), hydrate the hero from it, and show a Draft row under the workspace in the sidebar while the slot is non-empty. The row is highlighted on the new-task route, returns to the composer with the text restored, and disappears once the task is sent or the text is cleared. The hero is keyed by its draft owner so a workspace switch reads that workspace's draft instead of carrying text across. Proof: apps/app/tests/new-task-draft-state.test.tsx covers the slot's persistence and scoping; evals/specs/new-task-draft-return.e2e.test.ts replays the report (type, open another session, come back via the sidebar, survive a reload, clear) and fails on the previous source.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Warden review summary — ClearNative findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (138951 ms), confidentiality-review (193778 ms), spec-provenance-review (157123 ms), desktop-den-sync-review (228388 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (0a5b724eb8e0effaf37ae3d3d05d80bfa8a04e63). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Test evidence — an unsent new-task prompt survives opening another session and is reachable from the sidebar — ✅ passedSHA 0a5b724 · engine v1 ✅ 0/1 screenshots passed · 0 expectations passed · 0 failed · 0 pending [world] appWeb(daytona) · workspace(/tmp/openwork-new-task-draft-return-1789051978085) · session("Existing conversation") ⚪ UNVALIDATED — 1. an unsent new-task prompt survives opening another session and is reachable from the sidebar artifact 1
Test run created 2026-09-10T14:52:58.067Z · Source: |

Problem
Hover a workspace in the sidebar and click + (or the sidebar New session button). The empty composer opens and you start typing. To check a detail you click an existing session in the sidebar. There is now no way back: the new-task composer is gone, and clicking + again shows an empty composer — the prompt you were writing is lost.
Root cause
Both entry points call
onCreateTaskInWorkspace, which deliberately navigates to the workspace route without a session (/workspace/:id/session): the session is created only on send so opening the composer never waits on the engine and never litters empty sessions. Until send, the prompt lived inSessionEmptyHero'suseState("").Because there is no session id yet, that text was invisible to every mechanism that would otherwise preserve or surface it:
draft-store.ts) is keyed by session id;workbench-store.ts) are keyed by session id;conversation-tab-history.ts) explicitly resets whensessionIdis null.Opening any session unmounted the hero, dropping the text, and nothing in the UI represented the draft.
Fix
NEW_TASK_DRAFT_SESSION_ID = "__new-task__") in the existing draft store, viauseNewTaskDraftState(scope, workspaceId). It inherits the account/organization scoping session drafts already have, survives navigation and restarts, and stores text only (attachment chips are in-memoryFiles, same as session drafts). The hero hydrates from it on mount; the existing send path already clears the draft on submit and restores it on failure, so no extra plumbing is needed there.Draft: <first line>row under the workspace's sessions in the sidebar while the slot is non-empty (data-testid="sidebar-new-task-draft-<workspaceId>"). It is highlighted when you are on the new-task route, clicking it returns to the composer with the text restored, and it disappears once the task is sent or the text is cleared. + / New session also return to the restored draft.draftOwnerKey, so switching workspace reads that workspace's draft instead of carrying text across (theNewTaskComposerowner-change reset is unchanged and still covered bycomposer-focus-continuity.test.tsx).Chat-first mode (no workspace yet) has no persistence slot and behaves exactly as before.
Verification
apps/app/tests/new-task-draft-state.test.tsx— the slot outlives its component, is scoped per workspace and per account, clears on empty text, and is a no-op without a workspace.bun test --isolate tests/new-task-draft-state.test.tsx→ 2 pass.evals/specs/new-task-draft-return.e2e.test.ts(appWeb) — replays the report end to end: type without sending → Draft row appears (andopenwork.session-drafts.v2holds exactly one__new-task__key, not the real session's) → open the existing session (its composer is empty, the Draft row stays) → click the Draft row → composer shows the text → reload → still there → clear text → row and storage key gone.pnpm evals:e2e new-task-draft-return --local→ 1 passed (19 s).apps/app/srcstashed): 1 failed —Timed out … seeing testId=sidebar-new-task-draft-…, with the typed text visible in the hero but no way back.pnpm --filter @openwork/app typecheckclean;pnpm --filter @openwork/app test:core220 pass;node scripts/i18n-audit.mjs --ciclean.@openwork/appbun suite: 68 failures on bothorigin/devand this branch (identical set; pre-existing, not in the PR gate). Zero new failures.