Skip to content

fix(chat): name the already-on-model sessions in Switch All - #17670

Merged
iamwhatever merged 2 commits into
mainfrom
fix/bulk-switch-on-target-11103
Oct 7, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
fix/bulk-switch-on-target-11103

Conversation

@buluoray

@buluoray buluoray commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In Switch All Sessions, the user can see why the "Switch N sessions" count is lower than the session rows on screen, including a disabled "Switch 0 sessions".

The count leaves out sessions that already use the picked model, and nothing in the panel says so. Running sessions have their own "Skip N running sessions" line, but the already-on-target bucket has no surface at all. A lower count, or a disabled Switch 0 sessions, therefore cannot be reconciled with the visible rows (#11103).

Why it matters

A bulk switch resets every conversation it touches. When the number on the button does not match what the user can see, they cannot tell whether the switch will act on the sessions they expect, and a disabled Switch 0 looks like a bug instead of "nothing to do".

Not a goal

What changed (motivation → approach → change)

  • Symptom: the panel's count has two subtrahends and only one is rendered.
  • Root cause: bulkAffectedCount was an inline filter(...).length, so the excluded sessions were dropped without being counted into any named bucket the panel could render.
  • Change: new website/src/lib/bulkModelSwitch.ts partitionBulkSwitch(slots, pick, skipRunning) returns { affected, onTarget, skippedRunning }, disjoint and exhaustive, in the server's order (api_chat_slots_model checks the model before the busy state, so a running slot already on the target is onTarget). ChatSidebar.tsx reads affected for the button exactly as before, and renders a role="status" line N sessions already use this model (bulk-model-on-target) when a pick is made and onTarget > 0. After a pick, the "Skip N running sessions" label counts runningOffTarget (running sessions NOT on the pick), so a running session already on the pick is counted once, in the on-target line, not twice. Before a pick it still counts every running session. The line sits above the error notice and the Cancel/Switch row, so that row stays at two buttons.
  • Acceptance criterion 4 (a future predicate cannot ship without a surface) is a structural test: the partition must account for every slot exactly once, so an exclusion added without a bucket fails it.
  • Criterion 3 (displayModel): no model string is rendered by this change, only a count, so there is nothing to route through it.
  • New i18n key pages.chatSidebar.already_on_model (plural) in en.manual.json, every shipped catalog with the forms its language needs, pluralKeys.json, and the regenerated en-XA pseudolocale.

Backwards compatibility

Compatible: the Switch button's count and disable condition compute the same value as before; the change only adds a status line.

Removes nothing: the diff adds a helper, a status line and catalog keys, and replaces an inline filter with the helper that returns the same affected value.

Tests

  • website/src/lib/bulkModelSwitch.test.ts (new): an exhaustive model × running × skip matrix asserts every slot lands in exactly one bucket; plus the server-order case (running + on-target → onTarget), skip-off vs skip-on, and an unset model. Mutation: dropping the onTarget increment reddens 4 of 5 tests.
  • website/src/test/ChatSidebar.bulkModelRosterError.test.tsx (3 new cases): the line names the on-target count and updates when the pick changes; a disabled Switch 0 sessions (all sessions on the pick, one of them running) shows the line; no line when nothing is on the pick. Mutation: removing the line's render reddens the first two.
  • Same file, counts a running session once, in the skip line or the on-target line plus a no-skip-label assertion in the Switch 0 case: the rendered numbers add up to the rows when a running session is on the pick. Mutation: making the label count every running slot again reddens both. bulkModelSwitch.test.ts also asserts no slot is in both onTarget and runningOffTarget.
  • src/i18n suite (catalog parity, plural forms, key references): 733 passed. node scripts/i18n-check.mjs exits 0.

Manual verification

Driven against a pod built from this branch (kc-fix-11103, Chromium headless via Playwright): created three sessions through POST /api/chat/slots (two on claude-opus-5.5, one on claude-sonnet-5.5) next to the default session, opened ⋮ → Switch all to model…, and picked each model. Opus: line 2 sessions already use this model, button Switch 2 sessions, and 4 rows on screen reconcile. Sonnet: 1 session already uses this model, Switch 3 sessions. Re-driven on a pod rebuilt from c892ace9ba with a session running a real wait turn: the checkbox is absent when that session already uses the pick (1 + Switch 3 = 4 rows), and reads Skip 1 running session when it does not (1 + 2 + Switch 1 = 4 rows). Both pods were torn down afterwards.

Screenshots / video

Light, pick claude-opus-5.5 (2 of 4 sessions already on it):

Switch All panel, light, opus pick

Dark, pick claude-sonnet-5.5 (1 of 4):

Switch All panel, dark, sonnet pick

With a running session (pod rebuilt from c892ace9ba; 4 rows: the default session, alpha and gamma on claude-opus-5.5, and beta on claude-sonnet-5.5, running a 240 s wait turn):

Pick claude-sonnet-5.5: the running session already uses the pick, so the "Skip N running sessions" checkbox is gone. The panel reads 1 already on the model + Switch 3 = 4 rows.

Switch All, running session already on the pick: no skip checkbox

Pick claude-opus-5.5: the running session is not on the pick, so the panel reads Skip 1 running + 2 already on the model + Switch 1 = 4 rows.

Switch All, running session not on the pick: Skip 1 running session

Related Issues

Closes #11103

Decision for the owner

The issue asks which surface should account for the sessions already on the target model: a per-row model chip in the sidebar, a session list inside the panel, or one row-less status line. This draft ships the status line, because it is the smallest change that makes the count and a disabled Switch 0 add up, and it does not make the sidebar denser for every user all the time the way a per-row chip would.

Pattern harvest

Rule candidate: review-prompt
Pattern: a derived count that excludes items with a bare filter(...).length hides why each item was excluded; partition into named buckets so every exclusion has a surface and a test.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c892ace9ba7c55089f8f0af75c1099077b40f076 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the "Skip running sessions" checkbox disappearing after a pick, when every running session is already on that model, is the behaviour you want.

[DESIGN-REVIEWED] c892ace

Description read

[DESCRIPTION-READ] 0c61c09beb5687bd87accc6145234a1fc930552ff3a566fcb5f1bbae05a6998e

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of c892ace9ba7c55089f8f0af75c1099077b40f076 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

BulkSwitchPartition.skippedRunning has no production reader, and it is a second spelling of runningOffTarget that only the new tests use.

Not justified as shipped

  • Item 3 — zero consumers: the grep skippedRunning in website/src outside tests finds only the helper's own definition and increment. That makes 0 consumers. ChatSidebar.tsx reads affected, onTarget and runningOffTarget only. When skipping, it is the same set as runningOffTarget, and the test asserts that itself: expect(p.runningOffTarget).toBe(p.skippedRunning).
    Subtraction: delete the skippedRunning field and its increment. The exhaustiveness test then sums affected + onTarget + (skip ? runningOffTarget : 0).
    Clears when: the field is deleted, or a non-test reader of skippedRunning is counted.
  • Item 4 — undeclared: once a pick is made, the "Skip running sessions" checkbox now disappears when every running session is already on the pick (bulkRunningCount > 0 gate). The description only mentions the label count.

What this change ships

Inventory (4 items) — 2 justified

Intent: let a user see why "Switch N sessions" is lower than the visible rows, or reads 0 (#11103). FIX.

  1. New status line "N sessions already use this model" after a pick — justified
  2. After a pick, the "Skip N running sessions" count leaves out running sessions already on the pick — justified
  3. New partitionBulkSwitch helper with four counters — zero consumers (skippedRunning)
  4. After a pick, the skip-running checkbox hides when no running session is off the pick — undeclared

[FIRST-PRINCIPLES-REVIEWED] c892ace

Description read

[DESCRIPTION-READ] 1cd1c555cca3fae09d70a0bde6f6499728e4d21ad670720c0a5d515f6c9f95d1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c892ace9ba7c55089f8f0af75c1099077b40f076 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c892ace

Verdict parsed from the review's SHA-scoped output markers for commit c892ace9ba7c55089f8f0af75c1099077b40f076.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c892ace9ba7c55089f8f0af75c1099077b40f076: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ human override accepted

@buluoray overrode this lane for c892ace9ba7c55089f8f0af75c1099077b40f076 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c892ace9ba7c55089f8f0af75c1099077b40f076 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c892ace

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c892ace9ba7c55089f8f0af75c1099077b40f076: <one-sentence reason>

The Switch N count left out sessions already on the picked model with
nothing on screen to say so, so a lower count or a disabled "Switch 0
sessions" could not be reconciled with the visible rows. The count now
comes from partitionBulkSwitch, which puts every excluded session in a
named bucket, and the panel renders the on-target bucket as one status
line. A partition test fails if a future exclusion has no bucket.

Closes #11103
The skip checkbox counted every running session, including ones already
on the pick that the new on-target line also counts, so the panel still
added up to more than the rows. After a pick it now counts only running
sessions not on the pick (partitionBulkSwitch.runningOffTarget).

Refs #11103
@buluoray
buluoray force-pushed the fix/bulk-switch-on-target-11103 branch from 17078e9 to c892ace Compare October 7, 2026 09:23
@buluoray

buluoray commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the advisory lanes on 17078e9ec5 (Design, First Principles, UX — all CONCERNS):

  • Running on-target session counted twice (all three lanes): confirmed and fixed in c892ace9ba. The skip checkbox rendered bulkRunningCount (every running slot) next to the new on-target line. After a pick it now renders partitionBulkSwitch(...).runningOffTarget, so that bucket has a production reader and no slot is counted in both. The Switch 0 test now asserts no skip label when the only running session is on the pick, and a new test covers 1 on-target + 1 running skipped + 1 to switch = 3 rows. Reverting the label to the old count reddens both.
  • No screenshot of a running session / disabled Switch 0 (UX): not added. A running session needs a live turn on the pod, and the conductor has asked workers to keep load down while the App installation is rate limited. Both states are pinned by the component tests above.
  • "session" vs "conversation" in the panel header (UX suggestion): out of scope; the header copy predates this PR and the new string already says "session".

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 7, 2026
@buluoray
buluoray marked this pull request as ready for review October 7, 2026 18:20
@buluoray
buluoray requested a review from a team as a code owner October 7, 2026 18:20
@buluoray
buluoray requested a review from bolichen97 October 7, 2026 18:20
@buluoray

buluoray commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review override ux c892ace: the 09:27Z BLOCK asked for running-session screenshots; they were added and the UX re-run on this same head returned CONCERNS (advisory).

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray marked the ux AI finding as false positive, not applicable, or explicitly accepted for c892ace9ba7c55089f8f0af75c1099077b40f076.

the 09:27Z BLOCK asked for running-session screenshots; they were added and the UX re-run on this same head returned CONCERNS (advisory).

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 7, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. partitionBulkSwitch in bulkModelSwitch.ts returns the same affected set as the old inline filter, and it checks the model before the busy state, like the server does. The exhaustive partition test is a cheap guard against a future exclusion that shows nothing on screen.

One note, not blocking: once a model is picked, the "Skip N running" checkbox in ChatSidebar.tsx hides when every running session already uses that model. That is correct, since nothing is left to skip, but please say so in the PR body so nobody reads it as a regression.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

partitionBulkSwitch replaces the bare filter().length with named buckets that are disjoint and cover every session. The new "N sessions already use this model" line is what lets the Switch count and a disabled "Switch 0" match the rows on screen, so the root cause is addressed. The button's count and its disable condition give the same value as before. A running session that is already on the pick is now counted once, not twice, and the matrix and component tests pin this. One leftover from First Principles on this head is still unanswered: skippedRunning in website/src/lib/bulkModelSwitch.ts:35 has no production reader and duplicates runningOffTarget. Delete it, or post a disposition. Neither blocks the merge.

@kirocrew-computer was not available in this session. It was not needed for this review.

@iamwhatever
iamwhatever merged commit e1e583f into main Oct 7, 2026
119 of 127 checks passed
@iamwhatever
iamwhatever deleted the fix/bulk-switch-on-target-11103 branch October 7, 2026 22:15
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 7, 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.

Switch All Sessions counts by a session's model but never shows it, while the repo ships the display helper

3 participants