Skip to content

🪶 perf: Re-render Only the Draft's Leaves While Typing in the Composer - #18574

Draft
berry-13 wants to merge 3 commits into
devfrom
berry-13/feat-chatform-kb
Draft

berry-13 wants to merge 3 commits into
devfrom
berry-13/feat-chatform-kb

Conversation

@berry-13

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Every keystroke in the composer re-rendered the whole ChatForm, because the draft text was subscribed at the top of the component and read for only four small things: the field's value and direction, the dictation listening state, and the hints' "has text" flag. Those reads now live in two leaf components, DraftField and DraftHints, so typing re-renders the field and the hint line and leaves the form body, its hooks and its memoized children alone.

The same pass tidies three things in the form. Typing, dictation and sending each listed the same four blocking conditions; they now share one draftBlocked value, with sending adding its own gates on top. The URL-prompt and code-workspace notices sit in a status region that stays mounted, so screen readers announce them when they appear, and the target-failed Retry action uses the shared Button. Six app preferences ChatForm read from the Recoil store (speech, playback, maximize chat space, / and @ commands) now come through ComposerPreferencesContext, which the chat view already fills for main chat's composer and a side chat's.

Type of change

  • Refactor
  • Performance improvement

Testing

Tested environments/configuration:

  • Chromium through the mock Playwright profile (fake model, in-memory MongoDB), desktop 1280x900, dark and light
  • Walked about 30 composer states in dark mode: landing, typing, multi-line and collapsed drafts, temporary chat, / @ + popovers, attachments and uploads, pasted-text chip, run in flight with steer and queue, question batch, tool approval, URL prompt with a missing agent, maximize chat space, RTL, mobile

Automated tests:

  • npx jest --findRelatedTests on the changed files: 14 suites, 155 tests pass
  • Added to ChatForm.barRenders.spec.tsx: the form body does not re-run while the draft is typed, in a new chat and with a run in flight; it fails when the text subscription is put back in the form
  • ChatForm.queryParams.spec.tsx now finds its notices inside the status region
  • npx tsc --noEmit -p client/tsconfig.json: clean

Screenshots / recordings

The only visible change is the Retry action in the target-failed notice: an underlined secondary-color link before, the theme's hyperlink color with a hover underline after. Before is dev at 858e237, after is this branch, same scenario.

Before After
Dark Retry before, dark Retry after, dark
Light Retry before, light Retry after, light

Risk / compatibility

Low. Preferences keep their stored defaults when a composer renders outside a chat view. The new role="status" wrapper is always mounted, so a test that expects no status region in the composer would now find an empty one.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • Required documentation PR: N/A

Move the composer's text subscription into DraftField and DraftHints so a
keystroke no longer re-renders the whole ChatForm. Also merge the identical
interrupt and preempt branches and drop a pass-through pasted-text callback.
…Mounted

Typing, dictation and sending derived the same four blocking conditions in
three places; they now read one draftBlocked value, with sending adding its own
gates on top. The URL and code-workspace notices live in a status region that
stays mounted so screen readers announce them when they appear, and the target
Retry action uses the shared Button.
ChatForm read six app-wide preferences straight from the Recoil store. They now
join enterToSend and the others in ComposerPreferencesContext, which the chat
view fills once for every composer under it, main chat's and a side chat's, so
the composer no longer reaches into the app store. Outside a chat view each
falls back to its stored default.
@berry-13 berry-13 added ♿ a11y Accessibility 🔨 refactor Code cleanup without new features ⚡ performance Speed and efficiency improvements labels Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 03:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review the latest head, final review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T13:17:46.268833Z 23f3097 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 23f3097cd8

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♿ a11y Accessibility ⚡ performance Speed and efficiency improvements 🔨 refactor Code cleanup without new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants