Skip to content

fix(app): keep a brand-new session sendable while its first snapshot loads - #4757

Merged
yomgui merged 5 commits into
devfrom
e2e/fresh-session-send-gate
Sep 11, 2026
Merged

yomgui merged 5 commits into
devfrom
e2e/fresh-session-send-gate

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Root cause

Triage: reports/e2e-red-2026-09-09/triage.md → Cluster 1 "Fresh-session Run task click swallowed" (Brief B).

  1. A brand-new session refused to send for its first ~0.9 s on Daytona. handleCreateTaskInWorkspaceWithOpenMode navigated to the new session with an empty snapshot cache, so deriveSessionRenderModel reported "switching" (!hasSnapshot && isFetching) until the four-request snapshot round trip finished, and the composer's disabled={model.transitionState !== "idle" …} gate dropped any Run task click / Enter in that window with the draft intact (triage-probe-run4-immediate-click.log: disabled at t=386 ms, enabled at t=901 ms, nothing sent).
  2. A send that settled with a 5xx wedged the session. Since fix(app): clarify run activity and protect follow-up admission #4635 a prompt_async answered 5xx/408 is an uncertain admission, but the resulting admission_unknown hold could never end: the acceptance check treated absence as no evidence, Stop refused while admission was unknown, and the response body was dropped, so the person saw a paused composer with no explanation (session-error-technical-details test 2: runEnabled:false after 15 s).
  3. readComposerState reported an empty Lexical editor as "\n" (streamed-markdown-answer test 1 draftText === "").

