Skip to content

fix(playground): let the lead client be unchecked in the compare picker#3370

Merged
olartgabo merged 3 commits into
mainfrom
fix/playground-uncheck-lead-client
Jul 24, 2026
Merged

fix(playground): let the lead client be unchecked in the compare picker#3370
olartgabo merged 3 commits into
mainfrom
fix/playground-uncheck-lead-client

Conversation

@olartgabo

@olartgabo olartgabo commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

In the Playground client picker with Multiple clients on, the lead client — the one badged GLOBAL — cannot be unchecked. Clicking its row appears to do nothing, except that a different client silently disappears from the line-up. Clicking repeatedly eats one client per click until only the un-removable lead is left, which reads as "clicking it unchecked everything".

Root cause

Not in the picker UI. The lead is stored apart from the compare line-up (mcp-previewed-host-id vs mcp-inspector-selected-hosts:{projectId}), and usePersistedHost re-derives the line-up on every read.

deriveSelectedHostIds has a deliberate defensive branch for external surfaces (global host bar, project setup) that move the lead without rotating the array: "lead not in array → replace slot 0 with it, never grow". It cannot tell that case apart from "the user just removed the lead from the array", so:

stored [claude, slackbot, chatgpt] + lead claude
  → uncheck claude → stored [slackbot, chatgpt]
  → derive re-inserts claude at slot 0 → [claude, chatgpt]   // slackbot destroyed

Fix

setSelectedHostIds is an explicit in-app write, so it is authoritative about the line-up: when it drops the current lead from a non-empty array, the lead now follows to the new slot 0.

Clearing to [] deliberately stays a non-lead-change — that path (PlaygroundMain.handleMultiModelEnabledChange) means "fall back to the lead as the single implicit selection", so the lead has to survive it.

One change in the hook covers both surfaces: the chat-input ClientSelector and the header MultiHostPicker both route their writes through it. The count-preservation contract and the external-savePreviewedHostId derivation branches are untouched.

Testing

  • 3 new hook tests + 1 selector test. The two "drops the lead" tests fail on main exactly as described (['a','c'] instead of ['b','c']).
  • Green: use-persisted-host, MultiHostPicker, client-selector, PlaygroundMain.multi-host — 59 tests.
  • Verified in the running app with 4 clients: unchecking the lead removes it, promotes the next to GLOBAL, and leaves the third intact; unchecking again collapses cleanly to the survivor.

Notes / not in scope

  • The chip strip still renders no ✕ on the lead chip — that's an explicitly tested design decision (MultiHostPicker.test.tsx:297). The checkbox row is the removal path and now works; happy to make the two consistent if preferred.
  • The GLOBAL badge just means "lead / slot 0" and reads as confusing. Renaming it to Lead is a one-line change plus a test — left out to keep this diff to the bug.

Summary by cubic

Fixes the Playground compare picker so the Global lead can be unchecked without deleting other clients. Removing the lead from a non-empty lineup promotes the next client; clearing the list keeps the lead for single-host fallback.

  • Bug Fixes
    • setSelectedHostIds now updates the lead to the new slot 0 when the current lead is dropped; clearing to [] preserves the lead.
    • Applies to both ClientSelector and MultiHostPicker via usePersistedHost.
    • Added tests: 3 for usePersistedHost and 1 for ClientSelector; affected suites are green.

Written for commit 3bc0282. Summary will update on new commits.

Review in cubic

Unchecking the lead client (the one badged GLOBAL) did nothing visible
except silently delete a different client from the compare line-up.

The lead is stored apart from the line-up, and `usePersistedHost`
re-derives the line-up on every read. `deriveSelectedHostIds` has a
defensive branch for external surfaces that move the lead without
rotating the array ("lead not in array -> replace slot 0"), but it can't
tell that apart from the user removing the lead from the array. So:

  stored [claude, slackbot, chatgpt] + lead claude
    -> uncheck claude -> stored [slackbot, chatgpt]
    -> derive re-inserts claude at slot 0 -> [claude, chatgpt]

Claude never leaves and slackbot is gone. Repeating the click eats one
more client each time until only the un-removable lead is left, which
reads as "clicking it unchecked everything".

`setSelectedHostIds` is an explicit in-app write, so it is authoritative
about the line-up: when it drops the current lead from a non-empty
array, the lead now follows to the new slot 0. Clearing to `[]` stays a
non-lead-change — that path means "fall back to the lead as the single
implicit selection", so the lead has to survive it.

