Repository navigation
refactor(ui): preserve modal entry focus through native refs - #177200
Conversation
Prepare caller-owned focus targets while retaining the autofocus fallback for pending caller migrations. Keep modal callbacks on the synchronous native host to avoid reactive reads during imperative publication.
|
🦞👀 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.
Reviewed commit: 5ecf32a4ae
ℹ️ 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".
| manual: boolean; | ||
| label: string; | ||
| description: string; | ||
| initialFocus?: () => HTMLElement | null; |
There was a problem hiding this comment.
Reduce the refactor below its original production footprint
The required Solid refactor checklist says production LOC must decrease, but excluding tests this change adds 212 lines and removes 34 (+178) across 25 production files, largely to thread initialFocus refs through callers in place of one modal-owned lookup. This expands the focus contract and maintenance burden across unrelated dialogs rather than simplifying the owner; consolidate the registration in the modal primitive or otherwise shrink the production diff before landing.
AGENTS.md reference: ui/AGENTS.md:L3-L5
Useful? React with 👍 / 👎.
|
Codex review: needs maintainer review before merge. What this changesThis PR replaces modal-owned autofocus lookup with native focus targets supplied by each rendering caller. Example: Open the cold command palette and type “Summarize this project”.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored refactor completes an intentional focus-ownership cutover that current main still lacks; no definite introduced defect was found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherControl UI renderers provide native elements to the shared modal policy, which owns opening focus, cancellation, nested overlays, and return focus. flowchart LR
A[Dialog renderer] --> B[Native control ref]
B --> C[Modal host]
D[Plugin content adapter] --> C
C --> E[Shared modal policy]
E --> F[Native dialog and focus]
Technical reviewBest possible solution: Keep the shared modal lifecycle owner and explicit caller-owned focus refs, with DOM discovery confined to foreign content. Do we have a high-confidence way to reproduce the issue? This is a behavior-preserving refactor rather than a reported user bug; source confirms the DOM-discovery path being replaced. Is this the best way to solve the issue? The cutover follows the existing ref-ownership policy while preserving the modal's focus and cancellation decisions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a4c5e4019142. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +178, Tests +43. Total +221 across 32 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 19, 2026, 5:47 AM ET / 09:47 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…w#177200) * refactor(ui): pass explicit modal focus targets Prepare caller-owned focus targets while retaining the autofocus fallback for pending caller migrations. Keep modal callbacks on the synchronous native host to avoid reactive reads during imperative publication. * refactor(ui): pass the lightbox modal focus target * refactor(ui): register native modal focus targets
What Problem This Solves
Modal entry focus still discovers renderer-owned autofocus controls by traversing the dialog DOM. This completes the native-ref cutover across all current Modal callers.
User Impact
No intended visible change: opening focus, input during opening, cancellation, retained drafts, nested dialogs, and return focus keep their existing behavior. No migration or configuration changes.
Why This Change Was Made
The Modal policy now receives its initial native target from the rendering owner and reads live callbacks from the host. The caller audit covers all 50 production Modal constructors, including cold and loaded command palettes, conditional file-preview controls, model setup, provider login, and chat confirmations. Dialogs without an autofocus target retain native dialog focus. Plugin content remains a deliberate foreign-DOM island and resolves its own native autofocus target.
Direct/composed JSX refs forward the native controls. Existing layout, scroll, and domain owners remain intact, and lazy module boundaries remain unchanged. The cold-shell fixture now awaits the real bridge commit and asserts natural focus instead of forcing it.
Evidence
pnpm tsgo:uif95deb6e01d9wsfinding inextensions/signal/package.jsonon head and pinned basef95deb6e01d9; no new findingsThe first cold-shell test run caught a fixture timing gap: its focus assertion preceded
updateComplete. The corrected helper awaits that public boundary; the failed file alone was rerun. The unchangedliveValuehelper emits an existingSTRICT_READ_UNTRACKEDdiagnostic in the cold palette tests. Full browser and application proof runs throughci:full; no local E2E suite or parity run was used.createEffectcreateRenderEffectuntrackaddEventListenerThe query total is unchanged because the generic Modal lookup is removed and the plugin adapter gains its explicitly owned foreign-DOM lookup. All 11 survivors are island queries: ten in
components/markdown-tables.ts(lines 52, 69–71, 110, 135, 145, 186, 286, 303) and one inplugins/control-ui-components.ts:175.The four existing effects are retained layout/scroll/imperative owners in
command-palette-input.tsx:89,file-preview-modal.tsx:184,image-lightbox-content.tsx:452, andpages/plugins/credential-editor.tsx:73. Four intentional initial snapshots remain incommand-palette-view.tsx:360,confirm-dialog-view.tsx:10,input-dialog-view.tsx:13, andpages/chat/components/file-draft-recovery-dialog-view.tsx:25.Production LOC: 7,161 → 7,339. Tests: 2,439 → 2,482. Growth is native ref ownership at the existing rendering callers, plus the async focus-fixture assertions; no shared abstraction or new dependency was added.
Completed CI attribution
Full
ci:fullrun 39230437151 completed on5ecf32a4ae59. Both real-Gateway shards, eight other browser shards, type/lint, performance, and security passed. Two failures are inherited:chat-composer-plus-menu-loading.test.tsx—keeps the menu open and retries a failed content load70276985de6f: same hidden-menu / inaccessiblealertfailure at line 142; 1 failed, 6 passed, default pinned Bun and one worker.chat-details-changes.e2e.test.ts—Details change summary > observes only metadata while Details is presented and retains last-known changes on refresh failureAll changes—missing12 filesassertion also fail on latest completed scheduled main run 39225083411, head125b5e20dc7c.CI checkout
9cd8ffe51f08has actual main parent70276985de6fand reviewed head5ecf32a4ae59; inspected failure-source objects are unchanged between that parent and the tested merge. Landing uses the authorized native inherited-failure route; failed checks remain recorded as failures.