Repository navigation
fix(store): keep setup-script dismissal array identity on no-op repo fetches - #14211
Conversation
…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]>
📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
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]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/setup-script-prompt.ts (1)
131-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten 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
📒 Files selected for processing (4)
src/renderer/src/lib/setup-script-prompt.test.tssrc/renderer/src/lib/setup-script-prompt.tssrc/renderer/src/store/slices/repos-refresh-identity.test.tssrc/renderer/src/store/slices/ui.ts
Summary
Follow-up to #13744 / #13770 / #13803. Those PRs made
repos/projects/projectHostSetups/filterRepoIdsreferentially stable across a no-op catalog refresh. This sibling field still churned on every fetch:filterSetupScriptPromptDismissalsToValidReposalways didconst next: string[] = []and returned it.fetchRepos,fetchRuntimeEnvironmentRepos, andvalidateRepoScopedUiassign that helper result intoset()even when the catalog is already identity-stable.SetupScriptPromptCardObject.is-subscribes tosetupScriptPromptDismissedRepoIds, 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:repoIdkey togeneration-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():structuredClone/ hydrate rebuilds nested records).reconcileCatalogRows/areValuesEqualkeeprepos/projects/projectHostSetupsstable (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).retainValidFilterRepoIdskeepsfilterRepoIdswhen nothing is pruned (perf(renderer): index the repo catalog compat merge and keep catalog identity #13803).set({ setupScriptPromptDismissedRepoIds: next })replaced the array even when every dismissal was already a valid host-identity key.Fixing 1–3 without 4 leaves
SetupScriptPromptCardre-rendering on every catalog echo. Fixing 4 without 1–3 would still see a newvalidRepoHostIdentitiesset 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 builtnextagainst the store array never matches after a rebuild — same strings, new object. Nested catalog records still cannot be compared by reference after IPCstructuredClone/ hydrate; that is why the earlier PRs useareValuesEqual/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 keystoBe(input); rewrite / drop / dedupe allocate. Existing prune / migrate assertions kept.repos-refresh-identity.test.ts:fetchReposno-op seeded with production-shapedgetSetupScriptPromptDismissalKey(getRepoHostIdentityForParts(...))keys; asserts the store array is the same ref.Verified red then restored: reverting the helper to
return nextfails those three identity assertions and leaves the prune / migrate / allocate tests green.34 passed. Did not run the full suite or typecheck.
Made with Orca
Made with Orca 🐋