Skip to content

fix(chat): resolve agent prose links against the host app base#23

Merged
albanm merged 2 commits into
mainfrom
fix-broken-links
Jun 16, 2026
Merged

fix(chat): resolve agent prose links against the host app base#23
albanm merged 2 commits into
mainfrom
fix-broken-links

Conversation

@albanm

@albanm albanm commented Jun 16, 2026

Copy link
Copy Markdown
Member

Agent-authored chat links written as app-relative paths (/dataset/x/table, or
even bare dataset/x/table) were resolved against the chat iframe's own URL
(/agents/.../chat), producing broken full-page reloads.

What changed:

  • New pure resolveAgentLink helper (lib-vuetify/link-utils.ts) — resolves a
    raw href against the embedding app's origin + router base, deciding external vs.
    in-app and stripping the base prefix. Unit-tested, no vue-router/window deps.
  • AgentChatMessages.vue now forwards the raw href attribute (not the
    DOM-resolved .href), so app-relative links aren't corrupted by the iframe URL.
  • useAgentChatBase.ts navigates in-SPA only when the resolved path matches a real
    route, otherwise falls back to a full navigation.
  • Released as @data-fair/lib-vuetify-agents 0.6.1.

Why: models frequently write links that omit the deployment base prefix; these
were dead clicks. The host knows its router base, so resolution belongs there.

Regression risks:

  • Shared lib behavior change: same-origin links now require a route match to
    navigate in-SPA; all other cases (external, unmatched same-origin) fall back to a
    full navigation. Confirm no external embedder of the navigate event relied on
    receiving a pre-resolved URL.
  • mailto:/tel:/anchor hrefs route through the same path (treated as external ->
    full navigation); not covered by a test.

albanm and others added 2 commits June 16, 2026 11:42
Clicked links in chat prose were forwarded as the iframe-resolved href, so the
iframe's own /agents/.../chat URL became the resolution base and app-relative
links (e.g. /dataset/x/table, or a bare dataset/x/table) got mangled — the host
then full-reloaded to a 404 (missing the deployment base prefix).

- AgentChatMessages: forward the raw href the model wrote, not the DOM-resolved
  one, so intent survives the iframe round-trip.
- useAgentChatBase: resolve the link against our own router base via the new
  resolveAgentLink helper — strip the base when present, and when an app-relative
  path omits it, router.push it if it maps to a real route (in-SPA nav) instead of
  full-reloading; external origins and unmatched same-origin paths still do a full
  navigation.

Pure helper in lib-vuetify/link-utils.ts, unit-tested.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@albanm albanm merged commit 108c3cf into main Jun 16, 2026
4 checks passed
@albanm albanm deleted the fix-broken-links branch June 16, 2026 09:54
@github-actions github-actions Bot added the fix label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant