Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions docs/review-remaining-prs-2026-10-12.md

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
39 changes: 31 additions & 8 deletions src/tui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ import {
TerminalOptionsMenu,
UninstallMenu,
UpdateCheckerMenu,
buildMainMenuItems,
getMainMenuInstallSelectionIndex,
getMainMenuSelectionIndex,
type InstallSelection,
type MainMenuOption,
type UninstallSelection,
Expand All @@ -114,6 +116,7 @@ import {
List,
type ListEntry
} from './components/List';
import { PowerlineThemeSelector } from './components/PowerlineThemeSelector';

const GITHUB_REPO_URL = 'https://github.com/sirmalloc/ccstatusline';

Expand All @@ -127,6 +130,7 @@ type AppScreen = 'main'
| 'items'
| 'colorLines'
| 'colors'
| 'theme'
| 'terminalConfig'
| 'globalOverrides'
| 'confirm'
Expand Down Expand Up @@ -970,6 +974,13 @@ export const App: React.FC = () => {

const runningVersion = getPackageVersion();
const { activeGlobalCommand, effectiveInstallation, pinnedRelaunchCommand } = installationState;
// Menu "back" targets resolve the main-menu index from the option itself:
// buildMainMenuItems is conditional (theme entry hidden under powerline,
// save/exit appended when changed), so hardcoded positions drift.
const mainMenuIndex = (option: MainMenuOption): number => getMainMenuSelectionIndex(
buildMainMenuItems(isClaudeInstalled, false, effectiveInstallation, settings.powerline.enabled),
option
);
const pinnedVersionMismatch = pinnedRelaunchCommand
? getPinnedVersionMismatch(
effectiveInstallation,
Expand Down Expand Up @@ -1128,6 +1139,9 @@ export const App: React.FC = () => {
case 'colors':
setScreen('colorLines');
break;
case 'theme':
setScreen('theme');
break;
case 'terminalConfig':
setScreen('terminalConfig');
break;
Expand Down Expand Up @@ -1318,6 +1332,7 @@ export const App: React.FC = () => {
}}
isClaudeInstalled={isClaudeInstalled}
hasChanges={hasChanges}
settings={settings}
initialSelection={menuSelections.main}
onSelectionChange={(index) => { setMenuSelections(prev => ({ ...prev, main: index })); }}
powerlineFontStatus={powerlineFontStatus}
Expand All @@ -1333,9 +1348,8 @@ export const App: React.FC = () => {
}}
onLinesUpdate={updateLines}
onBack={() => {
// Save that we came from 'lines' menu (index 0)
// Clear the line selection so it resets next time we enter
setMenuSelections(prev => ({ ...prev, main: 0 }));
setMenuSelections(prev => ({ ...prev, main: mainMenuIndex('lines') }));
setScreen('main');
}}
initialSelection={menuSelections.lines}
Expand Down Expand Up @@ -1370,8 +1384,7 @@ export const App: React.FC = () => {
setScreen('colors');
}}
onBack={() => {
// Save that we came from 'colors' menu (index 1)
setMenuSelections(prev => ({ ...prev, main: 1 }));
setMenuSelections(prev => ({ ...prev, main: mainMenuIndex('colors') }));
setScreen('main');
}}
initialSelection={menuSelections.lines}
Expand Down Expand Up @@ -1406,8 +1419,7 @@ export const App: React.FC = () => {
setSettings(updatedSettings);
}}
onBack={() => {
// Save that we came from 'terminalConfig' menu (index 3)
setMenuSelections(prev => ({ ...prev, main: 3 }));
setMenuSelections(prev => ({ ...prev, main: mainMenuIndex('terminalConfig') }));
setScreen('main');
}}
/>
Expand All @@ -1419,8 +1431,7 @@ export const App: React.FC = () => {
setSettings(updatedSettings);
}}
onBack={() => {
// Save that we came from 'globalOverrides' menu (index 4)
setMenuSelections(prev => ({ ...prev, main: 4 }));
setMenuSelections(prev => ({ ...prev, main: mainMenuIndex('globalOverrides') }));
setScreen('main');
}}
/>
Expand Down Expand Up @@ -1566,6 +1577,18 @@ export const App: React.FC = () => {
}}
/>
)}
{screen === 'theme' && (
<PowerlineThemeSelector
mode='regular'
settings={settings}
onUpdate={(updatedSettings) => {
setSettings(updatedSettings);
}}
onBack={() => {
setScreen('main');
}}
/>
)}
{screen === 'powerline' && (
<PowerlineSetup
settings={settings}
Expand Down
16 changes: 11 additions & 5 deletions src/tui/__tests__/App.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ describe('Main menu structure', () => {
})).toEqual([
'lines',
'colors',
'theme',
'powerline',
'-',
'terminalConfig',
Expand All @@ -246,6 +247,7 @@ describe('Main menu structure', () => {
expect(getMenuValues(false, false)).toEqual([
'lines',
'colors',
'theme',
'powerline',
'-',
'terminalConfig',
Expand All @@ -272,6 +274,7 @@ describe('Main menu structure', () => {
expect(getMenuValues(true, false, installation)).toEqual([
'lines',
'colors',
'theme',
'powerline',
'-',
'terminalConfig',
Expand Down Expand Up @@ -311,14 +314,14 @@ describe('Main menu structure', () => {
sublabel: '(install first)'
}));
expect(buildManageInstallationItems()[0]).toEqual(expect.objectContaining({ label: '🔄 Check for Updates' }));
expect(getMainMenuInstallSelectionIndex(false)).toBe(7);
expect(getMainMenuInstallSelectionIndex(true, autoInstallation)).toBe(8);
expect(getMainMenuInstallSelectionIndex(true, pinnedInstallation)).toBe(8);
expect(getMainMenuSelectionIndex(buildMainMenuItems(true, false, autoInstallation), 'install')).toBe(8);
expect(getMainMenuInstallSelectionIndex(false)).toBe(8);
expect(getMainMenuInstallSelectionIndex(true, autoInstallation)).toBe(9);
expect(getMainMenuInstallSelectionIndex(true, pinnedInstallation)).toBe(9);
expect(getMainMenuSelectionIndex(buildMainMenuItems(true, false, autoInstallation), 'install')).toBe(9);
expect(getMainMenuSelectionIndex(
buildMainMenuItems(true, false, pinnedInstallation),
'manageInstallation'
)).toBe(8);
)).toBe(9);
});
});

Expand Down Expand Up @@ -412,6 +415,7 @@ describe('App after a global update run from the TUI', () => {

// An unsaved edit: Color Level 256 → Truecolor
await pressKey(rendered, KEYS.down, '▶ 🎨 Edit Colors');
await pressKey(rendered, KEYS.down, '▶ 🌈 Theme');
await pressKey(rendered, KEYS.down, '▶ ⚡ Powerline Setup');
await pressKey(rendered, KEYS.down, '▶ 💻 Terminal Options');
await pressKey(rendered, KEYS.enter, '▶ ▓ Color Level');
Expand Down Expand Up @@ -735,13 +739,15 @@ describe('App save with a widget whose hooks the status line command can\'t run'

// An unsaved edit, so the menu offers Save & Exit: Color Level 256 → Truecolor
await pressKey(rendered, KEYS.down, '▶ 🎨 Edit Colors');
await pressKey(rendered, KEYS.down, '▶ 🌈 Theme');
await pressKey(rendered, KEYS.down, '▶ ⚡ Powerline Setup');
await pressKey(rendered, KEYS.down, '▶ 💻 Terminal Options');
await pressKey(rendered, KEYS.enter, '▶ ▓ Color Level');
await pressKey(rendered, KEYS.enter, '(Truecolor)');
await pressKey(rendered, KEYS.escape, '💾 Save & Exit');

await pressKey(rendered, KEYS.up, '▶ ⚡ Powerline Setup');
await pressKey(rendered, KEYS.up, '▶ 🌈 Theme');
await pressKey(rendered, KEYS.up, '▶ 🎨 Edit Colors');
await pressKey(rendered, KEYS.up, '▶ 📝 Edit Lines');
await pressKey(rendered, KEYS.up, '▶ ⭐ Like ccstatusline?');
Expand Down
23 changes: 19 additions & 4 deletions src/tui/components/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import {
} from 'ink';
import React from 'react';

import type { InstallationMetadata } from '../../types/Settings';
import type {
InstallationMetadata,
Settings
} from '../../types/Settings';
import { type PowerlineFontStatus } from '../../utils/powerline';

import { List } from './List';

export type MainMenuOption = 'lines'
| 'colors'
| 'theme'
| 'powerline'
| 'terminalConfig'
| 'globalOverrides'
Expand All @@ -32,6 +36,7 @@ export interface MainMenuProps {
onSelectionChange?: (index: number) => void;
powerlineFontStatus: PowerlineFontStatus;
installation?: InstallationMetadata;
settings?: Settings;
}

interface MainMenuItem {
Expand Down Expand Up @@ -78,7 +83,8 @@ function getInstallationMenuItem(
export function buildMainMenuItems(
isClaudeInstalled: boolean,
hasChanges: boolean,
installation?: InstallationMetadata
installation?: InstallationMetadata,
powerlineEnabled = false
): MainMenuEntry[] {
const menuItems: MainMenuEntry[] = [
{
Expand All @@ -93,6 +99,14 @@ export function buildMainMenuItems(
description:
'Customize colors for each widget including foreground, background, and bold styling'
},
// Powerline mode has its own theme picker and ignores the regular-mode
// theme, so the entry only makes sense when powerline is off.
...(powerlineEnabled ? [] : [{
label: '🌈 Theme',
value: 'theme' as const,
description:
'Apply a built-in color theme to regular (non-powerline) mode as foreground colors'
}]),
{
label: '⚡ Powerline Setup',
value: 'powerline',
Expand Down Expand Up @@ -211,9 +225,10 @@ export const MainMenu: React.FC<MainMenuProps> = ({
initialSelection = 0,
onSelectionChange,
powerlineFontStatus,
installation
installation,
settings
}) => {
const menuItems = buildMainMenuItems(isClaudeInstalled, hasChanges, installation);
const menuItems = buildMainMenuItems(isClaudeInstalled, hasChanges, installation, settings?.powerline.enabled ?? false);

return (
<Box flexDirection='column'>
Expand Down
42 changes: 29 additions & 13 deletions src/tui/components/PowerlineThemeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function buildPowerlineThemeItems(
const theme = getPowerlineTheme(themeName);

return {
label: theme?.name ?? themeName,
label: theme?.name ?? (themeName === 'none' ? 'None (no theme)' : themeName),
sublabel: themeName === originalTheme ? '(original)' : undefined,
value: themeName,
description: theme?.description ?? ''
Expand Down Expand Up @@ -97,19 +97,31 @@ export function applyCustomPowerlineTheme(
};
}

export type ThemeSelectorMode = 'powerline' | 'regular';

export interface PowerlineThemeSelectorProps {
settings: Settings;
onUpdate: (settings: Settings) => void;
onBack: () => void;
// 'regular' targets the top-level theme applied in non-powerline mode
// (settings.theme); defaults to the powerline theme picker behavior.
mode?: ThemeSelectorMode;
}

export const PowerlineThemeSelector: React.FC<PowerlineThemeSelectorProps> = ({
settings,
onUpdate,
onBack
onBack,
mode = 'powerline'
}) => {
const themes = useMemo(() => getPowerlineThemes(), []);
const currentTheme = settings.powerline.theme ?? 'custom';
const isRegular = mode === 'regular';
const themes = useMemo(
() => (isRegular ? ['none', ...getPowerlineThemes().filter(name => name !== 'custom')] : getPowerlineThemes()),
[isRegular]
);
const currentTheme = isRegular
? settings.theme ?? 'none'
: settings.powerline.theme ?? 'custom';
const [selectedIndex, setSelectedIndex] = useState(Math.max(0, themes.indexOf(currentTheme)));
const [showCustomizeConfirm, setShowCustomizeConfirm] = useState(false);
const originalThemeRef = useRef(currentTheme);
Expand Down Expand Up @@ -137,12 +149,16 @@ export const PowerlineThemeSelector: React.FC<PowerlineThemeSelectorProps> = ({

latestOnUpdateRef.current({
...latestSettingsRef.current,
powerline: {
...latestSettingsRef.current.powerline,
theme: themeName
}
...(isRegular
? { theme: themeName === 'none' ? undefined : themeName }
: {
powerline: {
...latestSettingsRef.current.powerline,
theme: themeName
}
})
});
}, [selectedIndex, themes]);
}, [selectedIndex, themes, isRegular]);

useInput((input, key) => {
const shortcut = getPlainInput(input, key);
Expand All @@ -153,7 +169,7 @@ export const PowerlineThemeSelector: React.FC<PowerlineThemeSelectorProps> = ({
if (key.escape) {
onUpdate(originalSettingsRef.current);
onBack();
} else if (shortcut === 'c' || shortcut === 'C') {
} else if (!isRegular && (shortcut === 'c' || shortcut === 'C')) {
const currentThemeName = themes[selectedIndex];
if (currentThemeName && currentThemeName !== 'custom') {
setShowCustomizeConfirm(true);
Expand Down Expand Up @@ -204,14 +220,14 @@ export const PowerlineThemeSelector: React.FC<PowerlineThemeSelectorProps> = ({
return (
<Box flexDirection='column'>
<Text bold>
{`Powerline Theme Selection | `}
{`${isRegular ? 'Theme Selection (regular mode)' : 'Powerline Theme Selection'} | `}
<Text dimColor>
{`Original: ${originalThemeRef.current}`}
</Text>
</Text>
<Box>
<Text dimColor>
{`↑↓ navigate, Enter apply${selectedThemeName && selectedThemeName !== 'custom' ? ', (c)ustomize theme' : ''}, ESC cancel`}
{`↑↓ navigate, Enter apply${!isRegular && selectedThemeName && selectedThemeName !== 'custom' ? ', (c)ustomize theme' : ''}, ESC cancel`}
</Text>
</Box>

Expand All @@ -231,7 +247,7 @@ export const PowerlineThemeSelector: React.FC<PowerlineThemeSelectorProps> = ({
initialSelection={selectedIndex}
/>

{selectedThemeName && selectedThemeName !== 'custom' && (
{!isRegular && selectedThemeName && selectedThemeName !== 'custom' && (
<Box marginTop={1}>
<Text dimColor>Press (c) to customize this theme - copies colors to widgets</Text>
</Box>
Expand Down
Loading
Loading