Skip to content

perf(components): use Streamdown static mode for finished markdown - #494

Open
slashdevcorpse wants to merge 7 commits into
LodyAI:mainfrom
slashdevcorpse:perf/streamdown-static-mode
Open

slashdevcorpse wants to merge 7 commits into
LodyAI:mainfrom
slashdevcorpse:perf/streamdown-static-mode

Conversation

@slashdevcorpse

@slashdevcorpse slashdevcorpse commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Related issue

Refs #421

Problem / pressure

Finished chat turns still render Streamdown with mode="streaming". That path runs remend and block splitting on content that will not grow, adding work to the first-visit Markdown path when switching sessions.

Summary

MarkdownRenderer uses static for completed Markdown with closed fences. Growing content and completed content with an unclosed fence stay in streaming mode, preserving incomplete-fence repair. isAnimating is unchanged; this does not change Shiki caching or the publish interval.

The maintainer follow-up merges main 0b7ef6e6 and resolves the adjacent AGENTS.md rules: this mode policy and main's Mermaid click-to-activate, wheel, and fullscreen rules both remain intact. The original contribution remains the five-file rendering change.

Visual explanation

flowchart TD
  A[Markdown content] --> B{Still growing?}
  B -->|Yes| C[Streamdown streaming]
  B -->|No| D{Fence left open?}
  D -->|Yes| C
  D -->|No| E[Streamdown static]
Loading

Before / after

Before After
All turns use streaming. Growing turns and unclosed fences use streaming; completed content with closed fences uses static.
PR conflicts with main's Mermaid documentation. Both mode selection and current Mermaid interaction rules are retained.

Test plan

Validated on a04b9a8f, which merges main 0b7ef6e6:

  • Six components test files, 89 tests passed: markdown-streamdown-mode, markdown-streaming-reparse, markdown-idle-rerender, markdown-math-delimiters, markdown-mermaid-plugin, and markdown-mermaid-fullscreen (including mounted rendering).
  • pnpm --filter @lody/components typecheck passed.
  • Prettier on the five changed files passed; Oxlint on the four TS/TSX files reported no warnings or errors.
  • pnpm run docs check reported no errors after pinned ACP submodules were checked out; existing size warnings remain.
  • No full repository test run, live session-switch trace, or desktop performance acceptance claim. New-head CI runs separately.

Context handoff

Instructions for reviewing agents

  • Review focus: resolveMarkdownStreamdownMode, fence detection, and the mode prop in markdown-renderer.tsx.
  • Decisions to challenge: Keep an unclosed fenced block in streaming mode after completion; check quote/list fence boundaries and preserve Mermaid gestures.
  • Plausible failures / evidence gaps: Completed non-fence Markdown can differ from remend output. Mounted regression tests pass, but real session-switch frame time is unmeasured.

Authoring context

Original user prompt

The original contributor's triggering prompt was not provided in this maintainer handoff. The following is the current maintenance request, reproduced verbatim; it is not presented as the original contribution's authoring prompt.

Show maintenance request
请你修复它们的问题,然后 push 上去

Finished turns no longer run the streaming remend path. Growing turns keep mode streaming.

Model: grok-4.6
@slashdevcorpse
slashdevcorpse marked this pull request as ready for review September 8, 2026 03:21
Copilot AI lite review requested due to automatic review settings September 8, 2026 03:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eb160757e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/components/src/components/ai-gui/markdown-renderer.tsx Outdated
The invariant now matches isStreaming: static for frozen markdown, streaming while a turn is growing. Word-level animated stays off.

Model: grok-4.6
Interrupted finished turns with an open fence stay in streaming mode. Complete finished markdown still uses static mode.

Model: grok-4.6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2da32471c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/components/src/components/ai-gui/markdown-streamdown-mode.ts Outdated
Interrupted finished turns with indented or tilde fences stay in streaming mode so remend still runs. Closing fence length and 4-space indents follow CommonMark.

Model: grok-4.6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d98de526f9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/components/src/components/ai-gui/markdown-streamdown-mode.ts Outdated
Interrupted finished turns with blockquote or list-nested fences stay in streaming mode. Open-fence detection uses the existing CommonMark scanner.

Model: grok-4.6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59dcfd3c07

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

isStreaming: boolean,
text = ''
): 'static' | 'streaming' {
if (isStreaming || markdownHasUnclosedFence(text)) return 'streaming';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Track list context across continuation lines

When a cancelled response opens a fence on a continuation line of an existing list, such as 1. explanation\n ```ts\nconst x = 1, markdownFenceAt sees four leading spaces without knowing they include the list-item indent and returns no fence. This makes the new resolver choose static mode and skip incomplete-Markdown repair even though the fence remains open. This is fresh evidence beyond the prior container-prefix comment: direct-marker forms are now handled, but ordinary continuation-line forms are still missed. Preserve list-container state while scanning.

AGENTS.md reference: packages/components/src/components/ai-gui/AGENTS.md:L96-L96

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this. Open-fence detection now uses the same per-line CommonMark scanner as normalizeTexMathDelimiters. Same-line list/blockquote markers (10. ```tex, > ```tex) and 0–3 space continuation fences already stay on Streamdown streaming. A 4-space continuation after 1. explanation is an indented code block at document scope unless we carry list indent across lines. That is a full list parser, not this #421 slice. Interrupted mid-list continuation fences are an accepted freeze-path edge case (.github/codex-review.md).

@github-actions github-actions Bot added the status:needs-pr-attention External PR needs contributor attention before review label Sep 9, 2026
Keep the completed-Markdown mode policy alongside main's Mermaid interaction rules.

Model: gpt-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants