Skip to content
Draft
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
5 changes: 3 additions & 2 deletions src/cli/commands/deploy/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ANSI } from '../../constants';
import { getErrorMessage } from '../../errors';
import { ensureDefaultDeploymentTarget } from '../../operations/deploy';
import { canSkipDeploy } from '../../operations/deploy/change-detection';
import { symbols } from '../../tui/utils/symbols';
import { handleDeploy } from './actions';

export const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
Expand Down Expand Up @@ -34,9 +35,9 @@ export function createSpinnerProgress(): SpinnerProgress {
process.stdout.write(`\r${SPINNER_FRAMES[i]} ${step}...`);
}, 80);
} else if (status === 'success') {
console.log(` ${step}`);
console.log(`${symbols.success} ${step}`);
} else {
console.log(` ${step}`);
console.log(`${symbols.failure} ${step}`);
}
};

Expand Down
13 changes: 8 additions & 5 deletions src/cli/tui/components/AwsTargetConfigUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AgentCoreRegion as _AgentCoreRegion } from '../../../schema';
import { useListNavigation } from '../hooks';
import type { AwsConfigPhase, AwsTargetConfigState } from '../hooks/useAwsTargetConfig';
import { INTERACTIVE_COLORS } from '../theme';
import { symbols } from '../utils';
import { Cursor } from './Cursor';
import { SelectList } from './SelectList';
import { TextInput } from './TextInput';
Expand Down Expand Up @@ -153,10 +154,10 @@ export function AwsTargetConfigUI({ config, onExit, isActive }: AwsTargetConfigU
<Box marginTop={1} flexDirection="column">
<Box>
<Text color={focusedRow === 0 ? INTERACTIVE_COLORS.selection : undefined}>
{focusedRow === 0 ? '❯ ' : ' '}
{focusedRow === 0 ? `${symbols.cursor} ` : ' '}
</Text>
<Text bold color={focusedRow === 0 ? INTERACTIVE_COLORS.selection : 'cyan'}>
All Targets
{symbols.pointer} All Targets
</Text>
<Text dimColor> — Deploy to all {config.availableTargets.length} targets</Text>
</Box>
Expand All @@ -172,8 +173,10 @@ export function AwsTargetConfigUI({ config, onExit, isActive }: AwsTargetConfigU
const isFocused = focusedRow === i + 1;
return (
<Box key={i}>
<Text color={isFocused ? INTERACTIVE_COLORS.selection : undefined}>{isFocused ? '❯ ' : ' '}</Text>
<Text color={isChecked ? 'green' : 'gray'}>{isChecked ? '[✓]' : '[ ]'}</Text>
<Text color={isFocused ? INTERACTIVE_COLORS.selection : undefined}>
{isFocused ? `${symbols.cursor} ` : ' '}
</Text>
<Text color={isChecked ? 'green' : 'gray'}>{isChecked ? symbols.checkboxOn : symbols.checkboxOff}</Text>
<Text color={isFocused ? INTERACTIVE_COLORS.selection : undefined}> {target.name}</Text>
<Text dimColor>
{' '}
Expand Down Expand Up @@ -222,7 +225,7 @@ export function AwsTargetConfigUI({ config, onExit, isActive }: AwsTargetConfigU
) : (
filteredRegions.map((region, i) => (
<Text key={region} color={i === regionIndex ? INTERACTIVE_COLORS.selection : undefined}>
{i === regionIndex ? '❯' : ' '} {region}
{i === regionIndex ? symbols.cursor : ' '} {region}
</Text>
))
)}
Expand Down
19 changes: 15 additions & 4 deletions src/cli/tui/components/MultiSelectList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { symbols } from '../utils';
import type { SelectableItem } from './SelectList';
import { Box, Text } from 'ink';

Expand Down Expand Up @@ -39,24 +40,34 @@ export function MultiSelectList<T extends SelectableItem>(props: MultiSelectList

return (
<Box flexDirection="column">
{needsScroll && viewportStart > 0 && <Text dimColor> ↑ {viewportStart} more</Text>}
{needsScroll && viewportStart > 0 && (
<Text dimColor>
{' '}
{symbols.arrowUp} {viewportStart} more
</Text>
)}
{visibleItems.map((item, idx) => {
const actualIndex = viewportStart + idx;
const isCursor = actualIndex === selectedIndex;
const isChecked = selectedIds.has(item.id);
const checkbox = isChecked ? '[✓]' : '[ ]';
const checkbox = isChecked ? symbols.checkboxOn : symbols.checkboxOff;
return (
<Box key={item.id}>
<Text wrap="truncate">
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? '❯' : ' '} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? symbols.cursor : ' '} </Text>
<Text color={isChecked ? 'green' : undefined}>{checkbox} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{item.title}</Text>
{item.description && <Text dimColor> - {item.description}</Text>}
</Text>
</Box>
);
})}
{needsScroll && viewportEnd < items.length && <Text dimColor> ↓ {items.length - viewportEnd} more</Text>}
{needsScroll && viewportEnd < items.length && (
<Text dimColor>
{' '}
{symbols.arrowDown} {items.length - viewportEnd} more
</Text>
)}
</Box>
);
}
17 changes: 14 additions & 3 deletions src/cli/tui/components/SelectList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { symbols } from '../utils';
import { Box, Text } from 'ink';

