Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/providers/ssh-git-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ describe('SshGitProvider', () => {
cwd: '/home/user/repo',
stdin: null,
timeoutMs: 60_000,
operation: 'commit-message'
operation: 'commit-message',
shell: true
})
expect(result).toEqual(execResult)
})
Expand Down Expand Up @@ -473,15 +474,17 @@ describe('SshGitProvider', () => {
cwd: '/home/user/repo',
stdin: null,
timeoutMs: 60_000,
operation: 'commit-message'
operation: 'commit-message',
shell: true
})
expect(mux.request).toHaveBeenNthCalledWith(2, 'agent.execNonInteractive', {
binary: 'codex',
args: ['exec', 'PROMPT'],
cwd: '/home/user/repo',
stdin: null,
timeoutMs: 60_000,
operation: 'pull-request-fields'
operation: 'pull-request-fields',
shell: true
})

await provider.cancelGenerateCommitMessage('/home/user/repo')
Expand Down
6 changes: 5 additions & 1 deletion src/main/providers/ssh-git-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ export class SshGitProvider implements IGitProvider {
cwd,
stdin: plan.stdinPayload,
timeoutMs,
operation
operation,
// Why: commit/PR agents on SSH hosts are often installed by shell
// startup files, so this path allows relay-side shell PATH fallback.
shell: true
},
undefined,
operation
Expand Down Expand Up @@ -296,6 +299,7 @@ export class SshGitProvider implements IGitProvider {
timeoutMs: number
env?: Record<string, string>
operation?: string
shell?: boolean
},
signal?: AbortSignal,
operation?: string
Expand Down
25 changes: 23 additions & 2 deletions src/relay/agent-exec-handler-test-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,34 @@ import { vi } from 'vitest'
import type { MethodHandler, RequestContext } from './dispatcher'
import { AgentExecHandler } from './agent-exec-handler'

function hasFinally(value: unknown): value is Promise<unknown> {
return (
typeof value === 'object' &&
value !== null &&
'finally' in value &&
typeof value.finally === 'function'
)
}

export function withPlatform<T>(platform: NodeJS.Platform, fn: () => T): T {
const original = process.platform
Object.defineProperty(process, 'platform', { configurable: true, value: platform })
let restoreImmediately = true
const restore = (): void => {
Object.defineProperty(process, 'platform', { configurable: true, value: original })
}
try {
return fn()
const result = fn()
if (hasFinally(result)) {
restoreImmediately = false
return result.finally(restore) as T
}
restore()
return result
} finally {
Object.defineProperty(process, 'platform', { configurable: true, value: original })
if (restoreImmediately && process.platform === platform) {
restore()
}
}
}

Expand Down
Loading
Loading