Skip to content

Commit 098bed8

Browse files
fix: require complete UNC components in qualifiedFolder (codex r5)
resolve("\\\\") is "C:\\" and resolve("\\\\server") is "C:\\server" — the current drive again, not a UNC device. The UNC alternative now requires nonempty server and share components. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MaT4GH2aCGEmTg6bBPZBeU
1 parent 40378b3 commit 098bed8

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎packages/opencode/src/altimate/workspace/engine-probes.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ export function liveBridge(cwd: string, dir: string = join(homedir(), ".altimate
226226
* paths like "\repo" count as absolute to Node, but resolve() completes them
227227
* with the process's CURRENT drive — so a corrupt entry could match any cwd
228228
* on that drive and defeat the two-bridge decline. Drive-qualified (C:\ or
229-
* C:/) or UNC (\\server\share) only; POSIX keeps plain isAbsolute. The
230-
* platform parameter exists for tests. (codex r4) */
229+
* C:/) or complete UNC only: a UNC value needs nonempty server AND share
230+
* components — resolve("\\\\") is "C:\\" and resolve("\\\\server") is
231+
* "C:\\server", both on the current drive again. POSIX keeps plain
232+
* isAbsolute. The platform parameter exists for tests. (codex r4+r5) */
231233
export function qualifiedFolder(f: string, win: boolean = process.platform === "win32"): boolean {
232234
if (!f) return false
233-
return win ? /^([a-zA-Z]:[\\/]|\\\\)/.test(f) : isAbsolute(f)
235+
return win ? /^([a-zA-Z]:[\\/]|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)/.test(f) : isAbsolute(f)
234236
}
235237

236238
function pidAlive(pid: number): boolean {

‎packages/opencode/test/altimate/workspace/engine-probes.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,14 @@ describe("liveBridge", () => {
116116
expect(qualifiedFolder("C:\\ws", true)).toBe(true)
117117
expect(qualifiedFolder("c:/ws", true)).toBe(true)
118118
expect(qualifiedFolder("\\\\server\\share\\ws", true)).toBe(true)
119+
expect(qualifiedFolder("\\\\server\\share", true)).toBe(true)
119120
expect(qualifiedFolder("\\repo", true)).toBe(false)
120121
expect(qualifiedFolder("\\", true)).toBe(false)
122+
// Incomplete pseudo-UNC: resolve("\\\\") is "C:\\", resolve("\\\\server")
123+
// is "C:\\server" — the current drive again, not a UNC device.
124+
expect(qualifiedFolder("\\\\", true)).toBe(false)
125+
expect(qualifiedFolder("\\\\server", true)).toBe(false)
126+
expect(qualifiedFolder("\\\\server\\", true)).toBe(false)
121127
expect(qualifiedFolder("C:relative", true)).toBe(false)
122128
expect(qualifiedFolder("", true)).toBe(false)
123129
// posix branch

0 commit comments

Comments
 (0)