/**
* @fileoverview TabBar component
*
* Horizontal tab bar for session navigation in the TUI.
*
* @description
* Provides browser-like tab navigation for Claude sessions:
* - Active tab highlighted with blue background
* - Status indicators: green dot (alive) or red dot (dead)
* - Session names truncated to 15 characters
* - Keyboard shortcut hints on the right
*
* Tab switching is handled by parent via keyboard shortcuts (Ctrl+Tab).
*/
import React from 'react';
import { Box, Text } from 'ink';
import type { ScreenSession } from '../../types.js';
interface TabBarProps {
sessions: ScreenSession[];
activeSessionId: string | null;
onSelectSession: (sessionId: string) => void;
}
/**
* Tab bar component showing all available sessions.
*
* @description
* Renders a horizontal bar with one tab per session, showing:
* - Status indicator (filled/hollow circle for alive/dead)
* - Session name (truncated to 15 chars)
* - Visual highlighting for the active session
*
* @param props - Component props
* @param props.sessions - Array of all sessions to display as tabs
* @param props.activeSessionId - ID of currently active session for highlighting
* @param props.onSelectSession - Callback when a tab is clicked (unused, keyboard nav only)
* @returns The tab bar element
*/
export function TabBar({
sessions,
activeSessionId,
}: TabBarProps): React.ReactElement {
if (sessions.length === 0) {
return (
No sessions
);
}
return (
{sessions.map((session, index) => {
const isActive = session.sessionId === activeSessionId;
const name = (session.name || 'unnamed').slice(0, 15);
// Status indicator: filled circle for alive, hollow for dead
const statusIcon = session.attached ? '\u25CF' : '\u25CB';
const statusColor = session.attached ? 'green' : 'red';
return (
{isActive ? (
{' '}
{statusIcon} {name}{' '}
) : (
{' '}
{statusIcon}{' '}
{name}{' '}
)}
{index < sessions.length - 1 && |}
);
})}
{/* Shortcut hint */}
Ctrl+Tab: switch | Ctrl+W: close
);
}