Skip to content

FEAT: browse slash commands from an in-memory catalogue tree - #86

Merged
merefield merged 3 commits into
mainfrom
feat/in-memory-command-catalogue
Oct 20, 2026
Merged

merefield merged 3 commits into
mainfrom
feat/in-memory-command-catalogue

Conversation

@merefield

Copy link
Copy Markdown
Owner

Typing / previously waited for several app-server catalogue queries, and returning to a submenu fetched it again. This adds a shared, memory-only catalogue tree so connected sessions can be discovered in the background and previously fetched menus open immediately.

Faster browsing

  • Warm root catalogues from normal session discovery, using two background workers. Retain the submenus already fetched during root discovery; load deeper branches on demand and retain them by session and path.
  • Use synchronous cache hits for terminal suggestions and nested menus, preserving filtering, draft restoration, selection and composer focus. Local display commands remain usable during initial discovery.
  • Reuse the same Go cache for browser menu requests. Explicit terminal and browser Refresh controls bypass it.
  • Bound retention to 128 menus, 256 KiB per retained menu and a two-minute lifetime. Deduplicate simultaneous reads with the existing x/sync/singleflight dependency and let each caller cancel independently.

Freshness and actions

  • Scope entries to their session and daemon connection. Invalidate observed name, directory and model-setting changes; invalidate state-dependent submenus on turn-state changes while preserving stable root suggestions. Repeated notifications containing unchanged settings preserve the cache.
  • Reject invalidated or expired in-flight results. Bound background retries and concurrent reads; do not retain oversized menus or branches containing typed rename/directory arguments.
  • Cache display metadata only. Web preparation reads fresh options, command execution continues to re-read and validate the exact revision on the server, and attempted changes invalidate the affected catalogue. Cached menus never supply executable RPC parameters.
  • No disk persistence or new configuration. README documents lifetime, refresh and restart behaviour.

Validation

  • Full Go core suite with race detection; all 17 language screen regressions; go vet and formatting checks.
  • Tests cover startup warming, retention of discovered submenus, deep navigation without extra reads, session isolation, copy isolation, expiry, refresh, reconnect/settings invalidation, stale in-flight results, cancellation and memory bounds.
  • Real app-server fixtures verify that cached options cannot authorize a write after the session starts working.
  • Eight browser regressions cover slash discovery, draft retention, nested navigation, fresh refresh requests and separate write confirmation.
  • Native Windows command-menu, suggestion, cache-navigation and statusline regressions pass.
  • Frontend type/format checks and production build; regenerated embedded assets and rebuilt local binaries.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cache invalidation and empty-menu serialization introduce browsing failures and stale submenu reuse.

3 open issues
What changed in this PR

Adds a shared, in-memory command catalogue cache to make terminal and browser slash-command browsing faster.

Changes:

  • Warms root catalogues and retains submenus with bounded storage and expiry.
  • Adds immediate terminal cache hits and explicit refresh bypasses.
  • Preserves fresh action validation and adds cache, navigation, and refresh regressions.
File Description
web/​tests/​browser.spec.ts Checks explicit refresh requests.
web/​src/​SessionCommands.svelte Sends cache-bypassing refresh requests.
README.md Documents cache lifetime and refresh behavior.
internal/​web/​dist/​index.html References the rebuilt bundle.
internal/​web/​dist/​assets/​index-D1LQiLkx.js Includes browser refresh changes.
internal/​web/​control_commands.go Uses fresh reads for refresh and preparation.
internal/​web/​control_commands_test.go Tests fresh-read routing.
internal/​ui/​monitor_suggestions.go Opens cached suggestions immediately.
internal/​ui/​monitor_commands.go Adds cached navigation and forced refresh.
internal/​ui/​monitor_commands_inline.go Bypasses cache on inline refresh.
internal/​ui/​monitor_command_cache_test.go Tests cached navigation and local commands.
internal/​codex/​session_commands.go Exposes shared cache access.
internal/​codex/​session_commands_unix.go Scopes menus and collects discovered submenus.
internal/​codex/​session_commands_unix_test.go Tests submenu retention and write validation.
internal/​codex/​session_command_cache.go Implements bounded caching and background warming.
internal/​codex/​session_command_cache_test.go Tests cache lifecycle and isolation.
internal/​codex/​live_usage.go Holds the shared cache.
internal/​codex/​daemon_status_unix.go Tracks connection generations.
internal/​codex/​client.go Starts warming from telemetry discovery.
go.mod Makes singleflight dependency direct.

Review effort: Balanced

Comment thread internal/codex/session_command_cache.go Outdated
Comment thread internal/codex/session_command_cache.go Outdated
Comment thread internal/codex/session_commands_unix.go Outdated
@merefield
merefield merged commit 6af873c into main Oct 20, 2026
6 checks passed
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.

2 participants