Skip to content

fix(app)/test(evals): attachment upload in a new task moves into the thread while the upload is held (post-chain) - #4894

Merged
yomgui merged 2 commits into
devfrom
fix/attachment-upload-new-task-recheck
Sep 11, 2026
Merged

yomgui merged 2 commits into
devfrom
fix/attachment-upload-new-task-recheck

Conversation

@yomgui

@yomgui yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member

Re-check of #4811: on current dev, attachment-upload-loading-state test 2 ("sending an image in new task immediately moves it into the thread while upload is pending") failed deterministically with Timed out waiting for one decoded thread preview and cleared composer while upload is held after 30000ms (runs 34563247847 @ 71d22ac10, 34611588521 @ e53e2f7f7). Test 1 (existing chat) passed.

Culprit: #4838 4462762b4 — perf(chat): prioritize visible thread history and preserve scroll

#4811's proof ran at 2d1209665 = e4c5c3e3d + #4797's stack, and its merge (c9d09b320) is an empty diff; so ~70 dev commits between e4c5c3e3d and c9d09b320 were never covered by that proof. Bisect with daytona-e2e.yml (suite=full, only=attachment-upload-loading-state) on throwaway branches (deleted afterwards):

dev sha what run new-task test
07ff1c55b fix(mcp) #4773 34615505333 green (2/2)
e4e316d41 docs #4702 = 4462762b4^ 34617221149 red — different: past the send, fails after user.reload() with Session snapshot owner changed… (the #4797 reload race, fixed later on dev)
4462762b4 #4838 34617225877 red — this signature
9e49a882f docs #4705 34615510419 red, this signature
51a769f97 #4869 34615515810 red, this signature
b45546d05 #4877 (= #4757^) 34615521188 red, this signature
d44344ce2 #4724 (= #4861^) 34615421771 red, this signature
79b1384c9 #4861 34613879243 red, this signature
c9d09b320 #4811 merge 34613877007 red, this signature
71d22ac10 #4810 34613881257 red, this signature

