fix(ui): ensure consistent spacing in settings dialog

This commit is contained in:
Sehoon Shon
2026-01-27 12:17:21 -05:00
parent 0dc69bd364
commit 2791c50191
4 changed files with 77 additions and 38 deletions

View File

@@ -628,9 +628,9 @@ export function SettingsDialog({
const DIALOG_PADDING = 2; // Top and bottom borders
const SETTINGS_TITLE_HEIGHT = 1;
const SEARCH_BOX_HEIGHT = 3;
const SCROLL_ARROWS_HEIGHT = 2;
const SPACING_HEIGHT = 2;
const SCOPE_SELECTION_HEIGHT = 4;
const SCROLL_ARROWS_HEIGHT = 3;
const SPACING_HEIGHT = 5;
const SCOPE_SELECTION_HEIGHT = 7;
const BOTTOM_HELP_TEXT_HEIGHT = 1;
const RESTART_PROMPT_HEIGHT = showRestartPrompt ? 1 : 0;
const ITEM_HEIGHT = 3; // Label + description + spacing

View File

@@ -10,6 +10,7 @@ exports[`SettingsDialog > Initial Rendering > should render settings list with v
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -38,9 +39,12 @@ exports[`SettingsDialog > Initial Rendering > should render settings list with v
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -56,6 +60,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'accessibility settings
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -84,9 +89,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'accessibility settings
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -102,6 +110,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'all boolean settings d
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -130,9 +139,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'all boolean settings d
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -148,6 +160,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'default state' correct
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -176,9 +189,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'default state' correct
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -194,6 +210,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'file filtering setting
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -222,9 +239,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'file filtering setting
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -240,6 +260,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'focused on scope selec
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -268,9 +289,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'focused on scope selec
│ │
│ > Apply To │
│ ● 1. User Settings │
│ │
│ 2. Workspace Settings │
│ │
│ 3. System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -286,6 +310,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'mixed boolean and numb
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -314,9 +339,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'mixed boolean and numb
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -332,6 +360,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'tools and security set
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -360,9 +389,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'tools and security set
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
@@ -378,6 +410,7 @@ exports[`SettingsDialog > Snapshot Tests > should render 'various boolean settin
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ ▲ │
│ │
│ ● Preview Features (e.g., models) false │
│ Enable preview features (e.g., preview models). │
│ │
@@ -406,9 +439,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'various boolean settin
│ │
│ Apply To │
│ ● User Settings │
│ │
│ Workspace Settings │
│ │
│ System Settings │
│ │
│ │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"

View File

@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
import { useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Text, Box } from 'ink';
import { theme } from '../../semantic-colors.js';
import { useSelectionList } from '../../hooks/useSelectionList.js';
@@ -134,38 +133,41 @@ export function BaseSelectionList<
)}.`;
return (
<Box key={item.key} alignItems="flex-start">
{/* Radio button indicator */}
<Box minWidth={2} flexShrink={0}>
<Text
color={isSelected ? theme.status.success : theme.text.primary}
aria-hidden
>
{isSelected ? '●' : ' '}
</Text>
</Box>
{/* Item number */}
{showNumbers && !item.hideNumber && (
<Box
marginRight={1}
flexShrink={0}
minWidth={itemNumberText.length}
aria-state={{ checked: isSelected }}
>
<Text color={numberColor}>{itemNumberText}</Text>
<React.Fragment key={item.key}>
<Box alignItems="flex-start">
{/* Radio button indicator */}
<Box minWidth={2} flexShrink={0}>
<Text
color={isSelected ? theme.status.success : theme.text.primary}
aria-hidden
>
{isSelected ? '●' : ' '}
</Text>
</Box>
)}
{/* Custom content via render prop */}
<Box flexGrow={1}>
{renderItem(item, {
isSelected,
titleColor,
numberColor,
})}
{/* Item number */}
{showNumbers && !item.hideNumber && (
<Box
marginRight={1}
flexShrink={0}
minWidth={itemNumberText.length}
aria-state={{ checked: isSelected }}
>
<Text color={numberColor}>{itemNumberText}</Text>
</Box>
)}
{/* Custom content via render prop */}
<Box flexGrow={1}>
{renderItem(item, {
isSelected,
titleColor,
numberColor,
})}
</Box>
</Box>
</Box>
<Box height={1} flexShrink={0} />
</React.Fragment>
);
})}

View File

@@ -431,7 +431,7 @@ export function BaseSettingsDialog({
</Box>
)}
<Box height={1} />
<Box height={1} flexShrink={0} />
{/* Items list */}
{visibleItems.length === 0 ? (
@@ -445,6 +445,7 @@ export function BaseSettingsDialog({
<Text color={theme.text.secondary}></Text>
</Box>
)}
{showScrollUp && <Box height={1} flexShrink={0} />}
{visibleItems.map((item, idx) => {
const globalIndex = idx + scrollOffset;
const isActive =
@@ -533,7 +534,7 @@ export function BaseSettingsDialog({
</Box>
</Box>
</Box>
<Box height={1} />
<Box height={1} flexShrink={0} />
</React.Fragment>
);
})}
@@ -545,7 +546,7 @@ export function BaseSettingsDialog({
</>
)}
<Box height={1} />
<Box height={1} flexShrink={0} />
{/* Scope Selection */}
{showScopeSelector && (
@@ -566,7 +567,7 @@ export function BaseSettingsDialog({
</Box>
)}
<Box height={1} />
<Box height={1} flexShrink={0} />
{/* Help text */}
<Box marginX={1}>