diff --git a/web/src/components/Chat/MessageInput.tsx b/web/src/components/Chat/MessageInput.tsx index e572ee4..aaf9f6c 100644 --- a/web/src/components/Chat/MessageInput.tsx +++ b/web/src/components/Chat/MessageInput.tsx @@ -16,6 +16,7 @@ interface MessageInputProps { } interface FileAttachment { + id: string file: File attachment: Attachment preview?: string // 用于图片预览 @@ -92,6 +93,7 @@ export function MessageInput({ } const fileAttachment: FileAttachment = { + id: crypto.randomUUID(), file, attachment, preview: mediaType === 'image' ? base64 : undefined, @@ -170,6 +172,7 @@ export function MessageInput({ } const fileAttachment: FileAttachment = { + id: crypto.randomUUID(), file, attachment, preview: mediaType === 'image' ? base64 : undefined, @@ -295,7 +298,7 @@ export function MessageInput({
{attachments.map((att, index) => (
{att.preview ? ( diff --git a/web/src/components/Settings/ConfigPage.tsx b/web/src/components/Settings/ConfigPage.tsx index 4335b1a..e69f703 100644 --- a/web/src/components/Settings/ConfigPage.tsx +++ b/web/src/components/Settings/ConfigPage.tsx @@ -192,7 +192,7 @@ function TagEditor({ tags, onChange }: { tags: string[]; onChange: (t: string[])
{tags.map((t, i) => ( - + {t} @@ -286,8 +286,8 @@ function SourceEditor({
自定义路径
{customPaths.length > 0 && (
- {customPaths.map((p, i) => ( - + {customPaths.map((p) => ( + {p} diff --git a/web/src/hooks/useChat.ts b/web/src/hooks/useChat.ts index 4cb6522..5eb7ff8 100644 --- a/web/src/hooks/useChat.ts +++ b/web/src/hooks/useChat.ts @@ -236,7 +236,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: role as ChatMessage['role'], content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', attachments: msg.attachments, subagentTaskId: msg.subagent_task_id, @@ -249,7 +249,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_call', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -264,7 +264,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_result', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -278,7 +278,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: `${msg.content}\n\n${msg.resume_hint}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_pending', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -302,7 +302,7 @@ export function useChat(): UseChatReturn { id: generateMessageId(), role: 'assistant', content: `Error: ${message.message}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: message.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', } } @@ -362,7 +362,7 @@ export function useChat(): UseChatReturn { id: generateMessageId(), role: 'assistant', content: `Error: ${errMsg.message}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: errMsg.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', } setSubAgentStack((prev) => { @@ -423,7 +423,7 @@ export function useChat(): UseChatReturn { id: generateMessageId(), role: 'assistant', content: `Error: ${errMsg.message}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: errMsg.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', } const newStack = [...prev] @@ -800,7 +800,7 @@ export function useChat(): UseChatReturn { id: msg.id, role, content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', attachments: msg.attachments, reasoningContent: msg.reasoning_content, @@ -833,7 +833,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_call', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -856,7 +856,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: msg.content, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_result', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -877,7 +877,7 @@ export function useChat(): UseChatReturn { id: msg.id, role: 'tool', content: `${msg.content}\n\n${msg.resume_hint}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: msg.timestamp ?? Math.floor(Date.now() / 1000), type: 'tool_pending', toolName: msg.tool_name, toolCallId: msg.tool_call_id, @@ -893,7 +893,7 @@ export function useChat(): UseChatReturn { id: generateMessageId(), role: 'assistant', content: (message as { type: 'execution_cancelled'; message: string }).message, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: message.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', }, ]) @@ -910,7 +910,7 @@ export function useChat(): UseChatReturn { id: generateMessageId(), role: 'assistant', content: `Error: ${message.message}`, - timestamp: (message as any).timestamp ?? Math.floor(Date.now() / 1000), + timestamp: message.timestamp ?? Math.floor(Date.now() / 1000), type: 'message', }, ]) diff --git a/web/src/types/protocol.ts b/web/src/types/protocol.ts index 1822ea5..a21a7a7 100644 --- a/web/src/types/protocol.ts +++ b/web/src/types/protocol.ts @@ -260,6 +260,7 @@ export interface TaskMessagesLoaded { export interface ExecutionCancelled { type: 'execution_cancelled' message: string + timestamp?: number } export interface StreamDelta {