Skip to content

Defer proposed plan markdown rendering until users expand in ChatView#751

Merged
juliusmarminge merged 3 commits intomainfrom
t3code/plan-mode-thread-slowness
Mar 9, 2026
Merged

Defer proposed plan markdown rendering until users expand in ChatView#751
juliusmarminge merged 3 commits intomainfrom
t3code/plan-mode-thread-slowness

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 9, 2026

partial improvement of #717, potentially need further improvement in follow up:

For the slower “plan-ready” thread open, the main-thread stall dropped from roughly 237-243ms to 184-194ms. The inner React/JS FunctionCall dropped from roughly 224-229ms to 170-180ms.

That is about:

RunTask: 239.7ms average before to 189.4ms after, about 21% faster
EventDispatch: 238.5ms to 188.5ms, about 21% faster
RunMicrotasks: 238.1ms to 187.8ms, about 21% faster
main FunctionCall: 226.7ms to 174.8ms, about 23% faster
Layout: 4.1ms to 1.9ms, about 52% faster
UpdateLayoutTree: 9.9ms to 4.9ms, about 50% faster
So the change helped, and it helped in the way we’d expect: less layout/update work and a noticeably shorter renderer-blocking JS task.

It is still slower than opening a non-plan thread, though. The gap narrowed, but it did not disappear:

before: plan open was about 2.3x slower on RunTask
after: plan open is still about 1.9x slower on RunTask

Summary

  • defer full proposed-plan markdown rendering in ChatView so collapsed plans stay lightweight
  • add preview/collapsing helpers in proposedPlan.ts to strip heavy content until explicit expand
  • preserve plan UX/actions (follow-up prompt, export/save paths, sidebar behavior) while changing render timing
  • add regression coverage for long plan behavior, including hidden content only appearing after Expand plan

Testing

  • Added/updated tests in apps/web/src/proposedPlan.test.ts
  • Added browser-level ChatView test for long proposed plans in apps/web/src/components/ChatView.browser.tsx
  • Not run: bun lint
  • Not run: bun typecheck
  • Not run: bun run test

Note

Medium Risk
Changes proposed-plan rendering logic in ChatView/PlanSidebar, which could affect plan display/export UX or introduce subtle UI regressions for long/edge-case markdown. Covered by new unit and browser tests, but still touches core chat UI layout.

Overview
Defers heavy proposed-plan markdown rendering until the user expands it. Long plans in ChatView now render a truncated preview by default and only render the full markdown after clicking Expand plan, keeping collapsed cards lightweight.

Adds stripDisplayedPlanMarkdown and buildCollapsedProposedPlanPreviewMarkdown helpers in proposedPlan.ts (with tests) to drop redundant title/Summary headings and generate a line-limited preview with an ellipsis. The plan sidebar also uses the stripped markdown for its expanded view, and a new browser-level regression test asserts hidden long-plan content is not present until expansion.

Written by Cursor Bugbot for commit 039ce6e. This will update automatically on new commits. Configure here.

Note

Defer proposed plan markdown rendering until users expand in ChatView

  • Adds stripDisplayedPlanMarkdown and buildCollapsedProposedPlanPreviewMarkdown utilities in proposedPlan.ts to strip redundant title/Summary headings and generate truncated previews (default 8–10 lines) with an overflow ... indicator.
  • ProposedPlanCard in ChatView.tsx now renders the collapsed preview when canCollapse is true, showing an 'Expand plan' button to reveal the full content.
  • PlanSidebar.tsx applies stripDisplayedPlanMarkdown when rendering the expanded proposed plan, hiding the title and initial Summary heading.
  • Behavioral Change: Plans with a leading title or 'Summary' heading will no longer display those headings in either the sidebar or chat view.

Macroscope summarized 039ce6e.

- Keep long plan cards collapsed with lightweight preview text by default
- Render full plan markdown only after explicit expand to reduce thread open slowness
- Add tests for preview/strip helpers and browser coverage for expand behavior
@github-actions github-actions bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Mar 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a878a16e-dc5b-441b-a885-85dd74de90c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch t3code/plan-mode-thread-slowness

Comment @coderabbitai help to get the list of available commands and usage tips.

- remove deferred collapsed preview state in `ProposedPlanCard`
- always render collapsed preview with `ChatMarkdown` for simpler, consistent display
@juliusmarminge juliusmarminge merged commit 2fc0b01 into main Mar 9, 2026
8 checks passed
@juliusmarminge juliusmarminge deleted the t3code/plan-mode-thread-slowness branch March 9, 2026 22:20
@maskdotdev maskdotdev mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant