From 4930a24d07ed09093cf801075480e642dd59dc0b Mon Sep 17 00:00:00 2001 From: Alexander Farber Date: Sat, 13 Dec 2025 14:35:40 +0100 Subject: [PATCH] Polish the PR, minor improvements --- .../src/ui/components/ResumeSessionDialog.tsx | 22 ++++++++++++------- .../cli/src/ui/components/SessionListItem.tsx | 6 ++--- .../ui/components/StandaloneSessionPicker.tsx | 13 ++++++----- .../src/ui/hooks/useDialogSessionPicker.ts | 7 +----- .../ui/hooks/useStandaloneSessionPicker.ts | 13 ++++++----- .../cli/src/ui/utils/sessionPickerUtils.ts | 9 ++++++++ 6 files changed, 42 insertions(+), 28 deletions(-) diff --git a/packages/cli/src/ui/components/ResumeSessionDialog.tsx b/packages/cli/src/ui/components/ResumeSessionDialog.tsx index 8593eeb7..a52f89d0 100644 --- a/packages/cli/src/ui/components/ResumeSessionDialog.tsx +++ b/packages/cli/src/ui/components/ResumeSessionDialog.tsx @@ -10,6 +10,7 @@ import { SessionService, getGitBranch } from '@qwen-code/qwen-code-core'; import { theme } from '../semantic-colors.js'; import { useDialogSessionPicker } from '../hooks/useDialogSessionPicker.js'; import { SessionListItemView } from './SessionListItem.js'; +import { t } from '../../i18n/index.js'; export interface ResumeSessionDialogProps { cwd: string; @@ -59,10 +60,10 @@ export function ResumeSessionDialog({ padding={1} > - Resume Session + {t('Resume Session')} - Loading sessions... + {t('Loading sessions...')} ); @@ -78,10 +79,13 @@ export function ResumeSessionDialog({ {/* Header */} - Resume Session + {t('Resume Session')} {picker.filterByBranch && currentBranch && ( - (branch: {currentBranch}) + + {' '} + {t('(branch: {{branch}})', { branch: currentBranch })} + )} @@ -91,8 +95,10 @@ export function ResumeSessionDialog({ {picker.filterByBranch - ? `No sessions found for branch "${currentBranch}"` - : 'No sessions found'} + ? t('No sessions found for branch "{{branch}}"', { + branch: currentBranch ?? '', + }) + : t('No sessions found')} ) : ( @@ -130,10 +136,10 @@ export function ResumeSessionDialog({ B - {' to toggle branch · '} + {t(' to toggle branch') + ' · '} )} - {'↑↓ to navigate · Enter to select · Esc to cancel'} + {t('to navigate · Enter to select · Esc to cancel')} diff --git a/packages/cli/src/ui/components/SessionListItem.tsx b/packages/cli/src/ui/components/SessionListItem.tsx index 5d51b7bf..7e577b4c 100644 --- a/packages/cli/src/ui/components/SessionListItem.tsx +++ b/packages/cli/src/ui/components/SessionListItem.tsx @@ -22,9 +22,9 @@ export interface SessionListItemViewProps { showScrollDown: boolean; maxPromptWidth: number; /** - * Prefix characters to use for selected, scroll up, and scroll down states. - * Defaults to ['> ', '^ ', 'v '] (dialog style). - * Use ['> ', '^ ', 'v '] for dialog or ['> ', '^ ', 'v '] for standalone. + * Prefix characters for selection indicator and scroll hints. + * Dialog style uses '> ', '^ ', 'v ' (ASCII). + * Standalone style uses special Unicode characters. */ prefixChars?: { selected: string; diff --git a/packages/cli/src/ui/components/StandaloneSessionPicker.tsx b/packages/cli/src/ui/components/StandaloneSessionPicker.tsx index b519710e..2f13f75c 100644 --- a/packages/cli/src/ui/components/StandaloneSessionPicker.tsx +++ b/packages/cli/src/ui/components/StandaloneSessionPicker.tsx @@ -10,6 +10,7 @@ import { SessionService, getGitBranch } from '@qwen-code/qwen-code-core'; import { theme } from '../semantic-colors.js'; import { useSessionPicker } from '../hooks/useStandaloneSessionPicker.js'; import { SessionListItemView } from './SessionListItem.js'; +import { t } from '../../i18n/index.js'; // Exported for testing export interface SessionPickerProps { @@ -109,7 +110,7 @@ export function SessionPicker({ {/* Header row */} - Resume Session + {t('Resume Session')} @@ -126,8 +127,10 @@ export function SessionPicker({ {picker.filterByBranch - ? `No sessions found for branch "${currentBranch}"` - : 'No sessions found'} + ? t('No sessions found for branch "{{branch}}"', { + branch: currentBranch ?? '', + }) + : t('No sessions found')} ) : ( @@ -169,10 +172,10 @@ export function SessionPicker({ > B - {' to toggle branch · '} + {t(' to toggle branch') + ' · '} )} - {'↑↓ to navigate · Esc to cancel'} + {t('to navigate · Esc to cancel')} diff --git a/packages/cli/src/ui/hooks/useDialogSessionPicker.ts b/packages/cli/src/ui/hooks/useDialogSessionPicker.ts index 35547f4a..0292f829 100644 --- a/packages/cli/src/ui/hooks/useDialogSessionPicker.ts +++ b/packages/cli/src/ui/hooks/useDialogSessionPicker.ts @@ -19,15 +19,10 @@ import type { import { SESSION_PAGE_SIZE, filterSessions, + type SessionState, } from '../utils/sessionPickerUtils.js'; import { useKeypress } from './useKeypress.js'; -export interface SessionState { - sessions: SessionListItem[]; - hasMore: boolean; - nextCursor?: number; -} - export interface UseDialogSessionPickerOptions { sessionService: SessionService | null; currentBranch?: string; diff --git a/packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts b/packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts index f45f26fc..601f49ed 100644 --- a/packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts +++ b/packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts @@ -4,6 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +/** + * Session picker hook for standalone mode (fullscreen CLI picker). + * Uses useInput (ink) instead of useKeypress (KeypressContext). + * For dialog mode within the main app, use useDialogSessionPicker instead. + */ + import { useState, useEffect, useCallback, useRef } from 'react'; import { useInput } from 'ink'; import type { @@ -14,14 +20,9 @@ import type { import { SESSION_PAGE_SIZE, filterSessions, + type SessionState, } from '../utils/sessionPickerUtils.js'; -export interface SessionState { - sessions: SessionListItem[]; - hasMore: boolean; - nextCursor?: number; -} - export interface UseSessionPickerOptions { sessionService: SessionService | null; currentBranch?: string; diff --git a/packages/cli/src/ui/utils/sessionPickerUtils.ts b/packages/cli/src/ui/utils/sessionPickerUtils.ts index 09d9f704..89942fd8 100644 --- a/packages/cli/src/ui/utils/sessionPickerUtils.ts +++ b/packages/cli/src/ui/utils/sessionPickerUtils.ts @@ -6,6 +6,15 @@ import type { SessionListItem } from '@qwen-code/qwen-code-core'; +/** + * State for managing loaded sessions in the session picker. + */ +export interface SessionState { + sessions: SessionListItem[]; + hasMore: boolean; + nextCursor?: number; +} + /** * Page size for loading sessions. */