Skip to content

feat(artifacts): type-first selection composer, retire CommentPopover - #12998

Merged
iamwhatever merged 1 commit into
mainfrom
feat/artifact-selection-composer-9823
Sep 28, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
feat/artifact-selection-composer-9823

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Selecting text on any artifact surface opens the comment box straight away, and a typed comment is never lost.

Selecting text on an artifact page, the remote artifact page or the chat side panel's artifact view produced a selection pill whose Comment button opened a second, titled card (CommentPopover) to type into — an extra click and a pointer round-trip per annotation — while the file viewer (since #9812) opens a type-first comment box straight from the selection. Two comment inputs for one feature, already drifting: the IME guard, the keyboard contract, the selection restore and the draft handling existed only in the composer, and a typed comment on an artifact host could be dropped silently by anything that unmounted the card.

Why it matters

Both the Design and UX lanes on #9812 flagged the divergence: the same feature in two dresses, with the two comment inputs already drifting apart (IME guard, keyboard contract, selection restore, draft handling exist only in the composer). The original harm from #9760 — an extra click and a pointer round-trip per annotation — applied equally to the artifact pages. The issue's investigation comment settles the shape: SelectionComposer.onOpen(text) fires before focus moves into the input, which is the host's one chance to resolve the anchor from the live range, and onSubmit(comment, text) carries the typed comment. No product decision remains.

Not a goal

What changed (motivation → approach → change)

Goal → approach. Selecting text on an artifact now opens the type-first comment box straight away — the same SelectionToolbar composer the file viewer got in #9812 — on all four artifact hosts: the full artifact page (ArtifactDetailPage, markdown/text body and widget/html iframe body), the remote artifact page (RemoteArtifactDetailPage, markdown body and html iframe body), and the chat side panel (ArtifactPanel, both the docked and the full-screen mount). The two-stage flow — a selection pill with a Comment button that opened the titled CommentPopover card — is gone, and CommentPopover is deleted from CommentOverlay.tsx together with its capture entry, its unit/integration tests and the one i18n key only it used (components.commentOverlay.add_a_comment, removed from all 12 catalogs + en-XA).

