Skip to content

perf(layout): stabilize AppShell stream-event Set state to prevent cascade re-renders#610

Closed
HUQIANTAO wants to merge 1 commit into
op7418:mainfrom
HUQIANTAO:perf/14-stabilize-panel-context-sets
Closed

perf(layout): stabilize AppShell stream-event Set state to prevent cascade re-renders#610
HUQIANTAO wants to merge 1 commit into
op7418:mainfrom
HUQIANTAO:perf/14-stabilize-panel-context-sets

Conversation

@HUQIANTAO
Copy link
Copy Markdown

The stream-session-event handler was creating fresh Set objects on every ~100ms tick and passing them to useState unconditionally. These Sets flow into panelContextValue, causing ALL usePanel() consumers to re-render on every streaming text chunk even though the active session set rarely changes mid-stream. Use functional updaters with identity checks: return the same Set reference when content is identical to skip unnecessary state updates.

The 'stream-session-event' handler was creating fresh Set objects on
every ~100ms stream tick and passing them to useState unconditionally.
These Sets flow into panelContextValue (a new object reference every
render), causing ALL usePanel() consumers (UnifiedTopBar, ChatListPanel,
FileTreePanel, etc.) to re-render on every streaming text chunk — even
though the set of active sessions rarely changes mid-stream.

Use functional updaters with identity checks:
- activeStreamingSessions: compare size + contents against previous;
  return the same Set reference when identical
- pendingApprovalSessionIds: same comparison pattern

When the set content hasn't changed (the common case — usually the same
single session the whole time), the state update is skipped entirely,
preventing the cascade re-render through panelContextValue.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

@op7418
Copy link
Copy Markdown
Owner

op7418 commented Jun 8, 2026

Closing this PR as part of a batch of low-signal/bulk-generated submissions from the same account. Please open one focused PR with a clear problem statement, implementation rationale, and tests if this change is intentional.

@op7418 op7418 closed this Jun 8, 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.

2 participants