What changed

  • seedCreatedSessionSnapshot (session-sync) seeds the snapshot cache from the create-session response before navigating, stale (updatedAt: 0) so the real fetch still runs as a background refresh of a session already on screen. hasSnapshot is true from the first render → composer sendable immediately.
  • PromptAdmissionUnknownError keeps the settled 5xx body as its cause (promptAdmissionFailure); the surface shows it as the session error card right away while the hold still prevents any resend.
  • readPromptAdmission (accepted / absent / unknown): after the exact-message GET misses, list the idle conversation; when native lists it without the message, the settled POST did not admit it → new drain event admission_rejected halts like any definite failure (explicit retry only, never an automatic resend). Surface and global drainer probes dispatch it; on release the pending row is removed and the submitted composer is saved as an unsent message ("Restore unsent message"). Confirmed acceptance clears the stale failure card.
  • evals: readComposerState drops Lexical's trailing empty-paragraph "\n"; streamed-markdown-answer test 1 opens the fresh conversation through the sidebar's New session button (renamed from "New task" in Fix split-view sending and prioritize New session #4491 on Sep 5; the scenario added in fix(app): show sent messages immediately across new chats #4631 on Sep 8 still targeted the old label). Same action, current label — no assertion changed, no waits added.
  • Unit coverage: admission_rejected reducer (queued-drain-admission-wedge.test.ts), readPromptAdmission tri-state and settled-body preservation (opencode-session-native.test.ts).

Proof (Daytona, one spec at a time, OPENWORK_EVAL_REF pinned; sandboxes checked out the sha shown)

Placement line for every run: "lane":"e2e","daytona":true,"placement":"daytona","engine":"legacy","surface":"legacy".

spec sha result notes
session-error-technical-details 564e17c7d passed 2 / failed 0 / skipped 0 test 2 (the admission_unknown hold) passed: A became sendable 11.5 s after its 507, banner + runEnabled:false after the second 507. (First attempt at this sha: test 2 passed, test 1 died in Daytona provisioning — source post-prepare gate … 502 — before any assertion; re-run above is clean.)
connector-tool-call-branding 564e17c7d passed 1 / failed 0 / skipped 0
streamed-markdown-answer 09801d4bb (run 2) 1 passed / 3 failed test 1 "existing" scenario passed including draftText === "" and the reject/restore steps; "new" scenario then failed only on the stale New task label (fixed in 564e17c7d). Test 2 now passes the immediate send (session("New task") → click Run task 265 ms later → user row visible in 25 ms) and fails later on toggle-"Thought"-then-immediate-notSee (Cluster 7 class). Test 3 fails on Escape-then-notSee palette (Cluster 7, Brief K). CONT-01 passed.
streamed-markdown-answer 564e17c7d (runs 3, 4) 1 passed / 3 failed (×2) Tests 1 and 2 never reached an assertion: the streamedMarkdown world build failed with Video fixture write failed: 409 (see below). Test 3 failed on Cluster 7 / geometry steps; CONT-01 passed both times. So the "new" scenario of test 1 at this sha is unproven; its only change since run 2 is the button label, and run 2's failure listed button "New session" among the visible candidates.
saved-app-creation 564e17c7d 0 passed / 1 failed The Cluster-1 step is fixed: type → click Run task → app-creation reply visible 2.5 s later (dev screenshot showed the prompt stuck in the composer). Fails much later in "share dashboard apps with a teammate": openwork:browser:openUrl → Browser control requires a requesting conversation — pre-existing on dev (same error in nightly run 34387590503 @ 52a028817), not this cluster.
workspace-engine-upgrade 564e17c7d 0 passed / 1 failed Step 1 (palette → New session → type hi → click Run task within 0.35 s → reply) passed; dev failed exactly there (Timed out … seeing text=/^hi$/). Step 2 fails on new session route after reload on the /session New-task route — pre-existing since Sep 7 (nightlies 34090498133 / 34150647199 / 34193972847 at 24b811cbe/5afbfcb49/ad9786497 fail with the same message), i.e. #4577 changed what the sidebar New session does on that route; owner should re-express that step.

Verdict for this PR: Incomplete as a whole-file green (see out-of-scope failures above), Passed for every Cluster-1 claim: the fresh-session immediate send is observed in streamed-markdown-answer test 2, workspace-engine-upgrade step 1, saved-app-creation, connector-tool-call-branding; the 5xx hold release is observed in session-error-technical-details test 2.

Noticed, not touched

  • streamedMarkdown world build fails with Video fixture write failed: 409 in 3 of 4 runs at this base, never in the Sep 9 baseline/nightly logs. Every POST goes through managedDesktopPolicy(config).assertRequest → assert(...) → current() → identityChanged → 409 policy_identity_changed when the Den identity generation moves while the read is in flight; fix(desktop): recover credentials before engine readiness #4718 (1c455cfab, "recover credentials before engine readiness") now bumps that generation via PUT /den-session/identity during the first seconds after sign-in, exactly when the world writes the fixture. Real product race for any early write, not this cluster.
  • On an empty session, the error card for a held send is only rendered once the pending row is gone (renderedMessages.length === 0 && … && error branch), so with the new release path it appears at release (~10 s) instead of immediately; sessions with history show it immediately.
  • streamed-markdown-answer test 2 has a toggle-"Thought"-then-immediate-notSee race of the same shape as Brief K (Cluster 7).
  • workspace-engine-upgrade step 2 and saved-app-creation "share" step: spec/product drifts listed above.

…immediately

A freshly created session had no cached snapshot, so deriveSessionRenderModel
reported "switching" while the first snapshot round trip ran and the composer
disabled Run task. On Daytona that window is ~0.9 s and a click or Enter inside
it was silently dropped with the draft intact. Seed the snapshot cache from the
create response (stale, so the real fetch still runs as a background refresh).
…ad of wedging

A prompt_async answered with 5xx/408 is an uncertain admission (#4635), but
the hold it created could never end: the acceptance check treated absence as
no evidence, Stop refused while the admission was unknown, and the failure body
was dropped, so the person saw a paused composer with no explanation.

- Keep the settled response body on PromptAdmissionUnknownError and show it as
  the session error card right away; the hold still prevents any resend.
- readPromptAdmission: after the exact-message GET misses, list the idle
  conversation; when native lists it without the message the POST is settled
  and did not admit, so the drain receives admission_rejected and halts like
  any definite failure (explicit retry only, never an automatic resend).
- On release the pending row is removed and the submitted composer is kept as
  an unsent message to restore; on confirmed acceptance the stale failure card
  is cleared.
Lexical keeps one empty paragraph in an empty editor, which innerText reports
as "\n". readComposerState now drops that trailing line break so draftText
matches what the person sees; user.see("composer", { text }) already trimmed.
…ssion button

The sidebar button was renamed from "New task" to "New session" in #4491
(Sep 5) and the "new" scenario added in #4631 (Sep 8) still targeted the old
label, so it could never find the button. Same user action, current label.
@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 9:01pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 9:01pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 9:01pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 9:01pm UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

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 (92503 ms), confidentiality-review (136889 ms), spec-provenance-review (136617 ms), desktop-den-sync-review (181722 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 2
  • Distinct heads in retained window: 2
  • 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: 2/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[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@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 (564e17c7d6b3651e75b093a616f5a593f93932ba). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit 4a2f43213a12ee0bf7ce09e8ac38de90d5913f91 · selected evidence

Open review report

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4a2f432
Status: ✅  Deploy successful!
Preview URL: https://442feecb.openwork.pages.dev
Branch Preview URL: https://e2e-fresh-session-send-gate.openwork.pages.dev

View logs

@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 (4a2f43213a12ee0bf7ce09e8ac38de90d5913f91). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Resynced with origin/dev — merge commit 4a2f43213a12ee0bf7ce09e8ac38de90d5913f91

git merge origin/dev (at 9a60a4b59) into e2e/fresh-session-send-gate; no rebase, no amend, no force-push. Signed (%G? = G).

Conflicts resolved (both intents kept)

  • apps/app/src/react-app/domains/session/surface/session-surface.tsx — import lines only. Kept dev's new submitImmediateSessionTurn import (used by the cloud-MCP submit path dev added) and this PR's promptAdmissionFailure / readPromptAdmission imports; dropped hasAcceptedPromptMessage from the surface import because this PR replaced its only call site with readPromptAdmission (no remaining reference in the file).
  • apps/app/tests/opencode-session-native.test.ts — import lines only; union of both sides (PromptAdmissionUnknownError, promptAdmissionFailure, readPromptAdmission from this PR + submitImmediateSessionTurn from dev). No assertion changed.

Proof at 4a2f43213

  • pnpm --filter @openwork/app typecheck → clean.
  • bun test --isolate tests/opencode-session-native.test.ts tests/queued-drain-admission-wedge.test.ts tests/workspace-routes.test.ts → 80 pass / 0 fail.
  • pnpm --filter @openwork/app test (full suite, 230 files) → 1661 pass / 82 fail. Clean control on origin/dev 9a60a4b59 in a fresh worktree, same host, same command → 1658 pass / 82 fail, identical test names (comm diff empty). Pre-existing / host-specific to the full --isolate run (e.g. Platform context is missing, Request timed out, Computer Use requires the bundled OpenWork helper on macOS); none introduced here.
  • Daytona, OPENWORK_EVAL_REF=4a2f43213a12ee0bf7ce09e8ac38de90d5913f91 pnpm evals:e2e session-error-technical-details --daytona → 2 passed / 0 failed / 0 skipped ("lane":"e2e","daytona":true,"placement":"daytona", sandbox checked out Ref: 4a2f43213…). Both tests observe the Cluster-1 hold-release claim (a delayed submit error stays with its owner while another retained task remains sendable). Run sandboxes deleted.

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 4a2f4321 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-app — 4a2f4321 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 4a2f4321 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 4a2f4321 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