Skip to content

feat(frontend): open agent chat links in a new tab - #9426

Merged
bobbai00 merged 1 commit into
apache:mainfrom
eugenegujing:feat/agent-chat-links-new-tab
Nov 16, 2026
Merged

bobbai00 merged 1 commit into
apache:mainfrom
eugenegujing:feat/agent-chat-links-new-tab

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

A link in an agent chat message opened in the workflow tab, so one click replaced the editor with the linked page. The chat renders each message with <markdown>, and the rendered <a> had no target.

Links in a chat message now open in a new tab.

  • agent-chat.component.html binds the ready output of the message's <markdown> to a new openLinksInNewTab handler. ready fires after every render, so a message that is rendered again with new text is handled again.
  • The handler sets target="_blank" and rel="noopener noreferrer" on every link that resolves to an http or https address. That covers links to other sites, bare URLs that markdown turns into links, and also anchors, links without a protocol, absolute paths and full links to the app. A rendered link is not a router link and the app has <base href="/">, so each of those would load another page of the app in the editor's tab (#summary resolves to the app root).
  • Links with another scheme, such as mailto:, and links whose address cannot be parsed are left as they were.
  • A target or rel the link already carried is replaced, so a message cannot keep rel="opener".

The change is local to chat messages. The other markdown views (the Form View instructions, the dataset file preview, the dataset, model and hub workflow descriptions, and the system prompt tab of the agent's info dialog) render links the same way and are not changed here. They are a possible follow-up.

Before (main). The agent's answer holds a link to a documentation page. Clicking it loads the documentation in the same tab, so the editor and the conversation are gone.

Before the click After the click, the same tab
links-1-main-before-click links-2-main-after-click-same-tab-is-docs

After (this PR). The same click on the same conversation opens the documentation in a second tab. The editor's tab stays as it was.

links-3-this-pr-after-click-docs-in-new-tab

Any related issues, documentation, discussions?

Closes #9422.

How was this PR tested?

cd frontend && NODE_OPTIONS="--no-experimental-webstorage" npx ng test --watch=false --include src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts: 67 passed (52 before this PR). The 15 new tests render real messages through <markdown> and read the resulting links.

  • A link to another site over https and over http, a protocol-relative link and a bare URL open in a new tab with rel="noopener noreferrer".
  • An anchor, a link with an empty address, a link without a protocol, an absolute path, a full link to the app and a link to the same host on another port open in a new tab as well.
  • A mailto: link, a javascript: link (which Angular has already rewritten to unsafe:javascript:) and a link whose address cannot be parsed are untouched.
  • A target and rel already on a link are replaced.
  • A message without links renders as before. Several links in one message are each judged on their own, and so are links in every message of a conversation and in a message the user typed.
  • A message rendered again gets its new link handled, and a link that becomes a mailto: link loses the new-tab marks.

Also agent-panel.component.spec.ts (49 passed), which renders the chat inside the panel, npx prettier --check and npx eslint on the three touched files, and npx tsc --noEmit -p src/tsconfig.app.json. Four mutants were each caught by a test: an unparsable address treated as a link, every scheme treated as a web link, a link with an empty address skipped, and rel extended instead of replaced.

Live check on a local stack with the frontend served from this branch. One typed message held an anchor link, an absolute path, a mailto: link and a bare http://localhost:8080 URL, and the agent's answer held a link to a documentation page. In the rendered chat every link except the mailto: one had target="_blank" and rel="noopener noreferrer". Clicking the anchor link left the workflow editor and the conversation in place, where before the same click loaded the app root in the editor's tab.

Was this PR authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Code (claude-fable-5-2). Co-authored with Claude; the author reviewed the change before submission.

Links in a rendered agent chat message that resolve to an http or https address now get target="_blank" and rel="noopener noreferrer", and links with another scheme such as mailto are unchanged.
@github-actions github-actions Bot added feature frontend Changes related to the frontend GUI labels Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan, @Yicong-Huang
    You can notify them by mentioning @aglinxinyuan, @Yicong-Huang in a comment.

@bobbai00
bobbai00 self-requested a review November 15, 2026 05:22

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 0 must-fix · 0 advisory · 0 polish: no findings. The links get their new-tab marks on every render, and the specs run the real markdown pipeline.

Verification trace

Traced against ngx-markdown 21.2.0 and Angular 21.2: MarkdownComponent.render() writes the sanitized HTML and only then emits ready, on every entry point (data change, src, transclusion, reload), so each render is handled, streamed updates included. Angular's sanitizer keeps target and rel, so a raw rel="opener" reaches the handler and is replaced, which is what the replacement spec checks. isWebLink resolves against document.baseURI, the same base the browser uses for the click under <base href="/">.

@bobbai00
bobbai00 added this pull request to the merge queue Nov 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 15, 2026
@bobbai00
bobbai00 added this pull request to the merge queue Nov 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 15, 2026
@bobbai00
bobbai00 added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 16, 2026
@bobbai00
bobbai00 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into apache:main with commit 52093b4 Nov 16, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open links in agent chat messages in a new tab

2 participants