Skip to content

refactor(ui): share pending focus requests across choice and preview views - #176765

Merged
steipete merged 2 commits into
mainfrom
solid2/w-zero-component-focus
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
solid2/w-zero-component-focus

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

OptionCard and FilePreview now share one pending-focus primitive instead of each managing focus in a view effect. A recommendation can wait while the card is disabled, a replacement request can cancel it, and the request is consumed before the caller checks whether another control owns focus. Description and disabled updates retain the existing choice nodes and selection.

FilePreview keeps its immediate selection-handler focus and connected/open guards. Its remaining effect separately compares content-reset and active-row-reveal inputs, so sibling inventory updates can reveal the selected row without resetting the document being read. Focus still runs only initially or when the active path changes in document layout; switching layout alone does not refocus. Tags, classes, routes, and lazy boundaries are unchanged.

Scope and counts

Production metric Before After
OptionCard effects 1 0
FilePreview effects 2 1
Shared pending-focus effect 0 1
Render effects / untrack / direct listeners / DOM queries 0 0
Production LOC 647 671
Test LOC (three affected files) 1,114 1,207

The 24-line production increase is the 22-line shared lifetime primitive plus two lines in FilePreview. The remaining feature effect at ui/src/components/file-preview-modal.tsx:184 synchronizes the preview body's scroll reset and active-row reveal with committed DOM; the other effect lives once in ui/src/lib/reactive/pending-focus.ts:14. No new dependency, domain owner, cache, or config option.

Proof

Compared base 64e9443af525212642b0406fbc454727f267a68a with head b0b6d23717501dc58f234d411ee11943cff55ffd.

Check Result
pnpm tsgo:ui Exit 0; 17.80 s runner wall
option-card.test.tsx --maxWorkers=1 6 passed; exit 0; 54.37 s runner wall
file-preview-modal.test.ts --maxWorkers=1 14 passed; exit 0; 36.80 s runner wall
Targeted oxlint, five changed files Exit 0; 100.62 s runner wall
Formatting Initial exit 1; only FilePreview formatting repaired, then all five files passed
Canonical isolated review Scoped clean through P2; only FilePreview formatting changed afterward
Head pnpm ui:build Exit 0; Vite reported 2m 10s
Head strict performance Exit 1: Chat boot JS 1,492,456 B > 1,490,000; New Session boot JS 1,050,465 B > 1,050,000. Startup passes at 337,735 B gzip, 7 JS requests, 1 CSS request (38,500 B gzip)
Head focused browser capture Exit 0; four full frames and five asserted focus/retention contracts
Base pnpm ui:build Shared exact-base build exit 0; 317 s wall; same machine
Base strict performance Exit 1 with the same Chat and New Session boot-budget violations; exact metrics below
Base focused browser capture Exit 0; same frozen harness, four frames, all five assertions passed
Pixel comparison Both full FilePreview frames identical. OptionCard component/page pixels identical; only animated mascot pose and build footer differ
Production Knip Passed on final b0b6d237 head, exit 0; single run, 9m 9.9s
Built gzip metric Base Head Delta
Startup JS (7 requests) 337,692 B 337,735 B +43 B
Startup CSS (1 request) 38,500 B 38,500 B 0 B
Chat boot JS (25 requests) 1,492,375 B 1,492,456 B +81 B
New Session boot JS (20 requests) 1,050,396 B 1,050,465 B +69 B

The strict check exits 1 on both revisions because Chat exceeds 1,490,000 B and New Session exceeds 1,050,000 B. These exact metric failures reproduce at the merge base. Startup passes; no request count or lazy boundary changed. The small startup increase includes the shared focus primitive and remains below the current committed startup limit.

The unit tests retain the existing owner contracts and add coverage for a disabled pending recommendation, refusal consumption, cancellation by a request without a recommendation, keyed choice retention, active-row reveal, and layout-only focus restraint. The browser proof loads the full built app with synthetic data: a real Custodian question plus controlled publications from its existing store, followed by the registered FilePreview element after the Plugins route loads. No real Gateway, credentials, or user data.

The first browser attempt completed the OptionCard frames, then a hard navigation canceled an asset proxy request (ECONNRESET). The successful retained attempt uses the app's existing in-place navigation hook. No source or build change was needed.

