Files
orca/src/main/ipc/agent-pane-authority-ownership.ts
T
mirror 34fa2cd5ca
Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
source snapshot 2026-09-02
2026-09-02 02:03:16 +08:00

45 lines
1.4 KiB
TypeScript

export type AgentPaneAuthorityOwnershipSources = {
getPtyIdForPaneKey?: (paneKey: string) => string | undefined
getRuntimeTerminalHandleForPaneKey?: (paneKey: string) => string | undefined
}
function getRemoteRuntimeHandle(ptyId: string): string | null {
if (!ptyId.startsWith('remote:')) {
return null
}
const rest = ptyId.slice(7)
const separatorIndex = rest.indexOf('@@')
if (separatorIndex === -1) {
return rest.length > 0 && rest.trim() === rest ? rest : null
}
const encodedOwner = rest.slice(0, separatorIndex)
const encodedHandle = rest.slice(separatorIndex + 2)
if (!encodedOwner || !encodedHandle) {
return null
}
try {
const owner = decodeURIComponent(encodedOwner)
const handle = decodeURIComponent(encodedHandle)
if (!owner || owner.trim() !== owner || !handle || handle.trim() !== handle) {
return null
}
return `remote:${encodeURIComponent(owner)}@@${encodeURIComponent(handle)}` === ptyId
? handle
: null
} catch {
return null
}
}
export function createAgentPaneAuthorityOwnership(
sources: AgentPaneAuthorityOwnershipSources
): (paneKey: string, ptyId: string) => boolean {
return (paneKey, ptyId) => {
if (sources.getPtyIdForPaneKey?.(paneKey) === ptyId) {
return true
}
const runtimeHandle = sources.getRuntimeTerminalHandleForPaneKey?.(paneKey)
return Boolean(runtimeHandle && getRemoteRuntimeHandle(ptyId) === runtimeHandle)
}
}