teamDiscovery.ts
utils/teamDiscovery.ts
No strong subsystem tag
82
Lines
2323
Bytes
3
Exports
3
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 82 lines, 3 detected imports, and 3 detected exports.
Important relationships
Detected exports
TeamSummaryTeammateStatusgetTeammateStatuses
Keywords
memberstatusnamebackendtypeisactiveteamsteammateidletmuxpaneidmode
Detected imports
./swarm/backends/types.js./swarm/teamHelpers.js../utils/format.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
/**
* Team Discovery - Utilities for discovering teams and teammate status
*
* Scans ~/.claude/teams/ to find teams where the current session is the leader.
* Used by the Teams UI in the footer to show team status.
*/
import { isPaneBackend, type PaneBackendType } from './swarm/backends/types.js'
import { readTeamFile } from './swarm/teamHelpers.js'
export type TeamSummary = {
name: string
memberCount: number
runningCount: number
idleCount: number
}
export type TeammateStatus = {
name: string
agentId: string
agentType?: string
model?: string
prompt?: string
status: 'running' | 'idle' | 'unknown'
color?: string
idleSince?: string // ISO timestamp from idle notification
tmuxPaneId: string
cwd: string
worktreePath?: string
isHidden?: boolean // Whether the pane is currently hidden from the swarm view
backendType?: PaneBackendType // The backend type used for this teammate
mode?: string // Current permission mode for this teammate
}
/**
* Get detailed teammate statuses for a team
* Reads isActive from config to determine status
*/
export function getTeammateStatuses(teamName: string): TeammateStatus[] {
const teamFile = readTeamFile(teamName)
if (!teamFile) {
return []
}
const hiddenPaneIds = new Set(teamFile.hiddenPaneIds ?? [])
const statuses: TeammateStatus[] = []
for (const member of teamFile.members) {
// Exclude team-lead from the list
if (member.name === 'team-lead') {
continue
}
// Read isActive from config, defaulting to true (active) if undefined
const isActive = member.isActive !== false
const status: 'running' | 'idle' = isActive ? 'running' : 'idle'
statuses.push({
name: member.name,
agentId: member.agentId,
agentType: member.agentType,
model: member.model,
prompt: member.prompt,
status,
color: member.color,
tmuxPaneId: member.tmuxPaneId,
cwd: member.cwd,
worktreePath: member.worktreePath,
isHidden: hiddenPaneIds.has(member.tmuxPaneId),
backendType:
member.backendType && isPaneBackend(member.backendType)
? member.backendType
: undefined,
mode: member.mode,
})
}
return statuses
}
// Note: For time formatting, use formatRelativeTimeAgo from '../utils/format.js'