MCPcopy
hub / github.com/claude-code-best/claude-code / maybeGenerateTaskSummary

Function maybeGenerateTaskSummary

src/utils/taskSummary.ts:31–82  ·  view source on GitHub ↗
(
  options: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

29 * Fire-and-forget from query.ts — errors are logged, never thrown.
30 */
31export function maybeGenerateTaskSummary(
32 options: Record<string, unknown>,
33): void {
34 lastSummaryTime = Date.now()
35
36 try {
37 const messages = options.forkContextMessages as
38 | Array<{
39 type: string
40 message?: { content?: unknown }
41 }>
42 | undefined
43
44 if (!messages || messages.length === 0) return
45
46 // Extract a short status from the most recent assistant message
47 let lastAssistant: (typeof messages)[0] | undefined
48 for (let i = messages.length - 1; i >= 0; i--) {
49 if (messages[i]!.type === 'assistant') {
50 lastAssistant = messages[i]
51 break
52 }
53 }
54
55 let status: 'busy' | 'idle' = 'busy'
56 let waitingFor: string | undefined
57
58 if (lastAssistant?.message?.content) {
59 const content = lastAssistant.message.content
60 // Check if last block is tool_use
61 if (Array.isArray(content)) {
62 const lastBlock = content[content.length - 1] as
63 | Record<string, unknown>
64 | undefined
65 if (lastBlock?.type === 'tool_use') {
66 status = 'busy'
67 waitingFor = `tool: ${lastBlock.name || 'unknown'}`
68 }
69 }
70 }
71
72 // Fire-and-forget update to session registry
73 void updateSessionActivity({
74 status,
75 waitingFor,
76 }).catch(err => {
77 logForDebugging(`[taskSummary] updateSessionActivity failed: ${err}`)
78 })
79 } catch (err) {
80 logForDebugging(`[taskSummary] error: ${err}`)
81 }
82}

Callers 1

Calls 3

nowMethod · 0.80
updateSessionActivityFunction · 0.70
logForDebuggingFunction · 0.70

Tested by

no test coverage detected