Skip to content

feat(dashboard): show a spinner on the project chip while a pick waits - #29562

Merged
buluoray merged 1 commit into
mainfrom
fix/project-chip-pending-20351
Nov 4, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/project-chip-pending-20351

Conversation

@buluoray

@buluoray buluoray commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: While a project pick is still waiting, the project chip shows a spinner, so the pick no longer looks hung.

Picking a project calls setProject, which waits on POST /api/chat/slots/<slot>/project. That route waits on the slot's turn-preparation lock, and a cold spawn holds it for several seconds. The picker closes at once, but the chip keeps showing the old folder with no sign the pick was taken.

Why it matters

Every user who switches project on a chat that is starting a session sees a control that looks broken for seconds. Some pick again, which only queues more requests behind the same lock.

Not a goal

What changed (motivation → approach → change)

  • Symptom: the chip shows no in-flight state while the project route waits.
  • Cause: useSessionChoices.setProject awaited performSlotSwitch but exposed nothing to render.
  • Change: setProject keeps a per-slot count of picks in flight and the hook returns projectSwitching for the active chat. A count, not a flag, so overlapping picks clear only after the last one ends, and a pick waiting on one chat never shows on another. ChatPage passes it through ComposerDockView to ChatInput.
  • ChatInput: while projectSwitching is true the folder icon becomes a spinning Loader2, the chip's visible label reads "Switching project…" in place of the old folder name, the chip sets aria-busy, and an sr-only role="status" line announces the same text. This is the pattern the memory-mode chip already uses (spinner plus "Switching memory mode…" label).
  • ChatInput.tsx was at 1,999 lines and the file line cap is 2,000, so ComposerSizer and its spring constant COMPOSER_ROW_SPRING move whole, unchanged, into website/src/components/chat-input/ComposerSizer.tsx. ChatInput imports both from there.
  • New catalog key components.chatInput.switching_project in all 12 locales; en-XA.json regenerated.
  • website/scripts/capture-20351-project-chip-pending.mjs: screenshot harness that holds the project route the way the gateway does.

Backwards compatibility

Compatible: one new optional prop (projectSwitching, default false) and one new catalog key; with no pick in flight the chip renders exactly as before.

Removes nothing: the change only adds a pending state and a status line.

Tests

website/src/test/projectChipPending.test.tsx:

  • holds api.chatSlotProject behind a barrier and checks projectSwitching is true while held, then false after success, with the server's stored project written;
  • on failure the flag clears, no project is written, and the existing switch notice is dispatched;
  • switching to another chat shows no pending state, switching back shows it again, and two overlapping picks clear only after the last;
  • the chip renders the spinner, aria-busy="true", the visible "Switching project…" label and the matching status when pending, and the folder icon, the folder name and an empty status when not.

Mutation check: making projectSwitching always false reddens the three hook tests; removing the spinner and aria-busy, or restoring the folder name as the label while pending, each redden project chip > shows a spinner and announces the pending pick.

Proof: not provable -- frontend test (prove.py runs Python only)

Also run green: windowsProjectNameSites, ChatPage.pageOwners, ChatInputCoverage, ChatPage.memoryChip, src/i18n catalog tests, tsc -p tsconfig.app.json, eslint on the changed files, i18n-check, gen-ui-index --check.

Manual verification

Ran the screenshot harness against the built SPA (website/dist) with fixtures and the project route held, at 1200px and 390px wide: pending, success, and failure frames below.

Screenshots / video

Pending (route held): spinner and "Switching project…" on the project chip, picker closed.

pending, desktop

pending, narrow 390px

Success and failure

Success: the new project shows and the spinner is gone.

success, desktop

success, narrow

Failure: the spinner is gone, the chip keeps the project it had, and the existing switch notice explains.

failure, desktop

failure, narrow

Related Issues

Closes #20351
Follow-up to #17729.

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.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 4, 2026 10:30
@buluoray
buluoray requested a review from CrysisDeu November 4, 2026 10:30
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 45522f448e10a5b2262956bee0a7ddd2b46b91d6 — 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 does not.

First-Principles-Verdict: PASS

The pending spinner traces back to #20351, and the file split is required by the line cap. The only thing worth questioning is the screenshot script that ships with the change.

Notes

  • Item 7 — inherited: website/scripts/capture-20351-project-chip-pending.mjs adds a 117-line Playwright harness that the product never runs. The PR already embeds its screenshots, and website/AGENTS.md does not require such a script. The only thing supporting it is the 905 sibling capture-*.mjs files (glob website/scripts/capture-*.mjs), which is convention. Subtraction: delete the script and keep the screenshots in the PR body as the evidence.

What this change ships

Inventory (7 items) — 6 justified

Intent: when someone picks a project on a chat that is starting a session, they can see the pick was taken instead of a chip that looks hung. This is an ADDITION.

  1. While a pick waits, the project chip's folder icon becomes a spinner — justified
  2. While a pick waits, the chip's label reads "Switching project…" in place of the folder name — justified
  3. Screen readers get aria-busy and an announced status line — justified
  4. The pending state is tracked per chat and clears only after the last overlapping pick ends — justified
  5. ComposerSizer moves unchanged into chat-input/ComposerSizer.tsx, as the 2,000-line cap requires — justified
  6. A new "Switching project…" string in 12 locales — justified
  7. A Playwright screenshot script for this PR — inherited, from the convention of the other capture scripts

