Skip to content

Commit b349a38

Browse files
committed
refactor(cli): use dynamic keybinding and consistent casing for truncation hint
1 parent f3a03cc commit b349a38

8 files changed

Lines changed: 32 additions & 29 deletions

File tree

packages/cli/src/ui/components/ToolConfirmationQueue.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ describe('ToolConfirmationQueue', () => {
227227
// availableContentHeight = Math.max(9 - 6, 4) = 4
228228
// MaxSizedBox in ToolConfirmationMessage will use 4
229229
// It should show truncation message
230-
await waitFor(() => expect(lastFrame()).toContain('49 hidden (ctrl+o)'));
230+
await waitFor(() => expect(lastFrame()).toContain('49 hidden (Ctrl+O)'));
231231
expect(lastFrame()).toMatchSnapshot();
232232
unmount();
233233
});

packages/cli/src/ui/components/__snapshots__/ToolConfirmationQueue.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`ToolConfirmationQueue > calculates availableContentHeight based on avai
66
│ │
77
│ ? replace edit file │
88
│ │
9-
│ ... 49 hidden (ctrl+o) ... │
9+
│ ... 49 hidden (Ctrl+O) ... │
1010
│ 50 line │
1111
│ Apply this change? │
1212
│ │
@@ -96,7 +96,7 @@ exports[`ToolConfirmationQueue > renders expansion hint when content is long and
9696
│ │
9797
│ ? replace edit file │
9898
│ │
99-
│ ... 49 hidden (ctrl+o) ... │
99+
│ ... 49 hidden (Ctrl+O) ... │
100100
│ 50 line │
101101
│ Apply this change? │
102102
│ │

packages/cli/src/ui/components/messages/ToolOverflowConsistencyChecks.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('ToolOverflowConsistencyChecks: ToolGroupMessage and ToolResultDisplay
106106
);
107107

108108
// Verify truncation is occurring (standard mode uses MaxSizedBox)
109-
await waitFor(() => expect(lastFrame()).toContain('hidden (ctrl+o'));
109+
await waitFor(() => expect(lastFrame()).toContain('hidden (Ctrl+O'));
110110

111111
// In Standard mode, ToolGroupMessage calculates hasOverflow correctly now.
112112
// While Standard mode doesn't render the inline hint (ShowMoreLines returns null),

packages/cli/src/ui/components/messages/__snapshots__/DiffRenderer.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlterna
1010
`;
1111

1212
exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlternateBuffer = false > should correctly render a diff with multiple hunks and a gap indicator > with terminalWidth 30 and height 6 1`] = `
13-
"... 10 hidden (ctrl+o) ...
13+
"... 10 hidden (Ctrl+O) ...
1414
'test';
1515
21 + const anotherNew =
1616
'test';
@@ -20,7 +20,7 @@ exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlterna
2020
`;
2121

2222
exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlternateBuffer = false > should correctly render a diff with multiple hunks and a gap indicator > with terminalWidth 80 and height 6 1`] = `
23-
"... first 4 lines hidden (ctrl+o to show) ...
23+
"... first 4 lines hidden (Ctrl+O to show) ...
2424
════════════════════════════════════════════════════════════════════════════════
2525
20 console.log('second hunk');
2626
21 - const anotherOld = 'test';
@@ -103,7 +103,7 @@ exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlterna
103103
`;
104104

105105
exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlternateBuffer = true > should correctly render a diff with multiple hunks and a gap indicator > with terminalWidth 30 and height 6 1`] = `
106-
"... 10 hidden (ctrl+o) ...
106+
"... 10 hidden (Ctrl+O) ...
107107
'test';
108108
21 + const anotherNew =
109109
'test';
@@ -113,7 +113,7 @@ exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlterna
113113
`;
114114

115115
exports[`<OverflowProvider><DiffRenderer /></OverflowProvider> > with useAlternateBuffer = true > should correctly render a diff with multiple hunks and a gap indicator > with terminalWidth 80 and height 6 1`] = `
116-
"... first 4 lines hidden (ctrl+o to show) ...
116+
"... first 4 lines hidden (Ctrl+O to show) ...
117117
════════════════════════════════════════════════════════════════════════════════
118118
20 console.log('second hunk');
119119
21 - const anotherOld = 'test';

packages/cli/src/ui/components/messages/__snapshots__/ToolResultDisplay.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ exports[`ToolResultDisplay > renders string result as plain text when renderOutp
3737
`;
3838

3939
exports[`ToolResultDisplay > truncates very long string results 1`] = `
40-
"... 248 hidden (ctrl+o) ...
40+
"... 248 hidden (Ctrl+O) ...
4141
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4242
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4343
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