Before / after

All eight full baseline and head captures were inspected by both worker and parent: synthetic-only and showing the expected selection, focus handoff, and preview states. Both FilePreview frames are pixel-identical. The OptionCard frames differ by 1,954 and 1,949 pixels, entirely in the animated mascot and build footer; the component and page region has zero changed pixels. Accepted head captures were preserved without recapture. The comparison below uses the existing captures, with only the bottom 60-pixel build footer removed from the OptionCard frames.

Before and after: recommendation, description refresh, file selection, and document path

Evidence identity

Four source files retained their reviewed hashes through formatting/rebase. file-preview-modal.tsx changed only in formatting, to SHA-256 34962a24dc8a25a18b96f247ff43506ca96f5d813d16957266daf017734c147a.

Raw local evidence is retained under .artifacts/w-zero-component-focus/: validation.json, format-repair.json, final-source.json, proof-report.json, performance-comparison.json, visual-comparison.json, visual-regions.json, the build/performance/capture logs, and screenshot manifests. The original formatting and capture failures remain preserved separately from their successful replacements.

Full-CI attachment recovery

The first run, 39186103539, captured OPENCLAW_CI_FULL: false before the ci:full label was observed. Its three UI unit shards and two selected Control UI E2E shards passed; real-Gateway coverage was skipped, so it is not full proof. The workflow does not trigger on label changes. A same-head close/reopen with ci:full already attached selected the full plan in 39188357118.

That first run failed only chat boot JS gzip: 1,491,219 → 1,491,226 B against 1,490,000 B. The exact base fails the same named metric. New-session boot passes at 1,049,429 → 1,049,454 B; startup is 337,507 B with one CSS request. No budget or baseline changed.

Full-CI result and selection readiness

Full run 39188357118 completed on b0b6d237: all three UI unit shards, eight of nine Control UI E2E shards, and both real-Gateway shards passed. Its two failures were the same inherited chat boot JS gzip metric above and keeps retained comments usable after clearing history (replacement: true) in the selected-text E2E suite. The latter is not inherited: the exact test passes in scheduled main run 39183785855 at the original merge base.

That test failed during its first Add to chat click, before history was cleared: the toolbar appeared, then detached while Playwright awaited stability. Its synthetic text-selection helper could select attached transcript content before it became visible and before initial positioning settled. Plugin composer readiness does not establish transcript readiness. The correction adds only a wait for the selected passage to be visible and the existing transcript scroll-idle check before the first selection. The real click, reducedMotion: "no-preference", and all comment/history-retention assertions are unchanged. The toolbar intentionally dismisses on scroll or collapsed selection; the retained log does not establish which event dismissed it in the failing run. The final full-CI run passes the corrected selected-text shard. The earlier failure still does not establish the precise dismissal trigger.

The final branch was rebased without conflicts onto a9e5f4e3b7b2; main had no changes in the six affected files. Final head is 931c80117e689bc8e0fa1b27f5f3c1dcdc97e08d. The build, startup, visual, Knip, and original unit evidence above remains pinned to b0b6d237 and base 64e9443a; it is reused proof, not a final-head rerun.

Final-head check Result
Frozen dependency install Exit 0; 4.882 s; main's existing proc-safe dependency advanced to 0.4.2, no authored dependency changes
pnpm tsgo:ui Exit 0; 10.428 s; one final-head run
Canonical isolated delta review through P2 Published scoped clean; complete source and ownership contexts supplied
Scoped lint of selected-text E2E file Exit 0; one run, no diagnostics

The reviewed E2E source SHA-256 is fa23338a32dda1f5bd343ca3bfecf87327361a119fd8ad6936526f25aad11f8c, unchanged by the rebase. No additional local E2E or build was run for this correction.

Final-head full CI and inherited failures

Run 39190432776, attempt 1, completed on 931c80117e689bc8e0fa1b27f5f3c1dcdc97e08d with ci:full active. All three UI unit shards, eight of nine Control UI E2E shards, and one of two real-Gateway shards passed. The corrected selected-text suite passes; security-fast passes.

