({
initialTeams,
onDone
}: Props)
| 46 | * Dialog for viewing teammates in the current team |
| 47 | */ |
| 48 | export 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 | } |
nothing calls this directly
no test coverage detected