packages/cli/src/ui/components/shared/MaxSizedBox.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('<MaxSizedBox />', () => {
4242
);
4343
await waitUntilReady();
4444
expect(lastFrame()).toContain(
45-
'... first 2 lines hidden (ctrl+o to show) ...',
45+
'... first 2 lines hidden (Ctrl+O to show) ...',
4646
);
4747
expect(lastFrame()).toMatchSnapshot();
4848
unmount();
@@ -62,7 +62,7 @@ describe('<MaxSizedBox />', () => {
6262
);
6363
await waitUntilReady();
6464
expect(lastFrame()).toContain(
65-
'... last 2 lines hidden (ctrl+o to show) ...',
65+
'... last 2 lines hidden (Ctrl+O to show) ...',
6666
);
6767
expect(lastFrame()).toMatchSnapshot();
6868
unmount();
@@ -82,7 +82,7 @@ describe('<MaxSizedBox />', () => {
8282
);
8383
await waitUntilReady();
8484
expect(lastFrame()).toContain(
85-
'... first 2 lines hidden (ctrl+o to show) ...',
85+
'... first 2 lines hidden (Ctrl+O to show) ...',
8686
);
8787
expect(lastFrame()).toMatchSnapshot();
8888
unmount();
@@ -100,7 +100,7 @@ describe('<MaxSizedBox />', () => {
100100
);
101101
await waitUntilReady();
102102
expect(lastFrame()).toContain(
103-
'... first 1 line hidden (ctrl+o to show) ...',
103+
'... first 1 line hidden (Ctrl+O to show) ...',
104104
);
105105
expect(lastFrame()).toMatchSnapshot();
106106
unmount();
@@ -120,7 +120,7 @@ describe('<MaxSizedBox />', () => {
120120
);
121121
await waitUntilReady();
122122
expect(lastFrame()).toContain(
123-
'... first 7 lines hidden (ctrl+o to show) ...',
123+
'... first 7 lines hidden (Ctrl+O to show) ...',
124124
);
125125
expect(lastFrame()).toMatchSnapshot();
126126
unmount();
@@ -208,7 +208,7 @@ describe('<MaxSizedBox />', () => {
208208

209209
await waitUntilReady();
210210
expect(lastFrame()).toContain(
211-
'... first 21 lines hidden (ctrl+o to show) ...',
211+
'... first 21 lines hidden (Ctrl+O to show) ...',
212212
);
213213
expect(lastFrame()).toMatchSnapshot();
214214
unmount();
@@ -231,7 +231,7 @@ describe('<MaxSizedBox />', () => {
231231

232232
await waitUntilReady();
233233
expect(lastFrame()).toContain(
234-
'... last 21 lines hidden (ctrl+o to show) ...',
234+
'... last 21 lines hidden (Ctrl+O to show) ...',
235235
);
236236
expect(lastFrame()).toMatchSnapshot();
237237
unmount();
@@ -262,7 +262,7 @@ describe('<MaxSizedBox />', () => {
262262

263263
// The last line should only contain the hidden indicator, no leaked content
264264
expect(lastLine).toMatch(
265-
/^\.\.\. last \d+ lines? hidden \(ctrl\+o to show\) \.\.\.$/,
265+
/^\.\.\. last \d+ lines? hidden \(Ctrl\+O to show\) \.\.\.$/,
266266
);
267267
expect(lastFrame()).toMatchSnapshot();
268268
unmount();

packages/cli/src/ui/components/shared/MaxSizedBox.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { Box, Text, ResizeObserver, type DOMElement } from 'ink';
1010
import { theme } from '../../semantic-colors.js';
1111
import { useOverflowActions } from '../../contexts/OverflowContext.js';
1212
import { isNarrowWidth } from '../../utils/isNarrowWidth.js';
13+
import { Command } from '../../../config/keyBindings.js';
14+
import { formatCommand } from '../../utils/keybindingUtils.js';
1315

1416
/**
1517
* Minimum height for the MaxSizedBox component.
@@ -86,6 +88,7 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
8688
const totalHiddenLines = hiddenLinesCount + additionalHiddenLinesCount;
8789

8890
const isNarrow = maxWidth !== undefined && isNarrowWidth(maxWidth);
91+
const showMoreKey = formatCommand(Command.SHOW_MORE_LINES);
8992

9093
useEffect(() => {
9194
if (totalHiddenLines > 0) {
@@ -120,8 +123,8 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
120123
{totalHiddenLines > 0 && overflowDirection === 'top' && (
121124
<Text color={theme.text.secondary} wrap="truncate">
122125
{isNarrow
123-
? `... ${totalHiddenLines} hidden (ctrl+o) ...`
124-
: `... first ${totalHiddenLines} line${totalHiddenLines === 1 ? '' : 's'} hidden (ctrl+o to show) ...`}
126+
? `... ${totalHiddenLines} hidden (${showMoreKey}) ...`
127+
: `... first ${totalHiddenLines} line${totalHiddenLines === 1 ? '' : 's'} hidden (${showMoreKey} to show) ...`}
125128
</Text>
126129
)}
127130
<Box
@@ -142,8 +145,8 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
142145
{totalHiddenLines > 0 && overflowDirection === 'bottom' && (
143146
<Text color={theme.text.secondary} wrap="truncate">
144147
{isNarrow
145-
? `... ${totalHiddenLines} hidden (ctrl+o) ...`
146-
: `... last ${totalHiddenLines} line${totalHiddenLines === 1 ? '' : 's'} hidden (ctrl+o to show) ...`}
148+
? `... ${totalHiddenLines} hidden (${showMoreKey}) ...`
149+
: `... last ${totalHiddenLines} line${totalHiddenLines === 1 ? '' : 's'} hidden (${showMoreKey} to show) ...`}
147150
</Text>
148151
)}
149152
</Box>

packages/cli/src/ui/components/shared/__snapshots__/MaxSizedBox.test.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`<MaxSizedBox /> > accounts for additionalHiddenLinesCount 1`] = `
4-
"... first 7 lines hidden (ctrl+o to show) ...
4+
"... first 7 lines hidden (Ctrl+O to show) ...
55
Line 3
66
"
77
`;
@@ -16,12 +16,12 @@ Line 6
1616
Line 7
1717
Line 8
1818
Line 9
19-
... last 21 lines hidden (ctrl+o to show) ...
19+
... last 21 lines hidden (Ctrl+O to show) ...
2020
"
2121
`;
2222

2323
exports[`<MaxSizedBox /> > clips a long single text child from the top 1`] = `
24-
"... first 21 lines hidden (ctrl+o to show) ...
24+
"... first 21 lines hidden (Ctrl+O to show) ...
2525
Line 22
2626
Line 23
2727
Line 24
@@ -39,7 +39,7 @@ exports[`<MaxSizedBox /> > does not leak content after hidden indicator with bot
3939
4040
- Step 1: Do something important
4141
- Step 2: Do something important
42-
... last 18 lines hidden (ctrl+o to show) ...
42+
... last 18 lines hidden (Ctrl+O to show) ...
4343
"
4444
`;
4545

@@ -58,12 +58,12 @@ Line 3 direct child
5858

5959
exports[`<MaxSizedBox /> > hides lines at the end when content exceeds maxHeight and overflowDirection is bottom 1`] = `
6060
"Line 1
61-
... last 2 lines hidden (ctrl+o to show) ...
61+
... last 2 lines hidden (Ctrl+O to show) ...
6262
"
6363
`;
6464

6565
exports[`<MaxSizedBox /> > hides lines when content exceeds maxHeight 1`] = `
66-
"... first 2 lines hidden (ctrl+o to show) ...
66+
"... first 2 lines hidden (Ctrl+O to show) ...
6767
Line 3
6868
"
6969
`;
@@ -74,13 +74,13 @@ exports[`<MaxSizedBox /> > renders children without truncation when they fit 1`]
7474
`;
7575

7676
exports[`<MaxSizedBox /> > shows plural "lines" when more than one line is hidden 1`] = `
77-
"... first 2 lines hidden (ctrl+o to show) ...
77+
"... first 2 lines hidden (Ctrl+O to show) ...
7878
Line 3
7979
"
8080
`;
8181

8282
exports[`<MaxSizedBox /> > shows singular "line" when exactly one line is hidden 1`] = `
83-
"... first 1 line hidden (ctrl+o to show) ...
83+
"... first 1 line hidden (Ctrl+O to show) ...
8484
Line 1
8585
"
8686
`;

0 commit comments

Comments
 (0)