MCPcopy Index your code
hub / github.com/codeaashu/claude-code / updateAgentSummary

Function updateAgentSummary

src/tasks/LocalAgentTask/LocalAgentTask.tsx:359–407  ·  view source on GitHub ↗
(taskId: string, summary: string, setAppState: SetAppState)

Source from the content-addressed store, hash-verified

357 * Called by the periodic summarization service to store a 1-2 sentence progress summary.
358 */
359export function updateAgentSummary(taskId: string, summary: string, setAppState: SetAppState): void {
360 let captured: {
361 tokenCount: number;
362 toolUseCount: number;
363 startTime: number;
364 toolUseId: string | undefined;
365 } | null = null;
366 updateTaskState<LocalAgentTaskState>(taskId, setAppState, task => {
367 if (task.status !== 'running') {
368 return task;
369 }
370 captured = {
371 tokenCount: task.progress?.tokenCount ?? 0,
372 toolUseCount: task.progress?.toolUseCount ?? 0,
373 startTime: task.startTime,
374 toolUseId: task.toolUseId
375 };
376 return {
377 ...task,
378 progress: {
379 ...task.progress,
380 toolUseCount: task.progress?.toolUseCount ?? 0,
381 tokenCount: task.progress?.tokenCount ?? 0,
382 summary
383 }
384 };
385 });
386
387 // Emit summary to SDK consumers (e.g. VS Code subagent panel). No-op in TUI.
388 // Gate on the SDK option so coordinator-mode sessions without the flag don't
389 // leak summary events to consumers who didn't opt in.
390 if (captured && getSdkAgentProgressSummariesEnabled()) {
391 const {
392 tokenCount,
393 toolUseCount,
394 startTime,
395 toolUseId
396 } = captured;
397 emitTaskProgress({
398 taskId,
399 toolUseId,
400 description: summary,
401 startTime,
402 totalTokens: tokenCount,
403 toolUses: toolUseCount,
404 summary
405 });
406 }
407}
408
409/**
410 * Complete an agent task with result.

Callers 1

runSummaryFunction · 0.85

Calls 3

updateTaskStateFunction · 0.50
emitTaskProgressFunction · 0.50

Tested by

no test coverage detected