mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* refactor(agent-hooks): one predicate for whether an agent's status hooks are on "Global switch on and this agent not turned off" was spelled out separately in the startup controls, the settings reconcile, the retained-home reconcile, the WSL preflight RPC, the CLI preflight and the OpenCode plugin selection. They now share one function, in a module light enough for the CLI's per-launch Codex preflight to load. The PTY spawn env derives the Codex flag from the switch and opt-out list it already carries, the same way it does for OpenCode and Pi, instead of receiving a second copy. * fix(codex): launch and resume prep honour Codex's per-agent hook opt-out Turning Codex off in the per-agent hook settings removes Orca's Codex hook entry, but launch prep and session resume read only the global hooks switch, so the next Codex launch or resume wrote the entry straight back into the real ~/.codex or the account's home. Both now read the per-agent predicate, which the PTY spawn env and startup already honoured. * fix(codex): turning Codex off per agent clears the real ~/.codex entry While the real-home lane owns ~/.codex/hooks.json, the legacy system-home sweep stands down. That gate read only the global switch, so turning Codex off per agent ran remove() with the sweep still suppressed and left Orca's entry in the real ~/.codex. The gate now reads the per-agent predicate, the same as turning every hook off. * test(codex): cover the system ~/.codex sweep gate for Codex turned off The gate that lets the legacy system-home sweep run was an inline closure in startup, so reverting it to the global switch left CI green. It is now a pure function beside the gate it feeds, with a table test and a remove() test on a seeded ~/.codex: turning Codex off strips Orca's entry and keeps user hooks; with Codex on the entry stays. * fix(cli): keep the agent-status hooks predicate loadable by the packaged CLI The CLI's prepare-codex handler imported the predicate from src/main, but the Electron build rebuilds out/main from its declared entries only, so the packaged `orca agent hooks` commands could not load it (package jobs and the CLI bundle-parity test were red). The predicate reads only settings, so it now lives in src/shared, which the CLI compiles itself.
26 lines
967 B
TypeScript
26 lines
967 B
TypeScript
import type { GlobalSettings } from './global-settings-types'
|
|
import type { TuiAgent } from './tui-agent'
|
|
import { isTuiAgentEnabled } from './tui-agent-selection'
|
|
|
|
export type AgentStatusHooksSettings =
|
|
| Partial<Pick<GlobalSettings, 'agentStatusHooksEnabled' | 'disabledTuiAgents'>>
|
|
| null
|
|
| undefined
|
|
|
|
// Why shared: the CLI compiles shared/ itself, so its per-launch Codex preflight needs no out/main entry.
|
|
export function isAgentStatusHooksEnabled(
|
|
settings: Partial<Pick<GlobalSettings, 'agentStatusHooksEnabled'>> | null | undefined
|
|
): boolean {
|
|
return settings?.agentStatusHooksEnabled !== false
|
|
}
|
|
|
|
// Why: turning an agent off removes its hooks, so any install that reads only the global switch writes them back.
|
|
export function isAgentStatusHooksEnabledForAgent(
|
|
settings: AgentStatusHooksSettings,
|
|
agent: TuiAgent
|
|
): boolean {
|
|
return (
|
|
isAgentStatusHooksEnabled(settings) && isTuiAgentEnabled(agent, settings?.disabledTuiAgents)
|
|
)
|
|
}
|