Skip to content

Commit 18c9004

Browse files
NTaylorMullenkeithguerin
authored andcommitted
docs(skills): enhance pr-creator safety and interactivity (google-gemini#18616)
1 parent 67d9b76 commit 18c9004

13 files changed

Lines changed: 982 additions & 489 deletions

packages/cli/src/ui/components/AskUserDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,6 @@ const ChoiceQuestionView: React.FC<ChoiceQuestionViewProps> = ({
819819
items={selectionItems}
820820
onSelect={handleSelect}
821821
onHighlight={handleHighlight}
822-
focusKey={isCustomOptionFocused ? 'other' : undefined}
823822
maxItemsToShow={maxItemsToShow}
824823
showScrollArrows={true}
825824
renderItem={(item, context) => {

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import { Header } from './Header.js';
1010
import * as useTerminalSize from '../hooks/useTerminalSize.js';
1111
import { longAsciiLogo } from './AsciiArt.js';
1212
import * as semanticColors from '../semantic-colors.js';
13+
import * as terminalSetup from '../utils/terminalSetup.js';
1314
import { Text } from 'ink';
1415
import type React from 'react';
1516

1617
vi.mock('../hooks/useTerminalSize.js');
1718
vi.mock('../hooks/useSnowfall.js', () => ({
1819
useSnowfall: vi.fn((art) => art),
1920
}));
21+
vi.mock('../utils/terminalSetup.js', () => ({
22+
getTerminalProgram: vi.fn(),
23+
}));
2024
vi.mock('ink-gradient', () => {
2125
const MockGradient = ({ children }: { children: React.ReactNode }) => (
2226
<>{children}</>
@@ -37,6 +41,7 @@ vi.mock('ink', async () => {
3741
describe('<Header />', () => {
3842
beforeEach(() => {
3943
vi.clearAllMocks();
44+
vi.mocked(terminalSetup.getTerminalProgram).mockReturnValue(null);
4045
});
4146

4247
it('renders the long logo on a wide terminal', () => {
@@ -66,13 +71,24 @@ describe('<Header />', () => {
6671
);
6772
});
6873

74+
it('renders custom ASCII art as is when running in an IDE', () => {
75+
const customArt = 'CUSTOM ART';
76+
vi.mocked(terminalSetup.getTerminalProgram).mockReturnValue('vscode');
77+
render(
78+
<Header version="1.0.0" nightly={false} customAsciiArt={customArt} />,
79+
);
80+
expect(Text).toHaveBeenCalledWith(
81+
expect.objectContaining({
82+
children: customArt,
83+
}),
84+
undefined,
85+
);
86+
});
87+
6988
it('displays the version number when nightly is true', () => {
7089
render(<Header version="1.0.0" nightly={true} />);
7190
const textCalls = (Text as Mock).mock.calls;
72-
const versionText = Array.isArray(textCalls[1][0].children)
73-
? textCalls[1][0].children.join('')
74-
: textCalls[1][0].children;
75-
expect(versionText).toBe('v1.0.0');
91+
expect(textCalls[1][0].children.join('')).toBe('v1.0.0');
7692
});
7793

7894
it('does not display the version number when nightly is false', () => {
@@ -106,6 +122,7 @@ describe('<Header />', () => {
106122
comment: '',
107123
symbol: '',
108124
dark: '',
125+
focus: '',
109126
gradient: undefined,
110127
},
111128
status: {

packages/cli/src/ui/components/SessionBrowser.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type React from 'react';
88
import { useState, useCallback, useMemo, useEffect, useRef } from 'react';
99
import { Box, Text } from 'ink';
1010
import { Colors } from '../colors.js';
11+
import { theme } from '../semantic-colors.js';
1112
import { useTerminalSize } from '../hooks/useTerminalSize.js';
1213
import { useKeypress } from '../hooks/useKeypress.js';
1314
import path from 'node:path';
@@ -436,7 +437,7 @@ const SessionItem = ({
436437
if (isDisabled) {
437438
return Colors.Gray;
438439
}
439-
return isActive ? Colors.AccentPurple : c;
440+
return isActive ? theme.ui.focus : c;
440441
};
441442

442443
const prefix = isActive ? '❯ ' : ' ';
@@ -775,12 +776,10 @@ export const useSessionBrowserInput = (
775776
state.setSearchQuery('');
776777
state.setActiveIndex(0);
777778
state.setScrollOffset(0);
778-
return true;
779779
} else if (key.name === 'backspace') {
780780
state.setSearchQuery((prev) => prev.slice(0, -1));
781781
state.setActiveIndex(0);
782782
state.setScrollOffset(0);
783-
return true;
784783
} else if (
785784
key.sequence &&
786785
key.sequence.length === 1 &&
@@ -791,41 +790,34 @@ export const useSessionBrowserInput = (
791790
state.setSearchQuery((prev) => prev + key.sequence);
792791
state.setActiveIndex(0);
793792
state.setScrollOffset(0);
794-
return true;
795793
}
796794
} else {
797795
// Navigation mode input handling. We're keeping the letter-based controls for non-search
798796
// mode only, because the letters need to act as input for the search.
799797
if (key.sequence === 'g') {
800798
state.setActiveIndex(0);
801799
state.setScrollOffset(0);
802-
return true;
803800
} else if (key.sequence === 'G') {
804801
state.setActiveIndex(state.totalSessions - 1);
805802
state.setScrollOffset(
806803
Math.max(0, state.totalSessions - SESSIONS_PER_PAGE),
807804
);
808-
return true;
809805
}
810806
// Sorting controls.
811807
else if (key.sequence === 's') {
812808
cycleSortOrder();
813-
return true;
814809
} else if (key.sequence === 'r') {
815810
state.setSortReverse(!state.sortReverse);
816-
return true;
817811
}
818812
// Searching and exit controls.
819813
else if (key.sequence === '/') {
820814
state.setIsSearchMode(true);
821-
return true;
822815
} else if (
823816
key.sequence === 'q' ||
824817
key.sequence === 'Q' ||
825818
key.name === 'escape'
826819
) {
827820
onExit();
828-
return true;
829821
}
830822
// Delete session control.
831823
else if (key.sequence === 'x' || key.sequence === 'X') {
@@ -855,15 +847,12 @@ export const useSessionBrowserInput = (
855847
);
856848
});
857849
}
858-
return true;
859850
}
860851
// less-like u/d controls.
861852
else if (key.sequence === 'u') {
862853
moveSelection(-Math.round(SESSIONS_PER_PAGE / 2));
863-
return true;
864854
} else if (key.sequence === 'd') {
865855
moveSelection(Math.round(SESSIONS_PER_PAGE / 2));
866-
return true;
867856
}
868857
}
869858

@@ -878,21 +867,15 @@ export const useSessionBrowserInput = (
878867
if (!selectedSession.isCurrentSession) {
879868
onResumeSession(selectedSession);
880869
}
881-
return true;
882870
} else if (key.name === 'up') {
883871
moveSelection(-1);
884-
return true;
885872
} else if (key.name === 'down') {
886873
moveSelection(1);
887-
return true;
888874
} else if (key.name === 'pageup') {
889875
moveSelection(-SESSIONS_PER_PAGE);
890-
return true;
891876
} else if (key.name === 'pagedown') {
892877
moveSelection(SESSIONS_PER_PAGE);
893-
return true;
894878
}
895-
return false;
896879
},
897880
{ isActive: true },
898881
);

0 commit comments

Comments
 (0)