MCPcopy
hub / github.com/codeaashu/claude-code / TeamsDialog

Function TeamsDialog

src/components/teams/TeamsDialog.tsx:48–236  ·  view source on GitHub ↗
({
  initialTeams,
  onDone
}: Props)

Source from the content-addressed store, hash-verified

46 * Dialog for viewing teammates in the current team
47 */
48export function TeamsDialog({
49 initialTeams,
50 onDone
51}: Props): React.ReactNode {
52 // Register as overlay so CancelRequestHandler doesn't intercept escape
53 useRegisterOverlay('teams-dialog');
54
55 // initialTeams is derived from teamContext in PromptInput (no filesystem I/O)
56 const setAppState = useSetAppState();
57
58 // Initialize dialogLevel with first team name if available
59 const firstTeamName = initialTeams?.[0]?.name ?? '';
60 const [dialogLevel, setDialogLevel] = useState<DialogLevel>({
61 type: 'teammateList',
62 teamName: firstTeamName
63 });
64 const [selectedIndex, setSelectedIndex] = useState(0);
65 const [refreshKey, setRefreshKey] = useState(0);
66
67 // initialTeams is now always provided from PromptInput (derived from teamContext)
68 // No filesystem I/O needed here
69
70 const teammateStatuses = useMemo(() => {
71 return getTeammateStatuses(dialogLevel.teamName);
72 // eslint-disable-next-line react-hooks/exhaustive-deps
73 // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
74 }, [dialogLevel.teamName, refreshKey]);
75
76 // Periodically refresh to pick up mode changes from teammates
77 useInterval(() => {
78 setRefreshKey(k => k + 1);
79 }, 1000);
80 const currentTeammate = useMemo(() => {
81 if (dialogLevel.type !== 'teammateDetail') return null;
82 return teammateStatuses.find(t => t.name === dialogLevel.memberName) ?? null;
83 }, [dialogLevel, teammateStatuses]);
84
85 // Get isBypassPermissionsModeAvailable from AppState
86 const isBypassAvailable = useAppState(s => s.toolPermissionContext.isBypassPermissionsModeAvailable);
87 const goBackToList = (): void => {
88 setDialogLevel({
89 type: 'teammateList',
90 teamName: dialogLevel.teamName
91 });
92 setSelectedIndex(0);
93 };
94
95 // Handler for confirm:cycleMode - cycle teammate permission modes
96 const handleCycleMode = useCallback(() => {
97 if (dialogLevel.type === 'teammateDetail' && currentTeammate) {
98 // Detail view: cycle just this teammate
99 cycleTeammateMode(currentTeammate, dialogLevel.teamName, isBypassAvailable);
100 setRefreshKey(k => k + 1);
101 } else if (dialogLevel.type === 'teammateList' && teammateStatuses.length > 0) {
102 // List view: cycle all teammates in tandem
103 cycleAllTeammateModes(teammateStatuses, dialogLevel.teamName, isBypassAvailable);
104 setRefreshKey(k => k + 1);
105 }

Callers

nothing calls this directly

Calls 15

useRegisterOverlayFunction · 0.85
useSetAppStateFunction · 0.85
getTeammateStatusesFunction · 0.85
useIntervalFunction · 0.85
useAppStateFunction · 0.85
cycleTeammateModeFunction · 0.85
cycleAllTeammateModesFunction · 0.85
useKeybindingsFunction · 0.85
useInputFunction · 0.85
getMaxIndexFunction · 0.85
viewTeammateOutputFunction · 0.85
killTeammateFunction · 0.85

Tested by

no test coverage detected