fix(hooks): guard stale idle prompts
This commit is contained in:
@@ -5,12 +5,18 @@ import {
|
||||
} from "../../features/claude-code-session-state"
|
||||
import { log } from "../../shared/logger"
|
||||
import { createInternalAgentContinuationTextPart, resolveInheritedPromptTools } from "../../shared"
|
||||
import { isSessionActive } from "../shared/session-idle-settle"
|
||||
import { HOOK_NAME } from "./hook-name"
|
||||
import { BOULDER_CONTINUATION_PROMPT } from "./system-reminder-templates"
|
||||
import { resolveRecentPromptContextForSession } from "./recent-model-resolver"
|
||||
import type { BackgroundTaskStatusProvider, SessionState } from "./types"
|
||||
|
||||
export type BoulderContinuationResult = "injected" | "skipped_background_tasks" | "skipped_agent_unavailable" | "failed"
|
||||
export type BoulderContinuationResult =
|
||||
| "injected"
|
||||
| "skipped_active_session"
|
||||
| "skipped_background_tasks"
|
||||
| "skipped_agent_unavailable"
|
||||
| "failed"
|
||||
|
||||
const ACTIVE_BACKGROUND_TASK_STATUSES = new Set(["pending", "running"])
|
||||
|
||||
@@ -68,11 +74,16 @@ export async function injectBoulderContinuation(input: {
|
||||
sessionID,
|
||||
agent: continuationAgent ?? agent ?? "unknown",
|
||||
})
|
||||
return "skipped_agent_unavailable"
|
||||
}
|
||||
return "skipped_agent_unavailable"
|
||||
}
|
||||
|
||||
try {
|
||||
log(`[${HOOK_NAME}] Injecting boulder continuation`, { sessionID, planName, remaining })
|
||||
try {
|
||||
if (await isSessionActive(ctx.client, sessionID)) {
|
||||
log(`[${HOOK_NAME}] Skipped injection: session is active`, { sessionID })
|
||||
return "skipped_active_session"
|
||||
}
|
||||
|
||||
log(`[${HOOK_NAME}] Injecting boulder continuation`, { sessionID, planName, remaining })
|
||||
|
||||
const promptContext = await resolveRecentPromptContextForSession(ctx, sessionID)
|
||||
const inheritedTools = resolveInheritedPromptTools(sessionID, promptContext.tools)
|
||||
|
||||
Reference in New Issue
Block a user