mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 08:03:39 +00:00
- Add a terminal action to create a top-level workspace fork with captured agent context - Pre-mark local and SSH agent trust before launching forked Codex/Cursor/Copilot sessions - Use remote/Linux startup behavior for SSH and WSL forks, with Windows draft size fallback - Cover fork prompt cleanup, launch behavior, remote trust writes, and dialog busy-state tests
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import { ipcMain } from 'electron'
|
|
import {
|
|
type AgentTrustPreset,
|
|
markCodexProjectTrusted,
|
|
markCopilotFolderTrusted,
|
|
markCursorWorkspaceTrusted
|
|
} from '../agent-trust-presets'
|
|
import { markRemoteAgentWorkspaceTrusted } from '../remote-agent-trust-presets'
|
|
|
|
/**
|
|
* Why: cursor-agent, GitHub Copilot CLI, and Codex gate first-launch in an
|
|
* unfamiliar directory behind a "Do you trust this folder?" menu that consumes
|
|
* keystrokes (numbered options / single-letter shortcuts). Orca's draft-URL
|
|
* paste flow needs the input box, not the menu, so before Orca spawns the
|
|
* agent it asks main to write the same trust artifacts the agents write
|
|
* after the user accepts. Best-effort: any IO error is swallowed so a failed
|
|
* trust write never blocks the workspace from opening.
|
|
*/
|
|
export function registerAgentTrustHandlers(): void {
|
|
ipcMain.removeHandler('agentTrust:markTrusted')
|
|
ipcMain.handle(
|
|
'agentTrust:markTrusted',
|
|
async (
|
|
_event,
|
|
args: { preset: AgentTrustPreset; workspacePath: string; connectionId?: string }
|
|
): Promise<void> => {
|
|
if (!args || typeof args.workspacePath !== 'string' || !args.workspacePath) {
|
|
return
|
|
}
|
|
try {
|
|
const connectionId = typeof args.connectionId === 'string' ? args.connectionId.trim() : ''
|
|
if (connectionId) {
|
|
// Why: SSH-launched agents read trust artifacts from the remote
|
|
// user's home, not from this desktop process.
|
|
await markRemoteAgentWorkspaceTrusted({
|
|
preset: args.preset,
|
|
connectionId,
|
|
workspacePath: args.workspacePath
|
|
})
|
|
} else if (args.preset === 'cursor') {
|
|
markCursorWorkspaceTrusted(args.workspacePath)
|
|
} else if (args.preset === 'copilot') {
|
|
markCopilotFolderTrusted(args.workspacePath)
|
|
} else if (args.preset === 'codex') {
|
|
markCodexProjectTrusted(args.workspacePath)
|
|
}
|
|
} catch {
|
|
// Best-effort: see Why above. The user can still accept the trust
|
|
// prompt manually if writing the artifact fails.
|
|
}
|
|
}
|
|
)
|
|
}
|