Skip to content

fix(store): keep setup-script dismissal array identity on no-op repo fetches - #14211

Merged
nwparker merged 2 commits into
mainfrom
nwparker/setup-script-dismissal-identity
Aug 13, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/setup-script-dismissal-identity

Conversation

@nwparker

@nwparker nwparker commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #13744 / #13770 / #13803. Those PRs made repos / projects / projectHostSetups / filterRepoIds referentially stable across a no-op catalog refresh. This sibling field still churned on every fetch: filterSetupScriptPromptDismissalsToValidRepos always did const next: string[] = [] and returned it.

fetchRepos, fetchRuntimeEnvironmentRepos, and validateRepoScopedUi assign that helper result into set() even when the catalog is already identity-stable. SetupScriptPromptCard Object.is-subscribes to setupScriptPromptDismissedRepoIds, so a no-op refresh missed 100% of the time.

Return the original store array when the filtered result is element-wise identical to the input (not the sanitize copy). Allocate only when an entry is dropped, rewritten from a legacy generation-v1:repoId key to generation-v1:host\0repoId, or deduped. Call sites already assign the helper result — no second copy.

The chain — why a partial fix is inert

Identity has to survive every link from fetch to set():

  1. Catalog rows arrive over IPC (structuredClone / hydrate rebuilds nested records).
  2. reconcileCatalogRows / areValuesEqual keep repos / projects / projectHostSetups stable (perf(renderer): keep the repos array identity across no-op refetches #13744 / perf(renderer): keep catalog array identity and path-status cache on no-op refetches #13770 / perf(renderer): index the repo catalog compat merge and keep catalog identity #13803).
  3. retainValidFilterRepoIds keeps filterRepoIds when nothing is pruned (perf(renderer): index the repo catalog compat merge and keep catalog identity #13803).
  4. This helper still allocated, so set({ setupScriptPromptDismissedRepoIds: next }) replaced the array even when every dismissal was already a valid host-identity key.

Fixing 1–3 without 4 leaves SetupScriptPromptCard re-rendering on every catalog echo. Fixing 4 without 1–3 would still see a new validRepoHostIdentities set each time, but the array contents would match and the helper can now return the original store array — the last link is what this PR closes.

Reference compare fails on IPC clones

Dismissal keys are strings (generation-v1: + getRepoHostIdentityForParts(repoId, hostId)), so the element check is ===. The array itself is what subscribers compare. A reference compare of the helper's newly built next against the store array never matches after a rebuild — same strings, new object. Nested catalog records still cannot be compared by reference after IPC structuredClone / hydrate; that is why the earlier PRs use areValuesEqual / reconcileCatalogRows. This helper does not invent a fourth walker: it compares string entries against the original input.

Sanitize always allocates (including for [] and already-valid keys). Comparing against that copy would still return a new array and the empty-array / no-op cases would stay dead.

SSH hosts are already in the key (host\0repoId). Folder workspaces are not in this array; no change there.

Testing

  • setup-script-prompt.test.ts: empty array and already-valid host-identity keys toBe(input); rewrite / drop / dedupe allocate. Existing prune / migrate assertions kept.
  • repos-refresh-identity.test.ts: fetchRepos no-op seeded with production-shaped getSetupScriptPromptDismissalKey(getRepoHostIdentityForParts(...)) keys; asserts the store array is the same ref.

Verified red then restored: reverting the helper to return next fails those three identity assertions and leaves the prune / migrate / allocate tests green.

pnpm exec vitest run --config config/vitest.config.ts \
  src/renderer/src/lib/setup-script-prompt.test.ts \
  src/renderer/src/store/slices/repos-refresh-identity.test.ts

34 passed. Did not run the full suite or typecheck.

Made with Orca

Made with Orca 🐋

…fetches

filterSetupScriptPromptDismissalsToValidRepos always allocated a new
array, so fetchRepos, fetchRuntimeEnvironmentRepos, and
validateRepoScopedUi replaced setupScriptPromptDismissedRepoIds even
when every entry was already a valid host-identity key.
SetupScriptPromptCard Object.is-subscribes to that array, so a no-op
catalog refresh missed 100% of the time.

Return the original store array when the filtered result is
element-wise identical to the input. Allocate only when an entry is
dropped, rewritten from a legacy generation-v1:repoId key, or deduped.
Call sites already assign the helper result.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change preserves the original setup-script dismissal array when filtering does not alter its contents. Filtering and sanitization now return readonly string arrays. Tests cover unchanged, migrated, stale, and duplicate dismissal entries. Repository refresh tests verify that no-op refreshes retain dismissal array identity.

Mergeability Score: ⚪ Minimal · up to 19e6d

This localized change preserves the existing dismissal-array reference on no-op refreshes, reducing unnecessary UI updates without changing dismissal contents; no actionable merge-blocking risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and testing, but it omits required template sections such as Visual Proof, Checklist, and an explicit Fixes issue reference. Use the repository template sections, add an explicit linked issue such as "Fixes #...", mark Visual Proof as N/A with a reason, and complete the checklist.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: preserving setup-script dismissal array identity during no-op repository fetches.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

Return readonly string[] from filterSetupScriptPromptDismissalsToValidRepos
and sanitizeSetupScriptPromptDismissals, and update the store field type to
readonly. This prevents accidental mutation of the live store array on no-op
prune cycles. Add isUnchangedDismissalList type predicate for identity check.

Co-authored-by: Orca <[email protected]>

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/renderer/src/lib/setup-script-prompt.ts (1)

131-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the identity-preservation comments.

Keep the Object.is subscription rationale, but state it in one line at each site.

  • src/renderer/src/lib/setup-script-prompt.ts#L131-L135: replace the five-line implementation walkthrough with one line that states why unchanged arrays retain identity.
  • src/renderer/src/store/slices/repos-refresh-identity.test.ts#L299-L300: reduce the test rationale to one line.

As per coding guidelines, comments must be concise, non-obvious, and brief; prefer one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68ea2367-c84c-4957-95ff-3113f50e6d51

📥 Commits

Reviewing files that changed from the base of the PR and between 889dd4c and 19e6d3e.

📒 Files selected for processing (4)
  • src/renderer/src/lib/setup-script-prompt.test.ts
  • src/renderer/src/lib/setup-script-prompt.ts
  • src/renderer/src/store/slices/repos-refresh-identity.test.ts
  • src/renderer/src/store/slices/ui.ts

@nwparker
nwparker merged commit bc2df22 into main Aug 13, 2026
87 of 88 checks passed
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.

1 participant