Skip to content

fix(scaffolder): post-create refresh + existing-root gate (#7974) - #10272

Merged
iamwhatever merged 1 commit into
mainfrom
fix/scaffolder-post-create-refresh-7974
Sep 13, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/scaffolder-post-create-refresh-7974

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Two leftovers on the Project Scaffolder page, both deferred from the UX review of PR #5890.

  1. After a successful create, the preview above the Results card keeps its pre-create state. The rows that were just created stay ticked and enabled. A second click sends a create that does nothing.
  2. When a scan comes back empty but the root folder already exists, the empty state still offers "Create the root folder only" with no badge and no gating. Clicking it returns "0 created / 1 already existed".

Why it matters

The preview is the page's confirmation step. When it stops matching what is on disk, the user is invited to click a button whose only possible outcome is a no-op result that contradicts what they just did. Both paths waste a request and teach the user to distrust the preview.

What changed (motivation → approach → change)

The scan response already knows the truth (existing per row, root_existing for the root). So after a create succeeds, the page now asks for that truth again: createMut.onSuccess re-runs the scan against the root the create actually ran against (scanRoot from the mutation's own variables, not the live field, which may have drifted).

A plain re-scan would wipe the Results card the user is reading — scanMut.onSuccess clears it. The scan mutation now takes { path, keepResult }. The post-create refresh sets keepResult: true, which keeps the Results card, keeps the drift baseline (scannedInput), keeps the disclosure open, and keeps the user's hand-tuned selection (intersected with rows still creatable, so a row the user deliberately unticked is not re-armed by the server default). Manual Re-scan and Enter-scan behave exactly as before. A failed refresh renders in the root field's error slot and leaves the Results card alone.

The empty-state branch, when scan.root_existing is true, removes the "Create the root folder only" action entirely and switches the subtitle to a new i18n key (root_already_exists_nothing_to_create, added to all locales) — the subtitle states the outcome, and no control renders that could contradict it (a first iteration shipped a badge plus a disabled button; the UX review of that iteration blocked it because the dimmed button still read as clickable and contradicted the copy). The populated preview's landing state after a refresh is gated the same way: with the root's folder in place and nothing ticked, "Create sidebar folders" is disabled and a one-line reason (the same string) renders beside it.

Existing rows changed shape for the same reason, on the same UX evidence: a cold reader took the reduced-opacity disabled checkbox for a tickable control ("I can't tell if they're just unticked or actually locked"). An already-scaffolded row is pure state — it renders a FolderCheck icon (keeping the row's path as its accessible name) instead of a disabled checkbox, and because a create flips row.existing on the very row the user just ticked, the checkbox cross-fades into the icon through one animated slot (framer-motion, the codebase's standard) rather than hard-swapping. The Results card's skipped pill now says "already set up", the same words the row badges use, so the two surfaces stop describing one fact in two vocabularies.

flowchart LR
  subgraph Before
    A1[create succeeds]:::ctx --> B1[Results card]:::ctx
    B1 --> C1[preview keeps stale ticks]:::removed
  end
  subgraph After
    A2[create succeeds]:::ctx --> B2[Results card]:::ctx
    A2 --> D2[re-scan scanRoot, keepResult]:::added
    D2 --> E2[rows flip to Already set up]:::added
  end
  classDef added fill:#DCFCE7,stroke:#16A34A,color:#14532D,stroke-width:2px
  classDef changed fill:#FEF3C7,stroke:#D97706,color:#78350F,stroke-width:2px
  classDef removed fill:#FEE2E2,stroke:#DC2626,color:#7F1D1D,stroke-dasharray:4 3
  classDef ctx fill:#E0F2FE,stroke:#0284C7,color:#0C4A6E
  linkStyle 1 stroke:#DC2626,stroke-dasharray:4 3
  linkStyle 3,4 stroke:#16A34A,stroke-width:2px
Loading

🟩 added · 🟥 removed · 🟦 unchanged

Create now refreshes the preview it just outdated; the Results card stays.

Tests

Added to website/src/test/ProjectScaffolderPage.test.tsx:

  • after a successful create, scanProject is called a second time with the scanned root; the created rows lose their checkbox and render as read-only "Already set up" state (icon keeps the path as its accessible name) while result-created is still in the document, and the landing state's create button is disabled with a reason line beside it
  • the hand-tuned selection survives the refresh: a row the user unticked stays unticked even though the fresh scan's server default ticks it, and the open disclosure stays open
  • a failed post-create refresh keeps result-created and the preview in the document
  • with status: 'empty' and root_existing: true, the empty state offers no create action at all and the subtitle explains why
  • with status: 'empty' and root_existing: false, the button stays enabled (regression guard)

Existing create-success tests were extended to queue the refresh response and settle on it.

Manual verification

Drove both flows in a browser against a mocked backend (Vite harness + Playwright): populated preview → create → refreshed preview with kept Results card and disabled no-op button; empty scan with existing root → badge, disabled button, new subtitle. DOM state asserted, screenshots below are from those runs. npx tsc -b, eslint on touched files, and npm run i18n:check (with I18N_BASE_REF=main) all pass locally; vitest runs in CI.

Screenshots / video

Populated preview after a create — before: rows stay ticked and enabled; after: created rows lose their checkbox and read as "Already set up" state, Results card kept, no-op create disabled.

before: preview keeps stale ticks after create
after: preview refreshed, created rows read-only with badges, reason line under the gated button

The create click itself — rows cross-fade from ticked checkboxes to the done state while the Results card stays:

create-transition.webm

Empty scan with an existing root — before: enabled button with no explanation; after: no action is offered and the subtitle states there is nothing left to create.

before: empty state offers a no-op create
after: empty state with an existing root offers no action; the subtitle states the outcome

Related Issues

Closes #7974

Pattern harvest

Rule candidate: review-prompt
Pattern: a mutation's success handler updates the outcome surface but leaves the source preview stale, inviting a no-op retry — after a state-changing mutation, re-derive every dependent view or gate the action it feeds.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Re-derives the preview from the scan endpoint (the existing source of truth) instead of hand-patching client state — root-cause fix, failure path handled and tested.

[DESIGN-REVIEWED] 615290c

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 615290cf45b2762d958cbce7cc4ef8b131ae25b9 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 615290c

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

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 615290cf45b2762d958cbce7cc4ef8b131ae25b9 — 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.

All mechanical checks done. Findings summary before the verdict: the two fixes (post-create refresh, existing-root gating) are well-grounded — the re-scan approach follows the recorded decision in api.ts ("duplicating any part of that here would create a second answer to 'what does this tree contain'"), the cross-fade is mandated by website/AGENTS.md's one-element rule, and both no-op-create sites are fixed (no unfixed siblings). Two riders carry premise risk: the row checkbox→icon redesign deletes a pinned decision on evidence asserted only in the description, and the Results-pill relabel rests on consistency alone.

First-Principles-Verdict: CONCERNS

Two riders on a two-defect fix: the row redesign replaces a pinned decision on unlinked evidence, and the pill relabel rests on consistency alone.

Not justified as shipped

  • 6. Already-scaffolded rows lose the disabled checkbox for a FolderCheck icon — rides along; it deletes a pinned decision (the removed comment: "disabling the box is what makes that unmissable") on a cold-reader quote asserted only in the description — the linked UX run covers the empty-state button, not this row control.
  • 7. Results pill relabeled "already existed" → "already set up" across 13 locales — rides along; the only stated harm is "two surfaces … two vocabularies", the consistency form of INHERITED, with no named person who misread the pill.

What this change ships

Inventory (7 items) — 5 justified

Intent: stop the scaffolder from inviting a create whose only possible outcome is a no-op, after a create or on an already-scaffolded root. FIX (issue #7974, deferred from the #5890 UX review).

  1. After a successful create, the preview refreshes itself and created rows flip to "Already set up" — justified
  2. The Results card, drift baseline, and open disclosure survive that refresh; a failed refresh only marks the root field — justified
  3. The user's hand-tuned selection survives the refresh instead of resetting to server defaults — justified
  4. Empty state with an existing root offers no create action; a new subtitle (13 locales) states the outcome — justified
  5. Populated landing state disables "Create sidebar folders" with a reason when nothing is ticked and the root exists — justified
  6. Already-scaffolded rows swap the disabled checkbox for an icon, cross-faded per the one-element invariant — rides along; pinned opposite decision, evidence not linked
  7. Results pill says "already set up" instead of "already existed" — rides along; consistency-only relabel

Watch

  • Item 6 removes the pin shows an already-scaffolded row with a disabled checkbox it cannot tick and its comment; the replacing evidence ("I can't tell if they're just unticked or actually locked") is quoted but not pointable.
    Clears when: the feat(apps): create sidebar folders from a scanned project #5890 UX-review comment or run containing that cold-reader finding is linked from the PR.
  • Item 7 is a relabel with no named failing reader; it re-translates one string in 13 locale files and churns a key.
    Clears when: someone who conflated the pill's "already existed" with the rows' "already set up" is named — or the rename is dropped.

Subtractions

  • Drop the n_already_existed → n_already_set_up rename (13 locale files + en-XA + test): keep the existing key; fix 1 and fix 2 are complete without it.

[FIRST-PRINCIPLES-REVIEWED] 615290c

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

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

All evidence is in hand. The blind read ran, all four screenshots plus a recording of the cross-fade are supplied, and the primary controls (Scan, checkboxes, Create) were read correctly and confidently. The remaining findings are copy-coherence problems the blind reader hit directly on the new post-create landing state and the reused empty-state string.

UX-Verdict: CONCERNS

One string does duty on two screens and is literally false on one of them: "nothing left to create" renders above a still-tickable row.

Watch

  • Reason line lies while a creatable row remains: it renders on selectedCount === 0 && scan.root_existing even when "docs" sits unticked and tickable above it — reader: "is there really nothing left?" Hits every post-create landing with an excluded row, persistent, and teaches distrust of the exact copy this PR adds. Fix: show root_already_exists_nothing_to_create only when no creatable candidates remain; otherwise "Nothing selected — tick a folder to create it."
  • Empty state (shot-04): headline "No sub-projects found" + a subtitle about the root read as two different situations — reader: "no idea which situation I'm actually in." Fix: a subtitle covering both facts ("No sub-projects found, and this directory's folder already exists").
  • Kept Results card "2 created" under a preview saying nothing can be created — reader: "the one thing that would make me distrust the page." Smallest fix: mark it as a receipt ("Just created" / timestamp in the card header).
  • FolderCheck icon on done rows: reader couldn't tell "if they're buttons or decorations" and would click one. Harmless (no handler), but pairing it visually with its existing "Already set up" text at lower opacity would settle it.

[UX-REVIEWED] 615290c

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 615290c

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

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 12, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/scaffolder-post-create-refresh-7974 branch from e53ac84 to a7d824c Compare September 12, 2026 02:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 12, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/scaffolder-post-create-refresh-7974 branch from a7d824c to 0faf0f6 Compare September 12, 2026 03:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/scaffolder-post-create-refresh-7974 branch from 0faf0f6 to c16b811 Compare September 12, 2026 04:00
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/scaffolder-post-create-refresh-7974 branch from c16b811 to ef6873f Compare September 12, 2026 05:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 12, 2026
@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 Sep 12, 2026
After a successful create, re-scan the created-into root so the just-created
rows flip to the "Already set up" badge instead of staying ticked, while a new
keepResult flag on the scan mutation keeps the Results card on screen. In the
empty-state branch, render the root-existing badge, disable "Create the root
folder only", and switch the subtitle when the root folder already exists.

Closes #7974
@CrysisDeu
CrysisDeu force-pushed the fix/scaffolder-post-create-refresh-7974 branch from ef6873f to 615290c Compare September 12, 2026 08:45
@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 Sep 12, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • 6. Already-scaffolded rows lose the disabled checkbox for a FolderCheck icon — rides along (span=70b2306b7b03) — Rebut: the change does not ride along; it was demanded by this PR's own UX lane, in two pointable runs. Run 34667782442 (UX BLOCK) filed the Watch whose cold reader said "I can't tell if they're just unticked or actually locked … no idea" and prescribed "mute the whole row's text and drop the checkbox for existing rows, leaving the already_set_up badge as the state"; run 34669776256 (UX BLOCK) then required the replacement to cross-fade instead of hard-swap. The deleted pin was overridden by that reviewed evidence, not by an unsupported assertion.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • 7. Results pill relabeled "already existed" → "already set up" across 13 locales — rides along, consistency form of INHERITED (span=dd0aa17499e4) — Rebut: there is a named failing reader. The UX review of head 0faf0f6d (run 34669776256) filed a Watch that its cold reader "could not tell if they mean the same thing" when "Already set up" (row badges) and "already existed" (Results pill) became co-visible — a state this PR is the first to create. The relabel resolves that reviewed misreading, not an abstract symmetry preference.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Item 6 removes the pin; the replacing evidence is quoted but not pointable (span=06b6b4788f0c) — Answered with the pointer the clear condition asks for: the cold-reader finding "I can't tell if they're just unticked or actually locked" is the Watch in this PR's own UX review of head a7d824c3, run 34667782442 (verdict BLOCK), which prescribed dropping the checkbox on existing rows. The follow-up run 34669776256 shaped the replacement into the cross-fade that ships here.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Item 7 is a relabel with no named failing reader (span=75772c087693) — The clear condition is met: the reader who conflated the two strings is the UX lane's cold reader on head 0faf0f6d, run 34669776256 — its Watch records that this PR makes "Already set up" and "already existed" co-visible for the first time and "the reader could not tell if they mean the same thing", and prescribes renaming the Results pill to the already_set_up wording. The rename ships exactly that prescription.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Drop the n_already_existed → n_already_set_up rename; fixes 1 and 2 are complete without it (span=88a8798da070) — Declined. Dropping the rename would reinstate the vocabulary collision the UX lane flagged on head 0faf0f6d (run 34669776256): the collision only exists because this PR's refresh makes the row badges and the Results pill co-visible, so its fix belongs to this PR. The old key was deleted rather than kept because the repo's dead-key ratchet (src/i18n/deadKeys.test.ts) fails on an orphaned catalog key.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Reason line lies while a creatable row remains (span=944a2bcc27fe) — Accept-and-defer. The gate is correct (0 selected + existing root is a guaranteed no-op), the adjacent count already reads "0 selected", and making the copy exact for the tickable-rows-remaining case needs a new string across 13 locales. The First Principles lane on this same head is pressing this PR to shed rider scope, so the copy tightening is deferred to a follow-up issue rather than grown into this head.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Empty state headline and root subtitle read as two different situations (span=4eaf42628af0) — Accept-and-defer. The suggested merged subtitle ("No sub-projects found, and this directory's folder already exists") is a copy change to the new root_already_exists_nothing_to_create string across 13 locales; batched with the other deferred copy Watch into a follow-up rather than restarting the lane set on a head whose blocking lanes are green.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Kept Results card reads oddly under a preview that says nothing can be created (span=9be2f339fb04) — Accept-and-defer. Keeping the card is the issue's own requirement (the refresh must not cost the user the outcome they are reading); marking it as a receipt ("Just created" / timestamp) is a good refinement that adds a new string and a header change — deferred to the same follow-up as the other copy Watches.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • FolderCheck icon on done rows could read as a button (span=e592ded76176) — Accept-and-defer. The finding's own assessment is harmless (no handler); visually pairing the icon with its "Already set up" text is a styling nudge that belongs in the same copy/polish follow-up. Folding it into this head would restart the full lane set for a decoration tweak.

@iamwhatever
iamwhatever merged commit 591c37c into main Sep 13, 2026
71 checks passed
@iamwhatever
iamwhatever deleted the fix/scaffolder-post-create-refresh-7974 branch September 13, 2026 05:51
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 13, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…#7974) (kirodotdev#10272)

After a successful create, re-scan the created-into root so the just-created
rows flip to the "Already set up" badge instead of staying ticked, while a new
keepResult flag on the scan mutation keeps the Results card on screen. In the
empty-state branch, render the root-existing badge, disable "Create the root
folder only", and switch the subtitle when the root folder already exists.

Closes kirodotdev#7974
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.

Project scaffolder: refresh preview after create; gate empty-state action on existing root

2 participants