Skip to content

fix(chat): prevent source-row clicks from opening URL twice#104

Merged
quiet-node merged 1 commit intomainfrom
worktree-witty-pondering-papert
Apr 25, 2026
Merged

fix(chat): prevent source-row clicks from opening URL twice#104
quiet-node merged 1 commit intomainfrom
worktree-witty-pondering-papert

Conversation

@quiet-node
Copy link
Copy Markdown
Owner

Summary

  • Tighten delegated click selector in ChatBubble from [data-citation] to a[data-citation] so source-row footer buttons no longer match the delegated handler.
  • Source rows already own a click handler that calls open_url; they were matching the container's delegated [data-citation] handler too (used for hover highlighting), causing every source click to invoke open_url twice and open the URL twice in the browser.
  • Inline citation anchors (built by wrapCitations) keep their behavior; only delegated routing changes.

Test plan

  • bun run test (721/721 pass)
  • bun run validate-build (lint + format + typecheck + frontend build + backend build, exit 0)
  • Manual: run a /search turn, expand the Sources footer, click a source — confirm browser opens the URL exactly once.
  • Manual: click an inline citation in the answer body — confirm browser still opens the URL once.

The bubble container had a delegated click handler matching any
`[data-citation]` ancestor. Source-row buttons in the sources footer
carry `data-citation` for hover-link highlighting and own their own
click handler that invokes `open_url`. Clicks on a source row therefore
fired `open_url` once from the button handler and again from the
delegated container handler after bubbling, opening the URL twice in
the browser.

Tighten the delegated selector to `a[data-citation]` so only inline
citation anchors built by `wrapCitations` trigger it. Source-row
buttons no longer match, eliminating the double-fire.

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
@quiet-node quiet-node merged commit e1d2cdf into main Apr 25, 2026
3 checks passed
@quiet-node quiet-node deleted the worktree-witty-pondering-papert branch April 25, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant