mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
Merge pull request #2696 from QwenLM/feat/hooks-refactor-ui-event
refactor(ui): improve hook event handling with dedicated history items
This commit is contained in:
commit
06a0f4797d
12 changed files with 639 additions and 28 deletions
|
|
@ -6,7 +6,10 @@
|
|||
|
||||
import type React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { escapeAnsiCtrlCodes } from '../utils/textUtils.js';
|
||||
import {
|
||||
escapeAnsiCtrlCodes,
|
||||
sanitizeSensitiveText,
|
||||
} from '../utils/textUtils.js';
|
||||
import type { HistoryItem } from '../types.js';
|
||||
import {
|
||||
UserMessage,
|
||||
|
|
@ -26,7 +29,9 @@ import {
|
|||
RetryCountdownMessage,
|
||||
SuccessMessage,
|
||||
} from './messages/StatusMessages.js';
|
||||
import { Box } from 'ink';
|
||||
import { Box, Text } from 'ink';
|
||||
import { theme } from '../semantic-colors.js';
|
||||
import { MarkdownDisplay } from '../utils/MarkdownDisplay.js';
|
||||
import { AboutBox } from './AboutBox.js';
|
||||
import { StatsDisplay } from './StatsDisplay.js';
|
||||
import { ModelStatsDisplay } from './ModelStatsDisplay.js';
|
||||
|
|
@ -183,7 +188,9 @@ const HistoryItemDisplayComponent: React.FC<HistoryItemDisplayProps> = ({
|
|||
{itemForDisplay.type === 'compression' && (
|
||||
<CompressionMessage compression={itemForDisplay.compression} />
|
||||
)}
|
||||
{item.type === 'summary' && <SummaryMessage summary={item.summary} />}
|
||||
{itemForDisplay.type === 'summary' && (
|
||||
<SummaryMessage summary={itemForDisplay.summary} />
|
||||
)}
|
||||
{itemForDisplay.type === 'extensions_list' && <ExtensionsList />}
|
||||
{itemForDisplay.type === 'tools_list' && (
|
||||
<ToolsList
|
||||
|
|
@ -230,6 +237,30 @@ const HistoryItemDisplayComponent: React.FC<HistoryItemDisplayProps> = ({
|
|||
{itemForDisplay.type === 'btw' && itemForDisplay.btw && (
|
||||
<BtwMessage btw={itemForDisplay.btw} />
|
||||
)}
|
||||
{itemForDisplay.type === 'user_prompt_submit_blocked' && (
|
||||
<Box flexDirection="column">
|
||||
<Text color={theme.status.warning}>
|
||||
{`✕ UserPromptSubmit operation blocked by hook:\n${itemForDisplay.reason}\n\nOriginal prompt: ${sanitizeSensitiveText(itemForDisplay.originalPrompt)}`}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{itemForDisplay.type === 'stop_hook_loop' && (
|
||||
<InfoMessage
|
||||
text={`Ran ${itemForDisplay.stopHookCount} stop hooks\n ⎿ Stop hook error: ${itemForDisplay.reasons[itemForDisplay.reasons.length - 1]}`}
|
||||
/>
|
||||
)}
|
||||
{itemForDisplay.type === 'stop_hook_system_message' && (
|
||||
<Box flexDirection="column">
|
||||
<Text color={theme.text.primary}> ⎿ Stop says:</Text>
|
||||
<Box marginLeft={4} flexDirection="column">
|
||||
<MarkdownDisplay
|
||||
text={itemForDisplay.message}
|
||||
isPending={false}
|
||||
contentWidth={contentWidth - 4}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue