Repository navigation
refactor(ui): simplify chat composer lifecycles - #176451
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull 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".
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".
| // keystroke when that native path is available. | ||
| const thread = el.closest(".chat")?.querySelector<HTMLElement>(".chat-thread") ?? null; | ||
| const state = composerTextareaResizeObservers.get(el); | ||
| const thread = options.getTranscriptElement?.() ?? state?.getTranscriptElement() ?? null; |
There was a problem hiding this comment.
Pass the transcript getter to the composer companion
When a plugin replaces the default composer, ChatComposerCompanion constructs its question panel without getTranscriptElement (chat-view.tsx:181-192). Its multiline FreeTextTextarea therefore registers an observer whose getter always returns null; because this line removes the former DOM fallback for locating .chat-thread, growing an answer no longer publishes composer-input or composer-layout events to the transcript owner, which can break bottom-follow and scroll-anchor correction. Thread the transcript getter through the companion path as well.
AGENTS.md reference: AGENTS.md:L50-L51
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesThis PR replaces manual composer subscriptions, DOM searches, and event registration with shared Solid primitives and explicit refs. Example: Type / in the Chat composer.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 5 items remain Keep this PR open for focused repairs: the refactor direction is approved, but composer retention, mention dismissal, transcript wiring, and goal-clock tests need correction. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherChat and New Session project existing draft and session owners into native composer controls, which return editing and submission actions to those owners. flowchart LR
A[Draft and session owners] --> B[Solid projections]
B --> C[Composer presentation]
C --> D[Native textarea and menus]
D --> A
C --> E[Question companion]
D --> F[Transcript scroll owner]
E --> F
Technical reviewBest possible solution: Keep the shared primitives while preserving the mounted composer subtree, completing mention and companion wiring, and updating clock tests for reactive settlement. Do we have a high-confidence way to reproduce the issue? Source tracing establishes the incomplete wiring, and exact-head CI independently records textarea replacement and menu detachment; no target code was executed during this review. Is this the best way to solve the issue? Reusing existing projections, refs, and resource primitives fits the approved direction, but lifecycle simplification must retain the original DOM identity and migrate every affected caller. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6ef7539e3cf7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +119, Tests +27. Total +146 across 37 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 5:10 PM ET / 21:10 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7789f985c0
ℹ️ 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".
| menu.element.parentElement?.dispatchEvent( | ||
| new CustomEvent(CHAT_COMPOSER_DISMISS_INVOCATIONS_EVENT), | ||
| ); |
There was a problem hiding this comment.
Route Escape dismissal to the owning composer
When a slash or skill menu is open on New Session, its ComposerMenu is nested under .agent-chat__composer-combobox (new-session/composer.tsx:532-543), while the dismissal listener is on the ancestor .agent-chat__input (new-session/composer.tsx:476-487). Because CustomEvent does not bubble by default, dispatching it on parentElement never reaches that listener; moreover, the window capture handler has already prevented and stopped Escape, so the textarea's own Escape handler cannot close the menu either. Dispatch to the registered composer owner or make this event bubble.
AGENTS.md reference: AGENTS.md:L50-L51
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7b1b7b26d
ℹ️ 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".
| @@ -120,7 +120,7 @@ export function createChatComposerContext( | |||
| } | |||
| state.composerTextarea = nextTextarea; | |||
| if (nextTextarea) { | |||
| observeTextareaOverflow(nextTextarea); | |||
| observeTextareaOverflow(nextTextarea, () => props.getTranscriptElement?.() ?? null); | |||
There was a problem hiding this comment.
Refresh the transcript getter when remounting the composer
When a ChatComposer is disposed and mounted again with the same paneId—a supported flow covered by the same-pane remount test—the cached state retains this textareaRef because of ??=, so it continues closing over the first component instance's props.getTranscriptElement. That instance's viewport is disconnected, causing the newly mounted textarea's observer to receive null and stop publishing composer sizing events needed for transcript scroll anchoring. Store or refresh the getter per mount rather than retaining it in this callback.
AGENTS.md reference: AGENTS.md:L20-L20
Useful? React with 👍 / 👎.
b479084 to
4945183
Compare
4945183 to
6037930
Compare
|
Merged via squash.
|
* refactor(ui): simplify chat composer lifecycles * fix(ui): preserve composer ownership and timing contracts * fix(ui): separate composer viewport refs from virtualizer readiness * fix(ui): bubble nested composer menu dismissals * fix(ui): preserve native composer input lifetime * refactor(ui): simplify owned composer bindings * test(ui): exercise reader scroll intent in composer budget * test(ui): settle reader scroll before composer measurements * test(ui): restore an interior transcript scroll offset * test(ui): await final history before managed media capture
What Problem This Solves
The chat composer retained duplicate reactive subscriptions, DOM discovery, and imperative event registration after its Solid 2 migration. Use existing owner projections, live-value bindings, scroll-state handling, and timer/observer primitives, with explicit textarea, picker, mention, and transcript refs. Directly coupled New Session and custodian callers share those refs.
Preserve draft persistence, IME composition, native undo history, focus, menu node retention, and loading/empty transcript sizing. The native input subtree retains an intentional initial snapshot. Nested invocation-menu dismissal bubbles to the composer, queue focus returns after the action settles, and goal clocks sample current time on resume. Main's closed-picker laziness is retained on both plus-menu presentation memos. No new dependencies, tags, classes, routes, or lazy boundaries.
Wave-zero measurements
Production composer/command/picker families, excluding test-support modules. The already-landed dictation platform-listener change is outside this diff.
createEffectcreateRenderEffectuntrackaddEventListenersyntaxquerySelector(All)flush/ manual Solid ownersSurvivors under
ui/src/pages/chat/components/: effects atchat-composer.tsx:124(dictation/catalog/prediction owner reconciliation),chat-composer-question.tsx:83(question takeover and interrupted IME draft), andchat-composer-plus-menu.tsx:568(open capability-owner loading). Initial snapshots atchat-composer.tsx:30,62retain pane identity and dictation initialization;chat-composer-regions.tsx:34retains the native input subtree. Paired Gateway frame subscriptions remain atui/src/pages/chat/composer-dictation-session.ts:106,362. No owned-DOM listeners or queries remain in scope.Evidence
Current head
6037930e6e1303d1635dfde693207a16a4f78808, actual merge base737c8c126153d2b36d22fc50eb4ada8062394d93. Both builds use the same machine and Node 24.22.0 with compile/build caches disabled. Both strict checks fail the existing Chat and New Session gzip ceilings on base and head; no budget or bundler-policy change.pnpm install --frozen-lockfile,pnpm tsgo:uiThe preceding CI run exposed an unreliable scroll-test setup. An 8px raw offset remained inside the transcript's end-follow threshold; assuming a subsequent 100px wheel moved exactly 100px also ignored virtualizer geometry adjustments. The repaired probe first moves 200px into the transcript so a small virtualizer shrink cannot make its saved offset unreachable. It then samples settled geometry, moves farther with real wheel input, samples the full settled movement, returns to the exact original offset, and waits for final scroll idle before collecting the unchanged composer render-budget assertions. All six runtime-budget cases passed on the final head.
The managed-media capture also exposed a readiness gap: terminal run ownership retires before its final history refresh finishes. The existing pane adapter now waits for run/stream retirement and history loading to finish before decoding and capturing. Image counts, order, bounds, and node-identity assertions remain unchanged. This removes a demonstrated missing boundary; the earlier logs do not establish which media update replaced the images. The managed-media case passed on the final head.
Main now includes the Models-help assertion repair. The redundant test-only commit was dropped during the final rebase; all ten remaining patches replayed identically.
An earlier local 22-case invocation stalled in an external-SSD filesystem rename before any assertion verdict and was stopped; it is not claimed as a pass. Full green CI covers those files. No inherited-CI exception is needed for this final head. The interim rebase also exposed main's missing sidebar export; main's fix #176799 is now incorporated, and current typecheck/builds pass.
Changed production files: 12,007 → 12,118 lines (+111). Changed tests: 9,253 → 9,311 (+58). 42 files, 720 insertions / 551 deletions. Growth comes from explicit owned refs and JSX event wiring across consumers, plus small existing-primitive interfaces. This is an existing Solid refactor; a Lit codemod does not apply.
Before / after
Inspected synthetic production-build captures at 1280×900 compare earlier base
711ffb0d517with reviewed heade484aa4f80a2. Later changes preserve the rendering, retain main's closed-menu laziness, and repair test setup. Before is left; after is right. Full captures and crops were inspected for private data before publication.