Skip to content

Load / commands when the desktop composer gets focus - #5171

Closed
brsbl wants to merge 3 commits into
mainfrom
bb/command-catalog-focus-prefetch
Closed

brsbl wants to merge 3 commits into
mainfrom
bb/command-catalog-focus-prefetch

Conversation

@brsbl

@brsbl brsbl commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Desktop composers never prefetched the / command list. #1884 limited the focus-time prefetch to touch pointers, so the first / on desktop waited 0.4–1.8s for a server and host round trip.

What changed

  • On desktop, / commands now load when the composer gets focus, not on the first /.
  • The prefetch waits 400ms after focus, so threads you pass through quickly fetch nothing.
  • A desktop thread you stay on makes one /commands request, because composers autofocus.
  • Mobile behavior is unchanged.

How you verified

  • New hook test: leaving a composer before the delay sends no request for it.
  • Remote CI passed on head 1700743c98.
  • Branch web app in headless Chrome for Testing (fine pointer): composer focus sent one /commands request before typing.
  • In the same run, typing /qa showed the matching skill within about 200ms, with no loading state.

Part of #5192 (row 6: desktop prefetch)

BB-Thread: Investigate slow command lookup

🤖 Generated with Claude Code

AGENT GENERATED

Desktop composers waited a full server and host round trip on the first /.
Warm the catalog on focus for fine pointers too, as coarse pointers already do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl
brsbl added this pull request to stack #5173 October 8, 2026 02:36
@chatgpt-codex-connector

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

Copy link
Copy Markdown

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-08T02:38:46.879651Z f8fd739 PR opened
ℹ️ 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.

@brsbl brsbl changed the title Prefetch the / command list on desktop composer focus Load / commands when the desktop composer gets focus Oct 8, 2026
Desktop composers autofocus, so moving through worktree threads fired one
/commands request per thread. Wait 400ms and cancel when the composer's
catalog key changes first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-apply the desktop focus prefetch on main's refactored helpers: drop the
coarse-pointer gate from shouldPrefetchCommandCatalog, schedule the prefetch
400ms after focus via scheduleCommandCatalogPrefetch with cleanup, and port
the delay tests into the DOM-free prefetch test file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl

brsbl commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: this no longer holds up on current main. Branch kept for reference: bb/command-catalog-focus-prefetch (rebased onto main at 5ce5ee7).

  • Since fix(claude-code): discover live slash commands before and during threads #5777, every /commands request also runs provider.list_commands (apps/server/src/routes/projects.ts, listProviderLiveCommandsBestEffort). On a cache miss the Claude Code bridge starts a CLI process for the thread's cwd, and that cache is per cwd for 2 minutes. Desktop composers autofocus, so prefetching on focus would start a CLI probe for nearly every worktree thread you open, even if you never type /.
  • The focus flag this relies on (hasComposerFocused in NewThreadComposer.tsx and useComposerTypeahead.ts) never resets on blur, so the 400ms delay never cancels anything.
  • useProjectCommands uses staleTime: 0, so typing / still refetches after a prefetch.

A sound desktop prefetch needs a cheaper catalog path first, for example caching live provider commands per host and provider on the server, or a scan-only prefetch. I noted this on #5192 (row 6).

AGENT GENERATED

@brsbl brsbl closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant