Merge branch 'main' into feat/token_display

This commit is contained in:
qqqys 2026-03-18 21:40:16 +08:00 committed by GitHub
commit b66b390d55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
195 changed files with 23765 additions and 2508 deletions

View file

@ -103,7 +103,7 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({
const codeMatch = fullMatch.match(/^(`+)(.+?)\1$/s);
if (codeMatch && codeMatch[2]) {
renderedNode = (
<Text key={key} color={theme.text.accent}>
<Text key={key} color={theme.text.code}>
{codeMatch[2]}
</Text>
);

View file

@ -5,6 +5,34 @@
*/
import { theme } from '../semantic-colors.js';
import { AgentStatus } from '@qwen-code/qwen-code-core';
// --- Status Labels ---
export interface StatusLabel {
icon: string;
text: string;
color: string;
}
export function getArenaStatusLabel(status: AgentStatus): StatusLabel {
switch (status) {
case AgentStatus.IDLE:
return { icon: '✓', text: 'Idle', color: theme.status.success };
case AgentStatus.COMPLETED:
return { icon: '✓', text: 'Done', color: theme.status.success };
case AgentStatus.CANCELLED:
return { icon: '⊘', text: 'Cancelled', color: theme.status.warning };
case AgentStatus.FAILED:
return { icon: '✗', text: 'Failed', color: theme.status.error };
case AgentStatus.RUNNING:
return { icon: '○', text: 'Running', color: theme.text.secondary };
case AgentStatus.INITIALIZING:
return { icon: '○', text: 'Initializing', color: theme.text.secondary };
default:
return { icon: '○', text: status, color: theme.text.secondary };
}
}
// --- Thresholds ---
export const TOOL_SUCCESS_RATE_HIGH = 95;

View file

@ -0,0 +1,40 @@
/**
* @license
* Copyright 2025 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Shared layout calculation utilities for the terminal UI.
*/
/**
* Calculate the widths for the input prompt area based on terminal width.
*
* Returns the content width (for the text buffer), the total container width
* (including border + padding + prefix), the suggestions dropdown width,
* and the frame overhead constant.
*/
export const calculatePromptWidths = (terminalWidth: number) => {
const widthFraction = 0.9;
const FRAME_PADDING_AND_BORDER = 4; // Border (2) + padding (2)
const PROMPT_PREFIX_WIDTH = 2; // '> ' or '! '
const MIN_CONTENT_WIDTH = 2;
const innerContentWidth =
Math.floor(terminalWidth * widthFraction) -
FRAME_PADDING_AND_BORDER -
PROMPT_PREFIX_WIDTH;
const inputWidth = Math.max(MIN_CONTENT_WIDTH, innerContentWidth);
const FRAME_OVERHEAD = FRAME_PADDING_AND_BORDER + PROMPT_PREFIX_WIDTH;
const containerWidth = inputWidth + FRAME_OVERHEAD;
const suggestionsWidth = Math.max(20, Math.floor(terminalWidth * 1.0));
return {
inputWidth,
containerWidth,
suggestionsWidth,
frameOverhead: FRAME_OVERHEAD,
} as const;
};