Skip to content

Commit 9180639

Browse files
committed
fix(sidebar): keep transient worktree selections stable
Synthetic sidebar worktree rows are transient selections and are not present in the saved repositories list. Repository-store updates were treating those selections as missing and falling back to the previously selected saved repository, which could jump the UI back to an unrelated main repository after selecting a worktree from another repo family. Preserve transient synthetic worktree selections across repository list updates instead of replacing them during selection reconciliation. Validation: - yarn eslint app/src/lib/stores/app-store.ts - yarn compile:prod
1 parent f34dbca commit 9180639

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app/src/lib/stores/app-store.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,20 @@ export class AppStore extends TypedBaseStore<IAppState> {
30333033
r.id === selectedRepository.id
30343034
) || null
30353035

3036-
newSelectedRepository = r
3036+
if (r !== null) {
3037+
newSelectedRepository = r
3038+
} else if (
3039+
selectedRepository instanceof Repository &&
3040+
selectedRepository.id < 0
3041+
) {
3042+
// Synthetic sidebar-only worktree rows are transient selections and
3043+
// won't exist in the saved repositories list. Preserve the current
3044+
// selection across repository store updates instead of falling back to
3045+
// the previously selected saved repository.
3046+
newSelectedRepository = selectedRepository
3047+
} else {
3048+
newSelectedRepository = null
3049+
}
30373050
}
30383051

30393052
if (newSelectedRepository === null && this.repositories.length > 0) {

0 commit comments

Comments
 (0)