Repository navigation
fix(context): report a failed background-context injection instead of swallowing it - #20748
Conversation
… swallowing it Both companion surfaces posted their context fire-and-forget, so a rejected inject left the panel looking ready while the agent had never been told which document it held. Carried from fork PR #12666 onto current main: conflicts in PapyrusPage.tsx (main renamed CHAT_PANEL_WIDTH to chatWidth) and ArtifactDetailPage.tsx (kept main edit-token state beside the new context-notice state); bn/hi/ru copy moved to the informal register the style gates require. Fixes #20737 Co-authored-by: cixuuz <26782336+cixuuz@users.noreply.github.com> Co-authored-by: rnoack1 <69695077+rnoack1@users.noreply.github.com>
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check one thing before merge: the chat column's fixed [DESIGN-REVIEWED] 9274dd4 Description read[DESCRIPTION-READ] e83d4a6bb77d27ae96ef6e9a25ab35f8dfd7297e3361a8573288fd76311a2893 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The description's "false save error" harm is not on main: the removed lines are a bare Not justified as shipped
What this change shipsInventory (8 items) — 5 justifiedIntent: a user opening a document chat learns when the agent was never told which document it holds. FIX.
[FIRST-PRINCIPLES-REVIEWED] 9274dd4 Description read[DESCRIPTION-READ] 4808e10eb59af38c10311f835aa847ef11281188118b814996c0ec635fa26260 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The first-share notice tells the user to "mention the artifact in your next message" while the panel under it has no session and no message box. Watch
Suggestions
[UX-REVIEWED] 9274dd4 Description read[DESCRIPTION-READ] aeac26a6c8b9b3d51cf2a203c8a3507db606dc72a93760177da94871d1d21de4 That sha256 names everything this verdict read: the PR description, plus the 10 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings block this merge; one advisory finding. FINDING — website/src/pages/ArtifactDetailPage.tsx:1520 — [OPUS-REVIEWED] 9274dd4 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Keep both context posts ephemeral (the durable flag was a no-op on main), collapse the duplicate claim-map helpers into the ref, drop two tests that never checked what they named, replace six promise-sleeps with an act() flush, and read the sized co-author column in papyrusResizeAria now that the panel sits beside the notice. Scope the notice retraction to the newest request on the current slot (artifact) or the newest push (Papyrus), so a superseded session late success cannot clear the current failure; clear the Papyrus notice when the paper changes. Co-authored-by: rnoack1 <69695077+rnoack1@users.noreply.github.com>
50e6798 to
9274dd4
Compare
chenmingwei23
left a comment
There was a problem hiding this comment.
Batch approval: readiness: passed, no merge conflict, checks green.
Problem / Motivation
Goal: When the artifact companion chat or the Papyrus co-author could not be told which document it is holding, the user sees a notice in that chat column instead of nothing (or a false save error).
Opening the artifact companion chat, or the Papyrus co-author, silently POSTs
/api/chat/slots/<slot>/contextso the agent is told which document it is holding. Bothposts were fire-and-forget (
.catch(() => undefined)). When that POST was rejected thepanel still opened looking ready, so the user typed "summarize this" against an agent that
had never been told what "this" was.
On the artifact page the failure was worse than silent: it was routed through the page's
SAVE-error channel, so a background enqueue failure told a user with a dirty editor buffer
that their work had not been written.
Why it matters
The failure is invisible at exactly the moment the user acts on it. They get a confident
but unanchored answer and no reason to suspect the attach step, which is the one thing
they cannot see. The misrouted save error is worse: it reports data loss that did not
happen, on a page holding unsaved edits.
Not a goal
/contextendpoint, its validator, or its queue limits.What changed (motivation → approach → change)
Symptom: a rejected context POST left no user-visible trace on either surface (and on the
artifact page surfaced as a save failure). Root cause: the POST had no result handling at
all — a bare
.catchswallowing every rejection, and no state to render one.Each surface now owns a notice in its own chat column, mounted beside the composer its
copy names, and retracts it when the newest inject for the current session succeeds (a superseded session's late result is ignored; the Papyrus notice also clears when the paper changes). The artifact notice distinguishes
a first attach from a staleness refresh: a failed refresh means only the newest version is
missing, not that nothing was shared, and labelling that "not attached" was itself wrong.
The POST is routed through
useMutation, like every other write on these pages, ratherthan a bare promise chain. A memory-only claim map is held before the request so an
open/close/reopen inside the request window cannot inject twice; a rejected post releases
the claim so the next open retries instead of recording a delivered baseline. The claim is
deliberately not persisted — a resolved POST is not a durable-write acknowledgment, so a
claim outliving the page could suppress a nudge for an entry that was never stored.
Both posts gain
maxAge(3600s). Without a TTL a dormant slot accumulates entries against_MAX_CONTEXT_PER_SOURCE(10) and every later post answers 429.ArtifactChatPanelloses its fixedcalc(100vh - 240px)height for flex. With the noticeabove it in the same column, a fixed height put the composer past the fold whenever both
mounted.
Carried onto current main from fork PR #12666 by @rnoack1. Conflict resolution:
PapyrusPage.tsxkeeps main'schatWidth(from #11881) in place of the fork'sCHAT_PANEL_WIDTH;ArtifactDetailPage.tsxkeeps main's edit-token / save-conflict state beside the new context-notice state. The new bn/hi/ru strings were moved to the informal register (তুমি / तुम / ты) that the diff-scoped style gates require.Backwards compatibility
Compatible: no request field is added or removed, no validator is tightened, and no existing key changes meaning. Both posts keep
ephemeral: true; they gainmaxAge(3600s), an existing optional parameter ofPOST /api/chat/slots/{slot}/contextthat main already accepts.Removes nothing: the diff only adds a notice and result handling to a post whose failure was previously dropped.
Tests
Website only; no Python source is touched.
ArtifactDetailPage.companionChat.test.tsx— the notice appears on a rejected inject and is titled for the context failure rather than the save failure; it is taken down with the panel so it never names an absent composer; it mounts inside the chat column, not at page top; the panel carries no fixed height; a first failed share is never relabelled as a staleness failure; a user turn or a non-user row does not retract it. A superseded session's late success does not clear the current session's notice (fails on the previous head). "Nothing more happens" checks flush effects insideact()instead of sleeping.ArtifactDetailPageCoverage.test.tsx— a stale session re-open nudges rather than taking a silent baseline; the stale body names the version.PapyrusPageCoverage.test.tsx— the paper's identity is handed over silently; a rejected push renders the notice.papyrusResizeAria.test.tsx— reads the sized column box viaclosest('[style*="width"]'), since the panel now sits in a flex-1 child beside the notice.Manual verification
Run locally on this branch, rebased on current main:
npm run typecheck— clean.vitest runon the three touched test files plussrc/i18nwithI18N_BASE_REF=origin/main— all pass (the bn/hi/ru register gates included).npm run build— green.Screenshots / video
Before = current main build; after = this branch. Same fixtures: the
/contextpost answers 500.Artifact companion chat, resume nudge failed:
Papyrus co-author, first share failed:
More frames
429
context_not_queuedpath (same copy, pins the refusal path):First injection on a new bound session (first-share title, not the staleness title):
Related Issues
Fixes #20737
Replaces #12666 (thanks @rnoack1 — original fix and harnesses are theirs; authorship kept on the commit).
Pattern harvest
Rule candidate: review-prompt
Pattern: a background write whose only failure handling is
.catch(() => undefined)— theuser acts on the assumption it succeeded, and where the surface has an unrelated error
channel in scope, the rejection gets rendered as that channel's failure instead, so the
report is not merely absent but wrong.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.