The remaining assertion failures match completed test failures in the existing CI run 39190227860 at this PR's exact merge base, a9e5f4e3b7b2114caa573554766ab7b4850b39e4. Both baseline job logs attest that checkout. The tests failed several minutes before their jobs were cancelled:

Failing file / test Exact-base failure Later job cancellation
session-list-filter.e2e.test.ts — refetches instead of showing a row excluded by configured-agent filtering Same query equality assertion at 02:40:26 UTC 02:44:59 UTC
session-list-filter.e2e.test.ts — keeps the Sessions page query stable when the startup roster completes Same expected query-list assertions at 02:40:27 UTC 02:44:59 UTC
command-palette-search.real-gateway.e2e.test.ts — finds a grouped spawned conversation beyond the roster and treats a full result page as success Same compact-query equality assertion at 02:39:53 UTC 02:45:01 UTC

These are completed failing-test results, not a claim that the cancelled baseline suite completed. The newest scheduled-main run 39195750293, head 5ec30bfc7216adeb622700464db6dccae368e17e, now passes all three tests after main's separate test repair 246c6533a0c0 aligned them with conditional session queries. This PR uses the documented exact-merge-base evidence alternate; it does not claim those failures remain on latest main.

The current performance job also fails the existing Chat boot budget: exact CI base 3635488e is 1,491,366 B and the tested merge is 1,491,451 B (+85 B), both above 1,490,000 B. New Session passes at 1,049,566 → 1,049,635 B (+69 B). Startup passes at 337,534 B gzip and one CSS request (38,500 B). These are current CI measurements, separate from the same-machine local comparison above.

Native inherited-failure evidence binds the actual tested merge e5abc5d0d8b4b4b07187ad259b2ea979f7cc1000 to its ordered base/head parents, exact failure names, unchanged failing-test and budget source objects, and retained logs. No failing check is represented as green.

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T02:37:16.516596Z 931c801 New commits
ℹ️ 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.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR shares pending-focus handling between answer choices and file previews while preserving selection, focus, and document scroll behavior.

Example: A recommended “Review changes” choice arrives while the chat composer has focus.

  • Before: The card consumes its focus request and leaves keyboard focus in the composer.
  • After: The shared primitive consumes the request before the same composer-focus safeguard runs.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused source changes and useful built-app evidence support correctness, but skipped required WebKit validation and unresolved CI prevent a merge-ready assessment.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The shared focus owner is exercised through the full built Control UI with synthetic Custodian publications and the registered FilePreview element; inspected before/after screenshots and recorded browser assertions support preserved choice retention, search focus, and document navigation.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Answer choices and document previews must preserve keyboard focus and reading position while their properties refresh.
Reason: The maintainer-authored direction is established, both callers migrate together, and the shared mechanism preserves the previously repaired user contracts.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the focused refactor preserves existing focus safeguards, and no actionable code defect was found; required validation remains unresolved.

Priority: P3
Reviewed head: b0b6d23717501dc58f234d411ee11943cff55ffd

Before merge

  • Complete next step - Have the existing CI owners resolve the failed context and performance checks and their aggregate gate; no diff-caused runtime failure was established.

Findings

None.

Tests

  • Missing end-to-end proof: Required WebKit focus coverage remains unshown: the supplied browser proof does not identify WebKit, and every exact-head WebKit step was skipped.
Agent review details

How this fits together

Control UI components receive question or file-preview properties, derive presentation state, and apply focus and scroll changes to their owned DOM elements.

flowchart TD
  A[Question properties] --> B[OptionCard]
  C[Preview properties] --> D[FilePreview]
  B --> E[Pending focus primitive]
  D --> E
  E --> F[Component focus policy]
  F --> G[Owned DOM targets]
  D --> H[Scroll and row reveal]
Loading

Technical review

Best possible solution:

Retain the shared focus primitive and existing component policies, with required browser validation and CI gates resolved before landing.

Do we have a high-confidence way to reproduce the issue?

This is a behavior-preserving refactor; the supplied built-app comparisons exercise existing focus and retention contracts rather than establish a new upstream bug.

Is this the best way to solve the issue?

The small shared primitive removes duplicated focus-request mechanics while leaving readiness and target selection with existing component owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c2549f8295d0.