One change in the hook covers both surfaces (chat-input ClientSelector
and the header MultiHostPicker); both route their writes through it.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@olartgabo
olartgabo temporarily deployed to preview-pr-3370 July 23, 2026 01:10 — with GitHub Actions Inactive
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 23, 2026
@chelojimenez

chelojimenez commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8000d37d-b6c6-4047-bae9-eaa6fb5eefcc

📥 Commits

Reviewing files that changed from the base of the PR and between 401d61d and 8b745bf.

📒 Files selected for processing (3)
  • mcpjam-inspector/client/src/components/chat-v2/__tests__/client-selector.test.tsx
  • mcpjam-inspector/client/src/hooks/__tests__/use-persisted-host.test.tsx
  • mcpjam-inspector/client/src/hooks/use-persisted-host.ts

Walkthrough

Updated usePersistedHost to synchronize the persisted previewed host when selected-host arrays exclude the current lead, while preserving the lead when arrays are cleared. Added regression tests for multi-host and two-host lead promotion, empty-array behavior, and unchecking the Global selector row.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

mcpjam-inspector/client/src/components/chat-v2/__tests__/client-selector.test.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: ESLint configuration in --config is invalid:

  • Unexpected top-level property "__esModule".

    at ConfigValidator.validateConfigSchema (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:19)
    at ConfigArrayFactory._normalizeConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2984:21)
    at ConfigArrayFactory.loadFile (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2850:40)
    at createCLIConfigArray (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3660:35)
    at new CascadingConfigArrayFactory (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3735:29)
    at new CLIEngine (/soundcheck/node_modules/eslint/lib/cli-engine/cli-engine.js:617:36)
    at new ESLint (/soundcheck/node_modules/eslint/lib/eslint/eslint.js:430:27)
    at Object.execute (/soundcheck/node_modules/eslint/lib/cli.js:410:24)
    at async main (/soundcheck/node_modules/eslint/bin/eslint.js:152:22)

mcpjam-inspector/client/src/hooks/__tests__/use-persisted-host.test.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: ESLint configuration in --config is invalid:

  • Unexpected top-level property "__esModule".

    at ConfigValidator.validateConfigSchema (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:19)
    at ConfigArrayFactory._normalizeConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2984:21)
    at ConfigArrayFactory.loadFile (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2850:40)
    at createCLIConfigArray (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3660:35)
    at new CascadingConfigArrayFactory (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3735:29)
    at new CLIEngine (/soundcheck/node_modules/eslint/lib/cli-engine/cli-engine.js:617:36)
    at new ESLint (/soundcheck/node_modules/eslint/lib/eslint/eslint.js:430:27)
    at Object.execute (/soundcheck/node_modules/eslint/lib/cli.js:410:24)
    at async main (/soundcheck/node_modules/eslint/bin/eslint.js:152:22)

mcpjam-inspector/client/src/hooks/use-persisted-host.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: ESLint configuration in --config is invalid:

  • Unexpected top-level property "__esModule".

    at ConfigValidator.validateConfigSchema (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:19)
    at ConfigArrayFactory._normalizeConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadConfigData (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2984:21)
    at ConfigArrayFactory.loadFile (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2850:40)
    at createCLIConfigArray (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3660:35)
    at new CascadingConfigArrayFactory (/soundcheck/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3735:29)
    at new CLIEngine (/soundcheck/node_modules/eslint/lib/cli-engine/cli-engine.js:617:36)
    at new ESLint (/soundcheck/node_modules/eslint/lib/eslint/eslint.js:430:27)
    at Object.execute (/soundcheck/node_modules/eslint/lib/cli.js:410:24)
    at async main (/soundcheck/node_modules/eslint/bin/eslint.js:152:22)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Internal preview

Preview URL: https://mcp-inspector-pr-3370.up.railway.app
Deployed commit: f869c90
PR head commit: 3bc0282
Backend target: staging fallback.
Health: ✅ Convex reachable
Access is employee-only in non-production environments.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

Re-trigger cubic

@prathmeshpatel prathmeshpatel 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.

LGTM, thanks for the quick iteration

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 23, 2026
@olartgabo
olartgabo temporarily deployed to preview-pr-3370 July 23, 2026 22:40 — with GitHub Actions Inactive
@olartgabo
olartgabo enabled auto-merge (squash) July 24, 2026 00:11
@olartgabo
olartgabo merged commit 0c86117 into main Jul 24, 2026
12 checks passed
@olartgabo
olartgabo deleted the fix/playground-uncheck-lead-client branch July 24, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants