-
Notifications
You must be signed in to change notification settings - Fork 13.1k
feat(ui): make accept edits & yolo mode match shell mode styles #8200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
38cf81a
Add accept edits mode
miguelsolorio 375cdf3
Add yolo mode styles
miguelsolorio 52a8bdf
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio a14bd98
Format
miguelsolorio 717f6a0
Merge branch 'miguelsolorio/input-prompt-highlight' of https://githubโฆ
miguelsolorio f37f1a1
Refactor logic
miguelsolorio 94c0abc
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio ff58427
Update colors to use cyan for shell mode, warning for accept edits
miguelsolorio 124f680
Remove extra space from cases, move to its own line
miguelsolorio bdd0dbe
Add snapshot tests
miguelsolorio 2927bea
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio dc30cf6
Add aria label for announcing modes
miguelsolorio b20b129
Merge branch 'miguelsolorio/input-prompt-highlight' of https://githubโฆ
miguelsolorio feb882d
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio c8fb5be
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio 3d74084
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio e8fc9e1
Merge branch 'main' into miguelsolorio/input-prompt-highlight
miguelsolorio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import { useKeypress } from '../hooks/useKeypress.js'; | |
| import { keyMatchers, Command } from '../keyMatchers.js'; | ||
| import type { CommandContext, SlashCommand } from '../commands/types.js'; | ||
| import type { Config } from '@google/gemini-cli-core'; | ||
| import { ApprovalMode } from '@google/gemini-cli-core'; | ||
| import { parseInputForHighlighting } from '../utils/highlight.js'; | ||
| import { | ||
| clipboardHasImage, | ||
|
|
@@ -46,6 +47,7 @@ export interface InputPromptProps { | |
| suggestionsWidth: number; | ||
| shellModeActive: boolean; | ||
| setShellModeActive: (value: boolean) => void; | ||
| approvalMode: ApprovalMode; | ||
| onEscapePromptChange?: (showPrompt: boolean) => void; | ||
| vimHandleInput?: (key: Key) => boolean; | ||
| } | ||
|
|
@@ -64,6 +66,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({ | |
| suggestionsWidth, | ||
| shellModeActive, | ||
| setShellModeActive, | ||
| approvalMode, | ||
| onEscapePromptChange, | ||
| vimHandleInput, | ||
| }) => { | ||
|
|
@@ -709,21 +712,36 @@ export const InputPrompt: React.FC<InputPromptProps> = ({ | |
|
|
||
| const { inlineGhost, additionalLines } = getGhostTextLines(); | ||
|
|
||
| const showAutoAcceptStyling = | ||
| !shellModeActive && approvalMode === ApprovalMode.AUTO_EDIT; | ||
| const showYoloStyling = | ||
| !shellModeActive && approvalMode === ApprovalMode.YOLO; | ||
|
|
||
| let statusColor: string | undefined; | ||
| let statusText = ''; | ||
| if (shellModeActive) { | ||
| statusColor = theme.ui.symbol; | ||
| statusText = 'Shell mode'; | ||
| } else if (showYoloStyling) { | ||
| statusColor = theme.status.error; | ||
| statusText = 'YOLO mode'; | ||
| } else if (showAutoAcceptStyling) { | ||
| statusColor = theme.status.warning; | ||
| statusText = 'Accepting edits'; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <Box | ||
| borderStyle="round" | ||
| borderColor={ | ||
| shellModeActive | ||
| ? theme.status.warning | ||
| : focus | ||
| ? theme.border.focused | ||
| : theme.border.default | ||
| statusColor ?? (focus ? theme.border.focused : theme.border.default) | ||
| } | ||
| paddingX={1} | ||
| > | ||
| <Text | ||
| color={shellModeActive ? theme.status.warning : theme.text.accent} | ||
| color={statusColor ?? theme.text.accent} | ||
| aria-label={statusText || undefined} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chrstnb added an aria label here, let me know if this looks correct to you. |
||
| > | ||
| {shellModeActive ? ( | ||
| reverseSearchActive ? ( | ||
|
|
@@ -734,11 +752,13 @@ export const InputPrompt: React.FC<InputPromptProps> = ({ | |
| (r:){' '} | ||
| </Text> | ||
| ) : ( | ||
| '! ' | ||
| '!' | ||
| ) | ||
| ) : showYoloStyling ? ( | ||
miguelsolorio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| '*' | ||
| ) : ( | ||
| '> ' | ||
| )} | ||
| '>' | ||
| )}{' '} | ||
| </Text> | ||
| <Box flexGrow={1} flexDirection="column"> | ||
| {buffer.text.length === 0 && placeholder ? ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/cli/src/ui/components/__snapshots__/InputPrompt.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`InputPrompt > snapshots > should render correctly in shell mode 1`] = ` | ||
| "โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
| โ ! Type your message or @path/to/file โ | ||
| โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ" | ||
| `; | ||
|
|
||
| exports[`InputPrompt > snapshots > should render correctly in yolo mode 1`] = ` | ||
| "โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
| โ * Type your message or @path/to/file โ | ||
| โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ" | ||
| `; | ||
|
|
||
| exports[`InputPrompt > snapshots > should render correctly when accepting edits 1`] = ` | ||
| "โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
| โ > Type your message or @path/to/file โ | ||
| โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ" | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.