Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 0 additions & 112 deletions src/main/agent-hooks/server-process-lifetime-status.test.ts

This file was deleted.

34 changes: 7 additions & 27 deletions src/main/agent-hooks/server/server-ingest-terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
connectionId?: string | null
terminalHandle?: string
payload: ParsedAgentStatusPayload
/** `process`: derived from the pane's foreground process rather than parsed from its bytes. */
origin?: 'process'
/** Drop this write when a hook has reported the pane since then (the hook owns that command). */
yieldsToHookSince?: number
}): void {
const physicalPaneKey = event.paneKey.trim()
let paneKey = this.resolvePaneKeyAlias(physicalPaneKey)
Expand Down Expand Up @@ -47,19 +43,9 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
return
}
const tabId = paneKey !== physicalPaneKey ? parsedPaneKey?.tabId : reportedTabId
// Why: a verified process-lifetime Working proves a new agent run, as a hook new-turn event does.
const disposition = this.getAgentStatusDisposition(
paneKey,
event.origin === 'process' && event.payload.state === 'working'
? { processNewTurn: true }
: undefined
)
if (disposition === 'suppress') {
if (this.getAgentStatusDisposition(paneKey) !== 'accept') {
return
}
if (disposition === 'restart') {
this.observations.rebind(paneKey)
}
const worktreeId =
event.worktreeId !== undefined && event.worktreeId.trim().length > 0
? event.worktreeId.trim()
Expand Down Expand Up @@ -96,21 +82,15 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
const previous = this.state.lastStatusByPaneKey.get(paneKey) as
| EnrichedAgentHookEventPayload
| undefined
// Why: a hook that reported during this command owns it (OpenCode 1 `run` loads its plugin in-process).
const hookOwnsCommand =
event.yieldsToHookSince !== undefined &&
previous?.observation?.origin === 'hook' &&
previous.receivedAt >= event.yieldsToHookSince
if (
hookOwnsCommand ||
(previous?.payload.agentType === 'claude' &&
event.payload.agentType === 'claude' &&
isAgentStatusHeldOpenByChildWork(previous.payload) &&
previous.payload.subagents?.some((subagent) => subagent.state === 'working') === true)
previous?.payload.agentType === 'claude' &&
event.payload.agentType === 'claude' &&
isAgentStatusHeldOpenByChildWork(previous.payload) &&
previous.payload.subagents?.some((subagent) => subagent.state === 'working') === true
) {
// Why: OSC carries no child identity, so it cannot settle or repaint a row child agents hold open
// (working, or waiting on a child's prompt); their lifecycle hooks will.
if (previous && mutationBefore !== undefined) {
if (mutationBefore !== undefined) {
this.commitStatusRowMutation(mutationBefore, previous)
this.emitEnrichedStatus(previous)
}
Expand Down Expand Up @@ -175,7 +155,7 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
: event.payload
},
undefined,
event.origin ?? 'osc',
'osc',
undefined,
mutationBefore
)
Expand Down
9 changes: 2 additions & 7 deletions src/main/agent-hooks/server/server-status-disposition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export abstract class AgentHookServerStatusDisposition extends AgentHookServerSt
isReplay?: boolean
hasExplicitPrompt?: boolean
launchToken?: string
/** A process-lifetime Working: a fresh command whose foreground argv proves a new agent run. */
processNewTurn?: boolean
}
): 'accept' | 'restart' | 'suppress' {
const ownerPaneKey = this.resolvePaneKeyAlias(paneKey)
Expand Down Expand Up @@ -96,7 +94,7 @@ export abstract class AgentHookServerStatusDisposition extends AgentHookServerSt
return 'accept'
}
}
if (event && event.processNewTurn !== true && tokenFence) {
if (event && tokenFence) {
const launchToken = event.launchToken?.trim()
if (!launchToken || createHash('sha256').update(launchToken).digest('hex') !== tokenFence) {
return 'suppress'
Expand Down Expand Up @@ -136,10 +134,7 @@ export abstract class AgentHookServerStatusDisposition extends AgentHookServerSt
// Why the token is minted here: a revive proves a live lifecycle, and fencing follow-up
// status on that launch token stops a stale process reclaiming the pane's row without
// restoring retired orchestration authority.
if (
(isNewTurn || freshOpenCodeFamilyPrompt || event?.processNewTurn === true) &&
event?.isReplay !== true
) {
if ((isNewTurn || freshOpenCodeFamilyPrompt) && event?.isReplay !== true) {
this.closedAgentStatusPaneKeys.delete(paneKey)
this.closedAgentStatusPaneKeys.delete(ownerPaneKey)
const launchToken = event?.launchToken?.trim()
Expand Down
97 changes: 0 additions & 97 deletions src/main/opencode/hook-plugin-run-process-session-start.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/main/opencode/status-plugin-factory-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function getStatusPluginFactorySource(options: {
' const info = event.properties?.info;',
' if (!info?.id || info.parentID) return;',
' rememberSessionRoot(info.id, info.id);',
' if (isOpenCodeRunProcess()) return; // a `run` goes Busy at once; its start row only blinks idle',
' await enqueueLifecycle(() =>',
' disposed ? undefined : post("SessionStart", { sessionID: info.id })',
' );',
Expand Down
9 changes: 3 additions & 6 deletions src/main/opencode/status-plugin-runtime-state-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export function getStatusPluginRuntimeStateSource(): string[] {
'let messagePartPostInFlight = null;',
'let deliveredMessagePartFactoryID = null;',
'let lastAssistantPartPostAt = 0;',
...getRunProcessSource()
...getCommandProcessSource()
]
}

// Mirrors isOpenCodeRunCommand (src/shared/opencode-headless-command.ts) over this process's argv.
function getRunProcessSource(): string[] {
// Reads this OpenCode process's subcommand from its argv; only `--log-level` takes a separate value.
function getCommandProcessSource(): string[] {
return String.raw`
function isOpenCodeCommandProcess(command) {
// Why drop a leading path: a compiled binary reports its embedded entry script as argv[1].
Expand All @@ -73,8 +73,5 @@ function isOpenCodeCommandProcess(command) {
if (args[index] === "--log-level") index += 1;
}
return false;
}
function isOpenCodeRunProcess() {
return isOpenCodeCommandProcess("run");
}`.split('\n')
}
Loading
Loading