Polish the PR, minor improvements

This commit is contained in:
Alexander Farber
2025-12-13 14:35:40 +01:00
parent 7a97fcd5f1
commit 4930a24d07
6 changed files with 42 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ import { SessionService, getGitBranch } from '@qwen-code/qwen-code-core';
import { theme } from '../semantic-colors.js'; import { theme } from '../semantic-colors.js';
import { useDialogSessionPicker } from '../hooks/useDialogSessionPicker.js'; import { useDialogSessionPicker } from '../hooks/useDialogSessionPicker.js';
import { SessionListItemView } from './SessionListItem.js'; import { SessionListItemView } from './SessionListItem.js';
import { t } from '../../i18n/index.js';
export interface ResumeSessionDialogProps { export interface ResumeSessionDialogProps {
cwd: string; cwd: string;
@@ -59,10 +60,10 @@ export function ResumeSessionDialog({
padding={1} padding={1}
> >
<Text color={theme.text.primary} bold> <Text color={theme.text.primary} bold>
Resume Session {t('Resume Session')}
</Text> </Text>
<Box paddingY={1}> <Box paddingY={1}>
<Text color={theme.text.secondary}>Loading sessions...</Text> <Text color={theme.text.secondary}>{t('Loading sessions...')}</Text>
</Box> </Box>
</Box> </Box>
); );
@@ -78,10 +79,13 @@ export function ResumeSessionDialog({
{/* Header */} {/* Header */}
<Box marginBottom={1}> <Box marginBottom={1}>
<Text color={theme.text.primary} bold> <Text color={theme.text.primary} bold>
Resume Session {t('Resume Session')}
</Text> </Text>
{picker.filterByBranch && currentBranch && ( {picker.filterByBranch && currentBranch && (
<Text color={theme.text.secondary}> (branch: {currentBranch})</Text> <Text color={theme.text.secondary}>
{' '}
{t('(branch: {{branch}})', { branch: currentBranch })}
</Text>
)} )}
</Box> </Box>
@@ -91,8 +95,10 @@ export function ResumeSessionDialog({
<Box paddingY={1}> <Box paddingY={1}>
<Text color={theme.text.secondary}> <Text color={theme.text.secondary}>
{picker.filterByBranch {picker.filterByBranch
? `No sessions found for branch "${currentBranch}"` ? t('No sessions found for branch "{{branch}}"', {
: 'No sessions found'} branch: currentBranch ?? '',
})
: t('No sessions found')}
</Text> </Text>
</Box> </Box>
) : ( ) : (
@@ -130,10 +136,10 @@ export function ResumeSessionDialog({
<Text color={theme.text.accent} bold> <Text color={theme.text.accent} bold>
B B
</Text> </Text>
{' to toggle branch · '} {t(' to toggle branch') + ' · '}
</> </>
)} )}
{'↑↓ to navigate · Enter to select · Esc to cancel'} {t('to navigate · Enter to select · Esc to cancel')}
</Text> </Text>
</Box> </Box>
</Box> </Box>

View File

@@ -22,9 +22,9 @@ export interface SessionListItemViewProps {
showScrollDown: boolean; showScrollDown: boolean;
maxPromptWidth: number; maxPromptWidth: number;
/** /**
* Prefix characters to use for selected, scroll up, and scroll down states. * Prefix characters for selection indicator and scroll hints.
* Defaults to ['> ', '^ ', 'v '] (dialog style). * Dialog style uses '> ', '^ ', 'v ' (ASCII).
* Use ['> ', '^ ', 'v '] for dialog or ['> ', '^ ', 'v '] for standalone. * Standalone style uses special Unicode characters.
*/ */
prefixChars?: { prefixChars?: {
selected: string; selected: string;

View File

@@ -10,6 +10,7 @@ import { SessionService, getGitBranch } from '@qwen-code/qwen-code-core';
import { theme } from '../semantic-colors.js'; import { theme } from '../semantic-colors.js';
import { useSessionPicker } from '../hooks/useStandaloneSessionPicker.js'; import { useSessionPicker } from '../hooks/useStandaloneSessionPicker.js';
import { SessionListItemView } from './SessionListItem.js'; import { SessionListItemView } from './SessionListItem.js';
import { t } from '../../i18n/index.js';
// Exported for testing // Exported for testing
export interface SessionPickerProps { export interface SessionPickerProps {
@@ -109,7 +110,7 @@ export function SessionPicker({
{/* Header row */} {/* Header row */}
<Box paddingX={1}> <Box paddingX={1}>
<Text bold color={theme.text.primary}> <Text bold color={theme.text.primary}>
Resume Session {t('Resume Session')}
</Text> </Text>
</Box> </Box>
@@ -126,8 +127,10 @@ export function SessionPicker({
<Box paddingY={1} justifyContent="center"> <Box paddingY={1} justifyContent="center">
<Text color={theme.text.secondary}> <Text color={theme.text.secondary}>
{picker.filterByBranch {picker.filterByBranch
? `No sessions found for branch "${currentBranch}"` ? t('No sessions found for branch "{{branch}}"', {
: 'No sessions found'} branch: currentBranch ?? '',
})
: t('No sessions found')}
</Text> </Text>
</Box> </Box>
) : ( ) : (
@@ -169,10 +172,10 @@ export function SessionPicker({
> >
B B
</Text> </Text>
{' to toggle branch · '} {t(' to toggle branch') + ' · '}
</> </>
)} )}
{'↑↓ to navigate · Esc to cancel'} {t('to navigate · Esc to cancel')}
</Text> </Text>
</Box> </Box>
</Box> </Box>

View File

@@ -19,15 +19,10 @@ import type {
import { import {
SESSION_PAGE_SIZE, SESSION_PAGE_SIZE,
filterSessions, filterSessions,
type SessionState,
} from '../utils/sessionPickerUtils.js'; } from '../utils/sessionPickerUtils.js';
import { useKeypress } from './useKeypress.js'; import { useKeypress } from './useKeypress.js';
export interface SessionState {
sessions: SessionListItem[];
hasMore: boolean;
nextCursor?: number;
}
export interface UseDialogSessionPickerOptions { export interface UseDialogSessionPickerOptions {
sessionService: SessionService | null; sessionService: SessionService | null;
currentBranch?: string; currentBranch?: string;

View File

@@ -4,6 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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 { useState, useEffect, useCallback, useRef } from 'react';
import { useInput } from 'ink'; import { useInput } from 'ink';
import type { import type {
@@ -14,14 +20,9 @@ import type {
import { import {
SESSION_PAGE_SIZE, SESSION_PAGE_SIZE,
filterSessions, filterSessions,
type SessionState,
} from '../utils/sessionPickerUtils.js'; } from '../utils/sessionPickerUtils.js';
export interface SessionState {
sessions: SessionListItem[];
hasMore: boolean;
nextCursor?: number;
}
export interface UseSessionPickerOptions { export interface UseSessionPickerOptions {
sessionService: SessionService | null; sessionService: SessionService | null;
currentBranch?: string; currentBranch?: string;

View File

@@ -6,6 +6,15 @@
import type { SessionListItem } from '@qwen-code/qwen-code-core'; 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. * Page size for loading sessions.
*/ */