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

Function useSwarmBanner

src/components/PromptInput/useSwarmBanner.ts:44–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 * - --agent CLI flag: Returns "@agentName" with cyan background
43 */
44export function useSwarmBanner(): SwarmBannerInfo {
45 const teamContext = useAppState(s => s.teamContext)
46 const standaloneAgentContext = useAppState(s => s.standaloneAgentContext)
47 const agent = useAppState(s => s.agent)
48 // Subscribe so the banner updates on enter/exit teammate view even though
49 // getActiveAgentForInput reads it from store.getState().
50 useAppState(s => s.viewingAgentTaskId)
51 const store = useAppStateStore()
52 const [insideTmux, setInsideTmux] = React.useState<boolean | null>(null)
53
54 React.useEffect(() => {
55 void isInsideTmux().then(setInsideTmux)
56 }, [])
57
58 const state = store.getState()
59
60 // Teammate process: show @agentName with assigned color.
61 // In-process teammates run headless — their banner shows in the leader UI instead.
62 if (isTeammate() && !isInProcessTeammate()) {
63 const agentName = getAgentName()
64 if (agentName && getTeamName()) {
65 return {
66 text: `@${agentName}`,
67 bgColor: toThemeColor(
68 teamContext?.selfAgentColor ?? getTeammateColor(),
69 ),
70 }
71 }
72 }
73
74 // Leader with spawned teammates: tmux-attach hint when external, else show
75 // the viewed teammate's name when inside tmux / native panes / in-process.
76 const hasTeammates =
77 teamContext?.teamName &&
78 teamContext.teammates &&
79 Object.keys(teamContext.teammates).length > 0
80 if (hasTeammates) {
81 const viewedTeammate = getViewedTeammateTask(state)
82 const viewedColor = toThemeColor(viewedTeammate?.identity.color)
83 const inProcessMode = isInProcessEnabled()
84 const nativePanes = getCachedDetectionResult()?.isNative ?? false
85
86 if (insideTmux === false && !inProcessMode && !nativePanes) {
87 return {
88 text: `View teammates: \`tmux -L ${getSwarmSocketName()} a\``,
89 bgColor: viewedColor,
90 }
91 }
92 if (
93 (insideTmux === true || inProcessMode || nativePanes) &&
94 viewedTeammate
95 ) {
96 return {
97 text: `@${viewedTeammate.identity.agentName}`,
98 bgColor: viewedColor,
99 }
100 }
101 // insideTmux === null: still loading — fall through.

Callers 1

PromptInputFunction · 0.85

Calls 15

useAppStateFunction · 0.85
useAppStateStoreFunction · 0.85
isTeammateFunction · 0.85
isInProcessTeammateFunction · 0.85
getAgentNameFunction · 0.85
getTeamNameFunction · 0.85
toThemeColorFunction · 0.85
getViewedTeammateTaskFunction · 0.85
isInProcessEnabledFunction · 0.85
getCachedDetectionResultFunction · 0.85
getSwarmSocketNameFunction · 0.85
getActiveAgentForInputFunction · 0.85

Tested by

no test coverage detected