Skip to content

Commit 153c3ae

Browse files
committed
feat: update task run status during local session lifecycle
1 parent e1ec517 commit 153c3ae

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

apps/twig/src/renderer/features/sessions/service/service.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const mockAuthStore = vi.hoisted(() => ({
6161
client: {
6262
createTaskRun: vi.fn(),
6363
appendTaskRunLog: vi.fn(),
64+
updateTaskRun: vi.fn().mockResolvedValue(undefined),
6465
},
6566
})),
6667
},
@@ -237,6 +238,7 @@ describe("SessionService", () => {
237238
client: {
238239
createTaskRun: createTaskRunMock,
239240
appendTaskRunLog: vi.fn(),
241+
updateTaskRun: vi.fn().mockResolvedValue(undefined),
240242
},
241243
});
242244

@@ -373,6 +375,7 @@ describe("SessionService", () => {
373375
client: {
374376
createTaskRun: createTaskRunMock,
375377
appendTaskRunLog: vi.fn(),
378+
updateTaskRun: vi.fn().mockResolvedValue(undefined),
376379
},
377380
});
378381
mockTrpcAgent.start.mutate.mockResolvedValue({

apps/twig/src/renderer/features/sessions/service/service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ export class SessionService {
390390
throw new Error("Failed to create task run. Please try again.");
391391
}
392392

393+
// Signal that the local run is now in progress
394+
auth.client
395+
.updateTaskRun(taskId, taskRun.id, { status: "in_progress" })
396+
.catch((err) => log.warn("Failed to update task run status", { err }));
397+
393398
const result = await trpcVanilla.agent.start.mutate({
394399
taskId,
395400
taskRunId: taskRun.id,
@@ -896,6 +901,16 @@ export class SessionService {
896901
promptStartedAt: Date.now(),
897902
});
898903

904+
// Ensure task run status reflects active work
905+
const auth = useAuthStore.getState();
906+
if (auth.client) {
907+
auth.client
908+
.updateTaskRun(session.taskId, session.taskRunId, {
909+
status: "in_progress",
910+
})
911+
.catch((err) => log.warn("Failed to update task run status", { err }));
912+
}
913+
899914
try {
900915
const result = await trpcVanilla.agent.prompt.mutate({
901916
sessionId: session.taskRunId,

0 commit comments

Comments
 (0)