feat: 添加 UI 组件增强与测试覆盖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
unraid
2026-04-22 22:38:10 +08:00
parent 23bb09d240
commit 23fcbf9004
13 changed files with 1332 additions and 1299 deletions

View File

@@ -0,0 +1,31 @@
/**
* UserCrossSessionMessage — render a message received from another Claude session
* via UDS_INBOX (SendMessage tool).
*/
import type { TextBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
import * as React from 'react';
import { Box, Text } from '@anthropic/ink';
import { extractTag } from '../../utils/messages.js';
type Props = {
addMargin: boolean;
param: TextBlockParam;
};
export function UserCrossSessionMessage({ param, addMargin }: Props): React.ReactNode {
const text = param.text;
const extracted = extractTag(text, 'cross-session-message');
if (!extracted) {
return null;
}
const fromMatch = text.match(/from="([^"]*)"/);
const from = fromMatch?.[1] ?? 'another session';
return (
<Box flexDirection="row" marginTop={addMargin ? 1 : 0}>
<Text dimColor>[{from}] </Text>
<Text>{extracted}</Text>
</Box>
);
}