|
|
@@ -3,6 +3,7 @@ import {
|
|
|
BackgroundJobBoard,
|
|
|
type BackgroundJobRecord,
|
|
|
deriveTaskSessionLabel,
|
|
|
+ extractSessionId,
|
|
|
parseTaskIdFromTaskOutput,
|
|
|
parseTaskLaunchOutput,
|
|
|
parseTaskStatusOutput,
|
|
|
@@ -578,8 +579,10 @@ export function createTaskSessionManagerHook(
|
|
|
(input.event.properties as { status?: { type?: string } } | undefined)
|
|
|
?.status?.type === 'idle')
|
|
|
) {
|
|
|
- const sessionId =
|
|
|
- input.event.properties?.info?.id ?? input.event.properties?.sessionID;
|
|
|
+ const sessionId = extractSessionId(
|
|
|
+ input.event.properties?.info,
|
|
|
+ input.event.properties?.sessionID,
|
|
|
+ );
|
|
|
const job = sessionId ? backgroundJobBoard.get(sessionId) : undefined;
|
|
|
log('[task-session-manager] idle/status idle observed', {
|
|
|
sessionID: sessionId,
|
|
|
@@ -631,8 +634,10 @@ export function createTaskSessionManagerHook(
|
|
|
}
|
|
|
|
|
|
if (input.event.type === 'session.error') {
|
|
|
- const sessionId =
|
|
|
- input.event.properties?.info?.id ?? input.event.properties?.sessionID;
|
|
|
+ const sessionId = extractSessionId(
|
|
|
+ input.event.properties?.info,
|
|
|
+ input.event.properties?.sessionID,
|
|
|
+ );
|
|
|
if (sessionId && options.shouldManageSession(sessionId)) {
|
|
|
// Only clear injected terminal jobs for fatal errors.
|
|
|
// Rate-limit errors are recovered by ForegroundFallbackManager
|
|
|
@@ -655,8 +660,10 @@ export function createTaskSessionManagerHook(
|
|
|
(input.event.properties as { status?: { type?: string } } | undefined)
|
|
|
?.status?.type === 'busy'
|
|
|
) {
|
|
|
- const sessionId =
|
|
|
- input.event.properties?.info?.id ?? input.event.properties?.sessionID;
|
|
|
+ const sessionId = extractSessionId(
|
|
|
+ input.event.properties?.info,
|
|
|
+ input.event.properties?.sessionID,
|
|
|
+ );
|
|
|
const before = sessionId
|
|
|
? backgroundJobBoard.get(sessionId)
|
|
|
: undefined;
|
|
|
@@ -689,8 +696,10 @@ export function createTaskSessionManagerHook(
|
|
|
}
|
|
|
|
|
|
if (input.event.type !== 'session.deleted') return;
|
|
|
- const sessionId =
|
|
|
- input.event.properties?.info?.id ?? input.event.properties?.sessionID;
|
|
|
+ const sessionId = extractSessionId(
|
|
|
+ input.event.properties?.info,
|
|
|
+ input.event.properties?.sessionID,
|
|
|
+ );
|
|
|
if (!sessionId) return;
|
|
|
|
|
|
log(
|