feat(FN-1455): thread project scope into subtask session persistence
This commit is contained in:
@@ -6359,12 +6359,14 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
|||||||
|
|
||||||
const scopedStore = await getScopedStore(req);
|
const scopedStore = await getScopedStore(req);
|
||||||
const settings = await scopedStore.getSettings();
|
const settings = await scopedStore.getSettings();
|
||||||
|
const projectId = getProjectIdFromRequest(req);
|
||||||
const { createSubtaskSession } = await import("./subtask-breakdown.js");
|
const { createSubtaskSession } = await import("./subtask-breakdown.js");
|
||||||
const session = await createSubtaskSession(
|
const session = await createSubtaskSession(
|
||||||
description,
|
description,
|
||||||
scopedStore,
|
scopedStore,
|
||||||
scopedStore.getRootDir(),
|
scopedStore.getRootDir(),
|
||||||
settings.promptOverrides,
|
settings.promptOverrides,
|
||||||
|
projectId,
|
||||||
);
|
);
|
||||||
res.status(201).json({ sessionId: session.sessionId });
|
res.status(201).json({ sessionId: session.sessionId });
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export function setAiSessionStore(store: AiSessionStore): void {
|
|||||||
_aiSessionStore.on("ai_session:deleted", _aiSessionDeletedListener);
|
_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>(
|
function safeParseJson<T>(
|
||||||
text: string | null,
|
text: string | null,
|
||||||
@@ -194,7 +194,7 @@ function persistSubtaskSession(session: SubtaskInternalSession, status: "generat
|
|||||||
result: session.subtasks.length > 0 ? JSON.stringify(session.subtasks) : null,
|
result: session.subtasks.length > 0 ? JSON.stringify(session.subtasks) : null,
|
||||||
thinkingOutput: session.thinkingOutput,
|
thinkingOutput: session.thinkingOutput,
|
||||||
error: error ?? session.error ?? null,
|
error: error ?? session.error ?? null,
|
||||||
projectId: null,
|
projectId: session.projectId ?? null,
|
||||||
createdAt: session.createdAt.toISOString(),
|
createdAt: session.createdAt.toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
lockedByTab: null,
|
lockedByTab: null,
|
||||||
@@ -332,10 +332,12 @@ export async function createSubtaskSession(
|
|||||||
_store?: TaskStore,
|
_store?: TaskStore,
|
||||||
rootDir?: string,
|
rootDir?: string,
|
||||||
promptOverrides?: PromptOverrideMap,
|
promptOverrides?: PromptOverrideMap,
|
||||||
|
projectId?: string,
|
||||||
): Promise<SubtaskSession> {
|
): Promise<SubtaskSession> {
|
||||||
const sessionId = randomUUID();
|
const sessionId = randomUUID();
|
||||||
const session = {
|
const session = {
|
||||||
sessionId,
|
sessionId,
|
||||||
|
projectId,
|
||||||
initialDescription,
|
initialDescription,
|
||||||
subtasks: [],
|
subtasks: [],
|
||||||
status: "generating" as const,
|
status: "generating" as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user