Skip to content

fix(app): stop persisting hero keystrokes to the new-task draft slot once a send is in flight - #4861

Merged
yomgui merged 2 commits into
devfrom
fix/new-task-draft-slot-leak
Sep 11, 2026
Merged

yomgui merged 2 commits into
devfrom
fix/new-task-draft-slot-leak

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Root cause

Regression from #4796 (e925c7c99), flagged by the E2E risk gate as a new class (c) product regression on dev (workspace-new-task-hit-target — "Keep new tasks and sends instantly responsive" — red vs the last 3 nightlies at 2fcbae60e and 3f783066f, run 34519630856; gate table: /Users/guillaume/OpenWork Chat/reports/e2e-gate-baseline-2026-09-10.md).

#4796 made SessionEmptyHero persist every onDraftChange into the per-workspace __new-task__ draft slot so an unsent prompt survives opening another session. NewTaskComposer.handleRunTask clears the draft (onDraftChange(""), which empties the slot) and then awaits session creation while the composer stays live. Anything typed during that pending window flows through the same onDraftChange → hero setPrompt → persisted into __new-task__, even though that text is already carried into the created session as the continuation. The next New task hero hydrates from the slot and comes up pre-filled.

Gate signature (run 34519630856 at 3f783066f): sample 2 insertFocusedText → Error: Focused composer did not retain native insertText at workspace-new-task-hit-target.e2e.test.ts:336 — the hero already contained INSTANT-PENDING-DRAFT-B-… from sample 1, so the caret sat before it.

What changed

apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx (+20/−3):

  • The hero tracks a send in flight (sendInFlightRef). While set, setPrompt still updates local state but no longer persists to the __new-task__ slot — those keystrokes belong to the created session (continuation), not to the next new task.
  • If the send fails, the flag resets and the hero re-persists whatever the composer currently holds, so fix(app): keep an unsent new-task prompt reachable after opening another session #4796's promise (an unsent prompt stays reachable via the sidebar Draft row) still holds after a failed creation. On success the hero unmounts when the created session's route lands; the flag is intentionally left set so a keystroke in the frame before unmount cannot resurrect the slot.

The brief's step (2) — an explicit clear when the created session's route lands — turned out to be redundant: the composer already empties the slot synchronously at send time (onDraftChange("")) and, with (1), nothing writes it afterwards while the send is pending. I left it out to keep the diff minimal; happy to add it as belt-and-braces if preferred.

apps/app/tests/new-task-draft-send-in-flight.test.tsx (new): real SessionEmptyHero + real NewTaskComposer with only the Lexical editor stubbed by a textarea. Type → Run task (creation pending) → type while pending → resolve, route lands (hero unmounts) → reopen New task → composer and slot must be empty; then a failing send must re-persist the typed text.

Proof

