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

Function getPillLabel

src/tasks/pillLabel.ts:10–67  ·  view source on GitHub ↗
(tasks: BackgroundTaskState[])

Source from the content-addressed store, hash-verified

8 * two surfaces agree on terminology.
9 */
10export function getPillLabel(tasks: BackgroundTaskState[]): string {
11 const n = tasks.length
12 const allSameType = tasks.every(t => t.type === tasks[0]!.type)
13
14 if (allSameType) {
15 switch (tasks[0]!.type) {
16 case 'local_bash': {
17 const monitors = count(
18 tasks,
19 t => t.type === 'local_bash' && t.kind === 'monitor',
20 )
21 const shells = n - monitors
22 const parts: string[] = []
23 if (shells > 0)
24 parts.push(shells === 1 ? '1 shell' : `${shells} shells`)
25 if (monitors > 0)
26 parts.push(monitors === 1 ? '1 monitor' : `${monitors} monitors`)
27 return parts.join(', ')
28 }
29 case 'in_process_teammate': {
30 const teamCount = new Set(
31 tasks.map(t =>
32 t.type === 'in_process_teammate' ? t.identity.teamName : '',
33 ),
34 ).size
35 return teamCount === 1 ? '1 team' : `${teamCount} teams`
36 }
37 case 'local_agent':
38 return n === 1 ? '1 local agent' : `${n} local agents`
39 case 'remote_agent': {
40 const first = tasks[0]!
41 // Per design mockup: ◇ open diamond while running/needs-input,
42 // ◆ filled once ExitPlanMode is awaiting approval.
43 if (n === 1 && first.type === 'remote_agent' && first.isUltraplan) {
44 switch (first.ultraplanPhase) {
45 case 'plan_ready':
46 return `${DIAMOND_FILLED} ultraplan ready`
47 case 'needs_input':
48 return `${DIAMOND_OPEN} ultraplan needs your input`
49 default:
50 return `${DIAMOND_OPEN} ultraplan`
51 }
52 }
53 return n === 1
54 ? `${DIAMOND_OPEN} 1 cloud session`
55 : `${DIAMOND_OPEN} ${n} cloud sessions`
56 }
57 case 'local_workflow':
58 return n === 1 ? '1 background workflow' : `${n} background workflows`
59 case 'monitor_mcp':
60 return n === 1 ? '1 monitor' : `${n} monitors`
61 case 'dream':
62 return 'dreaming'
63 }
64 }
65
66 return `${n} background ${n === 1 ? 'task' : 'tasks'}`
67}

Callers 2

TurnDurationMessageFunction · 0.85
BackgroundTaskStatusFunction · 0.85

Calls 2

countFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected