Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(file-links): "could not check" is never "file not found"
review625136eda83c
diff --git a/CLAUDE.md b/CLAUDE.mdindex d076b44de..944615310 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1375,7 +1375,15 @@ session.agent prints paths relative to where IT runs; the launch cwd wins a tie so a link never changesmeaning when the pane moves. A Cmd/Ctrl+click on a path that exists under neither raises a`File not found: …` toast naming where it looked — the click is swallowed before the async- lookup, so without it the gesture silently did nothing. The path+ lookup, so without it the gesture silently did nothing. **"Could not check" is never "not+ found"**: a lookup has three outcomes (`PathLookup.unverified`, `PathResolution.unverified`), and+ `makeDirListingLookup` treats a REJECTED listing and an EMPTY one as unverified — `FsApi` is+ fail-open (`listDir` ends `catch { return [] }`, and a dead ControlMaster lists `[]`), so only a+ listing WITH entries can prove absence (same rule as `classifyEmptyListing`); `.git` is unverified+ too (both listing legs strip it). A failure is cached as a failure for ~1 s, never as an empty+ directory for the 3 s TTL. An unchecked launch-cwd candidate still lets the live cwd be tried (a+ hit there is proof). The toast then reads `Couldn't check <path>: <reason>` (`fileMissMessage`),+ and the link menu shows `Couldn't check: <reason>` instead of `Not found`. The pathdialect follows the FILESYSTEM-OWNING CORE, not the viewer: desktop-local may use its ownplatform, Server Edition and relay tabs use the core's reported `process.platform`, and SSHprojects are POSIX. A failed host-platform read disables file links for that connection — it@@ -1392,7 +1400,8 @@ session.right PRESS, not on `contextmenu`:** tmux 3.x binds `MouseDown3Pane` to its own `display-menu`, sothe press is what must be swallowed; a right-click OFF a link stays byte-identical (tmux menu,agent TUI, node menu). A path-shaped token that turns out not to exist still gets a menu ("Not- found" + Copy path) — its press was already swallowed, and a silent swallow reads as broken.+ found" + Copy path; "Couldn't check: <reason>" when its existence could not be checked) — its+ press was already swallowed, and a silent swallow reads as broken.Downloads report in a `DownloadStrip` floated over the terminal, not in a drawer that may beshut. The kanban card modal gets URL rows only (no file links there) and no "Open in canvasbrowser" (the node would land under the board).diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 5a4d5b5f6..98f3ff5af 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -49,8 +49,9 @@ import {installLinkContextMenu,cachedCwd,findExistingPath,- missingFileMessage,- makeDirListingLookup+ fileMissMessage,+ makeDirListingLookup,+ type UnverifiedPath} from '../terminal/file-links'import { linkMenuItems, resolveLinkTarget, type LinkMenuTarget } from '../terminal/link-menu'import { ContextMenu } from '../components/ContextMenu'@@ -3129,10 +3130,15 @@ export function TerminalNode({const getCwd = (): string | undefined => (data.cwd as string | undefined) || undefined// The pane's CURRENT directory — the second anchor for a relative path (see CwdSources).const getLiveCwd = cachedCwd(() => api.pty.paneCwd(id))- const onMissingFile = (token: string, tried: string[]): void => {+ // "Couldn't check" when any candidate could not be checked, "File not found" only for a+ // verified absence (`fileMissMessage`).+ const onMissingFile = (+ token: string,+ miss: { tried: string[]; unverified?: UnverifiedPath[] }+ ): void => {window.dispatchEvent(new CustomEvent('nodeterm:toast', {- detail: { kind: 'error', message: missingFileMessage(token, tried) }+ detail: { kind: 'error', message: fileMissMessage(token, miss) }}))}diff --git a/src/renderer/terminal/file-links.live-cwd.test.ts b/src/renderer/terminal/file-links.live-cwd.test.tsindex 38f98a9cd..a0dc341db 100644--- a/src/renderer/terminal/file-links.live-cwd.test.ts+++ b/src/renderer/terminal/file-links.live-cwd.test.ts@@ -70,7 +70,7 @@ describe('findExistingPath', () => {expect(asked).toBe(0)})- it('reads a throwing lookup or live-cwd read as a miss, never a rejection', async () => {+ it('reads a throwing lookup as unchecked (never a verified miss) and a throwing live-cwd read as unknown, never a rejection', async () => {const r = await findExistingPath('a/b',{},@@ -80,7 +80,7 @@ describe('findExistingPath', () => {lookup: () => Promise.reject(new Error('ssh down'))})- expect(r).toEqual({ found: false, tried: ['/one/a/b'] })+ expect(r).toEqual({ found: false, tried: ['/one/a/b'], unverified: [{ abs: '/one/a/b', reason: 'ssh down' }] })})it('uses the Windows dialect for both candidates', async () => {diff --git a/src/renderer/terminal/file-links.ts b/src/renderer/terminal/file-links.tsindex 4000a8f21..8091ea52d 100644--- a/src/renderer/terminal/file-links.ts+++ b/src/renderer/terminal/file-links.ts@@ -294,31 +294,74 @@ export interface CwdSources {getLiveCwd?(): Promise<string | undefined>}-/** Where a path token resolved: an existing entry, or every absolute path that was tried. */+/**+ * What one existence check knows about one absolute path. `exists: false` WITHOUT `unverified` is a+ * verified absence (the parent listed real entries and ours is not among them); WITH it, nothing is+ * known and `unverified` says why. "Could not read" must never be laundered into "nothing there" —+ * a dead ControlMaster is not evidence that a file is gone.+ */+export interface PathLookup {+ exists: boolean+ dir: boolean+ unverified?: string+}++/** A candidate path that could not be checked, and why. */+export interface UnverifiedPath {+ abs: string+ reason: string+}++/** Where a path token resolved: an existing entry, or every absolute path that was tried. A miss+ * carries `unverified` (non-empty) when any candidate could not be checked — then the answer is+ * "unknown", not "missing". Absent means every candidate was a verified absence. */export type PathResolution =| { found: true; abs: string; dir: boolean }- | { found: false; tried: string[] }+ | { found: false; tried: string[]; unverified?: UnverifiedPath[] }++/** The short reason an error carries, for a toast or a menu row. */+function reasonOf(err: unknown): string {+ const msg = err instanceof Error ? err.message : typeof err === 'string' ? err : ''+ return msg.trim() || 'the lookup failed'+}/*** Resolve a path token to an EXISTING file or directory: absolute (and `~/`) tokens are tried as* they are; a relative token against the launch cwd first, then the pane's live cwd. The launch cwd* wins when both hold a match, so a link never changes meaning just because the pane moved. The* live cwd is only asked when the first candidate misses — it is a tmux round trip, and the common- * case never pays it. A lookup that throws counts as a miss.+ * case never pays it.+ *+ * Three outcomes, not two: found, a verified miss, or unknown. A lookup that throws or answers+ * `unverified` records that candidate as UNCHECKED; if nothing is found, the result carries those+ * so the caller says "couldn't check", never "not found".+ *+ * An unchecked launch-cwd candidate still lets the live cwd be tried. A hit there is real evidence+ * (a listing returned the entry), whereas stopping would turn one flaky listing into a dead link for+ * a file we can prove exists. The cost is the tie-break: if the launch cwd ALSO held a same-named+ * file, the one we could not see would have won. Opening a file that provably exists at the path+ * the pane is standing in is the lesser surprise than a toast saying we could not check.*/export async function findExistingPath(token: string,convention: PathConventionOpts,- deps: CwdSources & { lookup(abs: string): Promise<{ exists: boolean; dir: boolean }> }+ deps: CwdSources & { lookup(abs: string): Promise<PathLookup> }): Promise<PathResolution> {const tried: string[] = []+ const unverified: UnverifiedPath[] = []const attempt = async (cwd: string | undefined): Promise<PathResolution | null> => {const abs = resolveFileToken(token, cwd, convention)if (!abs || tried.includes(abs)) return nulltried.push(abs)- const f = await deps.lookup(abs).catch(() => ({ exists: false, dir: false }))- return f.exists ? { found: true, abs, dir: f.dir } : null+ const f: PathLookup = await deps+ .lookup(abs)+ .catch((err: unknown) => ({ exists: false, dir: false, unverified: reasonOf(err) }))+ if (f.exists) return { found: true, abs, dir: f.dir }+ if (f.unverified !== undefined) unverified.push({ abs, reason: f.unverified || 'the lookup failed' })+ return null}+ const miss = (): PathResolution =>+ unverified.length ? { found: false, tried, unverified } : { found: false, tried }const first = await attempt(deps.getCwd())if (first) return firstif (deps.getLiveCwd && !isAnchoredToken(token, convention)) {@@ -328,7 +371,7 @@ export async function findExistingPath(if (second) return second}}- return { found: false, tried }+ return miss()}/** Does the token carry its own root (so no cwd can change where it points)? */@@ -365,7 +408,8 @@ export function cachedCwd(}}-/** The toast text for a Cmd/Ctrl+click on a path that exists nowhere we looked. */+/** The toast text for a Cmd/Ctrl+click on a path that exists nowhere we looked. Only for a+ * VERIFIED miss — see `fileMissMessage`. */export function missingFileMessage(token: string, tried: string[]): string {if (!tried.length) return `File not found: ${token} (no working directory to resolve it against)`return tried.length === 1@@ -373,13 +417,42 @@ export function missingFileMessage(token: string, tried: string[]): string {: `File not found: ${token} — looked in ${tried.join(' and ')}`}+/** The toast text when at least one candidate could not be checked and none was found. It must+ * not claim the file is gone: it names what it could not check and why, and a candidate that WAS+ * a verified miss is mentioned as exactly that. */+export function unverifiableFileMessage(+ token: string,+ tried: string[],+ unverified: UnverifiedPath[]+): string {+ const reasons = [...new Set(unverified.map((u) => u.reason))].join('; ')+ const unchecked = unverified.map((u) => u.abs)+ const missed = tried.filter((t) => !unchecked.includes(t))+ const head =+ unverified.length === 1+ ? `Couldn't check ${unchecked[0]}: ${reasons}`+ : `Couldn't check ${token} at ${unchecked.join(' or ')}: ${reasons}`+ return missed.length ? `${head} (not found at ${missed.join(' or ')})` : head+}++/** The honest sentence for a Cmd/Ctrl+click miss: "couldn't check" when any candidate was+ * unchecked, "not found" only when every one was a verified absence. */+export function fileMissMessage(+ token: string,+ miss: { tried: string[]; unverified?: UnverifiedPath[] }+): string {+ return miss.unverified?.length+ ? unverifiableFileMessage(token, miss.tried, miss.unverified)+ : missingFileMessage(token, miss.tried)+}+export interface FileLinkDeps extends CwdSources {/** Static compatibility option for direct unit consumers. Live terminals use `convention`. */windows?: boolean/** Dynamic host decision. `null` means the owning core's dialect was not observed, so file* links fail closed instead of borrowing the browser's OS. Takes precedence over `windows`. */convention?: () => PathConventionOpts | null- lookup(abs: string): Promise<{ exists: boolean; dir: boolean }>+ lookup(abs: string): Promise<PathLookup>activate(abs: string, dir: boolean): void}@@ -535,20 +608,43 @@ export function createUrlLinkProvider(term: Terminal, openUrl: (url: string) =>}}-/** Existence+dir-ness via cached parent-dir listings (one list covers all siblings). */+/**+ * Existence+dir-ness via cached parent-dir listings (one list covers all siblings).+ *+ * Only a listing that came back WITH entries can prove absence. Two answers cannot, and are+ * reported as `unverified` instead of a miss (the rule `lib/filesNode.ts classifyEmptyListing`+ * states at length):+ * - a `list` that REJECTS (a transport failure, a relay refusal, a dropped bridge);+ * - a listing that is EMPTY. `FsApi` is fail-open by contract — `core/fs-ops.listDir` and+ * `SshFs.listDir` end `catch { return [] }`, and the SSH IPC resolves `[]` for a project whose+ * ControlMaster is down — so `[]` is what a dead master, a permission error or a timeout looks+ * like. It is also what a directory that does not exist looks like; we cannot tell those apart+ * from here, so the answer names the doubt rather than telling the user their file is gone.+ * Plus one shape the listing can never answer: a `.git` entry, which both listing legs strip.+ *+ * A failure is cached as a FAILURE, for `failureTtlMs` (short: it only keeps a hover sweep from+ * re-listing the same dead directory per row) — never as an empty directory for the full TTL, which+ * used to turn one hiccup into three seconds of "not found".+ */export function makeDirListingLookup(list: (dir: string) => Promise<Array<{ name: string; dir: boolean }>>,ttlMs = 3000,- convention: () => PathConventionOpts | null = () => ({})-): (abs: string) => Promise<{ exists: boolean; dir: boolean }> {- const cache = new Map<string, { at: number; entries: Array<{ name: string; dir: boolean }> }>()+ convention: () => PathConventionOpts | null = () => ({}),+ opts: { failureTtlMs?: number; now?: () => number } = {}+): (abs: string) => Promise<PathLookup> {+ const failureTtlMs = opts.failureTtlMs ?? Math.min(1000, ttlMs)+ const now = opts.now ?? Date.now+ type Listing = { at: number; entries: Array<{ name: string; dir: boolean }> } | { at: number; error: string }+ const cache = new Map<string, Listing>()+ const fresh = (l: Listing | undefined): l is Listing =>+ !!l && now() - l.at < ('error' in l ? failureTtlMs : ttlMs)return async (abs) => {- const opts = convention()- if (!opts) return { exists: false, dir: false }+ const conv = convention()+ if (!conv) return { exists: false, dir: false, unverified: 'no filesystem to check it on' }// On POSIX a backslash is legal filename text, not a separator. Only the Windows dialect may// split on it; resolved Windows tokens normally use `/`, but accepting a native path here keeps// this boundary honest if another caller supplies one later.- const i = opts.windows+ const i = conv.windows? Math.max(abs.lastIndexOf('/'), abs.lastIndexOf('\\')): abs.lastIndexOf('/')// `C:/a.ts` splits to a dir of `C:`, which on Windows means "the current directory on drive@@ -561,15 +657,25 @@ export function makeDirListingLookup(? abs.slice(0, i) + separator: abs.slice(0, i)const name = abs.slice(i + 1)- const cacheKey = opts.windows ? dir.toLowerCase() : dir- const hit = cache.get(cacheKey)- const entries =- hit && Date.now() - hit.at < ttlMs ? hit.entries : await list(dir).catch(() => [])- if (!hit || Date.now() - (hit?.at ?? 0) >= ttlMs)- cache.set(cacheKey, { at: Date.now(), entries })- const e = entries.find((x) =>- opts.windows ? x.name.toLowerCase() === name.toLowerCase() : x.name === name- )+ const same = (a: string, b: string): boolean =>+ conv.windows ? a.toLowerCase() === b.toLowerCase() : a === b+ if (same(name, '.git')) return { exists: false, dir: false, unverified: 'directory listings hide .git' }+ const cacheKey = conv.windows ? dir.toLowerCase() : dir+ const cached = cache.get(cacheKey)+ let listing: Listing+ if (fresh(cached)) listing = cached+ else {+ listing = await list(dir).then(+ (entries): Listing =>+ entries.length+ ? { at: now(), entries }+ : { at: now(), error: `nothing listed in ${dir} (it may not exist, or the filesystem is unreachable)` },+ (err: unknown): Listing => ({ at: now(), error: reasonOf(err) })+ )+ cache.set(cacheKey, listing)+ }+ if ('error' in listing) return { exists: false, dir: false, unverified: listing.error }+ const e = listing.entries.find((x) => same(x.name, name))return { exists: !!e, dir: !!e?.dir }}}@@ -648,13 +754,15 @@ export function linkAtCell(}export interface LinkClickDeps extends LinkHitDeps {- lookup(abs: string): Promise<{ exists: boolean; dir: boolean }>+ lookup(abs: string): Promise<PathLookup>activateFile(abs: string, dir: boolean): voidopenUrl(url: string): void- /** A Cmd/Ctrl+click on a path that exists under neither cwd. The click is already swallowed (it+ /** A Cmd/Ctrl+click on a path found under neither cwd. The click is already swallowed (it* must be, before the async lookup), so without this it would do nothing at all — the host says- * where it looked instead. `tried` may be empty (nothing could anchor the token). */- onMissing?(token: string, tried: string[]): void+ * where it looked instead. `tried` may be empty (nothing could anchor the token); `unverified`+ * (non-empty when present) lists candidates that could NOT be checked, in which case the host+ * must not say the file is missing (`fileMissMessage`). */+ onMissing?(token: string, miss: { tried: string[]; unverified?: UnverifiedPath[] }): void}/**@@ -695,7 +803,7 @@ export function installLinkClickFallback(const convention = (deps.convention ? deps.convention() : { windows: deps.windows }) ?? {}void findExistingPath(hit.token, convention, deps).then((r) => {if (r.found) deps.activateFile(r.abs, r.dir)- else deps.onMissing?.(hit.token, r.tried)+ else deps.onMissing?.(hit.token, r)})}host.addEventListener('mouseup', onMouseUp, { capture: true })diff --git a/src/renderer/terminal/file-links.unverifiable.test.ts b/src/renderer/terminal/file-links.unverifiable.test.tsnew file mode 100644index 000000000..802dd4e03--- /dev/null+++ b/src/renderer/terminal/file-links.unverifiable.test.ts@@ -0,0 +1,169 @@+// "Could not check" must never read as "file not found". A dead ControlMaster, a rejected IPC, a+// permission error: none of them is evidence that a path is absent, and the Cmd/Ctrl+click toast+// must not tell the user a file sitting right there is gone.+import { describe, expect, it } from 'vitest'+import {+ fileMissMessage,+ findExistingPath,+ makeDirListingLookup,+ missingFileMessage,+ unverifiableFileMessage,+ type PathLookup+} from './file-links'++type Entry = { name: string; dir: boolean }++describe('makeDirListingLookup — a failed listing is not an empty directory', () => {+ it('answers a throwing list as unverified, not as a verified miss', async () => {+ const lookup = makeDirListingLookup(() => Promise.reject(new Error('ssh: master is dead')))+ const r = await lookup('/proj/src/a.ts')+ expect(r.exists).toBe(false)+ expect(r.unverified).toBe('ssh: master is dead')+ })++ it('does not serve a failure from the cache as an empty directory on the next call', async () => {+ let t = 0+ let calls = 0+ const answers: Array<Entry[] | Error> = [new Error('timeout'), [{ name: 'a.ts', dir: false }]]+ const lookup = makeDirListingLookup(+ async () => {+ const a = answers[calls++]+ if (a instanceof Error) throw a+ return a+ },+ 3000,+ () => ({}),+ { failureTtlMs: 500, now: () => t }+ )+ expect((await lookup('/proj/src/a.ts')).unverified).toBe('timeout')+ // Inside the short failure window the answer is still "could not check" — never `{exists:false}`.+ t = 100+ const again = await lookup('/proj/src/a.ts')+ expect(again.exists).toBe(false)+ expect(again.unverified).toBe('timeout')+ expect(calls).toBe(1)+ // Past it (and well inside the 3 s success TTL) the directory is asked again, and answers.+ t = 600+ expect(await lookup('/proj/src/a.ts')).toEqual({ exists: true, dir: false })+ expect(calls).toBe(2)+ })++ it('reads an EMPTY listing as unverified: FsApi is fail-open, and the parent of a real file is never empty', async () => {+ // `fs-ops.listDir` / `SshFs.listDir` end `catch { return [] }`, and the SSH IPC resolves `[]`+ // for a project whose master is down — so "listed nothing" is the dead-master case.+ const lookup = makeDirListingLookup(async () => [])+ const r = await lookup('/proj/src/a.ts')+ expect(r.exists).toBe(false)+ expect(r.unverified).toMatch(/\/proj\/src/)+ })++ it('still answers a verified miss when the listing has entries and ours is not among them', async () => {+ const lookup = makeDirListingLookup(async () => [{ name: 'b.ts', dir: false }])+ expect(await lookup('/proj/src/a.ts')).toEqual({ exists: false, dir: false })+ })++ it('never claims a `.git` entry is missing — both listing legs strip it', async () => {+ const lookup = makeDirListingLookup(async () => [{ name: 'src', dir: true }])+ const r = await lookup('/proj/.git')+ expect(r.exists).toBe(false)+ expect(r.unverified).toBeTruthy()+ })+})++const fake =+ (answers: Record<string, PathLookup | Error>) =>+ async (abs: string): Promise<PathLookup> => {+ const a = answers[abs]+ if (a instanceof Error) throw a+ return a ?? { exists: false, dir: false }+ }++describe('findExistingPath — three outcomes', () => {+ it('a throwing lookup gives unverifiable, not missing', async () => {+ const r = await findExistingPath(+ 'a/b',+ {},+ { getCwd: () => '/one', lookup: fake({ '/one/a/b': new Error('ssh down') }) }+ )+ expect(r).toEqual({ found: false, tried: ['/one/a/b'], unverified: [{ abs: '/one/a/b', reason: 'ssh down' }] })+ })++ it('carries an unverified lookup answer through', async () => {+ const r = await findExistingPath(+ 'a/b',+ {},+ { getCwd: () => '/one', lookup: fake({ '/one/a/b': { exists: false, dir: false, unverified: 'EACCES' } }) }+ )+ expect(r).toEqual({ found: false, tried: ['/one/a/b'], unverified: [{ abs: '/one/a/b', reason: 'EACCES' }] })+ })++ it('a found live-cwd candidate wins over an unverifiable launch-cwd one', async () => {+ const r = await findExistingPath(+ 'var/x.sql',+ {},+ {+ getCwd: () => '/launch',+ getLiveCwd: async () => '/live',+ lookup: fake({+ '/launch/var/x.sql': new Error('permission denied'),+ '/live/var/x.sql': { exists: true, dir: false }+ })+ }+ )+ expect(r).toEqual({ found: true, abs: '/live/var/x.sql', dir: false })+ })++ it('stays unverifiable when one candidate is a verified miss and the other could not be checked', async () => {+ const r = await findExistingPath(+ 'a/b',+ {},+ {+ getCwd: () => '/one',+ getLiveCwd: async () => '/two',+ lookup: fake({ '/two/a/b': { exists: false, dir: false, unverified: 'timeout' } })+ }+ )+ expect(r).toEqual({ found: false, tried: ['/one/a/b', '/two/a/b'], unverified: [{ abs: '/two/a/b', reason: 'timeout' }] })+ })++ it('a verified miss everywhere carries no `unverified` at all', async () => {+ const r = await findExistingPath('a/b', {}, { getCwd: () => '/one', getLiveCwd: async () => '/two', lookup: fake({}) })+ expect(r).toEqual({ found: false, tried: ['/one/a/b', '/two/a/b'] })+ expect('unverified' in r).toBe(false)+ })+})++describe('the Cmd/Ctrl+click toast', () => {+ it('never says "not found" about a path it could not check', () => {+ expect(unverifiableFileMessage('a/b', ['/one/a/b'], [{ abs: '/one/a/b', reason: 'ssh down' }])).toBe(+ "Couldn't check /one/a/b: ssh down"+ )+ })++ it('names the verified miss beside the unverified one without calling the file gone', () => {+ expect(+ unverifiableFileMessage('a/b', ['/one/a/b', '/two/a/b'], [{ abs: '/two/a/b', reason: 'timeout' }])+ ).toBe("Couldn't check /two/a/b: timeout (not found at /one/a/b)")+ })++ it('lists every unchecked candidate and each distinct reason once', () => {+ expect(+ unverifiableFileMessage(+ 'a/b',+ ['/one/a/b', '/two/a/b'],+ [+ { abs: '/one/a/b', reason: 'ssh down' },+ { abs: '/two/a/b', reason: 'ssh down' }+ ]+ )+ ).toBe("Couldn't check a/b at /one/a/b or /two/a/b: ssh down")+ })++ it('fileMissMessage picks the honest sentence', () => {+ expect(fileMissMessage('a/b', { tried: ['/one/a/b'] })).toBe(missingFileMessage('a/b', ['/one/a/b']))+ expect(fileMissMessage('a/b', { tried: ['/one/a/b'], unverified: [] })).toBe('File not found: /one/a/b')+ expect(fileMissMessage('a/b', { tried: ['/one/a/b'], unverified: [{ abs: '/one/a/b', reason: 'x' }] })).toBe(+ "Couldn't check /one/a/b: x"+ )+ })+})diff --git a/src/renderer/terminal/link-menu.test.ts b/src/renderer/terminal/link-menu.test.tsindex ed4f61203..9c5c6e733 100644--- a/src/renderer/terminal/link-menu.test.ts+++ b/src/renderer/terminal/link-menu.test.ts@@ -191,6 +191,21 @@ describe('linkMenuItems — a path that does not exist', () => {})})+describe('linkMenuItems — a path that could not be checked', () => {+ it('does not claim absence, says why, and still lets the text be copied', () => {+ const { calls, act } = recorder()+ const items = linkMenuItems(+ { kind: 'unverified', abs: '/home/me/proj/x.csv', reason: 'ssh down' },+ LOCAL_DESKTOP,+ act+ )+ expect(labels(items)).toEqual(["Couldn't check: ssh down", 'Copy path'])+ expect(labels(items)).not.toContain('Not found')+ click(items, 'Copy path')+ expect(calls).toEqual(['copy /home/me/proj/x.csv'])+ })+})+describe('relativeInside', () => {it('is the path below the root, or null', () => {expect(relativeInside('/a/b', '/a/b/c/d.ts')).toBe('c/d.ts')@@ -234,10 +249,27 @@ describe('resolveLinkTarget', () => {expect(await resolveLinkTarget({ kind: 'path', token: 'var/x.sql', abs: null }, find)).toEqual({ kind: 'missing', abs: 'var/x.sql' })})- it('reads a failed lookup (dead ControlMaster) as missing, never a throw', async () => {+ it('reads a failed lookup (dead ControlMaster) as unverified, never missing and never a throw', async () => {const boom = async (): Promise<PathResolution> => {throw new Error('ssh down')}- expect(await resolveLinkTarget({ kind: 'path', token: 'x', abs: '/x' }, boom)).toEqual({ kind: 'missing', abs: '/x' })+ expect(await resolveLinkTarget({ kind: 'path', token: 'x', abs: '/x' }, boom)).toEqual({+ kind: 'unverified',+ abs: '/x',+ reason: 'ssh down'+ })+ })++ it('reads a resolution with an unchecked candidate as unverified, naming that candidate', async () => {+ const find = async (): Promise<PathResolution> => ({+ found: false,+ tried: ['/launch/x', '/live/x'],+ unverified: [{ abs: '/live/x', reason: 'timeout' }]+ })+ expect(await resolveLinkTarget({ kind: 'path', token: 'x', abs: '/launch/x' }, find)).toEqual({+ kind: 'unverified',+ abs: '/live/x',+ reason: 'timeout'+ })})})diff --git a/src/renderer/terminal/link-menu.ts b/src/renderer/terminal/link-menu.tsindex 21a9439d9..4eabd2f7f 100644--- a/src/renderer/terminal/link-menu.ts+++ b/src/renderer/terminal/link-menu.ts@@ -21,9 +21,13 @@ import type { LinkHit, PathResolution } from './file-links'export type LinkMenuTarget =| { kind: 'url'; url: string }| { kind: 'file'; abs: string; dir: boolean }- /** Path-shaped text with nothing behind it (or a filesystem we could not reach). The right-click- * was already swallowed, so it still gets a menu — a click that shows nothing reads as broken. */+ /** Path-shaped text with nothing behind it — a VERIFIED absence. The right-click was already+ * swallowed, so it still gets a menu — a click that shows nothing reads as broken. */| { kind: 'missing'; abs: string }+ /** Path-shaped text whose existence could not be checked (a dead ControlMaster, a refused IPC, a+ * timeout). Distinct from `missing` so the menu never tells the user a file is gone when all we+ * know is that we could not look. */+ | { kind: 'unverified'; abs: string; reason: string }export interface LinkMenuContext {/** `downloadRoute` for the filesystem the path lives on. */@@ -68,8 +72,9 @@ export function relativeInside(root: string | undefined, abs: string): string |return path.startsWith(base + '/') && path.length > base.length + 1 ? path.slice(base.length + 1) : null}-/** A hit-test result → a menu target. A lookup that throws (a dead ControlMaster) is `missing`:- * the menu still opens, and the one thing it can honestly offer is the text. */+/** A hit-test result → a menu target. A lookup that throws, or a resolution with an unchecked+ * candidate, is `unverified` (never `missing`): the menu still opens, says it could not check, and+ * offers the one thing it honestly can — the text. */export async function resolveLinkTarget(hit: LinkHit,find: (token: string) => Promise<PathResolution>@@ -78,9 +83,12 @@ export async function resolveLinkTarget(const missing: LinkMenuTarget = { kind: 'missing', abs: hit.abs ?? hit.token }try {const r = await find(hit.token)- return r.found ? { kind: 'file', abs: r.abs, dir: r.dir } : missing- } catch {- return missing+ if (r.found) return { kind: 'file', abs: r.abs, dir: r.dir }+ const u = r.unverified?.[0]+ return u ? { kind: 'unverified', abs: u.abs, reason: u.reason } : missing+ } catch (err) {+ const reason = (err instanceof Error ? err.message : String(err ?? '')).trim() || 'the lookup failed'+ return { kind: 'unverified', abs: hit.abs ?? hit.token, reason }}}@@ -102,9 +110,12 @@ export function linkMenuItems(if (target.kind === 'url') return urlLinkMenuItems(target.url, act)const { abs } = target- if (target.kind === 'missing') {+ if (target.kind === 'missing' || target.kind === 'unverified') {return [- { type: 'label', label: 'Not found' },+ {+ type: 'label',+ label: target.kind === 'missing' ? 'Not found' : `Couldn't check: ${target.reason}`+ },{ label: 'Copy path', onClick: () => act.copy(abs) }]}