fix(agent-hooks): skip unavailable agent homes (#11442)
* fix(agent-hooks): skip unavailable agent homes * refactor(agent-hooks): separate Pi and OMP home fix * test(agent-hooks): update merged protocol harnesses * fix(agent-hooks): avoid redundant reconciliation * fix(agent-hooks): harden reconciliation and detection * test(agent-hooks): cover settings reconciliation * fix(agent-hooks): hydrate PATH for paired clients
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
} from '../runtime-client'
|
||||
import type { AgentHookInstallStatus } from '../../shared/agent-hook-types'
|
||||
import { getDefaultPersistedState } from '../../shared/constants'
|
||||
import type { PersistedState } from '../../shared/types'
|
||||
import type { GlobalSettings, PersistedState } from '../../shared/types'
|
||||
import {
|
||||
applyAgentStatusHooksEnabled,
|
||||
getManagedAgentHookStatuses
|
||||
@@ -75,7 +75,10 @@ function readEnabledFromDisk(): boolean {
|
||||
return state.settings?.agentStatusHooksEnabled !== false
|
||||
}
|
||||
|
||||
function updateEnabledOnDisk(enabled: boolean): string {
|
||||
function updateEnabledOnDisk(enabled: boolean): {
|
||||
settingsPath: string
|
||||
settings: Pick<GlobalSettings, 'agentCmdOverrides' | 'disabledTuiAgents'>
|
||||
} {
|
||||
const dataPath = getDataPath()
|
||||
const state = readPersistedState(dataPath)
|
||||
state.settings = {
|
||||
@@ -84,7 +87,13 @@ function updateEnabledOnDisk(enabled: boolean): string {
|
||||
agentStatusHooksEnabled: enabled
|
||||
}
|
||||
writePersistedState(dataPath, state)
|
||||
return dataPath
|
||||
return {
|
||||
settingsPath: dataPath,
|
||||
settings: {
|
||||
agentCmdOverrides: state.settings.agentCmdOverrides ?? {},
|
||||
disabledTuiAgents: state.settings.disabledTuiAgents ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRunningRuntime(client: RuntimeClient, enabled: boolean): Promise<boolean> {
|
||||
@@ -134,10 +143,11 @@ async function setAgentHooksEnabled(
|
||||
enabled: boolean
|
||||
): Promise<AgentHookCommandResult> {
|
||||
const updatedRuntime = await updateRunningRuntime(client, enabled)
|
||||
const settingsPath = updatedRuntime ? getDataPath() : updateEnabledOnDisk(enabled)
|
||||
const offlineUpdate = updatedRuntime ? null : updateEnabledOnDisk(enabled)
|
||||
const settingsPath = offlineUpdate?.settingsPath ?? getDataPath()
|
||||
const statuses = updatedRuntime
|
||||
? getManagedAgentHookStatuses()
|
||||
: applyAgentStatusHooksEnabled(enabled)
|
||||
: await applyAgentStatusHooksEnabled(enabled, offlineUpdate?.settings)
|
||||
return {
|
||||
enabled,
|
||||
settingsPath,
|
||||
|
||||
Reference in New Issue
Block a user