Skip to content

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.

fix(windows): quote dropped/pasted file paths for the Windows shell instead of POSIX-escaping

review15e02dfade3c
diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsx
index 75b17ba87..3965aa278 100644
--- a/src/renderer/components/kanban/CardModal.tsx
+++ b/src/renderer/components/kanban/CardModal.tsx
@@ -52,7 +52,9 @@ import { useSession } from '../../session/session'
// imports from `components/kanban/*`, and none of those re-import CardModal.
import { nodeUploadScope, wakeHibernatedNode } from '../../nodes/TerminalNode'
import { StationFailedChip } from '../StationFailedChip'
-import { droppedPaths } from '../../terminal/file-drop'
+import { dropDialect, droppedPaths } from '../../terminal/file-drop'
+import { hostPlatformFor } from '../../terminal/host-platform'
+import { isWindowsPlatform } from '@shared/platform-utils'
import { requestTerminalFocusOnExit } from '../../terminal/useMdModeFocus'
import type { ProjectKanban } from '@shared/types'
import type { KanbanSession } from './KanbanView'
@@ -141,7 +143,7 @@ interface CardModalProps {
* search / dictate / AI-name / the ⌘M view — ChatPanel or the output markdown, the same face the
* canvas node shows (the node itself is hidden under the board). */
export function CardModal({ session, projectId, projectName, projectColor, columnTitle, board, onChangeBoard, onClose, portsProjectId, onOpenCanvas, onRename, onEditSticky, onBrowserNav, onSetIcon, onOpenIssue, mentionables, team, onTravel, initialView, onSetColor, onDelete, onAiName }: CardModalProps) {
- const { api } = useSession()
+ const { api, source: coreSource } = useSession()
// The header slot decides "icon or smiley" on the NORMALIZED value, the answer NodeIconView
// itself gives — on the raw one, an invalid stored icon drew an empty, un-muted slot.
const sessionIcon = normalizeNodeIcon(session.icon)
@@ -778,10 +780,18 @@ export function CardModal({ session, projectId, projectName, projectColor, colum
agentId={createdAgent!}
// Same resolution as a drop onto this card's live viewer (ModalTerminal):
// an SSH node uploads over the master its PTY runs on.
- pathsForFiles={(files) =>
+ // The composer feeds the agent CLI, so a Windows core gets quoted paths.
+ pathsForFiles={async (files) =>
droppedPaths(files, {
sshRemoteTmux: !!session.spawn.sshRemoteTmux,
- projectId: session.spawn.sshRemoteTmux ? nodeUploadScope(session.spawn.ssh) : ''
+ projectId: session.spawn.sshRemoteTmux ? nodeUploadScope(session.spawn.ssh) : '',
+ dialect: dropDialect({
+ corePlatform: await hostPlatformFor(api),
+ remote: !!session.spawn.sshRemoteTmux || !!session.spawn.ssh,
+ agentPane: true,
+ localDesktop: coreSource === 'local' && !isBrowserRuntime(),
+ viewerWindows: isWindowsPlatform()
+ })
})
}
sshProjectId={session.spawn.sshRemoteTmux ? nodeUploadScope(session.spawn.ssh) : undefined}
diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsx
index a67f1777c..da08e8aeb 100644
--- a/src/renderer/components/kanban/ModalTerminal.tsx
+++ b/src/renderer/components/kanban/ModalTerminal.tsx
@@ -31,7 +31,13 @@ import {
import { useTerminalSearch } from '../../terminal/useTerminalSearch'
import { useTerminalGlass } from '../../lib/useTerminalGlass'
import { LocalTransport } from '../../terminal/local-transport'
-import { clipboardImages, droppedPaths, pasteHasText, pastedFiles } from '../../terminal/file-drop'
+import {
+ clipboardImages,
+ dropDialect,
+ droppedPaths,
+ pasteHasText,
+ pastedFiles
+} from '../../terminal/file-drop'
import { guardMiddleClickPaste } from '../../terminal/middle-click'
import { attachCopyOnSelect } from '../../terminal/copy-on-select'
import {
@@ -666,6 +672,18 @@ export function ModalTerminal({
if (!term || !files.length) return
// Clipboard bytes must be written before they have a path, which is not instant either.
const needsWrite = files.some((f) => !window.nodeTerminal.getPathForFile(f))
+ const st = useAgentStatus.getState().byId[nodeId]
+ const paneAgent = spawn.agentId ?? st?.agentId
+ const agentPane = agentProcessInPane(paneAgent, st)
+ // MIRROR TerminalNode.dropDialectFor: spelled for the core that owns the pane, not this window.
+ const dialect = dropDialect({
+ corePlatform: corePlatformRef.current,
+ remote: !!spawn.sshRemoteTmux || !!spawn.ssh,
+ shell: spawn.shell || useSettings.getState().settings.defaultShell || undefined,
+ agentPane,
+ localDesktop: session.source === 'local' && !isBrowserRuntime(),
+ viewerWindows: isWindowsPlatform()
+ })
let paths: string[]
if (spawn.sshRemoteTmux) {
// Uploads go over the master this card's PTY runs on — its scope, not the project's.
@@ -679,12 +697,12 @@ export function ModalTerminal({
} else if (needsWrite) {
setUploading(true)
try {
- paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '' })
+ paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '', dialect })
} finally {
setUploading(false)
}
} else {
- paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '' })
+ paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '', dialect })
}
if (!paths.length) return
// A drag-drop from another OS app doesn't bring our window forward (esp. macOS), so the
@@ -695,13 +713,11 @@ export function ModalTerminal({
term.focus()
// Same receipt as the canvas node (TerminalNode.insertFiles): attached only once the pane
// shows it.
- const st = useAgentStatus.getState().byId[nodeId]
- const paneAgent = spawn.agentId ?? st?.agentId
pasteWithImageReceipt(
term,
paths.join(' ') + ' ',
paths,
- agentProcessInPane(paneAgent, st) ? paneAgent : undefined,
+ agentPane ? paneAgent : undefined,
pasteReceipt.report
)
}
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 7c4e4ba20..ac45d5a37 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -35,7 +35,14 @@ import { ChatPanelFallback } from './ChatPanelFallback'
// shell has the panel's exact geometry, so a fast load still reads as the panel appearing.
const ChatPanel = lazy(() => import('./ChatPanel').then((m) => ({ default: m.ChatPanel })))
import { LocalTransport } from '../terminal/local-transport'
-import { clipboardImages, droppedPaths, pasteHasText, pastedFiles } from '../terminal/file-drop'
+import {
+ clipboardImages,
+ dropDialect,
+ droppedPaths,
+ pasteHasText,
+ pastedFiles,
+ type DropDialect
+} from '../terminal/file-drop'
import type { TerminalTransport } from '../terminal/transport'
import { guardMiddleClickPaste } from '../terminal/middle-click'
import { attachCopyOnSelect } from '../terminal/copy-on-select'
@@ -5723,6 +5730,18 @@ export function TerminalNode({
}
// Uploads go over the master this node's PTY runs on (`nodeUploadScope`).
const dropProjectId = (): string => nodeUploadScope(data.ssh as SshConnection | undefined)
+ // How a LOCAL path is spelled for this pane: POSIX escapes everywhere except a Windows core,
+ // where `\` is the separator and the shell / agent CLI wants quotes. Same core-platform source
+ // as the file links and the kill line — the filesystem-owning core, never the viewer.
+ const dropDialectFor = (agentPane: boolean): DropDialect =>
+ dropDialect({
+ corePlatform: corePlatformRef.current,
+ remote: remoteSession,
+ shell: data.shell || useSettings.getState().settings.defaultShell || undefined,
+ agentPane,
+ localDesktop: session.source === 'local' && !isBrowserRuntime(),
+ viewerWindows: isWindowsPlatform()
+ })
/**
* Files arriving by DROP or by PASTE become paths in the terminal — what a native terminal does
* on a drop, and the only thing a shell (or an agent reading its prompt) can act on. Shared so
@@ -5736,6 +5755,10 @@ export function TerminalNode({
// one before there is a path to paste — worth the same "this is going somewhere" overlay the
// SSH upload gets, since neither is instant and both paste nothing until they finish.
const needsWrite = files.some((f) => !window.nodeTerminal.getPathForFile(f))
+ const st = agentStatusStore.getState().byId[id]
+ const paneAgent = agentId ?? st?.agentId
+ const agentPane = agentProcessInPane(paneAgent, st)
+ const dialect = dropDialectFor(agentPane)
let paths: string[]
if (data.sshRemoteTmux) {
@@ -5760,7 +5783,7 @@ export function TerminalNode({
if (uploadNoteTimer.current) clearTimeout(uploadNoteTimer.current)
setUploadNote({ text: 'Saving pasted file…' })
try {
- paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '' })
+ paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '', dialect })
} finally {
setUploadNote(null)
}
@@ -5769,7 +5792,7 @@ export function TerminalNode({
uploadNoteTimer.current = setTimeout(() => setUploadNote(null), 2500)
}
} else {
- paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '' })
+ paths = await droppedPaths(files, { sshRemoteTmux: false, projectId: '', dialect })
}
if (!paths.length) return
// Enter the terminal and paste the path(s) like a real drop (trailing space to continue).
@@ -5783,13 +5806,11 @@ export function TerminalNode({
useTerminalFocus.getState().remember(id)
// A pasted image is only reported as attached once the agent's own pane shows it (claude's
// `[Image #N]`); otherwise the receipt says the path went in, unconfirmed.
- const st = agentStatusStore.getState().byId[id]
- const paneAgent = agentId ?? st?.agentId
pasteWithImageReceipt(
term,
paths.join(' ') + ' ',
paths,
- agentProcessInPane(paneAgent, st) ? paneAgent : undefined,
+ agentPane ? paneAgent : undefined,
pasteReceipt.report
)
useAgentStatus.getState().setActive(id, true)
@@ -6843,7 +6864,9 @@ export function TerminalNode({
pathsForFiles={(files) =>
droppedPaths(files, {
sshRemoteTmux: !!data.sshRemoteTmux,
- projectId: data.sshRemoteTmux ? dropProjectId() : ''
+ projectId: data.sshRemoteTmux ? dropProjectId() : '',
+ // The composer feeds the agent CLI, never the shell.
+ dialect: dropDialectFor(true)
})
}
// `@` lists this node's files where they live: the host's for an SSH node, over the
diff --git a/src/renderer/terminal/file-drop.test.ts b/src/renderer/terminal/file-drop.test.ts
index d4dd0c083..2dc3c0562 100644
--- a/src/renderer/terminal/file-drop.test.ts
+++ b/src/renderer/terminal/file-drop.test.ts
@@ -3,10 +3,13 @@ import {
canvasImageFiles,
canvasImageSink,
clipboardImages,
+ dropDialect,
+ droppedPaths,
escapeDroppedPath,
localPathsForFiles,
pasteHasText,
pastedFiles,
+ quoteDroppedPath,
uploadNameFor
} from './file-drop'
@@ -17,6 +20,131 @@ describe('escapeDroppedPath', () => {
})
})
+describe('quoteDroppedPath', () => {
+ const POSIX_CASES = [
+ '/tmp/Bishop Drew order.xlsx',
+ "/tmp/a'b$c",
+ '/Users/me/Screenshot 2026-10-12 at 10.10.10 (1).png',
+ '/tmp/plain.png',
+ 'C:\\Users\\Jane Doe\\x.png'
+ ]
+
+ it('posix (and the default) is byte-identical to escapeDroppedPath', () => {
+ for (const p of POSIX_CASES) {
+ expect(quoteDroppedPath(p, 'posix')).toBe(escapeDroppedPath(p))
+ expect(quoteDroppedPath(p)).toBe(escapeDroppedPath(p))
+ }
+ // Pinned literally, so a change to escapeDroppedPath itself shows up here too.
+ expect(quoteDroppedPath('/Users/me/Screenshot (1).png', 'posix')).toBe('/Users/me/Screenshot\\ \\(1\\).png')
+ })
+
+ it('double-quotes a Windows path with a space, backslashes untouched', () => {
+ const p = 'C:\\Users\\Jane Doe\\Screenshot 2026-10-12 101010.png'
+ for (const d of ['win-cmd', 'win-pwsh'] as const)
+ expect(quoteDroppedPath(p, d)).toBe(`"${p}"`)
+ })
+
+ it('leaves a path with nothing to quote bare, and never doubles a backslash', () => {
+ for (const d of ['win-cmd', 'win-pwsh'] as const) {
+ expect(quoteDroppedPath('C:\\a\\b.png', d)).toBe('C:\\a\\b.png')
+ expect(quoteDroppedPath('C:/a/my_file-1.png', d)).toBe('C:/a/my_file-1.png')
+ }
+ })
+
+ it('quotes parentheses and ampersands', () => {
+ expect(quoteDroppedPath('C:\\a\\shot (1).png', 'win-cmd')).toBe('"C:\\a\\shot (1).png"')
+ expect(quoteDroppedPath('C:\\a&b\\x.png', 'win-pwsh')).toBe('"C:\\a&b\\x.png"')
+ })
+
+ it('pwsh: `$` or a backtick takes single quotes, doubling an embedded quote', () => {
+ expect(quoteDroppedPath("C:\\O'Brien\\$x.png", 'win-pwsh')).toBe("'C:\\O''Brien\\$x.png'")
+ expect(quoteDroppedPath('C:\\a`b\\x.png', 'win-pwsh')).toBe("'C:\\a`b\\x.png'")
+ // A quote alone needs nothing special inside double quotes.
+ expect(quoteDroppedPath("C:\\O'Brien\\x.png", 'win-pwsh')).toBe('"C:\\O\'Brien\\x.png"')
+ })
+
+ it('cmd: `$` is literal, so double quotes are enough', () => {
+ expect(quoteDroppedPath('C:\\a$b\\x.png', 'win-cmd')).toBe('"C:\\a$b\\x.png"')
+ })
+})
+
+describe('dropDialect', () => {
+ const win = { corePlatform: 'win32', remote: false } as const
+
+ it('is posix for every non-Windows core, whatever the shell', () => {
+ for (const corePlatform of ['darwin', 'linux']) {
+ expect(dropDialect({ corePlatform, remote: false, shell: 'pwsh' })).toBe('posix')
+ expect(dropDialect({ corePlatform, remote: false, agentPane: true })).toBe('posix')
+ }
+ })
+
+ it('is posix for a remote (SSH) pane even on a Windows core', () => {
+ expect(dropDialect({ ...win, remote: true, shell: 'pwsh.exe' })).toBe('posix')
+ expect(dropDialect({ ...win, remote: true, agentPane: true })).toBe('posix')
+ })
+
+ it('reads the Windows shell', () => {
+ expect(dropDialect({ ...win, shell: 'pwsh' })).toBe('win-pwsh')
+ expect(dropDialect({ ...win, shell: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe' })).toBe('win-pwsh')
+ expect(dropDialect({ ...win, shell: 'cmd.exe' })).toBe('win-cmd')
+ expect(dropDialect({ ...win, shell: 'C:\\Program Files\\Git\\bin\\bash.exe' })).toBe('posix')
+ })
+
+ it('an unknown shell on Windows reads as cmd (double quotes, which pwsh also accepts)', () => {
+ expect(dropDialect({ ...win })).toBe('win-cmd')
+ expect(dropDialect({ ...win, shell: 'nu' })).toBe('win-cmd')
+ })
+
+ it('an agent pane on Windows is quoted for the CLI, whatever the shell under it', () => {
+ expect(dropDialect({ ...win, shell: 'cmd.exe', agentPane: true })).toBe('win-pwsh')
+ expect(dropDialect({ ...win, shell: 'bash.exe', agentPane: true })).toBe('win-pwsh')
+ })
+
+ it('an unobserved core platform falls back to the viewer ONLY for the local desktop core', () => {
+ expect(dropDialect({ corePlatform: null, remote: false, localDesktop: true, viewerWindows: true })).toBe('win-cmd')
+ // A Windows browser on a Server Edition / relay tab says nothing about the host.
+ expect(dropDialect({ corePlatform: null, remote: false, localDesktop: false, viewerWindows: true })).toBe('posix')
+ expect(dropDialect({ corePlatform: null, remote: false, localDesktop: true, viewerWindows: false })).toBe('posix')
+ })
+})
+
+describe('droppedPaths', () => {
+ afterEach(() => vi.unstubAllGlobals())
+
+ const stub = (local: string, uploaded = '/home/me/.nodeterm/uploads/x/Jane Doe.png') => {
+ const uploadFile = vi.fn(async () => uploaded)
+ vi.stubGlobal('window', {
+ nodeTerminal: {
+ getPathForFile: () => local,
+ files: { saveUpload: vi.fn() },
+ sshProject: { uploadFile }
+ }
+ })
+ return uploadFile
+ }
+ const file = () => new File(['png'], 'Jane Doe.png', { type: 'image/png' })
+
+ it('without a dialect, a local path is POSIX-escaped exactly as before', async () => {
+ stub('/tmp/Jane Doe.png')
+ expect(await droppedPaths([file()], { sshRemoteTmux: false, projectId: '' })).toEqual(['/tmp/Jane\\ Doe.png'])
+ })
+
+ it('spells a local path for the given dialect', async () => {
+ stub('C:\\Users\\Jane Doe\\shot.png')
+ expect(await droppedPaths([file()], { sshRemoteTmux: false, projectId: '', dialect: 'win-cmd' })).toEqual([
+ '"C:\\Users\\Jane Doe\\shot.png"'
+ ])
+ })
+
+ it('the SSH upload branch is always POSIX, whatever dialect is passed', async () => {
+ const uploadFile = stub('C:\\Users\\Jane Doe\\shot.png')
+ expect(await droppedPaths([file()], { sshRemoteTmux: true, projectId: 'p', dialect: 'win-pwsh' })).toEqual([
+ '/home/me/.nodeterm/uploads/x/Jane\\ Doe.png'
+ ])
+ expect(uploadFile).toHaveBeenCalledOnce()
+ })
+})
+
describe('uploadNameFor', () => {
it('keeps the file s own name when it has one', () => {
expect(uploadNameFor(new File(['x'], 'report.pdf', { type: 'application/pdf' }))).toBe(
diff --git a/src/renderer/terminal/file-drop.ts b/src/renderer/terminal/file-drop.ts
index df6a9e317..9678b6682 100644
--- a/src/renderer/terminal/file-drop.ts
+++ b/src/renderer/terminal/file-drop.ts
@@ -7,6 +7,60 @@ export function escapeDroppedPath(p: string): string {
return p.replace(/([ \t"'`\\()&;|<>$!*?[\]{}#~])/g, '\\$1')
}
+/**
+ * How a dropped path is spelled for the program reading the pane.
+ *
+ * - `posix`: backslash-escape (`escapeDroppedPath`) — zsh/bash/fish and the agent CLIs on
+ * macOS/Linux, every SSH host, and Git Bash on Windows. Byte-identical to the pre-dialect output.
+ * - `win-cmd` / `win-pwsh`: a Windows path, where `\` IS the separator and must never be doubled.
+ * Bare when nothing in it needs quoting, else double-quoted — what Windows Terminal and Explorer
+ * write on a drag-drop, and what cmd, PowerShell and the Windows agent CLIs read as one token.
+ * `win-pwsh` single-quotes (doubling `'`) a path holding `$` or a backtick, because PowerShell
+ * expands both inside double quotes. cmd cannot quote `%` at the prompt at all; a `%` filename
+ * is accepted as a known miss (vanishingly rare, and no spelling would fix it).
+ */
+export type DropDialect = 'posix' | 'win-cmd' | 'win-pwsh'
+
+const WIN_BARE = /^[A-Za-z0-9_\-.:\\/]+$/
+
+export function quoteDroppedPath(p: string, dialect: DropDialect = 'posix'): string {
+ if (dialect === 'posix') return escapeDroppedPath(p)
+ if (WIN_BARE.test(p)) return p
+ if (dialect === 'win-pwsh' && /[$`]/.test(p)) return `'${p.replace(/'/g, "''")}'`
+ return `"${p}"`
+}
+
+export interface DropDialectFacts {
+ /** `process.platform` reported by the core that owns the pane; null = not observed (yet). */
+ corePlatform: string | null
+ /** The pane runs on another (POSIX) machine: an SSH project, or a standalone `ssh` node. */
+ remote: boolean
+ /** The node's shell, or the resolved default. Unknown is fine — it reads as cmd's rules. */
+ shell?: string | null
+ /** An agent CLI owns the pane, so the reader is its composer, not the shell. */
+ agentPane?: boolean
+ /** Fallback when `corePlatform` is null — the SAME rule `terminalKillLine` applies: the viewer's
+ * OS stands in only for the desktop's own local core, never for a Server Edition/relay tab. */
+ localDesktop?: boolean
+ viewerWindows?: boolean
+}
+
+/** Which `DropDialect` a pane reads. Anything that is not provably a Windows core is `posix`, so
+ * every macOS/Linux/SSH drop is spelled exactly as before. */
+export function dropDialect(f: DropDialectFacts): DropDialect {
+ if (f.remote) return 'posix'
+ const platform = f.corePlatform ?? (f.localDesktop && f.viewerWindows ? 'win32' : null)
+ if (platform !== 'win32') return 'posix'
+ // Agent composers take a double-quoted path; `$`/backtick get pwsh's single quotes, which the
+ // CLIs read as quoting too.
+ if (f.agentPane) return 'win-pwsh'
+ const exe = (f.shell ?? '').split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/, '') ?? ''
+ if (exe === 'pwsh' || exe === 'powershell') return 'win-pwsh'
+ // Git Bash / MSYS / WSL bash read backslash escapes; `C:\\Users\\Jane\ Doe` is right there.
+ if (exe === 'bash' || exe === 'sh' || exe === 'zsh' || exe === 'fish' || exe === 'wsl') return 'posix'
+ return 'win-cmd'
+}
+
/** Extension for a clipboard blob that arrives with no filename, keyed off its MIME type. A
* screenshot is `image/png` with an empty `name`, and an agent asked to look at `pasted-<ts>`
* with no suffix has to guess what it is holding. */
@@ -185,15 +239,16 @@ export async function localPathsForFiles(files: File[], sink: UploadSink): Promi
/**
* Resolve dropped/pasted files to terminal-pasteable paths. For an SSH-project terminal a local
* path is useless on the host, so each file is uploaded over the project's ControlMaster and its
- * REMOTE absolute path is returned; for a local terminal the local path is used. Fail-open: files
- * that can't be resolved/uploaded are dropped from the result (never throws).
+ * REMOTE absolute path is returned (always POSIX-escaped — the host is POSIX whatever `dialect`
+ * says); for a local terminal the local path is used, spelled for `dialect` (default `posix`).
+ * Fail-open: files that can't be resolved/uploaded are dropped from the result (never throws).
*/
export async function droppedPaths(
files: File[],
- opts: { sshRemoteTmux: boolean; projectId: string }
+ opts: { sshRemoteTmux: boolean; projectId: string; dialect?: DropDialect }
): Promise<string[]> {
const pairs = await localFilesWithPaths(files, uploadsSink)
- if (!opts.sshRemoteTmux) return pairs.map((p) => escapeDroppedPath(p.path))
+ if (!opts.sshRemoteTmux) return pairs.map((p) => quoteDroppedPath(p.path, opts.dialect))
const uploaded = await Promise.all(
pairs.map((p) =>
window.nodeTerminal.sshProject
diff --git a/src/renderer/terminal/image-paste-confirm.test.ts b/src/renderer/terminal/image-paste-confirm.test.ts
index c885adcf3..7322e0af8 100644
--- a/src/renderer/terminal/image-paste-confirm.test.ts
+++ b/src/renderer/terminal/image-paste-confirm.test.ts
@@ -8,7 +8,7 @@ import {
pasteWithImageReceipt,
xtermScreenText
} from './image-paste-confirm'
-import { escapeDroppedPath } from './file-drop'
+import { escapeDroppedPath, quoteDroppedPath } from './file-drop'
// Screens captured from Claude Code 2.1.285 (see the fixture's provenance). `before` is the pane
// after one earlier paste (#12 on screen); `pngAndBmp` after pasting a png and a bmp together;
@@ -23,6 +23,11 @@ describe('expectation: only claude, only the extensions claude turned into [Imag
it('an escaped space still ends in the extension', () => {
expect(expectedImagePlaceholders('claude', [escapeDroppedPath('/a/pasted 2.png')])).toBe(1)
})
+ it('a quoted Windows path still counts (the quotes are not the extension)', () => {
+ expect(expectedImagePlaceholders('claude', [quoteDroppedPath('C:\\Users\\Jane Doe\\shot.png', 'win-cmd')])).toBe(1)
+ expect(expectedImagePlaceholders('claude', [quoteDroppedPath("C:\\a$b\\shot.PNG", 'win-pwsh')])).toBe(1)
+ expect(expectedImagePlaceholders('claude', ['"C:\\a b\\x.bmp"'])).toBe(0)
+ })
it('other agents and no agent get no expectation (nothing is claimed for them)', () => {
for (const a of ['codex', 'gemini', 'grok', 'copilot', 'opencode', undefined])
expect(expectedImagePlaceholders(a, ['/a/x.png'])).toBe(0)
diff --git a/src/renderer/terminal/image-paste-confirm.ts b/src/renderer/terminal/image-paste-confirm.ts
index 3fb161d36..d8704a8d8 100644
--- a/src/renderer/terminal/image-paste-confirm.ts
+++ b/src/renderer/terminal/image-paste-confirm.ts
@@ -15,6 +15,10 @@
// before the paste — never a fixed `#1`;
// - a backslash-escaped space (`pasted\ 2.png`, what `escapeDroppedPath` writes) still attaches.
//
+// Only the backslash-escaped (POSIX) spelling was measured. A Windows pane gets the path quoted
+// instead (`"C:\Users\Jane Doe\shot.png"`, `quoteDroppedPath`), so the extension is read with
+// one pair of surrounding quotes stripped; whether claude on Windows attaches it is a device check.
+//
// So for claude the pane itself says whether the image was taken, and we read it from OUR emulator
// (the xterm buffer), not from tmux — the pane app's output already arrives here. Other agents
// were not measured: they get no receipt either way, exactly as before, and nothing claims success
@@ -31,7 +35,7 @@ export function expectedImagePlaceholders(agentId: string | undefined, paths: st
if (!agentId || capabilityAgentId(agentId) !== 'claude') return 0
let n = 0
for (const p of paths) {
- const m = /\.([A-Za-z0-9]+)$/.exec(p)
+ const m = /\.([A-Za-z0-9]+)$/.exec(p.replace(/^(["'])(.*)\1$/, '$2'))
if (m && (CLAUDE_IMAGE_EXTENSIONS as readonly string[]).includes(m[1].toLowerCase())) n++
}
return n