Deduplicate repos in loadAll to prevent repeated sessions

Symlinks or multiple entries can resolve to the same repoRoot,
causing duplicate sessions in the returned list.
This commit is contained in:
Chris Wanstrath 2026-03-25 10:26:35 -07:00
parent 9f54ec9d51
commit f50d8eb90e

View File

@ -61,6 +61,7 @@ export interface GlobalSession extends Session {
export async function loadAll(): Promise<GlobalSession[]> {
const sandlotDir = join(homedir(), ".sandlot")
const all: GlobalSession[] = []
const seen = new Set<string>()
let repoDirs
try {
@ -89,7 +90,8 @@ export async function loadAll(): Promise<GlobalSession[]> {
}
}
if (repoRoot) {
if (repoRoot && !seen.has(repoRoot)) {
seen.add(repoRoot)
try {
const st = await load(repoRoot)
for (const session of Object.values(st.sessions)) {