Skip to content

feat: add streaming display optimization option#1422

Open
SameDesu123 wants to merge 7 commits into
kwaroran:mainfrom
SameDesu123:codex/streaming-display-optimization
Open

feat: add streaming display optimization option#1422
SameDesu123 wants to merge 7 commits into
kwaroran:mainfrom
SameDesu123:codex/streaming-display-optimization

Conversation

@SameDesu123
Copy link
Copy Markdown
Contributor

@SameDesu123 SameDesu123 commented Apr 28, 2026

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?
      • This PR is a scoped, opt-in streaming display performance change.

Summary

Adds an experimental, opt-in Streaming Display Optimization setting for streamed assistant responses. The default off mode keeps the normal rendering path close to the existing behavior, while balanced and strong reduce UI churn during long streamed responses.

Changes

  • Added a persisted streamingDisplayOptimizationMode setting with off, balanced, and strong options in Advanced Settings.
  • Added labels and help text for all supported locales.
  • Batched streaming display updates in balanced and strong modes with a timer plus requestAnimationFrame, while flushing pending output on completion or abort.
  • Reduced active streaming message remount churn by keeping the row identity stable while performance mode is enabled.
  • Computes streaming optimization eligibility in the parent chat list and passes plain props to the active streaming assistant message only.
  • Added a session-limited parse cache in ChatBody for repeated rendering of long messages.

Additional Notes

  • Validation: pnpm check reports 0 errors(in this changes).

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models.

  2. Over 80% of the code is AI generated.

@SameDesu123 SameDesu123 force-pushed the codex/streaming-display-optimization branch from 7f95ef4 to babc132 Compare April 29, 2026 01:11
@SameDesu123 SameDesu123 changed the title feat: add opt-in streaming display optimization feat: add streaming display optimization Apr 29, 2026
@SameDesu123 SameDesu123 force-pushed the codex/streaming-display-optimization branch from babc132 to c98f707 Compare May 2, 2026 11:12
@SameDesu123 SameDesu123 changed the title feat: add streaming display optimization feat: add streaming display optimization option May 9, 2026
@kwaroran
Copy link
Copy Markdown
Owner

There seem to be too many effect hooks for a performance update.

Although we can expect better performance when this option is enabled when the update rate is high,

the PR adds a lot of hooks that run when the variable is updated even when the option is disabled, which can worsen performance when the option is disabled, or even if the update rate is not high enough with option enabled

@SameDesu123
Copy link
Copy Markdown
Contributor Author

There seem to be too many effect hooks for a performance update.

Although we can expect better performance when this option is enabled when the update rate is high,

the PR adds a lot of hooks that run when the variable is updated even when the option is disabled, which can worsen performance when the option is disabled, or even if the update rate is not high enough with option enabled

Thanks, I think this concern is valid.

I’ll refactor this so the optimization state is computed once at the parent/current-chat level, and only the active streaming assistant message receives the optimized rendering props. When the mode is off, the normal rendering path should remain effectively unchanged.

@SameDesu123 SameDesu123 marked this pull request as draft May 11, 2026 13:57
@SameDesu123 SameDesu123 force-pushed the codex/streaming-display-optimization branch from 32217c5 to d461339 Compare May 11, 2026 13:58
@SameDesu123 SameDesu123 marked this pull request as ready for review May 11, 2026 14:04
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.

2 participants