[FIRST-PRINCIPLES-REVIEWED] 45522f4

Description read

[DESCRIPTION-READ] d71d93edc872934b94326b9c82e2b60d7fbe2ee6d68f44edd1c0877d4d48a39f

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 Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 45522f448e10a5b2262956bee0a7ddd2b46b91d6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the spinner state is a per-slot count kept next to the pick, it clears in finally, and screenshots of this revision show the pending, success and failure states.

Notes

  • ChatInput.tsx was sitting just under the line cap. Moving ComposerSizer out buys only a small margin, so the next feature added to this composer should begin by splitting out a real responsibility.

[DESIGN-REVIEWED] 45522f4

Description read

[DESCRIPTION-READ] 4c2d3938c3630725ab8e9c95da33b80496d2fa5739d1da311c535a0e808176c1

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 Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 45522f448e10a5b2262956bee0a7ddd2b46b91d6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The blind reader read the pending chip as intended ("the app is moving from one project to another"), and all three states have screenshots at both widths.

Notes

  • components.chatInput.switching_project: the label "Switching project…" doesn't name where the switch is going. Because of that, the reader couldn't tell from the failure frame (shot-05) whether the failed switch was to "website-docs", the name still on the chip. Show the target instead, e.g. "Switching to old-notes…", using the basename the chip already formats.
  • While the chip is pending, the reader "wouldn't click 'Switching project…' in case it interrupts the switch." A title on the chip saying another pick replaces this one would tell people they can safely pick again.

[UX-REVIEWED] 45522f4

Description read

[DESCRIPTION-READ] 2c1ed2df7a01464b771a2f01c99f065e498380b86cc64a2c8294b24f80732125

That sha256 names everything this verdict read: the PR description, plus the 9 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 Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 45522f4

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 45522f448e10a5b2262956bee0a7ddd2b46b91d6 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 45522f4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 45522f448e10a5b2262956bee0a7ddd2b46b91d6 false-positive: <reason, 20 to 500 characters>

@buluoray
buluoray force-pushed the fix/project-chip-pending-20351 branch from 5d4a380 to d666997 Compare November 4, 2026 10:55
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 4, 2026
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: UX Review on d666997 — addressed in 329e268.

Blocker (pending state not read as "switching"): fixed. While a pick waits, the chip's visible label now reads "Switching project…" next to the spinner, in place of the old folder name. This matches the memory-mode chip, which shows its spinner beside "Switching memory mode…". The sr-only status line stays as the live announcement. Test project chip > shows a spinner and announces the pending pick now asserts the visible label; putting the folder name back while pending reddens it. Screenshots in the description were recaptured on this head.

Note (failure toast vs. chip name): not changed here. The issue asks a failed pick to "use the existing error surface", and the toast text is the server's own refusal message, shared by every slot switch. After a failure the chip shows the project the chat actually has, so the chip is the true one. Naming the refused folder in the toast would change that shared notice for every switch, which is outside this PR's goal.

@buluoray
buluoray force-pushed the fix/project-chip-pending-20351 branch from 329e268 to b7c6626 Compare November 4, 2026 11:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 4, 2026
@buluoray
buluoray force-pushed the fix/project-chip-pending-20351 branch from b7c6626 to 45522f4 Compare November 4, 2026 13:20
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 4, 2026
@buluoray
buluoray enabled auto-merge (squash) November 4, 2026 14:47

@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 45522f4. The PR has 21 files; I read every hunk at this head: the product code, the new test, the capture script, and the one-line switching_project entry in each of the 13 locale files (en.json has no entry, the same as its sibling keys, which live in en.manual.json).

  • useSessionChoices.setProject keeps a per-slot count of picks in flight, raised before the request and lowered in finally, so it clears on success and on failure. A count rather than a flag means overlapping picks clear only after the last one, and a pick on one chat never shows on another.
  • ChatInput swaps the folder icon for a spinning Loader2, shows "Switching project…" as the label, sets aria-busy, and announces it through an sr-only role="status" line. The chip stays clickable, so the existing latest-wins ordering is unchanged.
  • ComposerSizer and COMPOSER_ROW_SPRING move unchanged into chat-input/ComposerSizer.tsx.
  • Tests cover the pending state, clearing on success and on failure, the per-chat scope, overlapping picks, and the chip's busy and idle render.

No regex, glob or case-blind matching is added in product code. The linked issue is T2. All 96 checks pass.

@buluoray
buluoray merged commit 7a56b95 into main Nov 4, 2026
97 checks passed
@buluoray
buluoray deleted the fix/project-chip-pending-20351 branch November 4, 2026 18:17
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 4, 2026
@rubencu rubencu mentioned this pull request Nov 5, 2026
5 tasks done
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.

Show progress while a project pick waits for turn preparation

2 participants