Repository navigation
Read a chip label from the link text on formatted links - #354
Merged
abhishekgahlot2 merged 2 commits intoNov 6, 2026
Merged
abhishekgahlot2 merged 2 commits into
abhishekgahlot2 merged 2 commits into
Conversation
The artifact chip label was built with children.join(""), so a link whose
text holds bold or inline code rendered "[object Object] report", and a link
whose text is a single wrapped run fell back to "Open". Both the label and
the badge initial came from that string, so [**Quarterly** report](x.pdf)
showed a "[" badge.
Walk the rendered children to their plain text instead, with a line break as
a space and an image as its alt text, and keep "Open" only as the fallback
for a link that carries no readable text.
Closes useagenthq#337
Contributor
|
recheck |
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
|
Merged, thanks @ElectLive. Bold or code inside a link label no longer turns into "[object Object]", and the tests pin both cases. |
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.
What is wrong
AnchorComponentbuilt the artifact chip label by stringifying the link's React children:children.join("")turns a React element into"[object Object]", and when the link text is a single wrapped run (bold, inline code) neither branch matches and the label falls back to"Open". The label also feeds the round badge initial (line 320), so the badge showed the first character of the broken string. Rendering the real component at01d1f32fgives:[**Quarterly** report](https://example.com/report.pdf)[[object Object] report[`data.csv`](https://example.com/data.csv)OOpenThe change
linkLabelTextwalks the rendered children to their plain text instead of stringifying them: text runs are joined, a line break reads as a space, and an image with no text of its own reads as its alt text."Open"stays as the fallback for a link that genuinely carries no readable text, so that case is unchanged.After the change the same three renders give
initial="Q" label="Quarterly report",initial="D" label="data.csv"andinitial="P" label="plain.pdf"(a plain text link was already correct and stays correct).Only
frontend/components/prompt-kit/markdown.tsxandfrontend/components/prompt-kit/markdown.test.tsxchange.Verification
Run in
frontend/with bun 1.4.3 on Windows. The three new cases are red before the fix and green after.bun test components/prompt-kitbun test components app libThe same 4 tests fail on
mainin this checkout without the change (1689 pass, 4 fail), so they are pre-existing and unrelated:app/server-boundary.test.ts"re-exports up to two levels...",components/chat/session-rail-layout.test.ts(2 cases) andcomponents/chat/terminal-surface.test.ts"fresh parser instances do not inherit disposed terminal cells". I did not touch those areas.bun run typecheck-> exits 0bun run lint-> exits 0,Checked 958 files,Found 248 warnings(all pre-existing repo-wide, none added in these files)USEAGENT_API_ORIGIN=https://app.useagent.org bun run build-> exits 0, all routes compiledbun test scripts/agent-docs.test.ts(repo root) -> 5 pass, 0 failWhat I did not do
I did not run this against app.useagent.org, because I have no account there and did not want to create one for a pull request. The proof above is the component's real server-rendered output (
renderToStaticMarkupof<Markdown>from this repo) plus the check the issue asks for,bun test components/prompt-kit. If a screenshot in the running app is required before this can be reviewed, tell me what to click and I will take one.Closes #337
Need help on this PR? Tag
@codesmith-botwith what you need.