Files
orca/src/main/ipc/session.ts
T
Jinwoo-HandOrca 3412919373 Route mutations by owner host; host header actions; per-host session persistence
- Fix ~30 owner-routing bugs found by call-site audit: SourceControl git
  ops, agent launch/notes, work-item preflight, repo icon, TabBar shell
  capabilities, GitHub project row edits, repo.update preference write
- Per-host splits for repo reorder and worktree sort-order persistence
- Host section headers gain a connection menu (focus, manage, ssh
  reconnect/disconnect, runtime check) and blocked-host update guidance
- Cmd+J palette shows owning-host badges when multiple hosts exist
- Partition persisted workspace session by execution host: host-keyed
  get/set/patch + IPC + preload, runtime-owned entries split to their
  partitions on write and merged on boot; legacy blob stays the local
  partition (zero-copy, idempotent migration)
- Keepalive regression tests pin no-teardown on runtime switch and
  boot-gated worktree purge; host scope documented as filter-only
- Fix host grouping for explicitly runtime-owned repos in All hosts view

Co-authored-by: Orca <help@stably.ai>
2026-06-09 19:25:51 -07:00

39 lines
1.5 KiB
TypeScript

import { ipcMain } from 'electron'
import type { Store } from '../persistence'
import type { WorkspaceSessionPatch, WorkspaceSessionState } from '../../shared/types'
export function registerSessionHandlers(store: Store): void {
// Why: hostId is an optional second arg so an older renderer that invokes
// these channels without it keeps reading/writing the 'local' partition
// exactly as before. Channel names stay stable.
ipcMain.handle('session:get', (_event, hostId?: string | null) => {
return store.getWorkspaceSession(hostId)
})
ipcMain.handle('session:set', (_event, args: WorkspaceSessionState, hostId?: string | null) => {
store.setWorkspaceSession(args, hostId)
})
ipcMain.handle('session:patch', (_event, args: WorkspaceSessionPatch, hostId?: string | null) => {
store.patchWorkspaceSession(args, hostId)
})
// Synchronous variant for the renderer's beforeunload handler.
// sendSync blocks the renderer until this returns, guaranteeing the
// data (including terminal scrollback buffers) is persisted to disk
// before the window closes — regardless of before-quit ordering.
ipcMain.on('session:set-sync', (event, args: WorkspaceSessionState, hostId?: string | null) => {
store.setWorkspaceSession(args, hostId)
store.flush()
event.returnValue = true
})
ipcMain.on(
'session:read-terminal-scrollback-sync',
(event, args: { ref?: unknown } | undefined) => {
event.returnValue =
typeof args?.ref === 'string' ? store.readTerminalScrollbackSnapshot(args.ref) : null
}
)
}