Skip to content
Merged
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
30 changes: 30 additions & 0 deletions packages/cli/src/ui/components/SettingsDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,36 @@ describe('SettingsDialog', () => {
});
unmount();
});

it('should render the bottom border correctly when height is constrained', async () => {
const settings = createMockSettings();
const onSelect = vi.fn();
const constrainedHeight = 15;

const renderResult = await renderDialog(settings, onSelect, {
availableTerminalHeight: constrainedHeight,
});

await renderResult.waitUntilReady();

await waitFor(() => {
const output = renderResult.lastFrame();
const lines = output.trim().split('\n');

// Verify height constraint
expect(lines.length).toBeLessThanOrEqual(constrainedHeight);

// Verify bottom border existence in the last line of the output
const lastLine = lines[lines.length - 1];
// 'round' border characters: ─, ╰, ╯
expect(lastLine).toMatch(/[─╰╯]/);
});

// SVG snapshot ensures visual layout and border rendering are preserved
await expect(renderResult).toMatchSvgSnapshot();

renderResult.unmount();
});
});

describe('Setting Descriptions', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ exports[`SettingsDialog > Initial Rendering > should render settings list with v
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;

exports[`SettingsDialog > Initial Rendering > should render the bottom border correctly when height is constrained 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ > Settings │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ ╰─Search to filter─────────────────────────────────────────────────────────────────────────────╯ │
│ ▲ │
│ ● Vim Mode false │
│ ▼ Enable Vim keybindings │
│ │
│ Apply To │
│ ● User Settings │
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;

exports[`SettingsDialog > Snapshot Tests > should render 'accessibility settings enabled' correctly 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export function BaseSettingsDialog({
flexDirection="row"
padding={1}
width="100%"
height="100%"
maxHeight={availableHeight}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The change from height="100%" to maxHeight={availableHeight} introduces a layout regression when availableHeight is undefined (the default state). In this case, the Box loses its height constraint, which can cause the dialog to overflow the terminal window. You should provide a fallback to "100%". Additionally, per repository rules, please add a detailed comment explaining how this height is derived to prevent incorrect refactoring in the future.

Suggested change
maxHeight={availableHeight}
maxHeight={availableHeight ?? '100%'} // Fallback to 100% to prevent overflow when availableHeight is undefined
References
  1. For complex layout calculations that depend on component rendering logic (like conditional borders or padding), add detailed comments explaining how the height is derived to prevent incorrect refactoring.

>
<Box flexDirection="column" flexGrow={1}>
{/* Title */}
Expand Down
Loading