diff --git a/packages/cli/src/ui/components/DialogManager.tsx b/packages/cli/src/ui/components/DialogManager.tsx
index ce2c93bb..c00c065e 100644
--- a/packages/cli/src/ui/components/DialogManager.tsx
+++ b/packages/cli/src/ui/components/DialogManager.tsx
@@ -28,7 +28,7 @@ import { useConfig } from '../contexts/ConfigContext.js';
import { useSettings } from '../contexts/SettingsContext.js';
import { SettingScope } from '../../config/settings.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 { type UseHistoryManagerReturn } from '../hooks/useHistoryManager.js';
import { IdeTrustChangeDialog } from './IdeTrustChangeDialog.js';
@@ -295,7 +295,7 @@ export const DialogManager = ({
return (
diff --git a/packages/cli/src/ui/components/SessionPicker.tsx b/packages/cli/src/ui/components/SessionPicker.tsx
index 767a1353..9729d4c6 100644
--- a/packages/cli/src/ui/components/SessionPicker.tsx
+++ b/packages/cli/src/ui/components/SessionPicker.tsx
@@ -5,7 +5,6 @@
*/
import { Box, Text } from 'ink';
-import { useEffect, useState } from 'react';
import type {
SessionListItem as SessionData,
SessionService,
@@ -17,6 +16,7 @@ import {
formatMessageCount,
truncateText,
} from '../utils/sessionPickerUtils.js';
+import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { t } from '../../i18n/index.js';
export interface SessionPickerProps {
@@ -125,27 +125,10 @@ export function SessionPicker(props: SessionPickerProps) {
centerSelection = true,
} = props;
- const [terminalSize, setTerminalSize] = useState({
- 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);
- };
- }, []);
+ const { columns: width, rows: height } = useTerminalSize();
+ // Calculate box width (width + 6 for border padding)
+ const boxWidth = width + 6;
// Calculate visible items (same heuristic as before)
// Reserved space: header (1), footer (1), separators (2), borders (2)
const reservedLines = 6;
@@ -153,7 +136,7 @@ export function SessionPicker(props: SessionPickerProps) {
const itemHeight = 3;
const maxVisibleItems = Math.max(
1,
- Math.floor((terminalSize.height - reservedLines) / itemHeight),
+ Math.floor((height - reservedLines) / itemHeight),
);
const picker = useSessionPicker({
@@ -166,17 +149,10 @@ export function SessionPicker(props: SessionPickerProps) {
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 (
@@ -184,7 +160,7 @@ export function SessionPicker(props: SessionPickerProps) {
flexDirection="column"
borderStyle="round"
borderColor={theme.border.default}
- width={width}
+ width={boxWidth}
height={height - 1}
overflow="hidden"
>
@@ -236,7 +212,7 @@ export function SessionPicker(props: SessionPickerProps) {
isLast={visibleIndex === picker.visibleSessions.length - 1}
showScrollUp={picker.showScrollUp}
showScrollDown={picker.showScrollDown}
- maxPromptWidth={promptMaxWidth}
+ maxPromptWidth={width}
prefixChars={PREFIX_CHARS}
boldSelectedPrefix={false}
/>
diff --git a/packages/cli/src/ui/utils/sessionPickerUtils.ts b/packages/cli/src/ui/utils/sessionPickerUtils.ts
index 3b8ab118..74560c5b 100644
--- a/packages/cli/src/ui/utils/sessionPickerUtils.ts
+++ b/packages/cli/src/ui/utils/sessionPickerUtils.ts
@@ -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(
sessions: SessionListItem[],