refactor(web): chat markdown links and file chips live in their own modules #22693
refactor/chat-markdown-tables fromrefs/pull/22693/head·merged by juliusmarminge View on GitHubChatMarkdown.tsx was a 3,560-line file that held every markdown renderer. This stack splits it into focused modules so each piece is readable on its own.
The file-link chip moves to chat/MarkdownFileLink.tsx, and its pure action helpers to MarkdownFileLink.logic.ts. External-link favicons and URL wrapping move to chat/MarkdownExternalLink.tsx. Same-document fragment clicks and heading ids move to chat/markdownFragments.ts, and the hast text helpers to chat/markdownHast.logic.ts.
This is a pure move. Each renderer was already its own component, so no render boundary changes. Behavior is unchanged.
| Before | After | |
|---|---|---|
ChatMarkdown.tsx lines | 2776 | 2068 |
| New files | chat/MarkdownFileLink.tsx (411), MarkdownFileLink.logic.ts (62), MarkdownExternalLink.tsx (110), markdownFragments.ts (113), markdownHast.logic.ts (42) | |
| Renders | unchanged: no component, subscription or context boundary moved | unchanged |
Renders were not measured for this layer. It changes no render boundaries: the components, their props, and the two contexts stay exactly as they were.
Tests run:
vp test run --project browser src/components/ChatMarkdown.browser.test.tsx src/components/ChatMarkdown.permissions.browser.test.tsx(11 passed)vp test run --project unit src/reactCompilerCoverage.test.tsfor every touched file (0 bailouts)tsc --noEmitfor apps/web, andvp linton changed files
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
Approvability#
Verdict: Approved at
717a53eMacroscope's review found this PR approvable — This refactor moves existing markdown link, file-chip, fragment, and HAST-rendering code into focused modules without changing call sites, props, or behavior. The large diff is primarily deletion and re-addition from relocating code, with no product-default, schema, configuration-suppression, or sensitive-area changes.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).e113e20. Prior analysis still applies.Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
cd850f14-9123-4f43-89de-f4d8f6d8ce03
📥 Commits
-
Reviewing files that changed from the base of the PR and between 717a53e868d8965865b6e89fc26c8a6519163f73 and e113e20a3ef097439956f98e500d23e65581c354.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
be9c83cb-aaf8-4797-8c3b-16ae81211edd
📥 Commits
-
Reviewing files that changed from the base of the PR and between deaa44462acc287c5960b75def7307bdc4ef3615 and 717a53e868d8965865b6e89fc26c8a6519163f73.
📒 Files selected for processing: 6
-
apps/web/src/components/ChatMarkdown.tsxapps/web/src/components/chat/MarkdownExternalLink.tsxapps/web/src/components/chat/MarkdownFileLink.logic.tsapps/web/src/components/chat/MarkdownFileLink.tsxapps/web/src/components/chat/markdownFragments.tsapps/web/src/components/chat/markdownHast.logic.ts
Limit details: You’ve used all 10 included reviews currently available.
-
📝 Walkthrough
-
Markdown link rendering, file actions, fragment navigation, and HAST text utilities now reside in dedicated modules.
ChatMarkdown.tsximports these modules instead of defining their implementations locally.Changes: Markdown rendering components
Layer / File(s) Summary File-link actions and rendering
apps/web/src/components/chat/MarkdownFileLink.logic.ts,apps/web/src/components/chat/MarkdownFileLink.tsxFile-link logic selects available actions and builds copy-menu items. The component handles previews, editor and browser opening, file reveal, copying, context menus, and action feedback. External-link rendering and HAST text
apps/web/src/components/chat/MarkdownExternalLink.tsx,apps/web/src/components/chat/markdownHast.logic.tsExternal links render a host icon or fallback, with break opportunities in link text. HAST utilities extract direct or descendant text and detect non-whitespace text. Fragment navigation and heading IDs
apps/web/src/components/chat/markdownFragments.tsFragment clicks resolve a target and scroll it into view. The rehype plugin assigns unique, prefixed IDs to headings without IDs. ChatMarkdown integration
apps/web/src/components/ChatMarkdown.tsxChatMarkdown.tsximports the extracted modules and removes the local implementations and exported file-link action helpers.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Merge Risk: ⚪ Minimal · up to
717a5-
This refactor moves markdown link and fragment code into separate modules without changing behavior. No actionable merge-blocking risk was identified.
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description explains the refactor and lists verification results, but it does not follow the required section structure. It omits the Problem, Change, and Scope and approval headings, provides no … Restructure the description using the required Problem, Change, Scope and approval, and Verification headings. Add the linked issue or explicit maintainer approval, include before and after screenshots if this qualifies as a UI change, and … Passed checks: 3 passed-
Check name Status Explanation Title check The title clearly and concisely describes the main change: moving chat Markdown links and file chips into separate modules. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Full details: Description check
-
Explanation
The description explains the refactor and lists verification results, but it does not follow the required section structure. It omits the Problem, Change, and Scope and approval headings, provides no issue or maintainer approval reference, and does not include required UI screenshots or a complete model and harness attribution.
Resolution
Restructure the description using the required Problem, Change, Scope and approval, and Verification headings. Add the linked issue or explicit maintainer approval, include before and after screenshots if this qualifies as a UI change, and identify the model and harness used by the agent.
-
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged this827f6d4
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes