Skip to content

perf(tui): prepare searchable picker rows once - #127620

Merged
steipete merged 1 commit into
mainfrom
codex/perf-tui-model-picker-current
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-tui-model-picker-current

Conversation

@steipete

@steipete steipete commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

SearchableSelectList.smartFilter() stripped ANSI, lowercased labels and descriptions, concatenated search fields, and rebuilt fuzzy-candidate wrappers for every stable row on every search edit. A large model picker therefore repeated the same immutable row projection for every typed character.

Why This Change Was Made

TUI picker callers construct fresh fixed rows immediately before opening an overlay, and the component has no row-refresh API. The first non-empty query now prepares normalized label, description, and combined fuzzy-search text once; later edits reuse those fields. Preparation stays lazy so opening a picker and selecting without searching pays no search-projection cost.

Filtering still applies the same exact-label, exact-description, and native fuzzy tiers. Tie sorting, ANSI handling, labels/descriptions/search text, active selection, callbacks, and errors are unchanged. Every filter and selection result remains the original item object.

User Impact

Search interaction in large model/provider lists is faster without changing visible ordering, matches, selection, keyboard behavior, or model routing. There is no provider-auth, catalog-freshness, configuration, protocol, persistence, or public projection change.

Evidence

Deterministic exact-owner fixture: 2,500 frozen model-like rows, 22 typed characters, constructor + every filter + render, 25 interactions × 7 trials.

  • median: 63.454 → 42.092 ms/interaction (-33.7%)
  • exact output digest before/after: 261c7a4dfc80464caf71fc3599cc9284b0483f42571ff2c5460a6ba3e9538d49
  • selected/filter results retained the exact original item objects
  • the final revision additionally defers all preparation until the first non-empty query

Validation:

  • selector component: 39/39 on the revised exact head
  • TUI command handlers, Gateway chat, and embedded backend: 267/267
  • all TUI components: 183/183
  • focused authenticated real PTY picker + /model: 2/2 on the revised exact head
  • node scripts/check-changed.mjs -- src/tui/components/searchable-select-list.ts: passed on the revised exact head
  • pnpm build: passed; only existing third-party direct-eval warnings
  • git diff --check: passed
  • fresh bundled Codex gpt-5.6-sol/high autoreview of the revised commit: clean, correct at 0.99

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 6:10 PM ET / 22:10 UTC.

ClawSweeper review

What this changes

This PR lazily prepares normalized searchable-picker row data on the first non-empty query so subsequent TUI filtering avoids rebuilding it.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness findings. This maintainer-authored TUI performance refactor is narrow and preserves the picker’s filtering and original-item selection contract; wait for the current head’s merge result and remaining checks before landing.

Priority: P3
Reviewed head: fd2cfdbdf48c1787b698434d5511c0aec61901a3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrow and preserves the filtering contract; exact-head merge and CI refresh are still needed before landing.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored refactor is outside the external-contributor proof gate; the PR body nevertheless describes focused terminal and PTY validation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored refactor is outside the external-contributor proof gate; the PR body nevertheless describes focused terminal and PTY validation.
Evidence reviewed 6 items Owner-boundary behavior: The cache is created inside the searchable picker and retains normalized label, description, and fuzzy text while returning the original item references.
Caller lifetime: Production callers create fresh model, agent, and context-mode row arrays immediately before opening an overlay; no caller refreshes rows during the overlay lifetime.
Existing behavior coverage: Colocated tests cover exact-label and description ordering, fuzzy ranking, ANSI handling, selected-item identity, keyboard input, and rendering.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts

Result: FAIL (partial) — step 2 expect_output Test Files: expected terminal output was not visible within 30 seconds: "Test Files"

node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127620-tNlkVe/target$ node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127620-tNlkVe/target

node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts
 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › rejects rendering oracle false positives 19ms
stdout | src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › keeps session modes scoped while trace changes and delivery stays process-owned
[behavior-evidence] tui-session-footer {"terminal":"real PTY","sourceModesVisible":true,"targetModesCleared":true,"traceTransitionVisible":true,"fixedDeliveryPr
opagated":true}

 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › renders local ready on startup 1ms
 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › renders a compact model and active thinking level in the footer 1ms
 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › keeps session modes scoped while trace changes and delivery stays process-owned 4375ms
 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › keeps the launch thinking override active across session-level changes 103ms
 ✓  tui-pty  src/tui/tui-pty-harness.e2e.test.ts › TUI PTY harness › shows startup activity while post-connect initialization is pending 1ms



































Assertions:

  • FAIL expect_output: Test Files

How this fits together

The terminal UI creates fixed picker rows for model, agent, context-mode, and local-shell choices. The searchable picker filters those rows while the operator types and returns the original selected item to its caller.

flowchart LR
A[Command and model data] --> B[Fixed picker rows]
B --> C[Searchable picker overlay]
C --> D[Lazy normalized row cache]
D --> E[Exact and fuzzy filtering]
E --> F[Original selected item]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check rollup is incomplete and the branch is behind main; refresh the merge result and require green checks for the exact head before landing.
  • Complete next step (P2) - No repair lane is needed; refresh the exact-head merge result and checks before landing.
Agent review details

Security

None.

PR surface

Source +6. Total +6 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 26 20 +6
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 26 20 +6

Review metrics

Metric Value Why it matters
Production versus test LOC production +26/-20; tests +0/-0 The one-file refactor adds a cache while removing repeated per-query projection work; no tests change.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the lazy cache at the searchable-picker owner and land it after the current head has a clean merge result and exact-head checks are green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the lazy cache at the searchable-picker owner and land it after the current head has a clean merge result and exact-head checks are green.

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

Not applicable: this is a performance refactor, and source inspection establishes unchanged filtering and selection semantics.

Is this the best way to solve the issue?

Yes: locating a lazy cache in the picker owner removes repeated work without adding a cross-layer cache or changing callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9903e404ef9f.

Labels

Label justifications:

  • P3: This is a bounded TUI performance improvement with no configuration, persistence, routing, or visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored refactor is outside the external-contributor proof gate; the PR body nevertheless describes focused terminal and PTY validation.

Evidence

What I checked:

Likely related people:

  • steipete: Feature-history shortlog across the picker, its tests, and TUI command callers shows the strongest contribution volume in this area. (role: recent TUI contributor; confidence: medium; files: src/tui/components/searchable-select-list.ts, src/tui/tui-command-handlers.ts)
  • Josh Avant: Blame ties the current-main smart-filter implementation to this contributor's commit. (role: current implementation contributor; confidence: medium; commits: ccbfa6c3a325; files: src/tui/components/searchable-select-list.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the merge result and wait for the remaining exact-head checks to finish green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-21T21:44:36.613Z sha 999473ff2c9389630413dd5c522edf64b256c6bd :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/perf-tui-model-picker-current branch from 999473f to fd2cfdb Compare August 21, 2026 22:04

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head fd2cfdbdf48c1787b698434d5511c0aec61901a3:

  • Exact-head CI run 32531370791, attempt 2: green. Attempt 1 had one unrelated tooling timeout (run-additional-boundary-checks waiting for a temporary child PID); the exact test passed locally 23/23, and the failed-job rerun passed.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 127620: passed against current origin/main; hosted CI/Testbox gates and review artifacts passed.
  • Searchable selector: 39/39. Authenticated real-PTY picker plus direct /model: 2/2. All TUI components: 183/183. TUI command handlers/Gateway chat/embedded backend: 267/267.
  • Final check-changed: passed. Full build: passed (existing dependency direct-eval warnings only). git diff --check: clean.
  • Exact-owner benchmark (2,500 rows, 22 characters): median 63.454 → 42.092 ms/interaction (−33.7%), exact output/identity digest 261c7a4dfc80464caf71fc3599cc9284b0483f42571ff2c5460a6ba3e9538d49.
  • Final bundled Codex gpt-5.6-sol/high autoreview: clean, correct 0.99.
  • ClawSweeper final-head re-review: reviewed exact head, no correctness/security findings. Its optional rank-up move (refresh merge result and exact-head checks) is satisfied by green exact-head CI plus current-main Testbox preparation. Its live-proof wrapper timed out waiting for the broad PTY summary after showing passing cases; the focused affected PTY proof passed 2/2 separately.

Patch is one production file (+26/−20), preserves lazy no-query behavior and original selected-item identity, and has no protocol/config/storage/security surface. No agent transcript is attached or published.

@steipete
steipete merged commit fd0c9f6 into main Aug 21, 2026
406 of 408 checks passed
@steipete
steipete deleted the codex/perf-tui-model-picker-current branch August 21, 2026 22:31

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants