Skip to content

Commit 4345438

Browse files
Ivan Zubmeta-codesync[bot]
authored andcommitted
Reset merge conflicts state on repo change to prevent cross-repo blocking
Summary: When ISL is backed by multiple repositories and the user switches between them via the CWD selector, the merge conflicts UI from the previous repo would persist and block the smartlog UI (disabling submit, rebase, split, land buttons, etc.) for the new repo that has no conflicts. Root cause: the \`mergeConflicts\` atom was a plain \`atom\` that was never reset on repo/cwd change. When switching from a repo with conflicts to one without, the server's merge conflict subscription only sends data when conflicts exist, so the stale state was never cleared. Fix: use \`atomResetOnRepoChange\` (new helper) instead of plain \`atom\` for the \`mergeConflicts\` state. This resets the atom to \`undefined\` when the repo root changes, but preserves it when only the subdirectory changes within the same repo (since merge conflicts are repo-scoped, not cwd-scoped). Reviewed By: evangrayk Differential Revision: D99821803 fbshipit-source-id: 0475d3730d7fea4623c0a44629fa0ea00b623edc
1 parent f664d4f commit 4345438

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

addons/isl/src/repositoryData.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ export const repoRootAndCwd = atom<string>(get => `${get(serverCwd)}\n${get(repo
123123
export function atomResetOnCwdChange<T>(defaultValue: T) {
124124
return atomResetOnDepChange(defaultValue, repoRootAndCwd);
125125
}
126+
127+
/** Like `atomResetOnCwdChange`, but only resets when the repo root changes, not subdirectory. */
128+
export function atomResetOnRepoChange<T>(defaultValue: T) {
129+
return atomResetOnDepChange(defaultValue, repoRootAtom);
130+
}

addons/isl/src/serverAPIState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {Dag, DagCommitInfo} from './dag/dag';
4343
import {readInterestingAtoms, serializeAtomsState} from './debug/getInterestingAtoms';
4444
import {atomFamilyWeak, configBackedAtom, readAtom, writeAtom} from './jotaiUtils';
4545
import platform from './platform';
46-
import {atomResetOnCwdChange, repositoryData} from './repositoryData';
46+
import {atomResetOnCwdChange, atomResetOnRepoChange, repositoryData} from './repositoryData';
4747
import {registerCleanup, registerDisposable} from './utils';
4848

4949
export {repositoryData};
@@ -249,7 +249,7 @@ export const uncommittedChangesFetchError = atom(get => {
249249
return get(latestUncommittedChangesData).error;
250250
});
251251

252-
export const mergeConflicts = atom<MergeConflicts | undefined>(undefined);
252+
export const mergeConflicts = atomResetOnRepoChange<MergeConflicts | undefined>(undefined);
253253
registerCleanup(
254254
mergeConflicts,
255255
subscriptionEffect('mergeConflicts', data => {

0 commit comments

Comments
 (0)