wip(foundry): capture remaining local changes

This commit is contained in:
Nathan Flurry 2026-03-15 10:23:56 -07:00
parent 6f85b59f31
commit 40bed3b0a1
6 changed files with 25 additions and 43 deletions

View file

@ -32,7 +32,6 @@ CREATE TABLE \`task_index\` (
--> statement-breakpoint
CREATE TABLE \`tasks\` (
\`task_id\` text PRIMARY KEY NOT NULL,
\`repo_id\` text NOT NULL,
\`title\` text NOT NULL,
\`status\` text NOT NULL,
\`repo_name\` text NOT NULL,

View file

@ -41,19 +41,3 @@ export const tasks = sqliteTable("tasks", {
pullRequestJson: text("pull_request_json"),
sessionsSummaryJson: text("sessions_summary_json").notNull().default("[]"),
});
/**
* Materialized task summary projection owned by the repository coordinator.
* Task actors push updates here; organization reads fan in through repositories.
*/
export const tasks = sqliteTable("tasks", {
taskId: text("task_id").notNull().primaryKey(),
repoId: text("repo_id").notNull(),
title: text("title").notNull(),
status: text("status").notNull(),
repoName: text("repo_name").notNull(),
updatedAtMs: integer("updated_at_ms").notNull(),
branch: text("branch"),
pullRequestJson: text("pull_request_json"),
sessionsSummaryJson: text("sessions_summary_json").notNull().default("[]"),
});

View file

@ -57,6 +57,7 @@ interface TaskActionCommand {
interface TaskSessionCommand {
sessionId: string;
authSessionId?: string;
}
interface TaskStatusSyncCommand {

View file

@ -113,7 +113,7 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
},
"task.command.workspace.mark_unread": async (loopCtx, msg) => {
await loopCtx.step("workspace-mark-unread", async () => markWorkspaceUnread(loopCtx));
await loopCtx.step("workspace-mark-unread", async () => markWorkspaceUnread(loopCtx, msg.body?.authSessionId));
await msg.complete({ ok: true });
},
@ -127,7 +127,7 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
const created = await loopCtx.step({
name: "workspace-create-session",
timeout: 5 * 60_000,
run: async () => createWorkspaceSession(loopCtx, msg.body?.model),
run: async () => createWorkspaceSession(loopCtx, msg.body?.model, msg.body?.authSessionId),
});
await msg.complete(created);
} catch (error) {
@ -140,12 +140,12 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
const created = await loopCtx.step({
name: "workspace-create-session-for-send",
timeout: 5 * 60_000,
run: async () => createWorkspaceSession(loopCtx, msg.body?.model),
run: async () => createWorkspaceSession(loopCtx, msg.body?.model, msg.body?.authSessionId),
});
await loopCtx.step({
name: "workspace-send-initial-message",
timeout: 5 * 60_000,
run: async () => sendWorkspaceMessage(loopCtx, created.sessionId, msg.body.text, []),
run: async () => sendWorkspaceMessage(loopCtx, created.sessionId, msg.body.text, [], msg.body?.authSessionId),
});
} catch (error) {
logActorWarning("task.workflow", "create_session_and_send failed", {
@ -159,7 +159,7 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
await loopCtx.step({
name: "workspace-ensure-session",
timeout: 5 * 60_000,
run: async () => ensureWorkspaceSession(loopCtx, msg.body.sessionId, msg.body?.model),
run: async () => ensureWorkspaceSession(loopCtx, msg.body.sessionId, msg.body?.model, msg.body?.authSessionId),
});
await msg.complete({ ok: true });
},
@ -170,12 +170,16 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
},
"task.command.workspace.set_session_unread": async (loopCtx, msg) => {
await loopCtx.step("workspace-set-session-unread", async () => setWorkspaceSessionUnread(loopCtx, msg.body.sessionId, msg.body.unread));
await loopCtx.step("workspace-set-session-unread", async () =>
setWorkspaceSessionUnread(loopCtx, msg.body.sessionId, msg.body.unread, msg.body?.authSessionId),
);
await msg.complete({ ok: true });
},
"task.command.workspace.update_draft": async (loopCtx, msg) => {
await loopCtx.step("workspace-update-draft", async () => updateWorkspaceDraft(loopCtx, msg.body.sessionId, msg.body.text, msg.body.attachments));
await loopCtx.step("workspace-update-draft", async () =>
updateWorkspaceDraft(loopCtx, msg.body.sessionId, msg.body.text, msg.body.attachments, msg.body?.authSessionId),
);
await msg.complete({ ok: true });
},
@ -189,7 +193,7 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
await loopCtx.step({
name: "workspace-send-message",
timeout: 10 * 60_000,
run: async () => sendWorkspaceMessage(loopCtx, msg.body.sessionId, msg.body.text, msg.body.attachments),
run: async () => sendWorkspaceMessage(loopCtx, msg.body.sessionId, msg.body.text, msg.body.attachments, msg.body?.authSessionId),
});
await msg.complete({ ok: true });
} catch (error) {
@ -233,7 +237,7 @@ const commandHandlers: Record<TaskQueueName, WorkflowHandler> = {
await loopCtx.step({
name: "workspace-close-session",
timeout: 5 * 60_000,
run: async () => closeWorkspaceSession(loopCtx, msg.body.sessionId),
run: async () => closeWorkspaceSession(loopCtx, msg.body.sessionId, msg.body?.authSessionId),
});
await msg.complete({ ok: true });
},

View file

@ -1328,14 +1328,6 @@ export async function publishWorkspacePr(c: any): Promise<void> {
githubToken: auth?.githubToken ?? null,
baseBranch: metadata.defaultBranch ?? undefined,
});
await c.db
.update(taskTable)
.set({
prSubmitted: 1,
updatedAt: Date.now(),
})
.where(eq(taskTable.id, 1))
.run();
await broadcastTaskUpdate(c);
}

View file

@ -104,15 +104,16 @@ export interface WorkspaceParsedDiffLine {
export interface WorkspacePullRequestSummary {
number: number;
title: string;
state: string;
url: string;
headRefName: string;
baseRefName: string;
repoFullName: string;
authorLogin: string | null;
isDraft: boolean;
updatedAtMs: number;
status: "draft" | "ready";
title?: string;
state?: string;
url?: string;
headRefName?: string;
baseRefName?: string;
repoFullName?: string;
authorLogin?: string | null;
isDraft?: boolean;
updatedAtMs?: number;
}
export interface WorkspaceSandboxSummary {
@ -241,6 +242,7 @@ export interface TaskWorkspaceRenameInput {
repoId: string;
taskId: string;
value: string;
authSessionId?: string;
}
export interface TaskWorkspaceSendMessageInput {