export interface SelectableItem {
Expand Down Expand Up @@ -45,7 +46,12 @@ export function SelectList<T extends SelectableItem>(props: {

return (
<Box flexDirection="column">
{needsScroll && viewportStart > 0 && <Text dimColor> ↑ {viewportStart} more</Text>}
{needsScroll && viewportStart > 0 && (
<Text dimColor>
{' '}
{symbols.arrowUp} {viewportStart} more
</Text>
)}
{visibleItems.map((item, idx) => {
const actualIndex = viewportStart + idx;
const selected = actualIndex === selectedIndex;
Expand All @@ -54,7 +60,7 @@ export function SelectList<T extends SelectableItem>(props: {
<Box key={item.id} marginTop={item.spaceBefore ? 1 : 0}>
<Text wrap="wrap">
<Text color={selected && !disabled ? 'cyan' : undefined} dimColor={disabled}>
{selected ? '❯' : ' '}{' '}
{selected ? symbols.cursor : ' '}{' '}
</Text>
<Text color={selected && !disabled ? 'cyan' : undefined} dimColor={disabled}>
{item.title}
Expand All @@ -64,7 +70,12 @@ export function SelectList<T extends SelectableItem>(props: {
</Box>
);
})}
{needsScroll && viewportEnd < items.length && <Text dimColor> ↓ {items.length - viewportEnd} more</Text>}
{needsScroll && viewportEnd < items.length && (
<Text dimColor>
{' '}
{symbols.arrowDown} {items.length - viewportEnd} more
</Text>
)}
</Box>
);
}
5 changes: 3 additions & 2 deletions src/cli/tui/components/StepIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useResponsive } from '../hooks/useResponsive';
import { symbols } from '../utils';
import { Box, Text } from 'ink';

interface StepIndicatorProps<T extends string> {
Expand Down Expand Up @@ -71,7 +72,7 @@ export function StepIndicator<T extends string>({
const isLastInRow = idx === rowSteps.length - 1;
const isLastStep = stepIdx === steps.length - 1;

const icon = isDone ? '✓' : isCurrent ? '●' : '○';
const icon = isDone ? symbols.stepDone : isCurrent ? symbols.stepCurrent : symbols.stepPending;
const color = isCurrent ? 'cyan' : isDone ? 'green' : 'gray';

return (
Expand All @@ -81,7 +82,7 @@ export function StepIndicator<T extends string>({
{' '}
{label}
</Text>
{showArrows && !isLastStep && !isLastInRow && <Text dimColor> </Text>}
{showArrows && !isLastStep && !isLastInRow && <Text dimColor> {symbols.branch} </Text>}
</Box>
);
})}
Expand Down
3 changes: 2 additions & 1 deletion src/cli/tui/screens/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { findConfigRoot } from '../../../../lib';
import { Cursor, ScreenLayout } from '../../components';
import { HINTS } from '../../copy';
import { symbols } from '../../utils';
import { Box, Text, useApp, useInput } from 'ink';
import React from 'react';

Expand Down Expand Up @@ -28,7 +29,7 @@ function QuickStart() {
<NoProjectMessage />
<Box marginTop={1}>
<Text>
<Text color="cyan"> </Text>
<Text color="cyan">{symbols.flag} </Text>
<Text dimColor>Press Enter to create a new project</Text>
</Text>
</Box>
Expand Down
6 changes: 3 additions & 3 deletions src/cli/tui/screens/mcp/AddGatewayScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { SelectableItem } from '../../components';
import { JwtConfigInput, useJwtConfigFlow } from '../../components/jwt-config';
import { HELP_TEXT } from '../../constants';
import { useListNavigation, useMultiSelectNavigation } from '../../hooks';
import { generateUniqueName } from '../../utils';
import { generateUniqueName, symbols } from '../../utils';
import type { AddGatewayConfig } from './types';
import {
AUTHORIZER_TYPE_OPTIONS,
Expand Down Expand Up @@ -283,11 +283,11 @@ export function AddGatewayScreen({
{advancedConfigItems.map((item, idx) => {
const isCursor = idx === advancedNav.cursorIndex;
const isChecked = advancedNav.selectedIds.has(item.id);
const checkbox = isChecked ? '[✓]' : '[ ]';
const checkbox = isChecked ? symbols.checkboxOn : symbols.checkboxOff;
return (
<Box key={item.id}>
<Text wrap="truncate">
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? '❯' : ' '} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? symbols.cursor : ' '} </Text>
<Text color={isChecked ? 'green' : undefined}>{checkbox} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{item.title}</Text>
</Text>
Expand Down
6 changes: 3 additions & 3 deletions src/cli/tui/screens/payment/AddPaymentManagerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Panel, Screen, StepIndicator, TextInput, WizardSelect } from '../../com
import type { SelectableItem } from '../../components';
import { HELP_TEXT } from '../../constants';
import { useListNavigation, useMultiSelectNavigation } from '../../hooks';
import { generateUniqueName } from '../../utils';
import { generateUniqueName, symbols } from '../../utils';
import type { AddPaymentManagerConfig } from './types';
import {
AUTH_TYPE_OPTIONS,
Expand Down Expand Up @@ -218,11 +218,11 @@ export function AddPaymentManagerScreen({
{advancedConfigItems.map((item, idx) => {
const isCursor = idx === advancedNav.cursorIndex;
const isChecked = advancedNav.selectedIds.has(item.id);
const checkbox = isChecked ? '[✓]' : '[ ]';
const checkbox = isChecked ? symbols.checkboxOn : symbols.checkboxOff;
return (
<Box key={item.id}>
<Text wrap="truncate">
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? '❯' : ' '} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{isCursor ? symbols.cursor : ' '} </Text>
<Text color={isChecked ? 'green' : undefined}>{checkbox} </Text>
<Text color={isCursor ? 'cyan' : undefined}>{item.title}</Text>
</Text>
Expand Down
109 changes: 109 additions & 0 deletions src/cli/tui/utils/__tests__/symbols.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { MultiSelectList } from '../../components/MultiSelectList.js';
import { SelectList } from '../../components/SelectList.js';
import { StepIndicator } from '../../components/StepIndicator.js';
import { isUnicodeSupported, symbols } from '../symbols.js';
import { render } from 'ink-testing-library';
import React from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';

vi.mock('../../hooks/useResponsive.js', () => ({
useResponsive: () => ({ width: 120, height: 40, isNarrow: false }),
}));

// Every non-ASCII glyph the TUI/console renders. None of these may appear when
// Unicode support is forced off (the legacy-Windows path).
const NON_ASCII_GLYPHS = ['❯', '↑', '↓', '✓', '✗', '●', '○', '→', '⚑', '▶'];

function withAscii(off: boolean, fn: () => void) {
const prev = process.env.AGENTCORE_ASCII;
process.env.AGENTCORE_ASCII = off ? '1' : '0';
try {
fn();
} finally {
if (prev === undefined) delete process.env.AGENTCORE_ASCII;
else process.env.AGENTCORE_ASCII = prev;
}
}

afterEach(() => {
delete process.env.AGENTCORE_ASCII;
});

describe('symbols', () => {
it('AGENTCORE_ASCII override flips Unicode detection', () => {
withAscii(true, () => expect(isUnicodeSupported()).toBe(false));
withAscii(false, () => expect(isUnicodeSupported()).toBe(true));
});

it('emits ASCII fallbacks when Unicode is off', () => {
withAscii(true, () => {
expect(symbols.cursor).toBe('>');
expect(symbols.checkboxOn).toBe('[x]');
expect(symbols.checkboxOff).toBe('[ ]');
expect(symbols.arrowUp).toBe('^');
expect(symbols.arrowDown).toBe('v');
expect(symbols.stepDone).toBe('x');
expect(symbols.stepCurrent).toBe('*');
expect(symbols.stepPending).toBe('o');
expect(symbols.branch).toBe('->');
expect(symbols.success).toBe('OK');
expect(symbols.failure).toBe('X');
// checked and unchecked stay distinguishable
expect(symbols.checkboxOn).not.toBe(symbols.checkboxOff);
});
});

it('emits original glyphs when Unicode is on', () => {
withAscii(false, () => {
expect(symbols.cursor).toBe('❯');
expect(symbols.checkboxOn).toBe('[✓]');
expect(symbols.stepCurrent).toBe('●');
});
});
});

describe('TUI glyph fallback (legacy Windows)', () => {
const items = [
{ id: 'a', title: 'Alpha' },
{ id: 'b', title: 'Bravo' },
];

it('SelectList renders no non-ASCII codepoints with Unicode off', () => {
withAscii(true, () => {
const { lastFrame } = render(<SelectList items={items} selectedIndex={0} maxVisibleItems={1} />);
const frame = lastFrame()!;
expect(frame).toContain('>');
for (const g of NON_ASCII_GLYPHS) expect(frame).not.toContain(g);
});
});

it('MultiSelectList keeps checkbox state distinguishable in both modes', () => {
withAscii(true, () => {
const { lastFrame } = render(
<MultiSelectList items={items} selectedIndex={0} selectedIds={new Set(['a'])} />
);
const frame = lastFrame()!;
expect(frame).toContain('[x]');
expect(frame).toContain('[ ]');
for (const g of NON_ASCII_GLYPHS) expect(frame).not.toContain(g);
});
withAscii(false, () => {
const { lastFrame } = render(
<MultiSelectList items={items} selectedIndex={0} selectedIds={new Set(['a'])} />
);
const frame = lastFrame()!;
expect(frame).toContain('[✓]');
expect(frame).toContain('[ ]');
});
});

it('StepIndicator renders no non-ASCII codepoints with Unicode off', () => {
withAscii(true, () => {
const steps = ['one', 'two', 'three'] as const;
const labels = { one: 'One', two: 'Two', three: 'Three' };
const { lastFrame } = render(<StepIndicator steps={[...steps]} currentStep="two" labels={labels} />);
const frame = lastFrame()!;
for (const g of NON_ASCII_GLYPHS) expect(frame).not.toContain(g);
});
});
});
1 change: 1 addition & 0 deletions src/cli/tui/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export { getCommandsForUI, type CommandMeta } from './commands';
export { diffLines, type DiffLine } from './diff';
export { generateUniqueName } from './naming';
export { isProcessRunning, cleanupStaleLockFiles } from './process';
export { symbols, isUnicodeSupported } from './symbols';
export { withMinDuration } from './timing';
Loading
Loading