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
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import { ipcMain } from 'electron'
|
|
import { agentHookServer, isValidPaneKey } from '../agent-hooks/server'
|
|
import { clearMigrationUnsupportedPtysForPaneKey } from '../agent-hooks/migration-unsupported-pty-state'
|
|
|
|
const MAX_PTY_ID_LENGTH = 512
|
|
|
|
export type AgentPaneAuthorityOwnership = {
|
|
ownsPty: (paneKey: string, ptyId: string) => boolean
|
|
}
|
|
|
|
export function registerAgentPaneAuthorityIpcHandlers(
|
|
ownership: AgentPaneAuthorityOwnership
|
|
): void {
|
|
ipcMain.removeAllListeners('agentStatus:retirePaneAuthority')
|
|
ipcMain.removeAllListeners('agentStatus:restorePaneAuthority')
|
|
ipcMain.removeAllListeners('agentStatus:transferPaneAuthority')
|
|
ipcMain.on('agentStatus:restorePaneAuthority', (_event, paneKey: unknown) => {
|
|
if (typeof paneKey !== 'string' || !isValidPaneKey(paneKey)) {
|
|
return
|
|
}
|
|
try {
|
|
agentHookServer.restorePaneAuthority(paneKey)
|
|
} catch (err) {
|
|
console.warn('[agent-hooks] restorePaneAuthority failed:', err)
|
|
}
|
|
})
|
|
ipcMain.on('agentStatus:retirePaneAuthority', (_event, paneKey: unknown) => {
|
|
if (typeof paneKey !== 'string' || !isValidPaneKey(paneKey)) {
|
|
return
|
|
}
|
|
try {
|
|
agentHookServer.retirePaneAuthority(paneKey)
|
|
clearMigrationUnsupportedPtysForPaneKey(paneKey)
|
|
} catch (err) {
|
|
console.warn('[agent-hooks] retirePaneAuthority failed:', err)
|
|
}
|
|
})
|
|
ipcMain.on('agentStatus:transferPaneAuthority', (_event, value: unknown) => {
|
|
if (!value || typeof value !== 'object') {
|
|
return
|
|
}
|
|
const args = value as Record<string, unknown>
|
|
const ptyId = typeof args.ptyId === 'string' ? args.ptyId : undefined
|
|
if (
|
|
typeof args.fromPaneKey !== 'string' ||
|
|
typeof args.toPaneKey !== 'string' ||
|
|
!isValidPaneKey(args.fromPaneKey) ||
|
|
!isValidPaneKey(args.toPaneKey) ||
|
|
args.fromPaneKey === args.toPaneKey ||
|
|
(args.ptyId !== undefined &&
|
|
(typeof args.ptyId !== 'string' ||
|
|
args.ptyId.length > MAX_PTY_ID_LENGTH ||
|
|
args.ptyId.trim() !== args.ptyId ||
|
|
args.ptyId.length === 0)) ||
|
|
!agentHookServer.canTransferPaneAuthority(args.fromPaneKey, ptyId, ownership.ownsPty)
|
|
) {
|
|
return
|
|
}
|
|
try {
|
|
agentHookServer.transferPaneAuthority(args.fromPaneKey, args.toPaneKey, ptyId)
|
|
} catch (err) {
|
|
console.warn('[agent-hooks] transferPaneAuthority failed:', err)
|
|
}
|
|
})
|
|
}
|