-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix(patch): cherry-pick d351f07 to release/v0.18.0-preview.1-pr-12535 to patch version v0.18.0-preview.1 and create version 0.18.0-preview.2 #13813
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
SandyTao520
merged 1 commit into
release/v0.18.0-preview.1-pr-12535
from
hotfix/v0.18.0-preview.1/0.18.0-preview.2/preview/cherry-pick-d351f07/pr-12535
Nov 25, 2025
+416
−103
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,8 @@ | |||||||||||||||||
| */ | ||||||||||||||||||
|
|
||||||||||||||||||
| import type React from 'react'; | ||||||||||||||||||
| import { Box } from 'ink'; | ||||||||||||||||||
| import { useState, useEffect } from 'react'; | ||||||||||||||||||
| import { Box, Text } from 'ink'; | ||||||||||||||||||
| import type { IndividualToolCallDisplay } from '../../types.js'; | ||||||||||||||||||
| import { StickyHeader } from '../StickyHeader.js'; | ||||||||||||||||||
| import { ToolResultDisplay } from './ToolResultDisplay.js'; | ||||||||||||||||||
|
|
@@ -14,7 +15,17 @@ import { | |||||||||||||||||
| ToolInfo, | ||||||||||||||||||
| TrailingIndicator, | ||||||||||||||||||
| type TextEmphasis, | ||||||||||||||||||
| STATUS_INDICATOR_WIDTH, | ||||||||||||||||||
| } from './ToolShared.js'; | ||||||||||||||||||
| import { | ||||||||||||||||||
| SHELL_COMMAND_NAME, | ||||||||||||||||||
| SHELL_FOCUS_HINT_DELAY_MS, | ||||||||||||||||||
| } from '../../constants.js'; | ||||||||||||||||||
| import { theme } from '../../semantic-colors.js'; | ||||||||||||||||||
| import type { Config } from '@google/gemini-cli-core'; | ||||||||||||||||||
| import { useInactivityTimer } from '../../hooks/useInactivityTimer.js'; | ||||||||||||||||||
| import { ToolCallStatus } from '../../types.js'; | ||||||||||||||||||
| import { ShellInputPrompt } from '../ShellInputPrompt.js'; | ||||||||||||||||||
|
|
||||||||||||||||||
| export type { TextEmphasis }; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -26,6 +37,10 @@ export interface ToolMessageProps extends IndividualToolCallDisplay { | |||||||||||||||||
| isFirst: boolean; | ||||||||||||||||||
| borderColor: string; | ||||||||||||||||||
| borderDimColor: boolean; | ||||||||||||||||||
| activeShellPtyId?: number | null; | ||||||||||||||||||
| embeddedShellFocused?: boolean; | ||||||||||||||||||
| ptyId?: number; | ||||||||||||||||||
| config?: Config; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| export const ToolMessage: React.FC<ToolMessageProps> = ({ | ||||||||||||||||||
|
|
@@ -40,41 +55,96 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({ | |||||||||||||||||
| isFirst, | ||||||||||||||||||
| borderColor, | ||||||||||||||||||
| borderDimColor, | ||||||||||||||||||
| }) => ( | ||||||||||||||||||
| <Box flexDirection="column" width={terminalWidth}> | ||||||||||||||||||
| <StickyHeader | ||||||||||||||||||
| width={terminalWidth} | ||||||||||||||||||
| isFirst={isFirst} | ||||||||||||||||||
| borderColor={borderColor} | ||||||||||||||||||
| borderDimColor={borderDimColor} | ||||||||||||||||||
| > | ||||||||||||||||||
| <ToolStatusIndicator status={status} name={name} /> | ||||||||||||||||||
| <ToolInfo | ||||||||||||||||||
| name={name} | ||||||||||||||||||
| status={status} | ||||||||||||||||||
| description={description} | ||||||||||||||||||
| emphasis={emphasis} | ||||||||||||||||||
| /> | ||||||||||||||||||
| {emphasis === 'high' && <TrailingIndicator />} | ||||||||||||||||||
| </StickyHeader> | ||||||||||||||||||
| <Box | ||||||||||||||||||
| width={terminalWidth} | ||||||||||||||||||
| borderStyle="round" | ||||||||||||||||||
| borderColor={borderColor} | ||||||||||||||||||
| borderDimColor={borderDimColor} | ||||||||||||||||||
| borderTop={false} | ||||||||||||||||||
| borderBottom={false} | ||||||||||||||||||
| borderLeft={true} | ||||||||||||||||||
| borderRight={true} | ||||||||||||||||||
| paddingX={1} | ||||||||||||||||||
| flexDirection="column" | ||||||||||||||||||
| > | ||||||||||||||||||
| <ToolResultDisplay | ||||||||||||||||||
| resultDisplay={resultDisplay} | ||||||||||||||||||
| availableTerminalHeight={availableTerminalHeight} | ||||||||||||||||||
| terminalWidth={terminalWidth} | ||||||||||||||||||
| renderOutputAsMarkdown={renderOutputAsMarkdown} | ||||||||||||||||||
| /> | ||||||||||||||||||
| activeShellPtyId, | ||||||||||||||||||
| embeddedShellFocused, | ||||||||||||||||||
| ptyId, | ||||||||||||||||||
| config, | ||||||||||||||||||
| }) => { | ||||||||||||||||||
| const isThisShellFocused = | ||||||||||||||||||
| (name === SHELL_COMMAND_NAME || name === 'Shell') && | ||||||||||||||||||
| status === ToolCallStatus.Executing && | ||||||||||||||||||
| ptyId === activeShellPtyId && | ||||||||||||||||||
| embeddedShellFocused; | ||||||||||||||||||
|
|
||||||||||||||||||
| const [lastUpdateTime, setLastUpdateTime] = useState<Date | null>(null); | ||||||||||||||||||
| const [userHasFocused, setUserHasFocused] = useState(false); | ||||||||||||||||||
| const showFocusHint = useInactivityTimer( | ||||||||||||||||||
| !!lastUpdateTime, | ||||||||||||||||||
| lastUpdateTime ? lastUpdateTime.getTime() : 0, | ||||||||||||||||||
| SHELL_FOCUS_HINT_DELAY_MS, | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||
| if (resultDisplay) { | ||||||||||||||||||
| setLastUpdateTime(new Date()); | ||||||||||||||||||
| } | ||||||||||||||||||
| }, [resultDisplay]); | ||||||||||||||||||
|
|
||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||
| if (isThisShellFocused) { | ||||||||||||||||||
| setUserHasFocused(true); | ||||||||||||||||||
| } | ||||||||||||||||||
| }, [isThisShellFocused]); | ||||||||||||||||||
|
|
||||||||||||||||||
| const isThisShellFocusable = | ||||||||||||||||||
| (name === SHELL_COMMAND_NAME || name === 'Shell') && | ||||||||||||||||||
| status === ToolCallStatus.Executing && | ||||||||||||||||||
| config?.getEnableInteractiveShell(); | ||||||||||||||||||
|
Comment on lines
+89
to
+92
Contributor
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. Similar to the check for
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| const shouldShowFocusHint = | ||||||||||||||||||
| isThisShellFocusable && (showFocusHint || userHasFocused); | ||||||||||||||||||
|
|
||||||||||||||||||
| return ( | ||||||||||||||||||
| <Box flexDirection="column" width={terminalWidth}> | ||||||||||||||||||
| <StickyHeader | ||||||||||||||||||
| width={terminalWidth} | ||||||||||||||||||
| isFirst={isFirst} | ||||||||||||||||||
| borderColor={borderColor} | ||||||||||||||||||
| borderDimColor={borderDimColor} | ||||||||||||||||||
| > | ||||||||||||||||||
| <ToolStatusIndicator status={status} name={name} /> | ||||||||||||||||||
| <ToolInfo | ||||||||||||||||||
| name={name} | ||||||||||||||||||
| status={status} | ||||||||||||||||||
| description={description} | ||||||||||||||||||
| emphasis={emphasis} | ||||||||||||||||||
| /> | ||||||||||||||||||
| {shouldShowFocusHint && ( | ||||||||||||||||||
| <Box marginLeft={1} flexShrink={0}> | ||||||||||||||||||
| <Text color={theme.text.accent}> | ||||||||||||||||||
| {isThisShellFocused ? '(Focused)' : '(ctrl+f to focus)'} | ||||||||||||||||||
| </Text> | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| )} | ||||||||||||||||||
| {emphasis === 'high' && <TrailingIndicator />} | ||||||||||||||||||
| </StickyHeader> | ||||||||||||||||||
| <Box | ||||||||||||||||||
| width={terminalWidth} | ||||||||||||||||||
| borderStyle="round" | ||||||||||||||||||
| borderColor={borderColor} | ||||||||||||||||||
| borderDimColor={borderDimColor} | ||||||||||||||||||
| borderTop={false} | ||||||||||||||||||
| borderBottom={false} | ||||||||||||||||||
| borderLeft={true} | ||||||||||||||||||
| borderRight={true} | ||||||||||||||||||
| paddingX={1} | ||||||||||||||||||
| flexDirection="column" | ||||||||||||||||||
| > | ||||||||||||||||||
| <ToolResultDisplay | ||||||||||||||||||
| resultDisplay={resultDisplay} | ||||||||||||||||||
| availableTerminalHeight={availableTerminalHeight} | ||||||||||||||||||
| terminalWidth={terminalWidth} | ||||||||||||||||||
| renderOutputAsMarkdown={renderOutputAsMarkdown} | ||||||||||||||||||
| /> | ||||||||||||||||||
| {isThisShellFocused && config && ( | ||||||||||||||||||
| <Box paddingLeft={STATUS_INDICATOR_WIDTH} marginTop={1}> | ||||||||||||||||||
| <ShellInputPrompt | ||||||||||||||||||
| activeShellPtyId={activeShellPtyId ?? null} | ||||||||||||||||||
| focus={embeddedShellFocused} | ||||||||||||||||||
| /> | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| )} | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| ); | ||||||||||||||||||
| ); | ||||||||||||||||||
| }; | ||||||||||||||||||
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { useState, useEffect } from 'react'; | ||
|
|
||
| /** | ||
| * Returns true after a specified delay of inactivity. | ||
| * Inactivity is defined as 'trigger' not changing for 'delayMs' milliseconds. | ||
| * | ||
| * @param isActive Whether the timer should be running. | ||
| * @param trigger Any value that, when changed, resets the inactivity timer. | ||
| * @param delayMs The delay in milliseconds before considering the state inactive. | ||
| */ | ||
| export const useInactivityTimer = ( | ||
| isActive: boolean, | ||
| trigger: unknown, | ||
| delayMs: number = 5000, | ||
| ): boolean => { | ||
| const [isInactive, setIsInactive] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (!isActive) { | ||
| setIsInactive(false); | ||
| return; | ||
| } | ||
|
|
||
| setIsInactive(false); | ||
| const timer = setTimeout(() => { | ||
| setIsInactive(true); | ||
| }, delayMs); | ||
|
|
||
| return () => clearTimeout(timer); | ||
| }, [isActive, trigger, delayMs]); | ||
|
|
||
| return isInactive; | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to identify a shell tool is incomplete and uses a hardcoded string. It's missing a check for
SHELL_TOOL_NAME(the internal tool name) and it hardcodes'Shell'instead of using theSHELL_NAMEconstant. This could lead to inconsistent behavior for identifying shell tools.To fix this, you should import
SHELL_NAMEfrom../../constants.jsandSHELL_TOOL_NAMEfrom@google/gemini-cli-coreand update the condition.