Provenance checked

  • OptionCard request lifetime and focus restraint keeps the original intent (fix(ui): keep composer focus when onboarding suggestions arrive #160677: Asynchronous onboarding suggestions must not steal composer focus or cause unintended submission; later keyed rendering preserves answer focus across background updates.)
  • OptionCard selection and display-only updates keeps the original intent (9b9f081: Recent control-lifetime work retained local selection across display-only refreshes and registered actual focus targets.)
  • FilePreview scroll, reveal, and focus effects keeps the original intent (6d01bf5: The Solid viewer migration preserved navigation and focus while preventing sibling inventory updates from resetting the document; subsequent input capture removed untracked reads without changing focus conditions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change and current main: The pinned introduction replaces component-local focus effects with one shared primitive; fetched main retains the original implementations, and its touched component files match the merge base. (ui/src/lib/reactive/pending-focus.ts:14, b0b6d2371750)
  • Focus safeguards preserved: The primitive clears pending state before calling component policy; OptionCard retains its outside-control focus check, and FilePreview retains its connected/open guards and immediate selection-handler focus. (ui/src/components/option-card.tsx:55, b0b6d2371750)
  • Historical behavior and ownership: Feature history spans the original onboarding cards, composer-focus repair, keyed-answer retention, Solid migration, and recent focus-target refactors. The contracts documented in fix(ui): keep composer focus when onboarding suggestions arrive #160677 and fix(ui): keep Ask OpenClaw answer focus during background updates #169349 remain intact. (ui/src/components/option-card.tsx:43, c2549f8295d0)
  • Inspected browser proof: The prepared before/after image shows synthetic built-app recommendation, description refresh, file-selection, and document-preview states with matching component appearance; the body additionally records asserted focus and retention outcomes. (b0b6d2371750)
  • Required checks remain unresolved: Exact-head UI shards, lint, types, and Control UI E2E passed. Context-check annotations reject the missing authored problem heading; performance and its aggregate gate failed. The body records matching strict-budget failures at the exact base, but detailed performance logs redirect to a proxy-blocked Azure host, so their CI failure signature was not independently verified. (b0b6d2371750)
  • WebKit validation did not run: All three exact-head UI jobs report both WebKit installation and “Test Control UI WebKit overlays and focus” as skipped; scoped Solid guidance requires WebKit coverage for focus changes. (.agents/skills/solid/references/testing.md:31, b0b6d2371750)

Likely related people:

  • Peter Steinberger: Raw commit 9b9f081 adds ui/src/components/option-card.tsx:42 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9b9f081451a7; files: ui/src/components/option-card.tsx)

PR surface

Source +24, Tests +91. Total +115 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 54 30 +24
Tests 2 98 7 +91
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 152 37 +115

Review metrics

Metric Value Why it matters
Production versus test growth Production +24 lines; tests +91 lines The production increase introduces the shared lifetime primitive; test growth covers deferred requests, refusal consumption, cancellation, retained choices, and preview reveal/focus boundaries.

Labels

Label changes:

  • add P3: This is a bounded UI refactor preserving established behavior, with no demonstrated urgent user-facing defect.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is a bounded UI refactor preserving established behavior, with no demonstrated urgent user-facing defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 18, 2026, 10:00 PM ET / October 19, 2026, 02:00 UTC.

@steipete steipete closed this Oct 19, 2026
@steipete steipete reopened this Oct 19, 2026
@steipete
steipete force-pushed the solid2/w-zero-component-focus branch from b0b6d23 to 931c801 Compare October 19, 2026 02:32

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 931c80117e

ℹ️ 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".

import { createEffect } from "solid-js";

/** Consume each focus request once, after its target is ready. */
export function createPendingFocus<T>(

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.

P1 Badge Keep the Solid refactor net-negative

This refactor introduces a 22-line shared primitive and increases the touched production files by 24 lines overall (54 additions versus 30 deletions), while the required Solid refactor checklist explicitly requires net production LOC to decrease. Please consolidate the focus logic without growing production code, or simplify equivalent code in the same coherent refactor.

AGENTS.md reference: ui/AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

@steipete
steipete merged commit ed3741c into main Oct 19, 2026
97 of 105 checks passed
@steipete
steipete deleted the solid2/w-zero-component-focus branch October 19, 2026 04:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant