Skip to content

Invalidate Codex model listing after CLI update - #945

Open
ymichael wants to merge 1 commit into
mainfrom
bb/missing-model-in-picker-thr_v5uzgw4ma5
Open

Invalidate Codex model listing after CLI update#945
ymichael wants to merge 1 commit into
mainfrom
bb/missing-model-in-picker-thr_v5uzgw4ma5

Conversation

@ymichael

@ymichael ymichael commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • invalidate the host daemon provider-maintenance runtime after successful in-app Codex CLI install/update
  • lease provider-maintenance runtime usage so stale runtime shutdown does not reject in-flight model-list or unarchive calls
  • invalidate system execution-options queries for the changed host after provider CLI prompt success so model pickers refetch immediately
  • add regression coverage for stale model-listing runtime invalidation, negative install events, prompt cache invalidation, and leased runtime retirement

Testing

  • pnpm exec turbo run test --filter=@bb/host-daemon -- --run src/command-dispatch.test.ts src/runtime-manager.test.ts
  • pnpm exec turbo run typecheck --filter=@bb/host-daemon
  • pnpm exec turbo run test --filter=@bb/app -- --run src/components/provider-cli/provider-cli-install.test.tsx src/hooks/cache-owners/cache-owner-registry.test.ts
  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec prettier --check apps/host-daemon/src/command-dispatch.ts apps/host-daemon/src/command-dispatch.test.ts apps/host-daemon/src/runtime-manager.ts apps/host-daemon/src/runtime-manager.test.ts apps/host-daemon/src/app.ts apps/app/src/hooks/cache-owners/system-cache-effects.ts apps/app/src/components/provider-cli/provider-cli-install-store.ts apps/app/src/components/provider-cli/provider-cli-install.test.tsx

@ymichael
ymichael marked this pull request as ready for review August 3, 2026 18:45
@SawyerHood

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

I am the SlopCop. I started the security, code quality, performance, architecture, and end-to-end review phases.

@SawyerHood

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

Browser and validation phase complete.

The Codex picker loaded seven models, including 5.6-Sol, 5.6-Terra, and 5.6-Luna. The Updates screen showed Codex 0.146.0. It offered no update action, so I could not execute the external update path.

Focused host-daemon tests passed: 11 tests. Focused app tests passed: 3 tests. Both affected package type checks passed.

@SawyerHood

SawyerHood commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

Security phase complete.

I found no security defect. The new stream function stays inside the daemon. Parsed wire input cannot set it. The change adds no command interpolation, new process spawn, data exposure, or protocol field.

I found one low availability race in the shared maintenance runtime. I cover it in the performance phase.

@SawyerHood

SawyerHood commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

Code quality and architecture phase complete.

The core design is sound. The server has no model-list cache. The daemon replaces the long-lived Codex runtime before the client refetches.

I found no duplicate production abstraction. The new injection seam follows an existing dispatch test pattern. No daemon protocol change exists, so the protocol version does not need a change.

Low findings: Prettier rejects command-dispatch.ts, the Codex-only rule needs a rationale comment, and the test does not cover failed or non-Codex installs. Other app windows also keep their client cache until a later refetch.

@SawyerHood

SawyerHood commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

Performance phase complete.

The normal path has good order. The daemon finishes runtime invalidation before the client starts its refetch. Runtime creation also has a generation guard.

Two low findings remain. The client invalidates active execution-option queries for every host, although only one host changed. The runtime shutdown can also reject a concurrent model-list or thread-unarchive call.

if (completedEvent?.success) {
if (queryClient !== null) {
void invalidateHostProviderCliStatus({ queryClient, hostId });
void invalidateSystemExecutionOptions({ queryClient });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 slopcop/review — Limit and share the cache refresh

This prefix invalidates active execution-option queries for all hosts, although only hostId changed.

This query client also belongs to one app window. Other windows keep the old model list until a later refresh.

Use a host-scoped key. Publish a real-time system change for other windows.

env,
}),
);
if (shouldInvalidateProviderMaintenanceRuntimeAfterProviderCliInstall({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 slopcop/review — Apply the project format

Prettier rejects this new if layout. Run Prettier on this file before merge.

expect(runtime.startThread).toHaveBeenCalledOnce();
});

it("invalidates the provider maintenance runtime after a successful Codex CLI update", async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 slopcop/review — Test the negative branches

This test covers only a successful Codex event. The predicate also contains failure and non-Codex branches.

Add cases that confirm those events do not shut down the runtime.

command,
events,
})) {
await options.runtimeManager.invalidateProviderMaintenanceRuntime();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 slopcop/review — Protect current maintenance calls before shutdown

This runtime also serves provider.list_models and thread.unarchive. Shutdown rejects their pending calls and can break the unarchive barrier.

Add a runtime lease. Alternatively, mark the runtime stale and wait for current calls before shutdown.

@SawyerHood SawyerHood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 SLOP COP 🚨 · review

The core mechanism is correct. I found no blocking defect and no security issue.

Findings:

  • Low: runtime shutdown can reject a concurrent model-list or thread-unarchive call.
  • Low: the client refresh covers all hosts but only one window.
  • Low: Prettier rejects the new condition layout.
  • Low: tests do not cover failed or non-Codex install events.

The Codex-only condition matches the current adapters. Codex keeps a long-lived model catalog, while other adapters refresh through separate paths.

No wire contract changed. The daemon protocol version does not need a change.

Validation:

  • The focused host-daemon suite passed 11 tests.
  • The focused app suite passed 3 tests.
  • Both affected package type checks passed.
  • All GitHub checks passed.
  • Browser QA loaded the Updates screen and seven live Codex models.

The test host offered no Codex update. I did not execute the external update path.

@ymichael
ymichael force-pushed the bb/missing-model-in-picker-thr_v5uzgw4ma5 branch from 846ebac to 2b539e4 Compare August 3, 2026 19:07
@ymichael

ymichael commented Aug 3, 2026

Copy link
Copy Markdown
Owner Author

Review follow-up pushed in 2b539e46d.

Addressed:

  • Ran/prevented Prettier issue in command-dispatch.ts.
  • Added negative coverage for failed Codex and successful non-Codex install events.
  • Added provider-maintenance runtime leases so invalidation detaches stale runtimes for future calls but defers shutdown until active model-list/unarchive calls finish.
  • Narrowed execution-options invalidation to the changed host plus hostId: null primary/default reads.
  • Added a short rationale comment for the Codex-only invalidation condition.

Not addressed in this PR:

  • Cross-window realtime broadcast for provider CLI install completion. That would require a broader server-owned cache invalidation event for host CLI updates; the initiating window now refreshes immediately, and other windows retain existing stale/focus/reconnect behavior.

@ymichael
ymichael marked this pull request as draft August 3, 2026 19:07
@ymichael
ymichael marked this pull request as ready for review August 3, 2026 20:20
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