Repository navigation
Description
Two bugs in the grab-selector reference card (the staged-element preview above the composer), observed in the embedded widget panel. Reported by Omri with screenshots, 2026-08-14.
1. Preview consumes most of the panel — needs max-height + user resize
ScaledSnapshot (apps/conciv/src/pane/grab-reference.tsx:12) scales the captured element to fit GRAB_PREVIEW_MAX_W (280px) by width only — height is preview.height * scale with no cap. Grabbing a tall element (a full <section>, in the report a whole hero section) produces a preview that fills most of the widget's vertical space, squeezing the transcript to a sliver.
Wanted:
- A max-height on the preview (design token, not a magic number), with the snapshot fitted inside (contain: scale by
min(widthScale, heightScale)). - User-resizeable: platform-native first — CSS
resizeon anoverflowcontainer (use-the-platform-ladder); only reach for custom drag machinery if the native handle genuinely can't work inside the panel.
Render sites (both must get the fix — the component is shared):
apps/conciv/src/pane/chat-pane.tsx:376(pane composer)apps/conciv/src/routes/panel.$sessionId.$view.tsx:68(panel route; note it duplicates theGRAB_PREVIEW_MAX_W = 280constant — consolidate while touching it)
2. REGRESSION: preview doesn't disappear on send — it lingers until the AI answers
Sending a message with a staged grab keeps the reference card sitting above the composer for the whole turn; it only vanishes when the assistant's response settles (second screenshot: message sent, typing indicator running, card still there).
Root cause, verified in code and history:
- Current (
apps/conciv/src/pane/chat-pane.tsx:282-290):const onSend = async (content: string | MultimodalContent) => { ... await chat.sendMessage(content) pane.grabStore.clear() }
chat.sendMessageresolves when the turn settles, so the clear runs after the AI answers. - Pre-rewrite behavior (
fbc8e8ac, "never lose what was typed"):pane.grabStore.clear()ran synchronously beforeawait sending. - Regression introduced by the chat-stack clean-room rewrite
cf49d700(feat!: chat-stack clean-room rewrite — @tanstack/ai subscribe/send/stop, runId-stamped wire, ui-kit-chat composer #212), which rebuiltonSendwith the clear after the await.
Fix direction: clear the grab store synchronously once the send is accepted (after the checkSend verdict passes and the message is handed to sendMessage, not after it resolves) — restoring the pre-#212 contract. The composer must never gate visible state on async settle.
Process requirement (regression)
RED test first, then the fix, then green — in that order, commits or test-run evidence showing the test failed against the current behavior before the fix:
- Add a failing browser test in
apps/conciv/test/chat-pane.browser.test.tsx(the suite already drives send flows): stage a grab, send, assert the grab reference card is gone immediately (while the turn is still streaming — not after settle). - Fix, re-run, green.
- Size/resize behavior gets its own test in
apps/conciv/test/grab-reference.browser.test.tsx(tall-preview fixture: card respects max-height; resize affordance present).
Activity
omridevk commentedon Aug 13, 2026
Deeper investigation (2026-08-14, code + history verified):
The lingering card: exact asymmetry found
The composer library already encodes the correct send contract —
packages/ui-kit-chat/src/primitives/composer/composer.tsxsubmit()(lines 277-290):The composer's own
state.grabs(draft-persistence copy) clears instantly on send. But the visible grab cards render from a different store:pane.grabStoreinapps/conciv/src/pane/chat-pane.tsx, which only syncs one way into the composer context (createEffect(() => context.setGrabs(grabTexts(pane.grabStore.grabs()))), chat-pane.tsx:132) and is cleared in the pane'sonSendafterawait chat.sendMessage(content)(chat-pane.tsx:288-289).sendMessagein subscribe mode resolves when the turn settles (and never rejects — see #207), so the card sits there until the AI answers.History: pre-rewrite (
fbc8e8ac) the pane cleared the grab store synchronously before awaiting the send. The #212 clean-room rewrite (cf49d700) rebuiltonSendwith the clear after the await — that's the regression commit.Fix shape (mirror the composer's own contract in the pane):
onSend: snapshotpane.grabStore.grabs(), clear the store synchronously once thecheckSendverdict passes and the message is dispatched — not after it resolves.grabStore.stageAll) in the pane'sonSendError, symmetric withrestoreDraft. NoterestoreDraftrestoresoriginal.grabsinto composer state but the pane store is the render source — without the pane-side re-stage the two stores desync on a rejected send.apps/conciv/src/routes/panel.$sessionId.$view.tsx:68).The size bug: resizer = Ark Splitter
ScaledSnapshot(apps/conciv/src/pane/grab-reference.tsx:12) fits width only (GRAB_PREVIEW_MAX_W = 280); height unbounded. Decisions:scale = min(1, maxWidth/width, maxHeight/height)with a max-height token.@conciv/ui-kit-system(packages/ui-kit-system/src/splitter.tsx); vertical orientation, preview panel + transcript side, respecting the max-height default. No hand-rolled drag machinery.GRAB_PREVIEW_MAX_Wis duplicated inchat-pane.tsx:64andpanel.$sessionId.$view.tsx:12— consolidate while touching.Test plan (RED first — regression mandate)
apps/conciv/test/chat-pane.browser.test.tsx— stage a grab, send, assert the grab card is gone immediately while the turn is still streaming. Must fail against current code before the fix; keep the failing-run evidence.onSendError.apps/conciv/test/grab-reference.browser.test.tsx— tall-preview fixture respects max-height (expand-and-verify, no rect measuring: assert via the splitter/panel contract, not getBoundingClientRect); splitter handle present and keyboard-operable (Ark splitter exposesrole="separator"with aria-valuenow).chore: #478 changeset + AGENTS.md changeset-coverage gate
fix(conciv): #478 per-submission grab snapshot — queued sends can't c…
refactor(conciv): #478 native CSS resize for the grab preview
fix(conciv): #478 composer always visible at minimum panel height
fix(conciv): #478 restore staged grabs when the send itself throws
fix(conciv+ui-kit-chat): #478 composer survives any panel height — sh…
fix(conciv): #478 the grabs container owns the resize; no clipped car…
fix(conciv): #478 grab strip resizes via the shared createResizable p…
fix(conciv+ui-kit-system): #478 grab strip drag responds from the ren…
fix(conciv+ui-kit-system): #478 grabber in its own lane; strip defaul…
fix(conciv): #478 preview zooms to card width via CSS container query…
fix(conciv): #478 preview scales via svg viewBox — image-like intrins…
fix(conciv): #478 strip is height-auto until dragged; preview contain…
fix(conciv): #478 first drag starts from the rendered strip height — …
fix(conciv+ui-kit-system): #478 resizable max bound — strip drags onl…
fix(conciv): #478 larger grabbable hit area around the strip pill
fix(conciv): #478 hover wash on the strip grab handle
fix(conciv): #478 hover brightens the pill itself, hit box stays invi…
docs(changeset): #478 describe the shipped strip/preview design
fix(conciv): #478 grab card clears on send + max-height with resizabl…
feat: #487 grabs are attachments — snapshot survives reload, cards in…