mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix review comments
This commit is contained in:
@@ -28,7 +28,7 @@ import { useConfig } from '../contexts/ConfigContext.js';
|
|||||||
import { useSettings } from '../contexts/SettingsContext.js';
|
import { useSettings } from '../contexts/SettingsContext.js';
|
||||||
import { SettingScope } from '../../config/settings.js';
|
import { SettingScope } from '../../config/settings.js';
|
||||||
import { AuthState } from '../types.js';
|
import { AuthState } from '../types.js';
|
||||||
import { AuthType, getGitBranch } from '@qwen-code/qwen-code-core';
|
import { AuthType } from '@qwen-code/qwen-code-core';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import { type UseHistoryManagerReturn } from '../hooks/useHistoryManager.js';
|
import { type UseHistoryManagerReturn } from '../hooks/useHistoryManager.js';
|
||||||
import { IdeTrustChangeDialog } from './IdeTrustChangeDialog.js';
|
import { IdeTrustChangeDialog } from './IdeTrustChangeDialog.js';
|
||||||
@@ -295,7 +295,7 @@ export const DialogManager = ({
|
|||||||
return (
|
return (
|
||||||
<SessionPicker
|
<SessionPicker
|
||||||
sessionService={config.getSessionService()}
|
sessionService={config.getSessionService()}
|
||||||
currentBranch={getGitBranch(config.getTargetDir())}
|
currentBranch={uiState.branchName}
|
||||||
onSelect={uiActions.handleResume}
|
onSelect={uiActions.handleResume}
|
||||||
onCancel={uiActions.closeResumeDialog}
|
onCancel={uiActions.closeResumeDialog}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import type {
|
import type {
|
||||||
SessionListItem as SessionData,
|
SessionListItem as SessionData,
|
||||||
SessionService,
|
SessionService,
|
||||||
@@ -17,6 +16,7 @@ import {
|
|||||||
formatMessageCount,
|
formatMessageCount,
|
||||||
truncateText,
|
truncateText,
|
||||||
} from '../utils/sessionPickerUtils.js';
|
} from '../utils/sessionPickerUtils.js';
|
||||||
|
import { useTerminalSize } from '../hooks/useTerminalSize.js';
|
||||||
import { t } from '../../i18n/index.js';
|
import { t } from '../../i18n/index.js';
|
||||||
|
|
||||||
export interface SessionPickerProps {
|
export interface SessionPickerProps {
|
||||||
@@ -125,27 +125,10 @@ export function SessionPicker(props: SessionPickerProps) {
|
|||||||
centerSelection = true,
|
centerSelection = true,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [terminalSize, setTerminalSize] = useState({
|
const { columns: width, rows: height } = useTerminalSize();
|
||||||
width: process.stdout.columns || 80,
|
|
||||||
height: process.stdout.rows || 24,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Keep fullscreen picker responsive to terminal resize.
|
|
||||||
useEffect(() => {
|
|
||||||
const handleResize = () => {
|
|
||||||
setTerminalSize({
|
|
||||||
width: process.stdout.columns || 80,
|
|
||||||
height: process.stdout.rows || 24,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// `stdout` emits "resize" when TTY size changes.
|
|
||||||
process.stdout.on('resize', handleResize);
|
|
||||||
return () => {
|
|
||||||
process.stdout.off('resize', handleResize);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
// Calculate box width (width + 6 for border padding)
|
||||||
|
const boxWidth = width + 6;
|
||||||
// Calculate visible items (same heuristic as before)
|
// Calculate visible items (same heuristic as before)
|
||||||
// Reserved space: header (1), footer (1), separators (2), borders (2)
|
// Reserved space: header (1), footer (1), separators (2), borders (2)
|
||||||
const reservedLines = 6;
|
const reservedLines = 6;
|
||||||
@@ -153,7 +136,7 @@ export function SessionPicker(props: SessionPickerProps) {
|
|||||||
const itemHeight = 3;
|
const itemHeight = 3;
|
||||||
const maxVisibleItems = Math.max(
|
const maxVisibleItems = Math.max(
|
||||||
1,
|
1,
|
||||||
Math.floor((terminalSize.height - reservedLines) / itemHeight),
|
Math.floor((height - reservedLines) / itemHeight),
|
||||||
);
|
);
|
||||||
|
|
||||||
const picker = useSessionPicker({
|
const picker = useSessionPicker({
|
||||||
@@ -166,17 +149,10 @@ export function SessionPicker(props: SessionPickerProps) {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const width = terminalSize.width;
|
|
||||||
const height = terminalSize.height;
|
|
||||||
|
|
||||||
// Calculate content width (terminal width minus border padding)
|
|
||||||
const contentWidth = width - 4;
|
|
||||||
const promptMaxWidth = contentWidth - 4;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
width={width}
|
width={boxWidth}
|
||||||
height={height - 1}
|
height={height - 1}
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
>
|
>
|
||||||
@@ -184,7 +160,7 @@ export function SessionPicker(props: SessionPickerProps) {
|
|||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
borderStyle="round"
|
borderStyle="round"
|
||||||
borderColor={theme.border.default}
|
borderColor={theme.border.default}
|
||||||
width={width}
|
width={boxWidth}
|
||||||
height={height - 1}
|
height={height - 1}
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
>
|
>
|
||||||
@@ -236,7 +212,7 @@ export function SessionPicker(props: SessionPickerProps) {
|
|||||||
isLast={visibleIndex === picker.visibleSessions.length - 1}
|
isLast={visibleIndex === picker.visibleSessions.length - 1}
|
||||||
showScrollUp={picker.showScrollUp}
|
showScrollUp={picker.showScrollUp}
|
||||||
showScrollDown={picker.showScrollDown}
|
showScrollDown={picker.showScrollDown}
|
||||||
maxPromptWidth={promptMaxWidth}
|
maxPromptWidth={width}
|
||||||
prefixChars={PREFIX_CHARS}
|
prefixChars={PREFIX_CHARS}
|
||||||
boldSelectedPrefix={false}
|
boldSelectedPrefix={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function truncateText(text: string, maxWidth: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters sessions to exclude empty ones (0 messages) and optionally by branch.
|
* Filters sessions optionally by branch.
|
||||||
*/
|
*/
|
||||||
export function filterSessions(
|
export function filterSessions(
|
||||||
sessions: SessionListItem[],
|
sessions: SessionListItem[],
|
||||||
|
|||||||
Reference in New Issue
Block a user