The other app commits in (07ff1c55b, 4462762b4) (#4837, #4829, #4782, #4836) do not touch the send/history path in a way that produces this state; #4861 and #4757 (the briefed suspects) postdate the first red and change nothing here. The suspected harness change #4810 only extends locate() miss diagnostics.

Root cause

Instrumented run on dev head (throwaway branch, state dumped by the spec at the timeout):

uploadingSeen:true attempts:0 rows:0 chips:2 ["ready","ready"]
composer:"Describe the attached image.×pasted-recording.mp4×"  alerts:["CancelledError"]
mount(ses_new) → sendEnsureStart{cached:"pending",observers:1} → unmount(ses_new) +1ms → mount(ses_new) +3ms
→ sendError{name:"Error", message:"CancelledError", revert:true}

#4838 made sendDraft await openingHistory.ensureFullSnapshot() (the uncapped read, via ensureQueryData) before submitting, so a follow-up decides against complete history whether to interrupt delegated work. That read is owned by the surface's useQuery observer. The hero's one-step Run task creates the session and the surface auto-sends from a mount effect as soon as the opening preview lands. Development builds (what the evals and developers run; index.react.tsx wraps the app in StrictMode) run every mount effect twice — StrictMode simulates an unmount — so the send started the read in the first pass, the simulated unmount removed the only observer, TanStack cancelled the consumed-signal read (Query.removeObserver → retryer.cancel({ revert: true })), and ensureQueryData rejected with CancelledError. handleSend treats that as a failed send: the pending row is removed, the draft and attachments are restored as "ready" chips, a CancelledError error card shows, and no upload POST ever starts. The auto-send mark was already consumed, so the second effect pass sends nothing.

The existing-chat test is immune because its snapshot is already cached (ensureQueryData resolves from cache). Not the #4797 owner-flip cancelQueries (that would be revert: undefined).

What changed

apps/app/src/react-app/domains/session/surface/session-history.tsx — ensureFullSnapshot: when ensureQueryData rejects with a TanStack CancelledError and the snapshot query still has an observer (the reader only re-subscribed), read again with fetchQuery. Once nobody observes the thread anymore (navigated away) the cancellation stands, so history actions abandoned by navigation behave exactly as before (history actions cannot run against a destination owner or after unmount still passes). #4838's intent — sends see complete history — is kept; the spec's timing claim is unchanged.

apps/app/tests/session-history.test.tsx — new test a send started from a mount effect survives StrictMode dropping and re-adding the reader mid-read: renders the real useOpeningSessionHistory under StrictMode, starts ensureFullSnapshot() from a mount effect, asserts the first uncapped read is aborted and that the send still resolves with complete history. Red without the fix (CancelledError revert: true, no re-issued read), green with it.

Follow-up worth considering (not in this PR): the hero path onCreateTaskWithPrompt does not seedCreatedSessionSnapshot like handleCreateTaskInWorkspace does since #4757, so its first send always waits one uncapped round trip.

Proof

Placement: Daytona, sandbox source verified 96a0a3af2815cc688b1067fd24939eed27284731 (--strict-ref, refMismatch:false).

  • OPENWORK_EVAL_REF=96a0a3af2… pnpm evals:e2e attachment-upload-loading-state --daytona --strict-ref ×2 sequential:
    • run 1: "passed":2,"failed":0,"skipped":0,"verdict":"passed" (existing chat 246.9 s, new task 252.3 s)
    • run 2: "passed":2,"failed":0,"skipped":0,"verdict":"passed" (existing chat 249.4 s, new task 258.4 s)
  • pnpm --filter @openwork/app typecheck → exit 0.
  • bun test tests/session-history.test.tsx → 23 pass / 0 fail (22 on dev + the new one). Red→green verified by reverting only the product file: 0 pass / 1 fail (Received length: 0 — no re-issued read).
  • bun test --isolate tests/ → the only reds are pre-existing on pristine origin/dev @ 667b450fd with identical output: session-snapshot-owner-flip.test.tsx (readEndpoints has an extra /opencode2), generated mention instructions > app preserves its label…, v2 provider catalog retains display names…. All other files pass on this branch when run as files.
  • Culprit PR's own spec, pnpm evals:e2e session-full-history-on-open --daytona --strict-ref: fails at spec line 100 (user.click({ role: "button", label: "Branch in new chat" }) → Located element was visible=false) identically on this branch (96a0a3af2) and on pristine origin/dev @ 667b450fd — a pre-existing red in the hover-only Branch step; the part that carries perf(chat): prioritize visible thread history and preserve scroll #4838's intent (latest-first opening, complete history loaded, lines 65–91) passes on both before that step.

Verdict for this spec: Passed (2/2, twice). Bisect branches bisect/aul-* deleted; all Daytona sandboxes from these runs were removed by the runner.

…s mid-send

Since #4838 an explicit send awaits the uncapped snapshot read
(ensureFullSnapshot) so it can decide against complete history whether
to interrupt delegated work. That read is owned by the surface's useQuery
observer. Development builds run every mount effect twice (StrictMode
simulates an unmount), so the hero's one-step Run task, which fires from
a mount effect, always saw its reader drop and re-subscribe while the read
was in flight; TanStack cancelled the read (CancelledError, revert) and
the send treated it as a failure: the pending row vanished, the draft and
attachments came back as ready chips, a CancelledError card appeared, and
no upload started.

When the reader is still present after the cancellation, read again
instead of failing the send. Once nobody observes the thread anymore the
cancellation stands, so history actions abandoned by navigation behave as
before.

Signed-off-by: Guillaume Loret <[email protected]>
@vercel

vercel Bot commented Sep 11, 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 11, 2026 6:40pm UTC
openwork-den Ready Ready Preview Sep 11, 2026 6:40pm UTC
openwork-diagnostics Ready Ready Preview Sep 11, 2026 6:40pm UTC
openwork-landing Ready Ready Preview, v0 Sep 11, 2026 6:40pm UTC

@github-actions

github-actions Bot commented Sep 11, 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 (22419 ms), confidentiality-review (6761 ms), desktop-den-sync-review (21517 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 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 (96a0a3af2815cc688b1067fd24939eed27284731). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

Pick up #4888 so ci-tests.yml's packaged Fast module step finds its test file.

Signed-off-by: Guillaume Loret <[email protected]>

@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 (be8468322d41589acf749dda7cf9350763602682). 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 be8468322d41589acf749dda7cf9350763602682 · selected evidence

Open review report

@yomgui
yomgui merged commit faee79d into dev Sep 11, 2026
27 checks passed
@yomgui
yomgui deleted the fix/attachment-upload-new-task-recheck branch September 11, 2026 18:49

This branch was successfully deployed

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