fix(run): preserve active boulder continuations
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getPlanProgress, readBoulderState, resolveBoulderPlanPath } from "../../features/boulder-state"
|
||||
import { getPlanProgress, normalizeSessionId, readBoulderState, resolveBoulderPlanPath } from "../../features/boulder-state"
|
||||
import { getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import {
|
||||
getActiveContinuationMarkerReason,
|
||||
@@ -51,19 +51,25 @@ async function hasActiveBoulderContinuation(
|
||||
if (progress.isComplete) return false
|
||||
if (!client) return false
|
||||
|
||||
const isTrackedSession = boulder.session_ids.includes(sessionID)
|
||||
const sessionOrigin = boulder.session_origins?.[sessionID]
|
||||
if (!isTrackedSession) {
|
||||
const normalizedSessionID = normalizeSessionId(sessionID)
|
||||
const normalizedTrackedSessionIDs = boulder.session_ids.map((trackedSessionID) => normalizeSessionId(trackedSessionID))
|
||||
if (!normalizedTrackedSessionIDs.includes(normalizedSessionID)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const isTrackedDescendant = await isTrackedDescendantSession(client, sessionID, boulder.session_ids)
|
||||
|
||||
if (isTrackedSession && sessionOrigin === "direct") {
|
||||
const sessionOrigin = boulder.session_origins?.[sessionID] ?? boulder.session_origins?.[normalizedSessionID]
|
||||
if (sessionOrigin === "direct") {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isTrackedSession && sessionOrigin !== "direct" && !isTrackedDescendant) {
|
||||
const trackedAncestorSessionIDs = normalizedTrackedSessionIDs
|
||||
.filter((trackedSessionID) => trackedSessionID !== normalizedSessionID)
|
||||
if (trackedAncestorSessionIDs.length === 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
const isTrackedDescendant = await isTrackedDescendantSession(client, sessionID, trackedAncestorSessionIDs)
|
||||
if (!isTrackedDescendant) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -82,23 +88,22 @@ async function hasActiveBoulderContinuation(
|
||||
return false
|
||||
}
|
||||
|
||||
return isTrackedSession || isTrackedDescendant
|
||||
return true
|
||||
}
|
||||
|
||||
async function isTrackedDescendantSession(
|
||||
client: RunContext["client"],
|
||||
sessionID: string,
|
||||
trackedSessionIDs: string[],
|
||||
trackedAncestorSessionIDs: string[],
|
||||
): Promise<boolean> {
|
||||
const ancestorSessionIDs = trackedSessionIDs.filter((trackedSessionID) => trackedSessionID !== sessionID)
|
||||
if (ancestorSessionIDs.length === 0) {
|
||||
if (trackedAncestorSessionIDs.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isSessionInBoulderLineage({
|
||||
client,
|
||||
sessionID,
|
||||
boulderSessionIDs: ancestorSessionIDs,
|
||||
boulderSessionIDs: trackedAncestorSessionIDs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user