Merge branch 'main' into feat/image-attachment

This commit is contained in:
LaZzyMan 2026-02-02 20:23:34 +08:00
commit c92e2b8351
301 changed files with 33924 additions and 5940 deletions

View file

@ -6,22 +6,21 @@
import { Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { tokenLimit } from '@qwen-code/qwen-code-core';
export const ContextUsageDisplay = ({
promptTokenCount,
model,
terminalWidth,
contextWindowSize,
}: {
promptTokenCount: number;
model: string;
terminalWidth: number;
contextWindowSize: number;
}) => {
if (promptTokenCount === 0) {
return null;
}
const percentage = promptTokenCount / tokenLimit(model);
const percentage = promptTokenCount / contextWindowSize;
const percentageUsed = (percentage * 100).toFixed(1);
const label = terminalWidth < 100 ? '% used' : '% context used';

View file

@ -23,6 +23,7 @@ const defaultProps = {
const createMockConfig = (overrides = {}) => ({
getModel: vi.fn(() => defaultProps.model),
getDebugMode: vi.fn(() => false),
getContentGeneratorConfig: vi.fn(() => ({ contextWindowSize: 131072 })),
getMcpServers: vi.fn(() => ({})),
getBlockedMcpServers: vi.fn(() => []),
...overrides,

View file

@ -26,13 +26,11 @@ export const Footer: React.FC = () => {
const { vimEnabled, vimMode } = useVimMode();
const {
model,
errorCount,
showErrorDetails,
promptTokenCount,
showAutoAcceptIndicator,
} = {
model: config.getModel(),
errorCount: uiState.errorCount,
showErrorDetails: uiState.showErrorDetails,
promptTokenCount: uiState.sessionStats.lastPromptTokenCount,
@ -57,6 +55,9 @@ export const Footer: React.FC = () => {
// Check if debug mode is enabled
const debugMode = config.getDebugMode();
const contextWindowSize =
config.getContentGeneratorConfig()?.contextWindowSize;
// Left section should show exactly ONE thing at any time, in priority order.
const leftContent = uiState.ctrlCPressedOnce ? (
<Text color={theme.status.warning}>{t('Press Ctrl+C again to exit.')}</Text>
@ -88,15 +89,15 @@ export const Footer: React.FC = () => {
node: <Text color={theme.status.warning}>Debug Mode</Text>,
});
}
if (promptTokenCount > 0) {
if (promptTokenCount > 0 && contextWindowSize) {
rightItems.push({
key: 'context',
node: (
<Text color={theme.text.accent}>
<ContextUsageDisplay
promptTokenCount={promptTokenCount}
model={model}
terminalWidth={terminalWidth}
contextWindowSize={contextWindowSize}
/>
</Text>
),