Skip to content

Grab selector card: no max-height (fills the widget) and lingers after send until the AI answers (regression from #212) #478

Closed

Description

@omridevk

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 resize on an overflow container (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 the GRAB_PREVIEW_MAX_W = 280 constant — 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.sendMessage resolves 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 before await 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 rebuilt onSend with 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:

  1. 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).
  2. Fix, re-run, green.
  3. 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

  1. added
    bug
    on Aug 13, 2026
  2. omridevk commented on Aug 13, 2026

    @omridevk
    ContributorAuthor

    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.tsx submit() (lines 277-290):

    const original = snapshotDraft()        // snapshot draft + attachments + quote + grabs
    ...
    clearDraft()                            // SYNCHRONOUS clear before the send settles
    const failure = await runSend(content)
    if (!failure) return
    restoreDraft(original)                  // rejected send restores the snapshot

    The composer's own state.grabs (draft-persistence copy) clears instantly on send. But the visible grab cards render from a different store: pane.grabStore in apps/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's onSend after await chat.sendMessage(content) (chat-pane.tsx:288-289). sendMessage in 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) rebuilt onSend with the clear after the await — that's the regression commit.

    Fix shape (mirror the composer's own contract in the pane):

    • In onSend: snapshot pane.grabStore.grabs(), clear the store synchronously once the checkSend verdict passes and the message is dispatched — not after it resolves.
    • On send failure: re-stage the snapshot (grabStore.stageAll) in the pane's onSendError, symmetric with restoreDraft. Note restoreDraft restores original.grabs into composer state but the pane store is the render source — without the pane-side re-stage the two stores desync on a rejected send.
    • Same contract applies to the panel route render site (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:

    • Default fit becomes contain: scale = min(1, maxWidth/width, maxHeight/height) with a max-height token.
    • User resize via Ark UI Splitter — already wrapped in @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_W is duplicated in chat-pane.tsx:64 and panel.$sessionId.$view.tsx:12 — consolidate while touching.

    Test plan (RED first — regression mandate)

    1. RED: 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.
    2. Fix, same test green.
    3. Rejected send: card restored (re-staged) after onSendError.
    4. 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 exposes role="separator" with aria-valuenow).
  3. added
    agent:in-progress
    agent-triaged
    agent:implemented-in-pr
    and removed
    agent:in-progress
    on Aug 13, 2026
  4. added 19 commits that reference this issue on Aug 13, 2026
  5. added 2 commits that reference this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-triagedagent:implemented-in-prbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions