feat(FN-1455): thread project scope into subtask session persistence

This commit is contained in:
gsxdsm
2026-04-11 19:50:19 -07:00
parent 98bf55c356
commit b2dc6ee90d
2 changed files with 6 additions and 2 deletions

View File

@@ -6359,12 +6359,14 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
const scopedStore = await getScopedStore(req);
const settings = await scopedStore.getSettings();
const projectId = getProjectIdFromRequest(req);
const { createSubtaskSession } = await import("./subtask-breakdown.js");
const session = await createSubtaskSession(
description,
scopedStore,
scopedStore.getRootDir(),
settings.promptOverrides,
projectId,
);
res.status(201).json({ sessionId: session.sessionId });
} catch (err: any) {

View File

@@ -69,7 +69,7 @@ export function setAiSessionStore(store: AiSessionStore): void {
_aiSessionStore.on("ai_session:deleted", _aiSessionDeletedListener);
}
type SubtaskInternalSession = SubtaskSession & { updatedAt: Date; agent?: any; thinkingOutput: string };
type SubtaskInternalSession = SubtaskSession & { updatedAt: Date; agent?: any; thinkingOutput: string; projectId?: string };
function safeParseJson<T>(
text: string | null,
@@ -194,7 +194,7 @@ function persistSubtaskSession(session: SubtaskInternalSession, status: "generat
result: session.subtasks.length > 0 ? JSON.stringify(session.subtasks) : null,
thinkingOutput: session.thinkingOutput,
error: error ?? session.error ?? null,
projectId: null,
projectId: session.projectId ?? null,
createdAt: session.createdAt.toISOString(),
updatedAt: new Date().toISOString(),
lockedByTab: null,
@@ -332,10 +332,12 @@ export async function createSubtaskSession(
_store?: TaskStore,
rootDir?: string,
promptOverrides?: PromptOverrideMap,
projectId?: string,
): Promise<SubtaskSession> {
const sessionId = randomUUID();
const session = {
sessionId,
projectId,
initialDescription,
subtasks: [],
status: "generating" as const,