Skip to content

Commit 62a6ff9

Browse files
committed
Replace reportActivity with recordActivity using taskRunId directly
1 parent 20a66cb commit 62a6ff9

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

apps/code/src/main/services/agent/schemas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ export const subscribeSessionInput = z.object({
183183
taskRunId: z.string(),
184184
});
185185

186-
// Report activity input — keeps the idle timeout debounce alive for the given task
187-
export const reportActivityInput = z.object({
188-
taskId: z.string().nullable(),
186+
// Record activity input — keeps the idle timeout debounce alive for the given session
187+
export const recordActivityInput = z.object({
188+
taskRunId: z.string(),
189189
});
190190

191191
// Agent events

apps/code/src/main/services/agent/service.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
397397
return false;
398398
}
399399

400-
public reportActivity(taskId: string | null): void {
401-
if (!taskId) return;
402-
for (const session of this.sessions.values()) {
403-
if (session.taskId === taskId) {
404-
this.recordActivity(session.taskRunId);
405-
}
406-
}
407-
}
408-
409-
private recordActivity(taskRunId: string): void {
400+
public recordActivity(taskRunId: string): void {
410401
const existing = this.idleTimeoutHandles.get(taskRunId);
411402
if (existing) clearTimeout(existing);
412403

apps/code/src/main/trpc/routers/agent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
promptInput,
1515
promptOutput,
1616
reconnectSessionInput,
17-
reportActivityInput,
17+
recordActivityInput,
1818
respondToPermissionInput,
1919
sessionResponseSchema,
2020
setConfigOptionInput,
@@ -184,9 +184,9 @@ export const agentRouter = router({
184184
log.info("All sessions reset successfully");
185185
}),
186186

187-
reportActivity: publicProcedure
188-
.input(reportActivityInput)
189-
.mutation(({ input }) => getService().reportActivity(input.taskId)),
187+
recordActivity: publicProcedure
188+
.input(recordActivityInput)
189+
.mutation(({ input }) => getService().recordActivity(input.taskRunId)),
190190

191191
onSessionIdleKilled: publicProcedure.subscription(async function* (opts) {
192192
const service = getService();

apps/code/src/renderer/features/task-detail/components/TaskLogsPanel.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
133133
}, [taskId, requestFocus]);
134134

135135
useEffect(() => {
136-
trpcClient.agent.reportActivity.mutate({ taskId }).catch(() => {});
136+
const taskRunId = session?.taskRunId;
137+
if (!taskRunId) return;
138+
trpcClient.agent.recordActivity.mutate({ taskRunId }).catch(() => {});
137139
const heartbeat = setInterval(
138140
() => {
139-
trpcClient.agent.reportActivity.mutate({ taskId }).catch(() => {});
141+
trpcClient.agent.recordActivity.mutate({ taskRunId }).catch(() => {});
140142
},
141143
5 * 60 * 1000,
142144
);
143145
return () => clearInterval(heartbeat);
144-
}, [taskId]);
146+
}, [session?.taskRunId]);
145147

146148
// Keep cloud session title aligned with latest task metadata.
147149
useEffect(() => {

0 commit comments

Comments
 (0)