Unit / types

  • New test on unmodified code: Expected: "" / Received: "and also check the rollback plan" (red, commit 5f2d534d7); green with the fix (69c17c524).
  • bun test --isolate tests/new-task-draft-send-in-flight.test.tsx tests/new-task-draft-state.test.tsx → 3 pass (fix(app): keep an unsent new-task prompt reachable after opening another session #4796's own tests stay green).
  • pnpm --filter @openwork/app test:core → 225 pass, 0 fail.
  • pnpm --filter @openwork/app typecheck → clean.
  • pnpm --filter @openwork/app test (full bun test --isolate tests/) did not complete: the runner stalls after tests/opencode-session-native.test.ts with no child process (reproduced twice, log silent >10 min) — unrelated to this diff, but I could not obtain a full-suite verdict. tests/composer-focus-continuity.test.tsx is red identically on unmodified code (SyntaxError: Export named 'deleteNativeSession' not found in bun's isolate loader) — pre-existing.

E2E — workspace-new-task-hit-target
This spec is a local-placement contract: workspaceNewTask throws SkipError unless place.kind === "local", so pnpm evals:e2e workspace-new-task-hit-target --daytona skips by design (skipped: 1, cli-run-1789074523605). The gate runs it via the "Product journeys" workflow (daytona-e2e.yml, --local on a Linux runner), so I dispatched that workflow — the exact gate environment:

ref sha run result
fix/new-task-draft-slot-leak (this PR, on origin/dev @ 9a60a4b59) 69c17c524 34532482730 failed at :379 — Timed out waiting for prompt request is held … held: 0 (auto-send of the first lazy send never fires; screenshot shows the created session with a CancelledError alert)
proof/new-task-draft-slot-leak-on-3f78306 = gate sha 3f783066f + these two commits (cherry-picked, signed) c29f789cf 34533114105 passed
same c29f789cf 34535074872 passed (2nd sequential run)

The :379 failure on this branch is not caused by this change: a clean control on my machine with source identical to origin/dev (9a60a4b59, fix reverted) fails identically at :379, and so does the fixed branch. Bisecting 3f783066f..9a60a4b59 with the same workflow (all failing at :336 = the leak only, i.e. auto-send still fine, unless noted):

So dev currently carries a second, independent regression from #4838 that breaks the first lazy send's auto-send and masks this spec before it reaches the point this PR fixes. This PR fixes the #4796 leak (proven at the gate sha); the gate spec will stay red on dev until #4838's regression is addressed.

Local macOS runs of the spec (--local, both fixed and control) also fail at :379; evidence under evals/results/test-runs/2026-09-10T21-11-34-087Z-… (fixed), …T21-22-08-292Z-… (fixed, quiet machine) and …T21-26-35-317Z-… (control, unmodified source) (renderer diagnostic + screenshot with the CancelledError).

E2E — #4796's behaviour (evals/specs/new-task-draft-return.e2e.test.ts, appWeb)

  • OPENWORK_EVAL_REF=69c17c524 pnpm evals:e2e new-task-draft-return --daytona → 2 passed, 0 skipped (both sandboxes auto-deleted).

Noticed but not touched

  • perf(chat): prioritize visible thread history and preserve scroll #4838 regression (above): first lazy send in a fresh session never issues its prompt request (CancelledError in the session surface); breaks workspace-new-task-hit-target on dev independently of this PR. Likely interacts with fix(app): interrupt delegated work before immediate follow-ups #4837's new submitImmediateSessionTurn(..., snapshot?.messages, …) in sendDraft.
  • bun test --isolate tests/ stalls after opencode-session-native.test.ts on macOS (parent process idles with no child).
  • composer-focus-continuity.test.tsx pre-existing red under bun isolate (deleteNativeSession export cycle).
  • Throwaway branch proof/new-task-draft-slot-leak-on-3f78306 is kept only as the referent of the two green runs; delete after review. Bisect branches were deleted.

@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 10:14pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
openwork-den Skipped Skipped Sep 10, 2026 10:14pm UTC
openwork-diagnostics Skipped Skipped Sep 10, 2026 10:14pm UTC
openwork-landing Skipped Skipped v0 Sep 10, 2026 10:14pm 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 (20298 ms), confidentiality-review (17946 ms), desktop-den-sync-review (17742 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 (69c17c52431cfd8016f5159c5f2c52fd7f18490b). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

Copy link
Copy Markdown
Contributor

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit 69c17c52431cfd8016f5159c5f2c52fd7f18490b · selected evidence

Open review report

@yomgui
yomgui merged commit 79b1384 into dev Sep 11, 2026
29 of 31 checks passed
@yomgui
yomgui deleted the fix/new-task-draft-slot-leak branch September 11, 2026 02:43

This branch had an error being deployed

1 failed, 1 active, and 3 inactive deployments
scheduled-e2e-regression — 69c17c52 Deployed Sep 10, 2026 by yomgui via Journey — Keep new tasks and sends instantly responsive #1353
Preview – openwork-app — 69c17c52 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 69c17c52 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 69c17c52 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-landing — 69c17c52 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