mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
fix(ui): added quotes around session id in resume tip (#26669)
This commit is contained in:
@@ -13,6 +13,7 @@ import { type SessionMetrics } from '../contexts/SessionContext.js';
|
||||
import {
|
||||
ToolCallDecision,
|
||||
getShellConfiguration,
|
||||
isWindows,
|
||||
type WorktreeSettings,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
@@ -22,6 +23,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
return {
|
||||
...actual,
|
||||
getShellConfiguration: vi.fn(),
|
||||
isWindows: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -44,6 +46,7 @@ vi.mock('../contexts/ConfigContext.js', async (importOriginal) => {
|
||||
});
|
||||
|
||||
const getShellConfigurationMock = vi.mocked(getShellConfiguration);
|
||||
const isWindowsMock = vi.mocked(isWindows);
|
||||
const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
||||
|
||||
const renderWithMockedStats = async (
|
||||
@@ -106,6 +109,7 @@ describe('<SessionSummaryDisplay />', () => {
|
||||
argsPrefix: ['-c'],
|
||||
shell: 'bash',
|
||||
});
|
||||
isWindowsMock.mockReturnValue(false);
|
||||
});
|
||||
|
||||
it('renders the summary display with a title', async () => {
|
||||
@@ -149,7 +153,7 @@ describe('<SessionSummaryDisplay />', () => {
|
||||
);
|
||||
const output = lastFrame();
|
||||
|
||||
// Standard UUID characters should not be escaped/quoted by default for bash.
|
||||
// Standard UUID characters are NOT wrapped in double quotes on non-Windows.
|
||||
expect(output).toContain('gemini --resume 1234-abcd-5678-efgh');
|
||||
unmount();
|
||||
});
|
||||
@@ -167,7 +171,8 @@ describe('<SessionSummaryDisplay />', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('renders a standard UUID-formatted session ID in the footer (powershell)', async () => {
|
||||
it('renders a standard UUID-formatted session ID in the footer (powershell) on Windows', async () => {
|
||||
isWindowsMock.mockReturnValue(true);
|
||||
getShellConfigurationMock.mockReturnValue({
|
||||
executable: 'powershell.exe',
|
||||
argsPrefix: ['-NoProfile', '-Command'],
|
||||
@@ -181,9 +186,8 @@ describe('<SessionSummaryDisplay />', () => {
|
||||
);
|
||||
const output = lastFrame();
|
||||
|
||||
// PowerShell doesn't wraps UUID in single quotes because
|
||||
// it contains no special characters.
|
||||
expect(output).toContain('gemini --resume 1234-abcd-5678-efgh');
|
||||
// PowerShell doesn't wrap UUID in quotes by default, but we wrap it in double quotes on Windows.
|
||||
expect(output).toContain('gemini --resume "1234-abcd-5678-efgh"');
|
||||
unmount();
|
||||
});
|
||||
|
||||
@@ -201,7 +205,8 @@ describe('<SessionSummaryDisplay />', () => {
|
||||
);
|
||||
const output = lastFrame();
|
||||
|
||||
// PowerShell wraps in single quotes and escapes internal single quotes by doubling them
|
||||
// PowerShell wraps in single quotes and escapes internal single quotes by doubling them.
|
||||
// Since it's already quoted, we don't add redundant double quotes.
|
||||
expect(output).toContain("gemini --resume '''; rm -rf / #'");
|
||||
unmount();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,11 @@ import type React from 'react';
|
||||
import { StatsDisplay } from './StatsDisplay.js';
|
||||
import { useSessionStats } from '../contexts/SessionContext.js';
|
||||
import { useConfig } from '../contexts/ConfigContext.js';
|
||||
import { escapeShellArg, getShellConfiguration } from '@google/gemini-cli-core';
|
||||
import {
|
||||
escapeShellArg,
|
||||
getShellConfiguration,
|
||||
isWindows,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
interface SessionSummaryDisplayProps {
|
||||
duration: string;
|
||||
@@ -24,11 +28,17 @@ export const SessionSummaryDisplay: React.FC<SessionSummaryDisplayProps> = ({
|
||||
const worktreeSettings = config.getWorktreeSettings();
|
||||
|
||||
const escapedSessionId = escapeShellArg(stats.sessionId, shell);
|
||||
let footer = `To resume this session: gemini --resume ${escapedSessionId}`;
|
||||
const footerSessionId =
|
||||
isWindows() &&
|
||||
!escapedSessionId.startsWith('"') &&
|
||||
!escapedSessionId.startsWith("'")
|
||||
? `"${escapedSessionId}"`
|
||||
: escapedSessionId;
|
||||
let footer = `To resume this session: gemini --resume ${footerSessionId}`;
|
||||
|
||||
if (worktreeSettings) {
|
||||
footer =
|
||||
`To resume work in this worktree: cd ${escapeShellArg(worktreeSettings.path, shell)} && gemini --resume ${escapedSessionId}\n` +
|
||||
`To resume work in this worktree: cd ${escapeShellArg(worktreeSettings.path, shell)} && gemini --resume ${footerSessionId}\n` +
|
||||
`To remove manually: git worktree remove ${escapeShellArg(worktreeSettings.path, shell)}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user