Files
orca/src/shared
brennanb2025andOrca 5d1169e368 Merge origin/main into brennanb2025/agent-status-preserve-restart
Resolves the agent-hooks refactor collision from #1678 (shared listener +
relay adapter). The refactor extracted listener internals into
`src/shared/agent-hook-listener.ts` and replaced server.ts's module-level
`lastStatusByPaneKey` Map with `state.lastStatusByPaneKey` on a shared
`HookListenerState`. This branch's persistence layer is re-anchored on the
new shape:

- `AgentStatusIpcPayload` now carries `connectionId: string | null` (from
  main) alongside `receivedAt` / `stateStartedAt` (from this branch).
- `src/main/agent-hooks/server.ts` rewritten as the slim adapter
  (~720 LoC) over the shared listener: defines a server-process-only
  `EnrichedAgentHookEventPayload = AgentHookEventPayload & {receivedAt,
  stateStartedAt}` stored in `state.lastStatusByPaneKey` (the shared module
  never reads this map, so the extra fields ride along untouched), keeps
  `last-status.json` v2 hydrate / sanitize / TTL / atomic-write / drop
  semantics. The new HTTP and `ingestRemote` paths both run through
  `attachStatusTiming` before caching.
- `src/main/index.ts` IPC fanout forwards the union: connectionId +
  receivedAt + stateStartedAt + ...payload.
- `src/preload/{api-types,index}.ts` keep the typed `AgentStatusIpcPayload`
  surface (which now subsumes both branches' fields).
- `src/main/agent-hooks/server.test.ts`: persistence tests preserved as-is;
  ingestRemote tests from main re-laxed from `toHaveBeenCalledWith({...})` to
  `expect.objectContaining({...})` so the listener's enriched payload doesn't
  fail strict equality.

Verified: pnpm tc:node + tc:web clean; 776/776 vitest tests pass across
agent-hooks, shared listener, relay, IPC handler, and renderer agent-status
slice + ui slice. tc:cli has pre-existing TS6307 errors on origin/main that
are not introduced by this merge.

Co-authored-by: Orca <help@stably.ai>
2026-05-11 00:40:49 -07:00
..