Change, by piece:

  • useFileArtifactComments (website/src/components/FileArtifactComments.tsx): requestAnchoredComment() is split. The Range→{quote, prefix, suffix, startOffset, endOffset} derivation becomes resolveSelectionAnchor(), called from the composer's onOpen and stored in a ref (never rendered); onSubmit feeds postMut from that ref. The hook returns selectionComposer and iframeSelection in place of requestAnchoredComment. onIframeSelect stores the bridge's anchor and hands the toolbar an iframeSelection; onOpen keeps that anchor when there is no live DOM range for the same text (so the frame's prefix/suffix are not replaced by the bare quote). Offsets from the frame are dropped as before — they are in the iframe body's text space, not the parent highlighter's.

  • ArtifactPanel: both SelectionToolbar mounts pass composer={layer.selectionComposer} and externalSelection={layer.iframeSelection}; the id: 'comment' and id: 'copy' actions are gone — the composer row is Add comment + Close (the max-two-buttons-per-row rule caps the row at two controls), and copying the selection is the composer's Cmd/Ctrl+C while its input is empty. The native mounts listen on the preview ref itself (not the scroll box) so the box opens only over text the anchor resolver can map; for an iframe body the toolbar is externalOnly and opens from the bridge's iframeSelection alone. It is suspended with the tab so a hidden panel's open box does not stay on screen (same contract as MarkdownPanel).

  • The annotated passage stays visible (from review): focusing the composer collapses the real selection, so on open every native host paints the passage through the CSS Custom Highlight API (::highlight(mc-annotate), the same paint the file viewer uses) and clears it on close/submit. That painter is extracted from MarkdownPanel into website/src/utils/annotationHighlight.ts (per-owner aggregation, unchanged behaviour) so all four hosts share it. Iframe bodies keep their own in-frame selection visible instead.

  • One composer wiring for every artifact host (from review): the pending/staged anchor promotion, the externalSelection state, the highlight token, the draft mirror and the draft guard live once, in website/src/hooks/useSelectionComposerAnchor.ts, parameterized by what actually differs per host — how the live DOM selection becomes an anchor (resolveDomAnchor, which also paints the highlight), how the anchor is read back (quoteOf / quoteOnly), what a submit posts, and the draft-store key. useFileArtifactComments, ArtifactDetailPage and RemoteArtifactDetailPage each call it; the three page-local copies of that block are gone, so a guard one host gets, every host gets.

  • A refused post never costs the comment (from review): the artifact hosts' onSubmit now returns a promise (postMut.mutateAsync(...) resolved to true/false), and SelectionToolbar waits on it — the box stays open with its text and its persisted draft while the post is in flight (submit held, a second Enter does not double-post), closes and clears the slot only on success, and on a rejected POST (offline, gateway restart, 5xx) keeps both, shows "Couldn’t save your comment. Your text is still here — try again." inside the box (the string makes no claim about closing: Close asks "Discard your unsaved comment?" and a confirmed discard clears the slot), and lets the retry post against the same anchor. While the post is in flight nothing waits on the network and nothing discards: Escape and ✕ close the box but ask nothing and clear nothing, and the host's own draft guard (Edit, version switch, full screen, close, Back, Fork) proceeds without asking — the text is already in the durable slot, and the flight's own settle decides it (a success clears the slot even after the box is gone; a refusal leaves it for the next open over the same passage). A confirmed discard mid-flight would have cleared the slot under a post that may still be refused, and waiting for the answer would have left the box stuck on a hung POST. A late success clears only the anchor that post was made against (a generation counter on the shared hook), so a slow post on one passage or one artifact cannot null the anchor of the box open on the next. The Add comment control shows a spinner and reads "Saving…" (new key components.selectionToolbar.saving, from UX review: a bare spinner read as "could be loading" and invited a re-select instead of a wait) and the input is read-only (a keystroke landing before the answer would be blanked by the success path), and on success the persisted slot is cleared even if the box was torn down mid-post (a slot that survived would come back as a draft of a comment already stored). A void onSubmit (the file viewer's local add) still closes at once. A composer post that fails is reported once, inside the box: the local hosts route it through a banner-free mutation (postAnchoredMut), so the page's "Comment action failed — " banner stays down for it (the sidebar's document-level add, replies, resolves and deletes keep their banner). New i18n key components.selectionToolbar.comment_post_failed in en.manual.json + 11 catalogs + en-XA.

  • The composer stays inside its document column (from review): the toolbar's clamp now also bounds the box's right edge by its container's, so a selection near the column's edge on the artifact page no longer opens the box over the comments sidebar's cards; a container narrower than the box (the docked side panel) keeps the viewport clamp alone.

  • The discard prompt is reachable from full screen (from review): Modal gains layer: 'top' (z-[10000]/[10001]) and useConfirm forwards it; all four hosts' "Discard your unsaved comment?" use it: the artifact panel and file viewer raise it from inside an opaque full-screen shell at z-[9999] (which otherwise painted over the prompt and left Exit full screen looking dead), and the two artifact pages raise it while the composer — itself a z-[9999] body portal — is still mounted and would swallow clicks on the prompt's buttons.

  • One Range→anchor derivation (from review): the quote / prefix / suffix / offset arithmetic every host ran on the live selection is now anchorFromRange(root, range) in website/src/utils/selectionAnchor.ts, called by the three artifact resolvers and by MarkdownPanel's selection-coords path; the per-host resolvers keep only what differs (containment predicate, source-coordinate lookup, the highlight paint).

  • Toolbars keyed per artifact (from review): both artifact pages key their SelectionToolbar mounts by the artifact (slug, provider/externalId), so a param-only navigation between cached artifacts (the route element is reused) remounts the box instead of carrying the previous artifact's draft and anchor into the next one's callbacks.

  • One draft guard, owned by the layer (from review): useFileArtifactComments returns guardCommentDraft (the shared hook's) and ArtifactPanel uses the active layer's guard directly for full screen enter/exit and close; the panel's own copy of that logic and the two pass-through members it needed (hasComposerDraft, clearComposerDraftSlot) are gone.

  • Draft store: memory is authoritative (from review): composerDraftStoreFor reads the tab's in-memory snapshot (deletions included) whenever one exists and consults sessionStorage only to seed a fresh tab, so a slot deletion whose storage write was refused cannot be resurrected from the stale record as a draft of an already-posted comment. The remote page's composer post also goes through its own postAnchoredMut, so its refusal raises the in-box notice alone.

  • Draft safety on the artifact hosts (from review): the composer reports its draft state, and every action that unmounts the toolbar asks "Discard your unsaved comment?" first — Edit and the version picker on the page, full screen enter/exit, close and Escape on the side panel, and Escape / Close / Back / Fork on the remote page (the file viewer's prompt wording). A typed draft is also persisted per artifact + passage through the shared draftStore, so a chat-slot switch (which replaces the whole side panel), a page navigation or a reload brings it back on the next open over the same passage (the remote page keys its store per provider + external id); a confirmed discard clears that passage's slot. External (iframe) selections restore too: externalSelection now carries the frame's start offset as the passage key, and the toolbar reads the store on that path like it does on the DOM path. File-viewer rider (from review, shared SelectionToolbar): an EMPTY open box re-targeted onto another passage now restores THAT passage's saved draft instead of leaving an empty box over its slot — previously the restore was skipped whenever the box was already visible, so the first keystroke overwrote the saved text.

  • ArtifactDetailPage / RemoteArtifactDetailPage: same pattern. handleMouseUp / handleMdMouseUp become anchor-only resolvers called from onOpen; the passive onMouseDown/onMouseUp probes on the prose wrappers (and their a11y eslint waivers) go away, since the toolbar owns the gesture. The DOM toolbar is mounted only while an anchored comment can be made (commentable on the local page; isMarkdown on the remote page); the iframe branches mount one with externalSelection wired to the bridge. A plain-source remote body gets no toolbar, as before.

  • SelectionToolbar: the externalSelection path now opens the composer like a DOM selection does — onOpen fires before focus, submit is live, a typed draft is not re-anchored by a new external selection, and setting it back to null closes an external-sourced box (the host revoked the selection). It saves no container offsets (there is no DOM range), so Escape closes without restoring the selection and the box does not follow a scroll; it is placed below the handed-over point, never over the line. New externalOnly prop: only externalSelection opens the toolbar (the iframe wrapper's own render-failure text is not annotatable). The composer's Cmd/Ctrl+C now copies the selection EXACTLY as made (boundary whitespace kept, via rawSelectedTextRef) — this reaches the file viewer's MarkdownPanel composer too; anchors stay trimmed. No production mount passed externalSelection before this PR (tests only), so the plain-row behaviour is unchanged.

  • Enumeration of every CommentPopover mount / requestAnchoredComment consumer, with verdicts: FileArtifactComments.tsx:282 → composer (this PR); ArtifactPanel.tsx:192 consumer → composer prop (this PR); ArtifactDetailPage.tsx ×2 (iframe + native) → composer (this PR); RemoteArtifactDetailPage.tsx → composer (this PR); capture/comment-popover-copy.{html,tsx} + scripts/capture-comment-popover-copy.mjs → deleted (subject gone); integration/CommentOverlay.integration.test.tsx CommentPopover block → deleted (CommentList / formatCommentsMessage blocks kept); src/test/CommentPopover.copy.test.tsx, CommentPopover.copyRaw.test.tsx → deleted (the composer's copy contract is pinned in SelectionToolbar.composer.test.tsx; the anchor-trim contract in ArtifactDetailPage.anchoredComments.test.tsx). Every other SelectionToolbar mount (MarkdownPanel ×2 composer, chat's plain rows) keeps its props; the one behaviour they inherit is the raw-text Cmd/Ctrl+C copy above. MarkdownPanel's per-file comment-draft store is extracted verbatim into website/src/utils/composerDraftStore.ts (composerDraftStoreFor(key), sessionStorage + in-memory twin) so the artifact hosts can use the same one — its behaviour is unchanged.

  • A post refused after its box was closed is still reported (from review): when ✕ / Escape closed the box mid-flight and the store then refuses the post, the toolbar has nothing left to render, so the shared hook reports the refusal once (onRefusedAfterClose, only when the box that posted is gone) and each host shows "Your comment wasn’t saved. Select the same text again to pick it up and try again." on the failure surface it already has (the page banner on both artifact pages, the sidebar's failure line in the side panel); on every host the notice is retired the moment a later composer post succeeds, so it cannot keep inviting a retry that already landed. The slot keeps the text, so that instruction holds: the same selection restores it. One new key, components.selectionToolbar.comment_post_failed_closed, in all 12 catalogs + en-XA.

  • One flight per draft, newer text always kept (from review): ComposerDraftStore gains hold / release, keyed by the passage AND the pending text. While a post is in flight, a read that would return exactly that pending text returns null on every store instance over the same key — so a second composer instance over the same passage (the side panel's full-screen layer, opened mid-post; or the same passage re-selected after Escape mid-flight) cannot restore the pending text and post it a second time — but the slot stays writable: what that second box types is the user's newer draft and is written. The flight's settle then clears the slot only if it still holds the text that was posted (clear(anchor, start, onlyIf)); a newer draft survives the old post's success and its refusal alike, and the next open over the passage restores it. (Round 26 held the whole slot and refused writes, which dropped that newer draft — reversed here.) The snapshot also carries tombstones: a slot this tab cleared stays cleared even when the storage write recording the deletion was refused, while storage still seeds a slot this tab never touched (a draft from an earlier page lifetime). The pending-post key is JSON.stringify([key, start, anchor, text]) — the anchor is the selected passage itself and may hold newlines, so a delimiter-joined key would have let a saved draft over A and an in-flight post over A\nB at the same offset mask each other (from review, round 28).

  • One count of outstanding posts, not one flag (from review): the shared hook counts posts in flight and the draft store counts holds per pending text, so when box A is closed mid-flight and box B posts over the same text, A settling first leaves the host "in flight" and the passage held until B settles — a guarded transition in that window still proceeds without discarding B's draft, and B's refusal still finds its text. The store's isHeld (no consumer) is removed.

  • The panel mounts a composer only where a selection can anchor (from review): ArtifactPanel mounts its SelectionToolbar for iframe bodies and for markdown / text — the two native kinds whose renderer attaches the preview ref, the same two the artifact page allows. Over json / svg / image (rich viewers, no ref) a composer could never open, so none is mounted — but the Copy row the panel shipped before this PR stays (from review): a single Copy control, no composer, over the scroll box, so a selection in a json / svg artifact keeps a reachable copy on touch, where there is no Cmd/Ctrl+C. The retired pill's dead Comment button is the only thing gone from those bodies. On the iframe branch both panel toolbars (docked and full screen) take the scroll box as containerRef (the preview ref is never attached there; externalOnly keeps the toolbar's own selection check off it), so the box's placement clamp has a right edge to honour and a right-half bridge selection cannot open the box over the comments sidebar.

  • The "not saved" banner never masks a later write, and is never masked by an earlier one (from review): on the remote page the orphaned-post notice is cleared by the user's next write attempt of any kind (the composer's included) — so it can never hide that attempt's own refusal — and it sits FIRST in the banner's fallback chain: a react-query error clears only on its own mutation's next mutate/reset, so a sidebar add refused earlier would otherwise sit in front of a fresher "not saved" notice for good (the composer posts through its own mutation and never resets postMut).

  • A box closed mid-flight abandons its flight (from review): the toolbar tracks the current flight (flightRef); Escape / ✕ mid-flight reset the submitting state so the next box over any passage opens editable, and the abandoned flight's settle only releases / clears the slot — it never touches the UI of a box it no longer owns.

  • The page anchor carries its neighbours (from review): ArtifactDetailPage's native resolver now forwards the prefix / suffix that anchorFromRange already computed (the old handleMouseUp never did), so a page comment on the second of two identical passages re-anchors to the second — rangeForAnchor scores a repeated quote by its context. The iframe path already carried them.

  • The "not saved" banner names the passage (from review): onRefusedAfterClose receives the annotated quote (folded to one line, clipped at 48 characters) and the notice reads "Your comment on “…” wasn’t saved. Select that text again to pick it up and try again." — the reader who dismisses it keeps a pointer to the text to select. The comment_post_failed_closed string is re-translated with the {{quote}} placeholder in all 13 catalogs.

  • Stale comments retired (from review): the two notes that described onMutErr rendering a composer refusal are replaced by the actual contract — the composer's mutation deliberately skips the page / sidebar banner so a refusal is reported once, in the box.

  • The draft slot is keyed on the word, not the drag (from review): the toolbar's slot offset now skips whatever leading whitespace the selection started on (start = pre.length + (raw.length − raw.trimStart().length), length = raw.trim().length), so it agrees with the trimmed passage the host is told about and with the hosts' own anchorFromRange offset — a draft typed after selecting " beta" is filed under beta's offset and re-selecting beta restores it, where before it was orphaned under a key no later selection could read. The same trimmed offsets feed Escape's selection restore and the scroll re-anchor.

  • The artifact page suspends its composer under a full-width panel (from review): on a narrow viewport an open comments / chat panel hides the document body; both ArtifactDetailPage toolbars now take suspended={narrowPanelOpen} (the body wrapper's own hidden condition) so the box, portalled to <body>, stops floating over the panel and returns with its draft when the panel closes — the same shape ArtifactPanel already passes.

  • A refusal never leaves the flight as the text's only copy (from review): with a post in flight and its box closed, a second box over the same passage may type a newer draft (kept — later words win) and then DISCARD it, emptying the slot; if the old post is then refused, the toolbar's settle writes the pending text back into the empty slot, so the "select that text again to pick it up" notice holds. A newer draft still in the slot is left alone; a success still clears. No new store layer — the flight already holds the text.

  • ✕ says that closing does not stop a post (from review): while a post is in flight the composer's close button is labelled "Close — saving continues" (components.selectionToolbar.close_saving_continues, 13 catalogs), so the cue sits at the point of action instead of the comment appearing later unannounced.

  • A refused post asks the store whether the slot is truly empty (from review): the write-back above must not overwrite a NEWER draft whose own post is still in flight — the store's read masks such a draft as null, exactly so a third box cannot re-post it. The store gains isEmpty(anchor, start), the unmasked check, and the settle restores the pending text only when it is true; a newer held draft survives the older refusal and is what the newer refusal finds in its box and in the slot.

  • The "not saved" notice is per artifact (from review): both artifact pages are one route element reused across artifacts; the notice names a passage of the artifact it was typed on and its draft waits under that artifact's key, so ArtifactDetailPage now clears it on [slug] and RemoteArtifactDetailPage on [provider, externalId] — it is never shown over the next artifact.

Copy. The composer's Cmd/Ctrl+C copies the raw, untrimmed selection — the contract the retired popover's Copy button had (CommentPopover.copyRaw.test.tsx, now pinned in SelectionToolbar.composer.test.tsx). Anchors are trimmed as before, so the stored data is unchanged. The visible Copy button is gone from the artifact hosts (two-per-row cap); the file viewer's composer keeps its own Copy action.

Backwards compatibility

Compatible: nothing a user can do today stops working — the same selection still leads to the same anchored comment in the same store, one step shorter. Internally this REMOVES CommentPopover (CommentOverlay.tsx) and useFileArtifactComments().requestAnchoredComment, and every consumer of both is enumerated with a verdict in the mount list above (all inside website/; none outside the diff). ComposerDraftStore gains hold / release and an optional third clear argument (additive). On the chat side panel json / svg bodies keep their Copy row (one control; only the pill's dead Comment button is gone — see the mount bullet). i18n: components.commentOverlay.add_a_comment is deleted (only the retired popover used it) and components.selectionToolbar.comment_post_failed_closed and components.selectionToolbar.saving are added, all across the 12 catalogs + en-XA. No production caller passed externalSelection before this PR; the behaviour change on that path is exercised only by the new artifact-host mounts.

Tests

  • website/src/test/FileArtifactComments.test.tsx (+5): onOpen resolves the live selection into an anchor pinned to THIS occurrence of a repeated quote (an indexOf anchor would land on the first — mutation-killed); onOpen with no live range anchors on the quote alone with no offsets; an in-iframe selection sets iframeSelection and keeps the bridge's prefix/suffix through onOpen (mutation-killed: dropping the keep-branch fails it); onClose discards both; onSubmit before any onOpen is a no-op.
  • website/src/test/SelectionToolbar.composer.test.tsx (+5, new describe): external selection opens the composer with onOpen before focus and submits the external text; Escape closes with one onClose; a new external selection over a typed draft does not re-anchor it (mutation-killed: removing the guard fails it); over an EMPTY box it re-opens; without a composer the plain row still shows.
  • website/src/test/ArtifactDetailPage.anchoredComments.test.tsx: rewritten against the composer input label, negative cases now wait past the toolbar's debounce, +1 scene for a selection made inside a widget iframe (bridge → composer → anchor is quote + context only).
  • website/src/test/RemoteArtifactDetailPageCoverage.test.tsx (+4), website/src/test/ArtifactPanelCoverage.test.tsx: adapted (the panel stub now asserts the active layer's composer is wired and the widget mount receives the bridge selection, and that no Comment action remains); on the remote page Escape, Back and Fork over a typed draft each ask first (Cancel keeps the draft and stays put; Discard proceeds), and a typed draft comes back when the same passage is selected after the page was unmounted (mutation-killed: dropping confirmDiscard + a stable draft key fails all four).
  • Refused-post retention: SelectionToolbar.composer.test.tsx (+3: a refused submit keeps text/draft/anchor, shows the notice, blocks a double-post while pending, and the retry goes through; a rejecting promise reads as a refusal; a void submit still closes at once), useSelectionComposerAnchor.test.tsx (+1: a refused submit keeps the pending anchor), FileArtifactComments.test.tsx (+2: refused post resolves false and the retry posts the same anchor; sidebar thread activation on native and iframe bodies), ArtifactDetailPage.anchoredComments.test.tsx (+1) and RemoteArtifactDetailPageCoverage.test.tsx (+1): the page keeps the typed comment and does not reveal the panel until the retry lands. Mutation checks: forcing the toolbar to close on a false outcome fails 2 tests; forcing the hook to clear on a false outcome fails 1.
  • website/src/hooks/useSelectionComposerAnchor.test.tsx (+5): the shared wiring — onOpen submits the DOM-resolved anchor once and clears; a staged bridge anchor is promoted only when the toolbar opens for that same text (a different text falls back to the quote alone); onClose / clearSelectionState drop pending + external selection; guardCommentDraft asks only while a draft is open and clears that passage's slot on a confirmed discard; the toolbar receives the host-keyed store and the same confirmDiscard.
  • Red on base: the five changed test files run against main fail 20 tests (composer absent / labels / stub shape); green here. Run by path only.
  • Coverage: FileArtifactComments.tsx graduated past the 80% per-file floor with the new tests, so its row is removed from .github/coverage-baselines/frontend.txt (the gate's own rule: a file that meets the floor leaves the baseline; adding a row is the forbidden direction).
  • Round-32 tests: SelectionToolbar.composer.test.tsx (+2: a selection dragged from the space before a word writes and restores its draft under the word's own offset — mutation check: the untrimmed offset fails it; the ✕ label reads "Close — saving continues" only while a post is in flight — mutation check: a fixed label fails it), ArtifactDetailPage.anchoredComments.test.tsx (+1: on a narrow viewport opening the comments panel hides the composer and closing it brings the typed draft back — mutation check: dropping suspended fails it).
  • Round-29 tests: ArtifactDetailPage.anchoredComments.test.tsx (the posted-anchor test now pins prefix ending in alpha and suffix opening with gamma — mutation check: dropping the pass-through fails it; the refused-after-close scene pins the quoted notice), useSelectionComposerAnchor.test.tsx (+1: the host receives the passage, folded and clipped to 48 characters with an ellipsis — mutation check: passing the raw quote fails it; the refusal test pins the argument), FileArtifactComments.test.tsx / RemoteArtifactDetailPageCoverage.test.tsx (notice pins updated to the quoted string). Capture driver: +2 assertions measuring the composer's right edge against the comments sidebar's left edge in the draft scene (871 ≤ 916 on both themes).
  • Round-28 tests: composerDraftStore.test.ts (+1: a hold over the multi-line passage A\nB never masks the sibling passage A's draft that spells the same bytes — mutation check: the delimiter-joined key fails it), FileArtifactComments.test.tsx (+1: the refused-after-close notice is gone once the retry it asks for lands — mutation check: onSuccess: invalidate alone fails it), SelectionToolbar.composer.test.tsx (+2: a re-target over an emptied box, DOM path and external path, opens without the previous passage's post-failed notice — mutation checks: dropping either setSubmitFailed(false) fails its test).
  • Round-27 tests: composerDraftStore.test.ts (the hold test now pins masking by text; +1: a newer draft written over a held passage is kept, the settling post clears only the text it posted, a matching conditional clear tombstones), SelectionToolbar.composer.test.tsx (+2: a newer draft typed over the passage after a mid-flight Escape survives the old post's success and its refusal, and comes back on the next open; the placement re-runs when the post-failed notice appears so an above-selection box does not grow over the passage — the refusal lands with no key event to re-run it; the in-flight tests pin the "Saving…" label). Mutation checks: an unconditional clear on success, a read that masks the whole held slot, and dropping submitFailed from the placement deps each fail their test. Capture driver: the in-flight scene asserts the Saving… label and no Add comment button (122 assertions).
  • Round-33 tests: SelectionToolbar.composer.test.tsx (+1: a refusal puts the pending text back when the newer draft typed over it was discarded, both outcomes — mutation check: dropping the write-back fails it), ArtifactPanelCoverage.test.tsx (json body gets a Copy-only toolbar and no composer; the widget body's toolbar container is the attached scroll box — mutation checks: dropping either fails them), RemoteArtifactDetailPageCoverage.test.tsx (+1: an earlier refused sidebar write does not hide a later "not saved" notice — mutation check: the old chain order fails it), artifactPanelsNarrow.test.ts (main's source pin follows the named narrowPanelOpen condition). Capture driver: +1 scene (kind=json, 4 assertions), 132/132.
  • Round-34 tests: composerDraftStore.test.ts (+1: isEmpty sees through a hold — a slot holding a newer in-flight draft is not empty; a discarded draft is, and a stale storage record does not un-empty it — mutation check: a masked isEmpty fails it), SelectionToolbar.composer.test.tsx (+1: a refused older post never overwrites a newer draft whose own post is still in flight — mutation check: the old read === null check fails it), ArtifactDetailPage.anchoredComments.test.tsx and RemoteArtifactDetailPageCoverage.test.tsx (+1 each: the "not saved" notice does not follow a param-only navigation to another artifact — mutation checks: dropping either page's reset fails its test).
  • Round-26 tests: useSelectionComposerAnchor.test.tsx (+1: the first of two outstanding posts settling does not make the second's draft discardable — mutation check: a flag instead of a count fails it), composerDraftStore.test.ts (holds count; releasing one of two keeps the passage held — mutation check: a set instead of a count fails it), ArtifactPanelCoverage.test.tsx (+1: json body toolbar — superseded in round 33 by the Copy-only row), RemoteArtifactDetailPageCoverage.test.tsx (+1: the "not saved" banner yields to the next write's own refusal — mutation check: the old chain order + no clear fails it). Capture driver: +1 scene (post=slowfail, 14 assertions).
  • Round-25 tests: composerDraftStore.test.ts (+2: a held slot reads as empty and refuses writes on every instance over the key until released; a slot seeded in storage by an earlier page lifetime is still read while a sibling this tab cleared stays cleared), SelectionToolbar.composer.test.tsx (+1: a flight abandoned by Escape neither freezes the next box nor closes it when it settles), useSelectionComposerAnchor.test.tsx (+1: a refusal is reported to the host only when the box that posted is gone), FileArtifactComments.test.tsx (+1: the sidebar's failure line carries the refused-after-close notice), ArtifactDetailPage.anchoredComments.test.tsx and RemoteArtifactDetailPageCoverage.test.tsx (+1 each: the page banner carries it, the same selection brings the text back and the retry posts it). Mutation checks: dropping the hold, dropping the abandon, dropping the orphan report, dropping the tombstones and letting read ignore a hold each fail their test. The capture driver gains 4 assertions on the refused-post scene (exactly one failure notice; no page banner with the store's raw reason).
  • Round-24 tests: useSelectionComposerAnchor.test.tsx (+1 generation guard — a late success on A leaves B's anchor; the in-flight guard test now pins proceed-without-asking and slot untouched), SelectionToolbar.composer.test.tsx (Escape mid-flight closes, keeps the slot, no prompt; a late success after ✕ clears the slot), composerDraftStore.test.ts (+1: a clear whose storage write is refused still wins), RemoteArtifactDetailPageCoverage.test.tsx (no page banner on a refused composer post). Mutation checks: dropping the generation compare, dropping the in-flight proceed, restoring the storage merge, dropping the mid-flight branch, and routing the remote post back through postMut each fail their test.
  • Round-23 tests: SelectionToolbar.composer.test.tsx (+1: Escape/✕ refused while a submit is in flight, then honoured after the refusal — mutation check: dropping the in-flight check fails it), useSelectionComposerAnchor.test.tsx (+1: the guard waits for the in-flight post — mutation check: dropping the wait fails it), ArtifactDetailPage.anchoredComments.test.tsx and FileArtifactComments.test.tsx (a refused composer post raises no page/sidebar banner — mutation check: routing back through the banner mutation fails it). selectionAnchor.test.ts builds its fixtures with createElement/textContent (Automated Rule Check: no innerHTML).
  • Round-22 tests: selectionAnchor.test.ts (+5: this-occurrence offset, leading-whitespace skip, Range.toString space across blocks, 32-char context caps and edge clamp, whitespace-only → null), RemoteArtifactDetailPageCoverage.test.tsx (+2: a draft does not follow a cached A→B navigation — mutation check: dropping the key fails it; Back's prompt on z-[10001]), ArtifactDetailPage.anchoredComments.test.tsx (Edit's prompt on z-[10001]), SelectionToolbar.composer.test.tsx (spinner while submitting).
  • Round-20 tests: SelectionToolbar.composer.test.tsx (+2: input read-only + slot cleared on a success after unmount; box clamped into the container column), ConfirmDialog.test.tsx (+1: layer: 'top' paints on z-[10001]), ArtifactPanelCoverage.test.tsx (+1: Exit full screen over a draft raises the prompt above the shell). Mutants killed: no slot clear before the mounted gate, read-only dropped, viewport-only clamp, layer dropped.
  • Static gates locally: tsc -b, eslint --max-warnings 0 on changed files, i18n:check, check-i18n-keys, lint:i18n, deadKeys/catalogParity/keyReference, theme-colors / phantom-classes / restyle-ratchet, jscpd (0 clones).
  • Screenshots: website/scripts/capture-artifact-selection-composer.mjs drives the isolated entry website/capture/artifact-selection-composer.{html,tsx} — the REAL ArtifactDetailPage / RemoteArtifactDetailPage / ArtifactPanel over a fetch stub at the API boundary, including the real sandboxed iframe and real in-iframe bridge (the driver selects text INSIDE the frame). 132/132 assertions pass per run (composer opens on selection, no Comment button, the annotated passage is highlighted under the box, the box holds exactly Add comment + Close, the posted anchor carries quote + offsets on the DOM path and quote + context only from the frame, the posted comment appears; Edit over a typed draft raises "Discard your unsaved comment?" with Discard comment + Cancel and Cancel keeps the text and stays out of edit mode; after a full reload a fresh document shows no box, re-selecting the same passage brings the typed draft back, and Escape over it asks first; with the fixture's post=fail the refused post keeps the text, re-enables the input and Add comment, stores nothing; with post=slow the in-flight box shows the spinner, holds Add comment, keeps the input read-only with its text, and the post lands when the store answers; the remote page opens the composer on its markdown body and from a selection inside its HTML iframe, Back over a typed draft asks first and Cancel keeps both, the posted anchor carries offsets + version_number; in the side panel's full screen a selection opens the composer, and Exit full screen over the draft raises the prompt on the z-[10001] layer where it is the topmost hit target at its Cancel button).

Manual verification

  • website/scripts/capture-artifact-selection-composer.mjs against the isolated entry (see Screenshots): 124/124 assertions on this head, scenes per theme: artifact page markdown body (open + post), widget body (in-iframe selection), page draft (Edit prompt; full reload then re-select restores), page in-flight (post=slow), page refused (post=fail), page closed-then-refused (post=slowfail: Escape mid-flight, then the 503 — the page banner, then re-selecting restores the text), side panel docked and full screen (prompt above the shell), remote page markdown and HTML bodies (Back prompt). The cached A→B navigation is covered by unit tests only.
  • Not run against a live gateway or the desktop shell: the driver stubs only the fetch boundary, so what it proves is the real components' behaviour over a stubbed store; the HTTP client itself is unchanged by this diff.
  • Local test runs hit a symlinked-node_modules Denied ID …@pierre/diffs…?worker&url from Vite's fs.allow on the editor tests of ArtifactDetailPage.test.tsx — identical on main in the same environment, not reachable in CI (real node_modules).

Screenshots / video

Full artifact page (markdown) Widget body (selection made inside the sandboxed iframe) Chat side panel
Dark Artifact page, dark: selecting "two weeks" opens the comment box Artifact page, widget body, dark: a selection made inside the iframe opens the same composer Chat side panel, dark: selecting "rollout checklist" opens the composer
Light Artifact page, light: selecting "two weeks" opens the comment box Artifact page, widget body, light: a selection made inside the iframe opens the same composer Chat side panel, light: selecting "rollout checklist" opens the composer

After typing and pressing Enter, the anchored comment lands in the durable store and shows in the sidebar (dark / light):

Artifact page, dark: the typed comment posted and listed in the comments sidebar
Artifact page, light: the typed comment posted and listed in the comments sidebar

A typed comment is never dropped silently. Any action that unmounts the box (Edit, a version switch, full screen, close, Escape, Back / Fork on the remote page) asks first, and a draft survives a teardown no guard can catch — leaving the page, a chat-slot switch — coming back when the same passage is selected again:

Edit over a typed draft asks first Draft typed Same passage re-selected after a full reload
Dark Artifact page, dark: the "Discard your unsaved comment?" prompt over a typed draft when Edit is clicked Artifact page, dark: a comment typed on "remaining teams" before the page is left Artifact page, dark: after a full reload, re-selecting "remaining teams" brings the typed comment back
Light Artifact page, light: the "Discard your unsaved comment?" prompt over a typed draft when Edit is clicked Artifact page, light: a comment typed on "remaining teams" before the page is left Artifact page, light: after a full reload, re-selecting "remaining teams" brings the typed comment back

The remote artifact page gets the same composer on both of its bodies, and its Back / Fork ask before leaving a typed draft behind:

Remote page, markdown body: composer open Remote page: Back over a typed draft asks first Remote page, HTML body: a selection inside the iframe opens the composer
Dark Remote artifact page, dark: selecting "measure adoption" opens the comment box Remote artifact page, dark: the "Discard your unsaved comment?" prompt after Back is clicked over a typed draft Remote artifact page, HTML body, dark: a selection made inside the sandboxed iframe opens the same composer
Light Remote artifact page, light: selecting "measure adoption" opens the comment box Remote artifact page, light: the "Discard your unsaved comment?" prompt after Back is clicked over a typed draft Remote artifact page, HTML body, light: a selection made inside the sandboxed iframe opens the same composer

The chat side panel over a json artifact (dark / light): no anchor resolver maps its selections, so no composer — the single-control Copy row the panel shipped before stays, and on touch is the only reachable copy:

Side panel, json body: Copy row, no composer
Dark Side panel over a json artifact, dark: selecting "rollout checklist" shows a single Copy control and no comment box
Light Side panel over a json artifact, light: selecting "rollout checklist" shows a single Copy control and no comment box

The chat side panel's full-screen mount: the composer over a selection in the full-screen body, and Exit full screen over that draft raising the prompt ABOVE the full-screen shell (dark / light):

Full screen: draft typed Full screen: Exit over the draft asks first, on top of the shell
Dark Side panel full screen, dark: a comment typed on "Review adoption metrics" Side panel full screen, dark: the "Discard your unsaved comment?" prompt painted above the full-screen shell after Exit full screen
Light Side panel full screen, light: a comment typed on "Review adoption metrics" Side panel full screen, light: the "Discard your unsaved comment?" prompt painted above the full-screen shell after Exit full screen

While the store is answering (dark / light): the submit control reads "Saving…" with a spinner, the input is read-only, a second Enter cannot post twice; ✕ and Escape still close the box but keep the draft in its slot for the flight to decide:

Artifact page, dark: the comment box while its post is in flight — the submit button reads Saving… with a spinner, input read-only
Artifact page, light: the comment box while its post is in flight — the submit button reads Saving… with a spinner, input read-only

A post the store refuses never costs the comment (dark / light): the typed text stays in the box, read-only only while the post is in flight, with "Couldn’t save your comment. Your text is still here — try again." and Add comment offered again; nothing was stored, so the comments panel did not reveal:

Artifact page, dark: after the comment store refused the post, the composer keeps the typed comment and shows the retry notice
Artifact page, light: after the comment store refused the post, the composer keeps the typed comment and shows the retry notice

The box closed mid-flight (Escape / ✕), then the store refused the post (dark / light): the box is gone, so the page banner says so — "Your comment on “Draft the rollout checklist” wasn’t saved. Select that text again to pick it up and try again." — one notice, naming the passage, no raw store reason; re-selecting the passage brings the text back:

Artifact page, dark: after Escape closed the box mid-post and the store then refused it, the page banner reports the comment was not saved and how to get it back
Artifact page, light: after Escape closed the box mid-post and the store then refused it, the page banner reports the comment was not saved and how to get it back

Related Issues

Closes #9823
Context: #9812 (the file viewer's type-first composer and the Design / UX approval of its shape), #9760 (the original extra-click harm).

Pattern harvest

Rule candidate: when a host lets a SelectionToolbar composer open from an externalSelection, resolve the anchor in the host's onSelect/bridge handler FIRST and let onOpen keep it when there is no live DOM range for the same text — onOpen cannot re-derive it, and overwriting it with the bare quote silently loses prefix/suffix.
Rule candidate: a useEffect that opens a composer at mount must be declared after the visibility effect that fires onClose on !visible, or the mount-time run of the latter closes the box the former just opened.
Rule candidate: when the same SelectionToolbar composer is mounted by several hosts, the anchor promotion + draft guard belong in one shared hook parameterized by the host's resolver and submit — a guard added to one inline copy is a guard the other copies silently lack (the remote page shipped three rounds without the discard prompt its siblings had).
Rule candidate: a store accessor that MASKS state for one caller (a held draft reads as null so a second box cannot re-post it) must not be the accessor another caller uses to test emptiness — give emptiness its own unmasked accessor, or the masking caller's safety becomes the other caller's data loss.
Not generalizable: the sidebar footer's "+ Add comment" sharing a verb with the composer's submit predates this PR (the retired popover used the same label); a distinct verb there is a CommentsSidebar follow-up across every host of that sidebar, not a selection-composer change.
Not generalizable: the artifact pages drop the iframe's start/end offsets on purpose (the parent highlighter's text space differs); the remote page keeps them because the provider's anchor schema requires them — a per-store contract, not a rule.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A: no user docs describe the retired popover; component contracts are documented in the source.
  • No secrets, credentials, or internal references in the diff

@CrysisDeu
CrysisDeu requested review from a team and hoang-phan98 September 23, 2026 04:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 9fb84794d3aebb4d2fa923f6730747d520a0db72 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify on touch: markdown/text artifact bodies lose their visible Copy control, and the composer's focus collapses the selection the OS copy callout needs.

[DESIGN-REVIEWED] 9fb8479

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 9fb84794d3aebb4d2fa923f6730747d520a0db72 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

No RFC covers replacing the pill→popover flow; the "No RFC" rationale rests on #9823's investigation — a maintainer should confirm that issue settles this shape.

The core deletion is sound on the lane's own terms: base carried two spellings of "comment on a selection" (CommentPopover in CommentOverlay.tsx and the SelectionComposer shipped on base SelectionToolbar.tsx), already diverged — the popover holds its draft in bare useState, so unmount loses it. This PR keeps one spelling; grep for CommentPopover after the change finds 0 references. New surface is consumed: useSelectionComposerAnchor 3 consumers, selectionAnchor/annotationHighlight 5 each, composerDraftStore 2, Modal layer 4 — all counted excluding tests. The Copy-button removal is derived from the documented max-two-buttons-per-row rule (website/AUTOSDE.yaml). Deleted tests pinned the deleted component's behavior, which the composer tests carry forward.

What this change ships

Inventory (10 items) — 10 justified

Intent: selecting text on any artifact surface opens the comment box immediately and a typed comment is never lost — a FIX (extra-click flow and silent draft loss), executed by consolidating onto the existing composer.

  1. Selecting text on artifact page, remote page, or side panel opens the comment box at once — justified
  2. The pill→popover two-stage flow and CommentPopover are deleted; one comment input remains — justified
  3. Panel's Copy button gone on commentable kinds; the empty composer's Ctrl/Cmd+C copies instead — justified
  4. Non-anchorable kinds (json, svg) keep a copy-only selection row — justified
  5. The annotated passage stays highlighted while the box is open — justified
  6. Typed comments persist across teardowns; discarding asks first — justified
  7. A refused post keeps the text and offers retry; in-flight shows "Saving…" with read-only input — justified
  8. A post refused after the box closed shows a page banner naming the passage — justified
  9. Discard prompts paint above full-screen shells (Modal layer: 'top') — justified
  10. New capture tooling for composer states replaces the deleted popover capture; one dead i18n key removed — justified

[FIRST-PRINCIPLES-REVIEWED] 9fb8479

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 9fb84794d3aebb4d2fa923f6730747d520a0db72 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9fb8479

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9fb84794d3aebb4d2fa923f6730747d520a0db72: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 9fb84794d3aebb4d2fa923f6730747d520a0db72 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Failure banner never says the typed text is kept — the blind reader couldn't tell "pick it up" from having to retype.

Watch

  • comment_post_failed_closed ("Select that text again to pick it up and try again", en.manual.json) omits the one fact that defuses the loss: the draft survives. The blind reader on shot-31: "I can't tell whether 'pick it up' means my words come back or I must retype" — a user on this rare but high-anxiety path (close mid-flight + refused post) retypes from memory or distrusts the recovery. Fix: state it — "…wasn't saved, but your text is kept. Select that text again to bring it back and try again."

[UX-REVIEWED] 9fb8479

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 9fb84794d3aebb4d2fa923f6730747d520a0db72 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9fb8479

Verdict parsed from the review's SHA-scoped output markers for commit 9fb84794d3aebb4d2fa923f6730747d520a0db72.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9fb84794d3aebb4d2fa923f6730747d520a0db72: <one-sentence reason>

@CrysisDeu CrysisDeu changed the title Artifact pages: type-first selection composer, retire CommentPopover feat(artifacts): type-first selection composer, retire CommentPopover Sep 23, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/artifact-selection-composer-9823 branch from c11e865 to 465bd4d Compare September 23, 2026 05:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/artifact-selection-composer-9823 branch from 465bd4d to 5aa2194 Compare September 23, 2026 05:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/artifact-selection-composer-9823 branch from 5aa2194 to c754e2f Compare September 23, 2026 06:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/artifact-selection-composer-9823 branch from c754e2f to 175e280 Compare September 23, 2026 06:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 23, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=e8bc62bbfe9d
Disposition: fixed in the next push.

  • website/src/components/FileArtifactComments.tsx:267 (and ArtifactDetailPage.tsx:1088) — comments claim onMutErr renders the composer refusal, but postAnchoredMut is wired banner-free

Outcome: both comments are rewritten to the actual contract: the composer's mutation deliberately skips the sidebar / page banner (onError: invalidate) so a refusal is reported once, in the box, and the typed text plus its persisted draft stay for the retry. No behaviour change; the misleading text is gone.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=25ddbd9785f7
Disposition: rebutted with measurement — the four frames the lane read predate the clamp; they are replaced by fresh captures, and the driver now asserts the geometry.

  • Watch: shots 10/11/13/14 show the composer (left ≈ selection’s left, unclamped) covering the sidebar card header, contradicting the clamp claim

Outcome: no code change. Shots 10/11/13/14 (the draft-typed and draft-restored frames) were captured on head e1cd749, before the column clamp landed on 59ad205, and were never re-attached. On this head the capture driver measures the draft scene: the box ends at x=871 and the comments sidebar starts at x=916 on both themes (the box stays clear of the comments sidebar — 2 new assertions, 124/124), and the four frames are re-captured and re-attached with the next push so the description shows what ships.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=856a5cdfb1ee
Disposition: out of scope — the two "Add comment" controls with two jobs predate this PR (the retired popover had the same label above the same sidebar button); recorded for the human look the lane asks for.

  • Watch: "Add comment" appears twice with two jobs on one screen (composer submit vs sidebar’s + Add comment)

Outcome: no code change. The retired CommentPopover used the same components.commentOverlay.add_comment label for its submit, beside the same sidebar + Add comment (the non-anchored, document-level path), so the pairing is the page's existing vocabulary and this PR swaps the input, not the model. Renaming either is a page-vocabulary decision that touches the sidebar's own add path and the side panel's bar (flagged by this lane on ca21ef8 as the same family); it is recorded here for that decision rather than changed unilaterally.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=6ea12d23d5ac
Disposition: adopted in the next push.

  • Suggestion: comment_post_failed_closed should quote the annotated passage so "select the same text again" names a text

Outcome: the shared hook hands the host the annotated passage (whitespace folded, clipped at 48 characters with an ellipsis) and the notice now reads "Your comment on “” wasn’t saved. Select that text again to pick it up and try again." on all three hosts; the string is re-translated with the {{quote}} placeholder in all 13 catalogs (ko uses ‘ ’ per its style rule). Tests: useSelectionComposerAnchor.test.tsx (+1: the passage arrives folded and clipped — mutation check: the raw quote fails it; the refusal test pins the argument), page / file-viewer / remote scenes pin the quoted notice; the capture driver's refused-after-close frames are re-shot and re-attached.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=5533a6f699ce
Disposition: rebutted — the shape was decided and recorded on #9812 / #9823; the maintainer decision the lane names is escalated, not posted here.

  • Item 1 — product-shape change without accepted RFC

Outcome: no code change. The type-first composer as the one comment input was accepted on #9812 (Design and UX lanes plus the issue author, for the file viewer); #9823 is that author asking for the same input on the artifact hosts, and the conductor-dispatched investigation on #9823 records the scope this PR implements. No RFC covers per-surface comment-input choices in either direction; this lane passed the identical premise on heads e1cd749, 4e0145f, 621d357 and 43a915e, rated it CONCERNS on fca6e87, and BLOCK on b6653a9, 8a36264, ca21ef8 and this head. The description's Not a goal section states the record explicitly. The item is escalated to the conductor for the maintainer decision the lane names as its clearance; this PR posts no override.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=da468325cce0
Disposition: rebutted — same premise as Item 1; escalated to the conductor for the maintainer decision, no override posted.

  • Blockers — product-shape change without accepted RFC (CommentPopover deleted, composer mounted on four surfaces)

Outcome: no code change. The type-first composer as the one comment input was accepted on #9812 (Design and UX lanes plus the issue author, for the file viewer); #9823 is that author asking for the same input on the artifact hosts, and the conductor-dispatched investigation on #9823 records the scope this PR implements. No RFC covers per-surface comment-input choices in either direction; this lane passed the identical premise on heads e1cd749, 4e0145f, 621d357 and 43a915e, rated it CONCERNS on fca6e87, and BLOCK on b6653a9, 8a36264, ca21ef8 and this head. The description's Not a goal section states the record explicitly. The item is escalated to the conductor for the maintainer decision the lane names as its clearance; this PR posts no override.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=23dbf0c7f905

Disposition: fixed (next head)

  • boundary whitespace makes persisted drafts unreachable

Outcome: the toolbar's slot offset now skips the leading whitespace of the drag (start = pre.length + (raw.length - raw.trimStart().length), length = raw.trim().length), so it agrees with the trimmed passage the host is told about and with the hosts' own anchorFromRange offset. Selecting " beta" and typing files the draft under 6|beta, and re-selecting "beta" reads it back. The same trimmed offsets feed Escape's selection restore and the scroll re-anchor. Test: SelectionToolbar.composer.test.tsx "a selection dragged from the space BEFORE a word…" (mutant with the untrimmed offset fails it).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=6504b7c8bc2e

Disposition: fixed (next head)

  • ArtifactDetailPage.tsx:2265 toolbars pass no suspended on a narrow viewport

Outcome: both toolbars on the artifact page now take suspended={narrowPanelOpen} where narrowPanelOpen = isMobile && panel !== 'none' is the same condition the body wrapper's hidden class uses — the same shape ArtifactPanel already passes. Test: ArtifactDetailPage.anchoredComments.test.tsx "on a narrow viewport, opening the comments panel hides the composer… and keeps the draft" (draft survives the toggle; mutant without suspended fails it).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=82eb7d6ad555

Disposition: fixed (next head)

  • Escape/✕ during "Saving…" closes the box but never cancels the post, with no cue at the point of action

Outcome: while a post is in flight the ✕ button's aria-label/title read "Close — saving continues" (new key components.selectionToolbar.close_saving_continues, 13 catalogs + en-XA), so the control says at the point of action that closing does not abort the post. Test pins the label swap on both sides of the flight.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=6f14dd78a6e0

Disposition: out of scope (pre-existing)

  • "Add comment" (durable annotation) vs the panel bar's "1 comment to send to this chat"

Outcome: the to-chat forwarding bar and its wording predate this PR and belong to the chat side panel, not to the composer this PR ports; the retired popover used the same "Add comment" label above the same bar, so the pairing is unchanged by this change. Renaming the forwarding act (e.g. "Send 1 comment to the agent") is a reasonable follow-up on the panel bar's own strings and is recorded here for the human look rather than folded into this already-wide diff.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=97663f1f6241

Disposition: fixed (next head)

  • composerDraftStore.ts:97 discarding a replacement draft can erase the in-flight draft

Outcome: the flight's settle now covers the path. On a refusal, if the slot is EMPTY — the newer draft typed over the held passage was itself discarded (or trimmed to nothing) — the toolbar writes the pending text back into the slot (SelectionToolbar.tsx, settle branch), so the notice's "select the text again to pick it up" holds and the flight is no longer the text's only copy. A newer draft that is still there is left alone (later words win, as before); a success still clears. No fourth store layer: the pending text is already retained by the flight, and the store doc names the path. Test: SelectionToolbar.composer.test.tsx "a refusal puts the pending text back when the newer draft typed over it was discarded" (both outcomes; mutant without the write-back fails it).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=12d43a663671

Disposition: fixed (next head)

  • RemoteArtifactDetailPage.tsx:185 ?? orphanedPostError is the last term of the chain

Outcome: it is the FIRST term now. Every write path already clears it before mutating (onAdd/onReply/onMarkReview/onDelete and the composer post), so it can never mask a fresher mutation error — while a react-query error from an earlier refused sidebar add, which only clears on that mutation's own next mutate/reset, no longer sits in front of it (the composer posts through its own mutation and never resets postMut). Test: RemoteArtifactDetailPageCoverage.test.tsx "an earlier refused sidebar write does not hide a later 'not saved' notice" (mutant with the old order fails it).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=f1b27074cbbb

Disposition: fixed (next head)

  • ArtifactPanel.tsx:228 json/svg lose the Copy row; :535 iframe branch hands the toolbar an unattached containerRef

Outcome: (1) the kinds no anchor resolver maps (json, svg, …) mount the toolbar with a single Copy action and no composer, as the panel shipped before this PR — one control, inside the two-per-row cap; on touch that is the only reachable copy. The composer rows themselves stay without a Copy control: a third control beside Add comment + ✕ was GPT's blocking two-per-row finding in round 4, ruled to drop it. (2) On the iframe branch both toolbars (docked and full screen) now take the scroll box as containerRef (usesIframe ? scrollRef : previewRef, usesIframe ? fsScrollRef : fsPreviewRef) — attached on every branch, so the placement clamp has a right edge to honour; externalOnly keeps the toolbar's own selection check off it. Tests: ArtifactPanelCoverage.test.tsx "gives a json body a Copy-only toolbar and no composer" and the widget test's container assertion (mutants without either fail them). Capture: new panel-json-1-copy shots (dark/light) in the body; driver 132/132.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=f591af13b310

Disposition: rebutted

  • Item 1 — product shape without an RFC

Outcome: unchanged premise, unchanged answer (same span rebutted on every head since round 15; PASS on c5c3748aa, CONCERNS here). The type-first composer shape was decided on #9812 (Design/UX approval of the file-viewer composer) and #9823's investigation asked for it to be ported to the artifact hosts as-is; this PR removes a duplicate input rather than introducing a new interaction. An RFC would document a decision already taken. The body's Problem / Motivation and Not-a-goal sections say so; if a maintainer disagrees, the clearance path is theirs (override on this head or a docs/decisions record), not a code change here.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=23dbf0c7f905

Disposition: fixed (next head)

  • SelectionToolbar.tsx:994 a refused post overwrites a newer in-flight draft

Outcome: the write-back no longer asks read, which masks a held draft as null. The store gains isEmpty(anchor, start) — the UNMASKED check, true only when the passage has no draft at all — and the refused flight puts its text back only when that is true. A newer draft whose own post is still in flight (the case the hold-counting was written for) is therefore never overwritten: the older refusal leaves it, the newer refusal finds it in its own box and in the slot for the next open. Tests: composerDraftStore.test.ts "isEmpty sees through a hold" (mutant with a masked isEmpty fails it) and SelectionToolbar.composer.test.tsx "a refused older post never overwrites a newer draft whose own post is still in flight" (mutant with the old read === null check fails it). The discarded-newer-draft case from the last round still restores (its test is unchanged and green).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=6504b7c8bc2e

Disposition: fixed (next head)

  • ArtifactDetailPage.tsx:1134 refused-after-close notice is not tied to artifact identity

Outcome: both pages now reset the notice with the route param: ArtifactDetailPage clears commentActionError on [slug] and RemoteArtifactDetailPage clears orphanedPostError on [provider, externalId], so a notice naming A's passage (whose draft waits under A's key) is not shown over B. useFileArtifactComments is left as is, per the finding: its tab id pins the slug. Tests: "the 'not saved' notice does not follow a param-only navigation to another artifact" in both page suites (each mutant without its reset fails its test).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=5240292db20e

Disposition: rebutted (pre-existing pairing, out of scope)

  • Two visible "Add comment" controls (composer submit vs sidebar footer)

Outcome: the pairing predates this PR: the retired CommentPopover submitted with the same "Add comment" label next to the same sidebar footer, so this PR neither introduces nor widens it — it removes one input stage. The composer's label is the shared components.commentOverlay.add_comment the chat composer uses (MarkdownPanel), and renaming the sidebar footer is a CommentsSidebar change that touches every host of that sidebar, not the selection composer. Recorded as a follow-up candidate in the body's Pattern harvest; not folded here.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=d8bebcb8af6e

Disposition: rebutted

  • Composer keeps a Copy icon in MarkdownPanel but artifact hosts pass an empty actions row

Outcome: the anchorable rows stay without a Copy control, as ruled in round 4: a third control beside Add comment + ✕ was GPT's blocking two-per-row finding, and the ruling was to drop it rather than add an overflow menu to a one-line composer. Touch is not left without copy: a touch selection raises the platform's own selection callout (Copy is its first item on iOS and Android), and the composer opens UNFOCUSED on touch precisely so that callout stays usable (SelectionToolbar.composer.test.tsx "opens unfocused on a touch device"); the Cmd/Ctrl+C path is the desktop equivalent, where no callout exists. json/svg keep a Copy-only row because they have no composer at all — one control, not a third. MarkdownPanel's three-control row predates this PR and is grandfathered, not a pattern this PR may grow. If a maintainer wants the file-viewer/artifact composers to carry Copy after all, that is a product ruling across #9812 and this PR, not a code change here.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=db475ac19fc7

Disposition: rebutted

  • Item 3 — Copy button dropped from the selection row on anchorable artifact bodies (touch loses copy)

Outcome: the anchorable rows stay without a Copy control, as ruled in round 4: a third control beside Add comment + ✕ was GPT's blocking two-per-row finding, and the ruling was to drop it rather than add an overflow menu to a one-line composer. Touch is not left without copy: a touch selection raises the platform's own selection callout (Copy is its first item on iOS and Android), and the composer opens UNFOCUSED on touch precisely so that callout stays usable (SelectionToolbar.composer.test.tsx "opens unfocused on a touch device"); the Cmd/Ctrl+C path is the desktop equivalent, where no callout exists. json/svg keep a Copy-only row because they have no composer at all — one control, not a third. MarkdownPanel's three-control row predates this PR and is grandfathered, not a pattern this PR may grow. If a maintainer wants the file-viewer/artifact composers to carry Copy after all, that is a product ruling across #9812 and this PR, not a code change here.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=3989cb6a88ed

Disposition: rebutted (same premise as the Item 3 finding)

  • Inventory 3 — explicit Copy button removed; copy relocated to Cmd/Ctrl+C — symmetry-inherited

Outcome: same item as the headline finding, same answer: the row stays at two controls by the round-4 ruling; touch copies through the platform's selection callout (composer opens unfocused on touch); desktop through Cmd/Ctrl+C; json/svg keep a Copy-only row because they have no composer. A maintainer's product ruling, not a code change, is what would change it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=8d9b0c379089

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 1 — type-first composer replaces the pill→CommentPopover flow on all four hosts

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=5a080fd9536f

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 2 — CommentPopover + tests, capture entry and add_a_comment key deleted

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=e105b157b92d

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 4 — refused/in-flight post handling

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=8d93d8b49013

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 5 — shared wiring extracted to useSelectionComposerAnchor + annotationHighlight + composerDraftStore

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=dd06202547a0

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 6 — Modal/ConfirmDialog layer:'top'

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=25d4c5918480

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 7 — draftStore.hold/release + generation counter

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=810442e40285

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 8 — Copy-only row kept for non-anchorable kinds (json/svg)

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

span=6a48d23ad593

Disposition: acknowledged (lane marks it justified; no action)

  • Inventory 9 — new selectionToolbar keys

Outcome: the lane's own inventory marks this item justified against the stated intent (type-first composer on every artifact surface, typed comment never lost, CommentPopover retired). Nothing to fix or rebut; the body's What changed section declares it.

…ire CommentPopover

Selecting text on an artifact — the full artifact page, the remote artifact
page and the chat side panel — now opens the same type-first comment box the
file viewer got in #9812 (`SelectionToolbar`'s `composer`), instead of a
selection pill with a Comment button that opened a titled popover.

- `useFileArtifactComments` exposes `selectionComposer` (+ `iframeSelection`)
  in place of `requestAnchoredComment`: the anchor is resolved from the live
  range in `onOpen`, the anchored post fires from `onSubmit`.
- `ArtifactDetailPage` / `RemoteArtifactDetailPage` follow the same shape;
  the bare mouseup probes on the prose wrappers go away.
- Iframe (widget/html) bodies keep working: the bridge's selection reaches the
  toolbar as `externalSelection`, which now opens the composer too (SelectionToolbar).
- `CommentPopover` is deleted from `CommentOverlay.tsx` with its capture entry,
  tests and the orphaned `components.commentOverlay.add_a_comment` key (13 catalogs).

Closes #9823
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.

Artifact pages: adopt the type-first selection composer, retire CommentPopover

2 participants