Skip to content

fix(ui): render injected XML blocks and PR refs like the rest of the app in thread UI#3602

Closed
adboio wants to merge 1 commit into
mainfrom
posthog-code/thread-ui-xml-rendering
Closed

fix(ui): render injected XML blocks and PR refs like the rest of the app in thread UI#3602
adboio wants to merge 1 commit into
mainfrom
posthog-code/thread-ui-xml-rendering

Conversation

@adboio

@adboio adboio commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

The canvas Thread side panel (ThreadPanel) rendered user prompts as plain whitespace-pre-wrap text, so the injected context blocks (<user_custom_instructions>, <canvas_generation_instructions>, <channel_context>) and inline mention chips (<github_pr/>, <file/>, …) leaked as raw XML tags instead of getting their custom rendering. PR URLs in agent prose also rendered as plain anchors rather than the GithubRefChip the conversation view uses — the thread UI was out of step with the rest of the app.

Changes

  • ChatMarkdown: render GitHub issue/PR URLs as GithubRefChip (mirrors MarkdownRenderer), so PR refs in agent prose get their chip rendering in both the main ChatThread and the canvas ThreadPanel.
  • Shared usePromptDisplayContent hook: extracts the channel_context → canvas_generation_instructions → user_custom_instructions stripping chain that was copy-pasted in both UserMessage and UserBubble; both now consume the hook (no behavior change — covered by existing tests).
  • ThreadPanel.UserPromptRow: uses the hook to strip the injected blocks (always-on; the panel has no split-tab tags so the flag arg is false) and parses mention chips via parseFileMentions, falling back to ChatMarkdown — matching how UserMessage/UserBubble render prompts.

How did you test this?

  • ChatMarkdown.test.tsx — new: GitHub PR URL → GithubRefChip, non-GitHub links stay plain anchors.
  • ThreadPanel.test.tsx — new: injected custom-instructions + channel-context XML is stripped (not rendered raw); injected <github_pr/> chip renders as a chip.
  • usePromptDisplayContent.test.ts — new: covers all three block types, flag-gating of tags, and always-on stripping.
  • Existing UserMessage.test.tsx (5), channelContext/customInstructions/canvasInstructions (10), and full chat-thread + session-update + ThreadPanel suites (84 tests, 14 files) pass. tsc --noEmit and biome check clean.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

…app in thread UI

The canvas Thread side panel (ThreadPanel) rendered user prompts as plain
pre-wrap text, so injected context blocks (<user_custom_instructions>,
<canvas_generation_instructions>, <channel_context>) and inline mention
chips (<github_pr/>, <file/>, …) leaked as raw XML tags. Its agent prose
also went through ChatMarkdown, which rendered GitHub PR/issue URLs as
plain anchors instead of the GithubRefChip the conversation view uses.

- ChatMarkdown: render GitHub issue/PR URLs as GithubRefChip (matches
  MarkdownRenderer), so PR refs in agent prose get their chip rendering in
  both the main ChatThread and the canvas ThreadPanel.
- Extract the duplicated "strip channel_context → canvas_instructions →
  custom_instructions" chain (previously copy-pasted in UserMessage and
  UserBubble) into a shared usePromptDisplayContent hook; adopt it in both.
- ThreadPanel.UserPromptRow: use the hook to strip the injected blocks
  (always-on; the panel has no split-tab tags so the flag arg is false)
  and parse mention chips via parseFileMentions, falling back to
  ChatMarkdown — matching how UserMessage/UserBubble render prompts.

Generated-By: PostHog Code
Task-Id: 2e8b4b7c-4b0e-41cb-9c19-429b773df630
@trunk-io

trunk-io Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/sessions/components/chat-thread/ChatMarkdown.tsx

Reviewed by React Doctor for commit 89ae939.

@adboio adboio closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant