Skip to content

fix(app): keep an unsent new-task prompt reachable after opening another session - #4796

Merged
yomgui merged 1 commit into
devfrom
fix/new-session-draft-return
Sep 10, 2026
Merged

yomgui merged 1 commit into
devfrom
fix/new-session-draft-return

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

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 in SessionEmptyHero's useState("").

Because there is no session id yet, that text was invisible to every mechanism that would otherwise preserve or surface it:

  • the persisted draft store (draft-store.ts) is keyed by session id;
  • the workbench tabs (workbench-store.ts) are keyed by session id;
  • conversation back/forward history (conversation-tab-history.ts) explicitly resets when sessionId is null.

Opening any session unmounted the hero, dropping the text, and nothing in the UI represented the draft.

Fix

  1. Persist the new-task prompt under a reserved per-workspace slot (NEW_TASK_DRAFT_SESSION_ID = "__new-task__") in the existing draft store, via useNewTaskDraftState(scope, workspaceId). It inherits the account/organization scoping session drafts already have, survives navigation and restarts, and stores text only (attachment chips are in-memory Files, 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.
  2. Show a 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.
  3. The per-workspace hero is keyed by draftOwnerKey, so switching workspace reads that workspace's draft instead of carrying text across (the NewTaskComposer owner-change reset is unchanged and still covered by composer-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 (and openwork.session-drafts.v2 holds 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).
    • Negative control on the unfixed source (apps/app/src stashed): 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 typecheck clean; pnpm --filter @openwork/app test:core 220 pass; node scripts/i18n-audit.mjs --ci clean.
  • Full @openwork/app bun suite: 68 failures on both origin/dev and this branch (identical set; pre-existing, not in the PR gate). Zero new failures.

…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.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 10, 2026 2:53pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 2:53pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 2:53pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 2:53pm UTC

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native 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

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@different-ai different-ai deleted a comment from github-actions Bot Sep 10, 2026
@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Test evidence — an unsent new-task prompt survives opening another session and is reachable from the sidebar — ✅ passed

SHA 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")
[user] label=New session · click(label=New session) · see(composer, editable, text="") · notSee(testId=sidebar-new-task-draft-ws_b91dc437a5f2) · type(composer, "Ask about the deploy checklist before Friday") · see(testId=sidebar-new-task-draft-ws_b91dc437a5f2, text="Draft: Ask about the deploy checklist before Friday")
[probe] storage(openwork.session-drafts.v2)
[user] testId=sidebar-session-ses_f7430385affekz4c0w0U5snRSr · click(testId=sidebar-session-ses_f7430385affekz4c0w0U5snRSr) · see(composer, editable, text="") · see(testId=sidebar-new-task-draft-ws_b91dc437a5f2, text="Draft: Ask about the deploy checklist before Friday") · testId=sidebar-new-task-draft-ws_b91dc437a5f2 · click(testId=sidebar-new-task-draft-ws_b91dc437a5f2) · see(composer, editable, text="Ask about the deploy checklist before Friday") · screenshot · reload · see(testId=sidebar-new-task-draft-ws_b91dc437a5f2, text="Draft: Ask about the deploy checklist before Friday") · testId=sidebar-new-task-draft-ws_b91dc437a5f2 · click(testId=sidebar-new-task-draft-ws_b91dc437a5f2) · see(composer, editable, text="Ask about the deploy checklist before Friday") · type(composer, " ", replace) · press(Backspace) · see(composer, editable, text="") · notSee(testId=sidebar-new-task-draft-ws_b91dc437a5f2)
[probe] storage(openwork.session-drafts.v2)
steps 1 ✅ start a new task and type without sending (3.7s) · 2 ✅ open the existing conversation to look something up (0.3s) · 3 ✅ come back to the draft from the sidebar (0.5s) · 4 ✅ the draft also survives a restart of the renderer (2.1s) · 5 ✅ clearing the prompt removes the draft and its sidebar row (3.6s)
verdict passed · 11 user observations (see ×8, notSee ×2, screenshot ×1) · 2 probes · steps 5/5

⚪ UNVALIDATED — 1. an unsent new-task prompt survives opening another session and is reachable from the sidebar artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

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: evals/results/test-runs/2026-09-10T14-52-58-066Z-an-unsent-new-task-prompt-survives-opening-another-session-and-is-reachable-from/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4796 --test-run 2026-09-10T14-52-58-066Z-an-unsent-new-task-prompt-survives-opening-another-session-and-is-reachable-from

@yomgui
yomgui merged commit e925c7c into dev Sep 10, 2026
27 checks passed
@yomgui
yomgui deleted the fix/new-session-draft-return branch September 10, 2026 15:01

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 0a5b724e Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-app — 0a5b724e Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 0a5b724e Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 0a5b724e Deployed Sep 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant