feat(site): rewrite localhost URLs in agent chat to port-forward links#22891
Merged
feat(site): rewrite localhost URLs in agent chat to port-forward links#22891
Conversation
Uses streamdown's built-in urlTransform prop to intercept http://localhost:PORT URLs in agent chat messages and rewrite them to port-forwarded workspace URLs. When the agent outputs a bare URL like http://localhost:3000 or a markdown link like [app](http://localhost:8080/path), the URL is rewritten to the workspace's port-forward subdomain (e.g. https://3000--agent--workspace--user.wildcard.host). This makes links clickable directly from the chat without manual port-forwarding. The transform is built in AgentDetail where workspace and proxy context are available, then threaded as an optional prop through AgentDetailView -> AgentDetailTimeline -> ConversationTimeline -> Response -> Streamdown. When any required context is missing (no workspace, no wildcard proxy host), URLs pass through unchanged. Only real links are transformed — URLs inside backtick code spans remain literal text, which is correct since streamdown's urlTransform operates on HAST element attributes (href, src), not text node content.
DanielleMaywood
approved these changes
Mar 10, 2026
Contributor
DanielleMaywood
left a comment
There was a problem hiding this comment.
Assuming you've tested this to work, LGTM
The AgentDetail component now calls useProxy(), which requires a ProxyProvider in the tree. The storybook stories were missing this provider, causing test failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses streamdown's built-in
urlTransformprop to intercepthttp://localhost:PORTURLs in agent chat messages and rewrite them to port-forwarded workspace URLs.When the agent outputs a bare URL like
http://localhost:3000or a markdown link like[app](http://localhost:8080/path), the URL is rewritten to the workspace's port-forward subdomain (e.g.https://3000--agent--workspace--user.wildcard.host). This makes links clickable directly from the chat without manual port-forwarding.How it works
The transform is built in
AgentDetailwhere workspace and proxy context are available, then threaded as an optional prop through the component tree:urlTransformAPI — no monkey-patching or rehype pluginsportForwardURL()utility fromutils/portForwardlocalhost,127.0.0.1,0.0.0.0)What gets transformed
http://localhost:8080(bare URL, auto-linked by remark-gfm)[my app](http://localhost:3000/path)(explicit link)\http://localhost:8080\`` (inline code)https://example.com(non-localhost)