Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open the T3 Code web app or the desktop app and start a new chat.
- Send a message that asks the agent to reply with this Markdown exactly, then keep writing several long paragraphs so the reply stays in progress: a heading that reads Setup, a blank line, a second heading that reads Setup, a blank line, and a link labeled Second setup that points at #setup-1.
- Wait until the Second setup link is visible and the reply is still arriving, with the control to stop the reply still shown.
- Scroll so the second Setup heading is above the visible area and the Second setup link remains on screen.
- Click Second setup.
Expected behavior
Clicking Second setup while the reply is still arriving scrolls to the second Setup heading.
Actual behavior
The view stays where it is, and the second Setup heading does not come into view. After the reply finishes, clicking Second setup scrolls to that heading.
Impact
Minor bug or occasional failure. Web and desktop readers encounter this whenever they follow a link to a repeated heading while the reply is still streaming.
Version or commit
main at c2eb8f3369. The cause is at apps/web/src/components/chat/markdownStreamBlocks.ts:16.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
Received: "<h1 id="user-content-setup">Setup</h1><h1 id="user-content-setup">Setup</h1>"Automated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/apps/web/src/components/chat/markdownStreamBlocks.test.tsx b/apps/web/src/components/chat/markdownStreamBlocks.test.tsx
index 2574f25fc0..c2fa1a06d0 100644
--- a/apps/web/src/components/chat/markdownStreamBlocks.test.tsx
+++ b/apps/web/src/components/chat/markdownStreamBlocks.test.tsx
@@ -8,13 +8,14 @@ import ReactMarkdown from "react-markdown";
import { describe, expect, it } from "vite-plus/test";
import { splitMarkdownBlocks } from "./markdownStreamBlocks";
+import { rehypeHeadingIds } from "./markdownFragments";
// Whitespace between top-level blocks collapses in the rendered message.
const html = (source: string) =>
renderToStaticMarkup(
<ReactMarkdown
remarkPlugins={[remarkAssistantInsights, ...CHAT_MARKDOWN_REMARK_PLUGINS]}
- rehypePlugins={CHAT_MARKDOWN_REHYPE_PLUGINS}
+ rehypePlugins={[...CHAT_MARKDOWN_REHYPE_PLUGINS, rehypeHeadingIds]}
>
{source}
</ReactMarkdown>,
@@ -25,6 +26,7 @@ const html = (source: string) =>
describe("splitMarkdownBlocks", () => {
it.each([
"# Title\n\nFirst paragraph with `code` and **bold**.\n\nSecond [link](https://example.com).",
+ "# Setup\n\n# Setup\n\n[Second setup](#setup-1)",
"- one\n- two\n\n- loose three\n\n continued\n\nAfter the list.",
"1. first\n\n2. second\n\nText\n\n3) restarted",
"```ts\nconst a = 1;\n\n\nconst b = 2;\n```\n\nafter\n\n~~~\nx\n\n~~~~\n\ny\n~~~\n\nend",
@@ -39,9 +41,9 @@ describe("splitMarkdownBlocks", () => {
])("renders each block as the whole text renders it, at every streamed prefix: %j", (text) => {
for (let end = 0; end <= text.length; end++) {
const source = text.slice(0, end);
- const blocks = splitMarkdownBlocks(source);
- expect(blocks?.join("")).toBe(source);
- expect(blocks!.map(html).join("")).toBe(html(source));
+ const blocks = splitMarkdownBlocks(source) ?? [source];
+ expect(blocks.join("")).toBe(source);
+ expect(blocks.map(html).join("")).toBe(html(source));
}
});cd apps/web && pnpm exec vp test run src/components/chat/markdownStreamBlocks.test.tsxWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity