2025-03-31 22:32:19 +08:00
|
|
|
|
<template>
|
2026-01-15 04:54:53 +08:00
|
|
|
|
<div class="chat-container">
|
2025-03-31 22:32:19 +08:00
|
|
|
|
<div class="chat">
|
|
|
|
|
|
<div class="chat-header">
|
|
|
|
|
|
<div class="header__left">
|
2026-03-20 17:51:12 +08:00
|
|
|
|
<slot name="header-left"></slot>
|
2026-03-23 09:43:04 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="currentThread?.title && currentThread.title !== '新的对话'"
|
|
|
|
|
|
class="conversation-title"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ currentThread.title }}
|
|
|
|
|
|
</div>
|
2025-03-31 23:02:05 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="header__right">
|
2026-05-29 22:19:58 +08:00
|
|
|
|
<button
|
2026-06-01 22:29:18 +08:00
|
|
|
|
v-if="showStateEntry"
|
2026-05-29 22:19:58 +08:00
|
|
|
|
type="button"
|
2026-06-01 22:29:18 +08:00
|
|
|
|
class="agent-nav-btn agent-state-btn state-entry-btn"
|
|
|
|
|
|
:class="{ active: sideActive === 'state' }"
|
|
|
|
|
|
title="查看状态"
|
|
|
|
|
|
@click.stop="toggleStatePanel"
|
2026-05-29 22:19:58 +08:00
|
|
|
|
>
|
|
|
|
|
|
<SquareCheck size="18" class="nav-btn-icon" />
|
2026-06-01 22:29:18 +08:00
|
|
|
|
<span class="hide-text">状态</span>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
</button>
|
2026-05-12 15:26:48 +08:00
|
|
|
|
<slot
|
|
|
|
|
|
name="header-right"
|
2026-05-29 22:19:58 +08:00
|
|
|
|
:side-active="sideActive"
|
2026-05-12 15:26:48 +08:00
|
|
|
|
:has-active-thread="!!currentChatId"
|
|
|
|
|
|
:toggle-agent-panel="toggleAgentPanel"
|
|
|
|
|
|
></slot>
|
2025-03-31 22:32:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
<div
|
|
|
|
|
|
ref="chatContentContainerRef"
|
|
|
|
|
|
class="chat-content-container"
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
'has-file-panel': sideActive === 'file',
|
2026-06-01 22:29:18 +08:00
|
|
|
|
'has-state-panel': sideActive === 'state'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<!-- Main Chat Area -->
|
2026-03-21 16:41:32 +08:00
|
|
|
|
<div class="chat-main" ref="chatMainRef">
|
2026-03-20 17:51:12 +08:00
|
|
|
|
<div class="chat-box">
|
2026-04-19 18:13:18 +08:00
|
|
|
|
<template v-for="row in conversationRows" :key="row.key">
|
|
|
|
|
|
<div v-if="row.type === 'conversation'" class="conv-box">
|
2026-06-02 00:08:38 +08:00
|
|
|
|
<template v-for="(displayItem, itemIndex) in row.displayItems" :key="displayItem.key">
|
2026-04-19 18:13:18 +08:00
|
|
|
|
<AgentMessageComponent
|
|
|
|
|
|
v-if="displayItem.type === 'message'"
|
|
|
|
|
|
:message="displayItem.message"
|
|
|
|
|
|
:is-processing="isDisplayMessageProcessing(row.conv, displayItem)"
|
|
|
|
|
|
:show-refs="showMsgRefs(displayItem.message)"
|
|
|
|
|
|
:hide-tool-calls="true"
|
2026-05-30 17:54:36 +08:00
|
|
|
|
:mention="mentionConfig"
|
2026-04-19 18:13:18 +08:00
|
|
|
|
@retry="retryMessage(displayItem.message)"
|
|
|
|
|
|
>
|
|
|
|
|
|
</AgentMessageComponent>
|
|
|
|
|
|
<ToolCallsGroupComponent
|
|
|
|
|
|
v-else
|
|
|
|
|
|
:tool-calls="displayItem.toolCalls"
|
2026-06-02 00:08:38 +08:00
|
|
|
|
:is-active="isToolGroupActive(row.conv, itemIndex, row.displayItems)"
|
2026-04-19 18:13:18 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
2026-05-22 00:59:05 +08:00
|
|
|
|
<AgentArtifactsCard
|
|
|
|
|
|
v-if="shouldShowArtifacts(row.conv)"
|
|
|
|
|
|
:artifacts="currentArtifacts"
|
|
|
|
|
|
:thread-id="currentChatId"
|
|
|
|
|
|
@saved="handleArtifactSaved"
|
|
|
|
|
|
@open-preview="openPanelPreview"
|
|
|
|
|
|
/>
|
2026-04-19 18:13:18 +08:00
|
|
|
|
<!-- 显示对话最后一个消息使用的模型 -->
|
|
|
|
|
|
<RefsComponent
|
|
|
|
|
|
v-if="shouldShowRefs(row.conv)"
|
|
|
|
|
|
:message="getLastMessage(row.conv)"
|
|
|
|
|
|
:show-refs="['model', 'copy', 'sources']"
|
|
|
|
|
|
:is-latest-message="false"
|
|
|
|
|
|
:sources="getConversationSources(row.conv)"
|
2026-04-13 18:06:25 +08:00
|
|
|
|
/>
|
2026-04-19 18:13:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="chat-inline-notice">
|
|
|
|
|
|
<span>{{ row.notice.message }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-06-24 00:15:51 +08:00
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<!-- 生成中的加载状态 - 增强条件支持主聊天和resume流程 -->
|
2026-04-19 23:44:46 +08:00
|
|
|
|
<div class="generating-status" v-if="isReplyLoading && conversations.length > 0">
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<div class="generating-indicator">
|
|
|
|
|
|
<div class="loading-dots">
|
|
|
|
|
|
<div></div>
|
|
|
|
|
|
<div></div>
|
|
|
|
|
|
<div></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span class="generating-text">正在生成回复...</span>
|
|
|
|
|
|
</div>
|
2025-06-24 00:15:51 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<div class="bottom" :class="{ 'start-screen': !conversations.length }">
|
|
|
|
|
|
<!-- 人工审批弹窗 - 放在输入框上方 -->
|
|
|
|
|
|
<HumanApprovalModal
|
|
|
|
|
|
:visible="approvalState.showModal"
|
2026-03-17 03:39:48 +08:00
|
|
|
|
:questions="approvalState.questions"
|
2026-03-07 23:28:25 +08:00
|
|
|
|
@submit="handleQuestionSubmit"
|
|
|
|
|
|
@cancel="handleQuestionCancel"
|
2026-01-24 15:24:25 +08:00
|
|
|
|
/>
|
2025-12-19 04:04:48 +08:00
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<div class="message-input-wrapper">
|
2026-02-02 21:44:10 +08:00
|
|
|
|
<!-- 加载状态:加载消息 -->
|
|
|
|
|
|
<div v-if="isLoadingMessages" class="chat-loading">
|
|
|
|
|
|
<div class="loading-spinner"></div>
|
|
|
|
|
|
<span>正在加载消息...</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 打招呼区域 - 在输入框上方 -->
|
2026-05-24 00:47:08 +08:00
|
|
|
|
<div v-if="!conversations.length" class="chat-greeting-input">
|
2026-03-26 03:24:24 +08:00
|
|
|
|
<h1>{{ randomGreeting }}</h1>
|
2026-02-02 21:44:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<AgentInputArea
|
|
|
|
|
|
v-model="userInput"
|
|
|
|
|
|
:is-loading="isProcessing"
|
|
|
|
|
|
:disabled="!currentAgent"
|
2026-03-24 21:42:37 +08:00
|
|
|
|
:send-button-disabled="isSendButtonDisabled"
|
2026-03-20 17:51:12 +08:00
|
|
|
|
:mention="mentionConfig"
|
2026-05-21 23:06:33 +08:00
|
|
|
|
:thread-id="currentChatId"
|
2026-01-24 15:24:25 +08:00
|
|
|
|
:supports-file-upload="supportsFileUpload"
|
2026-05-24 00:47:08 +08:00
|
|
|
|
:attachments="currentPendingThreadAttachments"
|
2026-01-24 15:24:25 +08:00
|
|
|
|
@send="handleSendOrStop"
|
2026-03-20 17:51:12 +08:00
|
|
|
|
@upload-attachment="handleAttachmentUpload"
|
2026-05-24 00:47:08 +08:00
|
|
|
|
@remove-attachment="handleAttachmentRemove"
|
2026-03-16 21:39:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template #actions-left-extra>
|
2026-05-24 00:47:08 +08:00
|
|
|
|
<slot name="input-actions-left" :has-active-thread="!!currentChatId"></slot>
|
2026-03-16 21:39:49 +08:00
|
|
|
|
</template>
|
2026-05-25 21:02:23 +08:00
|
|
|
|
<template #actions-right-extra>
|
|
|
|
|
|
<slot name="input-actions-right" :has-active-thread="!!currentChatId"></slot>
|
|
|
|
|
|
</template>
|
2026-03-16 21:39:49 +08:00
|
|
|
|
</AgentInputArea>
|
2026-01-24 15:24:25 +08:00
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
<AttachmentTmpUploadModal
|
|
|
|
|
|
v-model:open="attachmentUploadModalOpen"
|
|
|
|
|
|
:thread-id="currentChatId"
|
|
|
|
|
|
:ensure-thread="ensureAttachmentThread"
|
|
|
|
|
|
@added="handleTmpAttachmentsAdded"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2026-03-16 21:39:49 +08:00
|
|
|
|
<div class="bottom-actions" v-if="conversations.length > 0">
|
|
|
|
|
|
<p class="note">当前智能体:{{ currentThreadAgentName }};请注意辨别内容的可靠性</p>
|
2025-12-19 04:04:48 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-24 15:24:25 +08:00
|
|
|
|
</div>
|
2025-12-19 04:04:48 +08:00
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
<!-- Agent Panel Area -->
|
|
|
|
|
|
|
2026-02-02 21:44:10 +08:00
|
|
|
|
<div
|
2026-05-29 22:19:58 +08:00
|
|
|
|
class="side-panel side-panel--file"
|
2026-02-02 21:44:10 +08:00
|
|
|
|
ref="panelWrapperRef"
|
|
|
|
|
|
:class="{
|
2026-05-29 22:19:58 +08:00
|
|
|
|
'is-visible': sideActive === 'file',
|
2026-05-12 15:26:48 +08:00
|
|
|
|
'no-transition': isResizing
|
2026-02-02 21:44:10 +08:00
|
|
|
|
}"
|
|
|
|
|
|
:style="{
|
2026-05-29 22:19:58 +08:00
|
|
|
|
flexBasis: sideActive === 'file' ? `${panelRatio * 100}%` : '0px'
|
2026-02-02 21:44:10 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AgentPanel
|
2026-05-29 22:19:58 +08:00
|
|
|
|
v-if="sideActive === 'file'"
|
2026-02-02 21:44:10 +08:00
|
|
|
|
:agent-state="currentAgentState"
|
|
|
|
|
|
:thread-id="currentChatId"
|
|
|
|
|
|
:panel-ratio="panelRatio"
|
2026-05-22 00:59:05 +08:00
|
|
|
|
:preview-tabs="agentPanelPreviewTabs"
|
|
|
|
|
|
:active-preview-path="agentPanelActivePreviewPath"
|
|
|
|
|
|
:view-mode="agentPanelViewMode"
|
2026-02-02 21:44:10 +08:00
|
|
|
|
@refresh="handleAgentStateRefresh"
|
|
|
|
|
|
@resize="handlePanelResize"
|
|
|
|
|
|
@resizing="handleResizingChange"
|
2026-05-22 00:59:05 +08:00
|
|
|
|
@open-preview="openPanelPreview"
|
|
|
|
|
|
@activate-preview="activatePanelPreview"
|
|
|
|
|
|
@close-preview-tab="closePanelPreviewTab"
|
|
|
|
|
|
@close-preview-path="closePanelPreviewPath"
|
|
|
|
|
|
@view-mode-change="setAgentPanelViewMode"
|
2026-02-02 21:44:10 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
|
|
|
|
|
|
<div
|
2026-06-01 22:29:18 +08:00
|
|
|
|
class="side-panel side-panel--state"
|
|
|
|
|
|
:class="{ 'is-visible': sideActive === 'state' }"
|
2026-05-29 22:19:58 +08:00
|
|
|
|
:style="{
|
2026-06-01 22:29:18 +08:00
|
|
|
|
flexBasis: sideActive === 'state' ? '340px' : '0px'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
2026-06-01 22:29:18 +08:00
|
|
|
|
<div v-if="sideActive === 'state'" class="state-panel">
|
|
|
|
|
|
<div class="side-panel__header state-panel-header">
|
|
|
|
|
|
<span class="state-panel-title">状态</span>
|
|
|
|
|
|
<span class="state-panel-summary">{{ stateSummaryLabel }}</span>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
<div class="state-panel-body">
|
|
|
|
|
|
<section class="state-section">
|
|
|
|
|
|
<div class="state-section-header">
|
|
|
|
|
|
<span class="state-section-title">待办</span>
|
|
|
|
|
|
<span v-if="totalTodoCount" class="state-section-meta">
|
|
|
|
|
|
{{ completedTodoCount }}/{{ totalTodoCount }} · {{ todoProgress }}%
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="currentTodos.length" class="todo-panel-list">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(todo, index) in currentTodos"
|
|
|
|
|
|
:key="`${todo.content}-${index}`"
|
|
|
|
|
|
class="todo-item"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="todo-item-icon" :class="todo.status || 'unknown'">
|
|
|
|
|
|
<CheckCircleOutlined v-if="todo.status === 'completed'" />
|
|
|
|
|
|
<SyncOutlined v-else-if="todo.status === 'in_progress'" spin />
|
|
|
|
|
|
<ClockCircleOutlined v-else-if="todo.status === 'pending'" />
|
|
|
|
|
|
<CloseCircleOutlined v-else-if="todo.status === 'cancelled'" />
|
|
|
|
|
|
<QuestionCircleOutlined v-else />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="todo-item-body">
|
|
|
|
|
|
<span class="todo-item-text">{{ todo.content }}</span>
|
|
|
|
|
|
</div>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
</div>
|
2026-06-01 22:29:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="state-section-empty">暂无待办</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="state-section">
|
|
|
|
|
|
<div class="state-section-header">
|
|
|
|
|
|
<span class="state-section-title">附件/文件</span>
|
|
|
|
|
|
<span class="state-section-meta">{{ currentStateFiles.length }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="currentStateFiles.length" class="state-list">
|
|
|
|
|
|
<div v-for="file in currentStateFiles" :key="file.key" class="state-list-item">
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="file.icon"
|
|
|
|
|
|
class="state-list-item-icon"
|
|
|
|
|
|
:style="{ color: file.iconColor }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div class="state-list-item-body">
|
|
|
|
|
|
<div class="state-list-item-title">{{ file.name }}</div>
|
|
|
|
|
|
<div class="state-list-item-meta">{{ file.meta || file.path }}</div>
|
|
|
|
|
|
</div>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-06-01 22:29:18 +08:00
|
|
|
|
<div v-else class="state-section-empty">暂无附件或文件</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="state-section">
|
|
|
|
|
|
<div class="state-section-header">
|
|
|
|
|
|
<span class="state-section-title">产物</span>
|
|
|
|
|
|
<span class="state-section-meta">{{ currentArtifactFiles.length }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="currentArtifactFiles.length" class="state-list">
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-for="file in currentArtifactFiles"
|
|
|
|
|
|
:key="file.path"
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="state-list-item state-list-item--button"
|
|
|
|
|
|
:title="`打开 ${file.name}`"
|
|
|
|
|
|
@click="openPanelPreview(file)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="file.icon"
|
|
|
|
|
|
class="state-list-item-icon"
|
|
|
|
|
|
:style="{ color: file.iconColor }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div class="state-list-item-body">
|
|
|
|
|
|
<div class="state-list-item-title">{{ file.name }}</div>
|
|
|
|
|
|
<div class="state-list-item-meta">{{ file.meta }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="state-section-empty">暂无产物</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="state-section">
|
|
|
|
|
|
<div class="state-section-header">
|
|
|
|
|
|
<span class="state-section-title">子智能体</span>
|
|
|
|
|
|
<span class="state-section-meta">{{ currentSubagentRuns.length }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="currentSubagentRuns.length" class="state-list">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(run, index) in currentSubagentRuns"
|
|
|
|
|
|
:key="run.id || `${run.subagent_type || 'subagent'}-${index}`"
|
|
|
|
|
|
class="state-list-item"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img
|
|
|
|
|
|
class="state-subagent-icon"
|
|
|
|
|
|
:src="getSubagentIconSrc(run)"
|
|
|
|
|
|
:alt="`${getSubagentRunName(run)}图标`"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div class="state-list-item-body">
|
|
|
|
|
|
<div class="state-list-item-title state-subagent-title">
|
|
|
|
|
|
<span>{{ getSubagentRunName(run) }}</span>
|
|
|
|
|
|
<CheckCircleOutlined
|
|
|
|
|
|
v-if="run.status === 'completed'"
|
|
|
|
|
|
class="state-subagent-completed-icon"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="state-list-item-meta">
|
|
|
|
|
|
{{ run.description || getSubagentRunMeta(run) }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="state-section-empty">暂无子智能体运行</div>
|
|
|
|
|
|
</section>
|
2026-05-29 22:19:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-03-31 22:32:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-15 06:01:34 +08:00
|
|
|
|
</div>
|
2025-03-31 22:32:19 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-04-20 23:55:51 +08:00
|
|
|
|
import {
|
|
|
|
|
|
ref,
|
|
|
|
|
|
reactive,
|
|
|
|
|
|
onMounted,
|
|
|
|
|
|
watch,
|
|
|
|
|
|
nextTick,
|
|
|
|
|
|
computed,
|
|
|
|
|
|
onUnmounted,
|
|
|
|
|
|
onActivated,
|
2026-05-24 00:47:08 +08:00
|
|
|
|
onDeactivated
|
2026-04-20 23:55:51 +08:00
|
|
|
|
} from 'vue'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import { message } from 'ant-design-vue'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
import { SquareCheck } from 'lucide-vue-next'
|
2026-06-01 22:29:18 +08:00
|
|
|
|
import { getFileIcon, getFileIconColor, formatFileSize } from '@/utils/file_utils'
|
|
|
|
|
|
import { generatePixelAvatar } from '@/utils/pixelAvatar'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
import {
|
|
|
|
|
|
CheckCircleOutlined,
|
|
|
|
|
|
ClockCircleOutlined,
|
|
|
|
|
|
CloseCircleOutlined,
|
|
|
|
|
|
QuestionCircleOutlined,
|
|
|
|
|
|
SyncOutlined
|
|
|
|
|
|
} from '@ant-design/icons-vue'
|
2025-12-19 04:04:48 +08:00
|
|
|
|
import AgentInputArea from '@/components/AgentInputArea.vue'
|
2025-05-15 22:34:32 +08:00
|
|
|
|
import AgentMessageComponent from '@/components/AgentMessageComponent.vue'
|
2025-06-24 00:15:51 +08:00
|
|
|
|
import RefsComponent from '@/components/RefsComponent.vue'
|
2026-04-13 18:06:25 +08:00
|
|
|
|
import ToolCallsGroupComponent from '@/components/ToolCallsGroupComponent.vue'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import { handleChatError, handleValidationError } from '@/utils/errorHandler'
|
|
|
|
|
|
import { ScrollController } from '@/utils/scrollController'
|
|
|
|
|
|
import { AgentValidator } from '@/utils/agentValidator'
|
|
|
|
|
|
import { useAgentStore } from '@/stores/agent'
|
2026-04-24 22:42:51 +08:00
|
|
|
|
import { useChatThreadsStore } from '@/stores/chatThreads'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import { useChatUIStore } from '@/stores/chatUI'
|
2026-03-23 09:43:04 +08:00
|
|
|
|
import { useConfigStore } from '@/stores/config'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
|
|
|
import { MessageProcessor } from '@/utils/messageProcessor'
|
2026-03-16 19:18:45 +08:00
|
|
|
|
import { agentApi, threadApi } from '@/apis'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import HumanApprovalModal from '@/components/HumanApprovalModal.vue'
|
|
|
|
|
|
import { useApproval } from '@/composables/useApproval'
|
2026-03-20 17:51:12 +08:00
|
|
|
|
import { useAgentThreadState } from '@/composables/useAgentThreadState'
|
|
|
|
|
|
import { useAgentRunStream } from '@/composables/useAgentRunStream'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
import { useAgentStreamHandler } from '@/composables/useAgentStreamHandler'
|
2026-03-25 13:46:52 +08:00
|
|
|
|
import { useStreamSmoother } from '@/composables/useStreamSmoother'
|
2026-03-20 17:51:12 +08:00
|
|
|
|
import { useAgentMentionConfig } from '@/composables/useAgentMentionConfig'
|
2026-03-29 10:55:00 +08:00
|
|
|
|
import AgentArtifactsCard from '@/components/AgentArtifactsCard.vue'
|
2026-01-24 15:24:25 +08:00
|
|
|
|
import AgentPanel from '@/components/AgentPanel.vue'
|
2026-05-27 18:22:29 +08:00
|
|
|
|
import AttachmentTmpUploadModal from '@/components/AttachmentTmpUploadModal.vue'
|
2026-06-02 00:08:38 +08:00
|
|
|
|
import { normalizeToolCalls } from '@/components/ToolCallingResult/toolRegistry'
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== PROPS & EMITS ====================
|
2025-03-31 23:02:05 +08:00
|
|
|
|
const props = defineProps({
|
2025-08-31 12:22:49 +08:00
|
|
|
|
agentId: { type: String, default: '' },
|
2026-05-25 21:02:23 +08:00
|
|
|
|
singleMode: { type: Boolean, default: true },
|
|
|
|
|
|
sendDisabled: { type: Boolean, default: false }
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2026-03-24 02:32:35 +08:00
|
|
|
|
const emit = defineEmits(['thread-change'])
|
2025-08-11 21:29:33 +08:00
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== STORE MANAGEMENT ====================
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const agentStore = useAgentStore()
|
2026-04-24 22:42:51 +08:00
|
|
|
|
const chatThreadsStore = useChatThreadsStore()
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const chatUIStore = useChatUIStore()
|
2026-03-23 09:43:04 +08:00
|
|
|
|
const configStore = useConfigStore()
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const { agents, selectedAgentId, agentConfig, configurableItems, availableKnowledgeBases } =
|
|
|
|
|
|
storeToRefs(agentStore)
|
2026-04-24 22:42:51 +08:00
|
|
|
|
const { threads, currentThreadId, currentThread } = storeToRefs(chatThreadsStore)
|
2025-08-25 01:46:31 +08:00
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
// ==================== LOCAL CHAT & UI STATE ====================
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const userInput = ref('')
|
2026-03-24 21:42:37 +08:00
|
|
|
|
const sendCooldownActive = ref(false)
|
|
|
|
|
|
let sendCooldownTimer = null
|
2026-03-26 03:24:24 +08:00
|
|
|
|
// 预设的打招呼文本
|
|
|
|
|
|
const greetingMessages = [
|
|
|
|
|
|
'👋 您好,有什么可以帮您?',
|
|
|
|
|
|
'👋 你好!有什么想聊的吗?',
|
|
|
|
|
|
'👋 嘿,有什么我可以帮助你的?',
|
|
|
|
|
|
'👋 欢迎!今天想讨论什么话题?',
|
|
|
|
|
|
'👋 你好呀,随时为你服务!'
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
// 随机选择一个打招呼文本
|
|
|
|
|
|
const randomGreeting = greetingMessages[Math.floor(Math.random() * greetingMessages.length)]
|
|
|
|
|
|
|
2025-11-08 13:59:56 +08:00
|
|
|
|
// 业务状态(保留在组件本地)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const chatState = reactive({
|
|
|
|
|
|
currentThreadId: null,
|
|
|
|
|
|
// 以threadId为键的线程状态
|
|
|
|
|
|
threadStates: {}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2026-04-24 22:42:51 +08:00
|
|
|
|
const setCurrentThreadId = (threadId) => {
|
|
|
|
|
|
chatState.currentThreadId = threadId || null
|
|
|
|
|
|
chatThreadsStore.setCurrentThreadId(threadId || null)
|
|
|
|
|
|
}
|
2026-03-25 13:46:52 +08:00
|
|
|
|
const streamSmoother = useStreamSmoother({
|
|
|
|
|
|
getThreadState: (threadId) => chatState.threadStates[threadId] || null
|
|
|
|
|
|
})
|
2026-03-20 17:51:12 +08:00
|
|
|
|
const { getThreadState, resetOnGoingConv, stopThreadStream } = useAgentThreadState({
|
|
|
|
|
|
chatState,
|
2026-03-25 13:46:52 +08:00
|
|
|
|
getCurrentThreadId: () => chatState.currentThreadId,
|
|
|
|
|
|
onStopThread: (threadId) => streamSmoother.flushThread(threadId),
|
|
|
|
|
|
onBeforeResetThread: (threadId) => streamSmoother.resetThread(threadId),
|
|
|
|
|
|
onBeforeCleanupThread: (threadId) => streamSmoother.resetThread(threadId)
|
2026-03-20 17:51:12 +08:00
|
|
|
|
})
|
2025-05-15 22:34:32 +08:00
|
|
|
|
|
2026-04-24 22:42:51 +08:00
|
|
|
|
// 组件级别的消息、附件与提示状态
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadMessages = ref({})
|
2026-03-04 08:53:50 +08:00
|
|
|
|
const threadFilesMap = ref({})
|
|
|
|
|
|
const threadAttachmentsMap = ref({})
|
2026-05-27 18:22:29 +08:00
|
|
|
|
const attachmentUploadModalOpen = ref(false)
|
2026-04-19 18:13:18 +08:00
|
|
|
|
const threadConfigNoticeMap = ref({})
|
|
|
|
|
|
const threadPendingConfigNoticeMap = ref({})
|
|
|
|
|
|
const threadConfigSnapshotMap = ref({})
|
|
|
|
|
|
const configNoticeSyncDepth = ref(0)
|
|
|
|
|
|
const configNoticeScrollVersion = ref(0)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-11-08 13:59:56 +08:00
|
|
|
|
// 本地 UI 状态(仅在本组件使用)
|
|
|
|
|
|
const localUIState = reactive({
|
2026-04-18 13:32:27 +08:00
|
|
|
|
chatMainWidth: typeof window !== 'undefined' ? window.innerWidth : 0
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2025-08-25 13:57:47 +08:00
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
// Agent Panel State
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const sideActive = ref('')
|
2026-02-02 21:44:10 +08:00
|
|
|
|
const isResizing = ref(false)
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const defaultPanelRatio = 0.3
|
|
|
|
|
|
const previewPanelRatio = 0.65
|
|
|
|
|
|
const minPanelRatio = 0.25
|
|
|
|
|
|
const maxPanelRatio = 0.75
|
|
|
|
|
|
const minChatMainWidth = 350
|
|
|
|
|
|
const panelRatio = ref(defaultPanelRatio) // 面板宽度比例 (0-1)
|
|
|
|
|
|
const agentPanelPreviewTabs = ref([])
|
|
|
|
|
|
const agentPanelActivePreviewPath = ref('')
|
|
|
|
|
|
const agentPanelViewMode = ref('tree')
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const chatContentContainerRef = ref(null)
|
2026-02-02 21:44:10 +08:00
|
|
|
|
const panelWrapperRef = ref(null) // 直接操作 DOM
|
2026-03-26 06:07:18 +08:00
|
|
|
|
let resizeStartX = 0
|
|
|
|
|
|
let resizeStartWidth = 0
|
2026-02-02 21:44:10 +08:00
|
|
|
|
let panelContainerWidth = 0
|
2026-06-01 22:29:18 +08:00
|
|
|
|
let streamingStateRefreshTimer = null
|
2025-11-14 12:50:32 +08:00
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const getPanelContainerWidth = () => {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const container = chatContentContainerRef.value || panelWrapperRef.value?.parentElement
|
|
|
|
|
|
return container?.clientWidth || (typeof window !== 'undefined' ? window.innerWidth : 0)
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getMaxPanelRatio = (containerWidth = getPanelContainerWidth()) => {
|
|
|
|
|
|
if (!containerWidth) return maxPanelRatio
|
2026-05-24 00:47:08 +08:00
|
|
|
|
return Math.max(
|
|
|
|
|
|
minPanelRatio,
|
|
|
|
|
|
Math.min(maxPanelRatio, (containerWidth - minChatMainWidth) / containerWidth)
|
|
|
|
|
|
)
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const clampPanelRatio = (ratio, containerWidth = getPanelContainerWidth()) => {
|
|
|
|
|
|
return Math.max(minPanelRatio, Math.min(ratio, getMaxPanelRatio(containerWidth)))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const setPanelRatioForViewMode = () => {
|
|
|
|
|
|
const hasPreview = Boolean(agentPanelActivePreviewPath.value)
|
|
|
|
|
|
panelRatio.value = clampPanelRatio(hasPreview ? previewPanelRatio : defaultPanelRatio)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const showFilePanel = (mode = 'tree') => {
|
|
|
|
|
|
sideActive.value = 'file'
|
2026-05-31 13:40:15 +08:00
|
|
|
|
agentPanelViewMode.value =
|
|
|
|
|
|
mode === 'preview' && agentPanelActivePreviewPath.value ? 'preview' : 'tree'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
setPanelRatioForViewMode()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const showFileTreePanel = () => {
|
|
|
|
|
|
sideActive.value = 'file'
|
|
|
|
|
|
agentPanelActivePreviewPath.value = ''
|
|
|
|
|
|
agentPanelViewMode.value = 'tree'
|
|
|
|
|
|
setPanelRatioForViewMode()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const getPanelFileName = (file) => {
|
|
|
|
|
|
if (file?.name) return file.name
|
|
|
|
|
|
if (file?.path) return String(file.path).split('/').pop() || String(file.path)
|
|
|
|
|
|
return '未知文件'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const getArtifactMetaLabel = (path) => {
|
|
|
|
|
|
const filename = getPanelFileName({ path })
|
|
|
|
|
|
if (!filename.includes('.')) return '交付文件'
|
|
|
|
|
|
const extension = filename.split('.').pop()
|
|
|
|
|
|
return extension ? `交付文件 · ${extension.toUpperCase()}` : '交付文件'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getSubagentRunName = (run) => run?.subagent_name || run?.subagent_type || '子智能体'
|
|
|
|
|
|
|
|
|
|
|
|
const getSubagentAgent = (run) => {
|
|
|
|
|
|
const subagentId = run?.subagent_type
|
|
|
|
|
|
if (!subagentId) return null
|
|
|
|
|
|
return agents.value.find((agent) => agent.id === subagentId || agent.slug === subagentId) || null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getSubagentIconSrc = (run) => {
|
|
|
|
|
|
const agent = getSubagentAgent(run)
|
|
|
|
|
|
return agent?.icon || generatePixelAvatar(run?.subagent_type || run?.id || getSubagentRunName(run))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getSubagentRunMeta = (run) => {
|
|
|
|
|
|
const artifacts = Array.isArray(run?.artifacts) ? run.artifacts.length : 0
|
|
|
|
|
|
return artifacts ? `${artifacts} 个产物` : run?.id || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const normalizePanelPath = (path) => String(path || '').replace(/\/+$/, '')
|
|
|
|
|
|
|
|
|
|
|
|
const isSameOrChildPanelPath = (path, targetPath) => {
|
|
|
|
|
|
const normalizedPath = normalizePanelPath(path)
|
|
|
|
|
|
const normalizedTargetPath = normalizePanelPath(targetPath)
|
|
|
|
|
|
if (!normalizedPath || !normalizedTargetPath) return false
|
|
|
|
|
|
return (
|
|
|
|
|
|
normalizedPath === normalizedTargetPath || normalizedPath.startsWith(`${normalizedTargetPath}/`)
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const resetAgentPanelState = () => {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
sideActive.value = ''
|
2026-05-22 00:59:05 +08:00
|
|
|
|
panelRatio.value = defaultPanelRatio
|
|
|
|
|
|
agentPanelPreviewTabs.value = []
|
|
|
|
|
|
agentPanelActivePreviewPath.value = ''
|
|
|
|
|
|
agentPanelViewMode.value = 'tree'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const setAgentPanelViewMode = (mode) => {
|
2026-05-24 00:47:08 +08:00
|
|
|
|
agentPanelViewMode.value =
|
|
|
|
|
|
mode === 'preview' && agentPanelActivePreviewPath.value ? 'preview' : 'tree'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
setPanelRatioForViewMode()
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const activatePanelPreview = (path) => {
|
|
|
|
|
|
if (!path) return
|
|
|
|
|
|
agentPanelActivePreviewPath.value = path
|
2026-05-29 22:19:58 +08:00
|
|
|
|
showFilePanel('preview')
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const openPanelPreview = (file, keepTreeOpen = false) => {
|
|
|
|
|
|
if (!file?.path) return
|
|
|
|
|
|
|
|
|
|
|
|
const tab = {
|
|
|
|
|
|
...file,
|
|
|
|
|
|
path: String(file.path),
|
|
|
|
|
|
name: getPanelFileName(file)
|
|
|
|
|
|
}
|
|
|
|
|
|
const existingIndex = agentPanelPreviewTabs.value.findIndex((item) => item.path === tab.path)
|
|
|
|
|
|
|
|
|
|
|
|
if (existingIndex >= 0) {
|
|
|
|
|
|
agentPanelPreviewTabs.value = agentPanelPreviewTabs.value.map((item, index) =>
|
|
|
|
|
|
index === existingIndex ? { ...item, ...tab } : item
|
|
|
|
|
|
)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
agentPanelPreviewTabs.value = [...agentPanelPreviewTabs.value, tab]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
agentPanelActivePreviewPath.value = tab.path
|
2026-05-29 22:19:58 +08:00
|
|
|
|
showFilePanel(keepTreeOpen ? 'tree' : 'preview')
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const closePanelPreviewTab = (path) => {
|
|
|
|
|
|
if (!path) return
|
|
|
|
|
|
|
|
|
|
|
|
const closingIndex = agentPanelPreviewTabs.value.findIndex((item) => item.path === path)
|
|
|
|
|
|
const nextTabs = agentPanelPreviewTabs.value.filter((item) => item.path !== path)
|
|
|
|
|
|
agentPanelPreviewTabs.value = nextTabs
|
|
|
|
|
|
|
|
|
|
|
|
if (agentPanelActivePreviewPath.value !== path) return
|
|
|
|
|
|
|
|
|
|
|
|
const nextActiveTab = nextTabs[Math.min(closingIndex, nextTabs.length - 1)]
|
|
|
|
|
|
agentPanelActivePreviewPath.value = nextActiveTab?.path || ''
|
|
|
|
|
|
agentPanelViewMode.value = nextActiveTab ? 'preview' : 'tree'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
setPanelRatioForViewMode()
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const closePanelPreviewPath = (targetPath) => {
|
|
|
|
|
|
if (!targetPath) return
|
|
|
|
|
|
|
|
|
|
|
|
const nextTabs = agentPanelPreviewTabs.value.filter(
|
|
|
|
|
|
(item) => !isSameOrChildPanelPath(item.path, targetPath)
|
|
|
|
|
|
)
|
|
|
|
|
|
const shouldCloseActive = isSameOrChildPanelPath(agentPanelActivePreviewPath.value, targetPath)
|
|
|
|
|
|
agentPanelPreviewTabs.value = nextTabs
|
|
|
|
|
|
|
|
|
|
|
|
if (!shouldCloseActive) return
|
|
|
|
|
|
|
|
|
|
|
|
const nextActiveTab = nextTabs[0]
|
|
|
|
|
|
agentPanelActivePreviewPath.value = nextActiveTab?.path || ''
|
|
|
|
|
|
agentPanelViewMode.value = nextActiveTab ? 'preview' : 'tree'
|
2026-05-29 22:19:58 +08:00
|
|
|
|
setPanelRatioForViewMode()
|
2026-05-22 00:59:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== COMPUTED PROPERTIES ====================
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const currentAgentId = computed(() => {
|
|
|
|
|
|
if (props.singleMode) {
|
2026-05-24 00:47:08 +08:00
|
|
|
|
return props.agentId || selectedAgentId.value || agents.value[0]?.id || ''
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-05-24 00:47:08 +08:00
|
|
|
|
return selectedAgentId.value
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-11-07 12:28:58 +08:00
|
|
|
|
const currentAgentName = computed(() => {
|
2026-01-24 15:24:25 +08:00
|
|
|
|
const agent = currentAgent.value
|
|
|
|
|
|
return agent ? agent.name : '智能体'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2025-09-09 20:25:48 +08:00
|
|
|
|
|
2025-11-07 12:38:29 +08:00
|
|
|
|
const currentAgent = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!currentAgentId.value || !agents.value || !agents.value.length) return null
|
|
|
|
|
|
return agents.value.find((a) => a.id === currentAgentId.value) || null
|
|
|
|
|
|
})
|
2026-04-24 22:42:51 +08:00
|
|
|
|
const currentChatId = computed(() => currentThreadId.value)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-03-16 21:39:49 +08:00
|
|
|
|
const currentThreadAgentName = computed(() => {
|
|
|
|
|
|
const threadAgentId = currentThread.value?.agent_id
|
|
|
|
|
|
if (threadAgentId && agents.value?.length) {
|
|
|
|
|
|
const threadAgent = agents.value.find((agent) => agent.id === threadAgentId)
|
|
|
|
|
|
if (threadAgent?.name) {
|
|
|
|
|
|
return threadAgent.name
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return currentAgentName.value
|
|
|
|
|
|
})
|
2025-11-08 10:51:30 +08:00
|
|
|
|
// 检查当前智能体是否支持文件上传
|
|
|
|
|
|
const supportsFileUpload = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!currentAgent.value) return false
|
|
|
|
|
|
const capabilities = currentAgent.value.capabilities || []
|
|
|
|
|
|
return capabilities.includes('file_upload')
|
|
|
|
|
|
})
|
2025-11-14 12:50:32 +08:00
|
|
|
|
|
|
|
|
|
|
const supportsFiles = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!currentAgent.value) return false
|
|
|
|
|
|
const capabilities = currentAgent.value.capabilities || []
|
|
|
|
|
|
return capabilities.includes('files')
|
|
|
|
|
|
})
|
2025-11-14 12:50:32 +08:00
|
|
|
|
|
|
|
|
|
|
// AgentState 相关计算属性
|
|
|
|
|
|
const currentAgentState = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return currentChatId.value ? getThreadState(currentChatId.value)?.agentState || null : null
|
|
|
|
|
|
})
|
2026-03-04 08:53:50 +08:00
|
|
|
|
const currentThreadAttachments = computed(() => {
|
|
|
|
|
|
if (!currentChatId.value) return []
|
|
|
|
|
|
return threadAttachmentsMap.value[currentChatId.value] || []
|
|
|
|
|
|
})
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const currentPendingThreadAttachments = computed(() =>
|
|
|
|
|
|
currentThreadAttachments.value.filter((attachment) => !attachment?.request_id)
|
|
|
|
|
|
)
|
2026-03-29 10:55:00 +08:00
|
|
|
|
const currentArtifacts = computed(() => {
|
|
|
|
|
|
const artifacts = currentAgentState.value?.artifacts
|
|
|
|
|
|
return Array.isArray(artifacts) ? artifacts : []
|
|
|
|
|
|
})
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const currentArtifactFiles = computed(() =>
|
|
|
|
|
|
currentArtifacts.value
|
|
|
|
|
|
.map((path) => String(path || '').trim())
|
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
|
.map((path) => ({
|
|
|
|
|
|
path,
|
|
|
|
|
|
name: getPanelFileName({ path }),
|
|
|
|
|
|
meta: getArtifactMetaLabel(path),
|
|
|
|
|
|
icon: getFileIcon(path),
|
|
|
|
|
|
iconColor: getFileIconColor(path)
|
|
|
|
|
|
}))
|
|
|
|
|
|
)
|
2026-04-01 03:17:15 +08:00
|
|
|
|
const currentTodos = computed(() => {
|
|
|
|
|
|
const todos = currentAgentState.value?.todos
|
|
|
|
|
|
return Array.isArray(todos) ? todos : []
|
|
|
|
|
|
})
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const currentSubagentRuns = computed(() => {
|
|
|
|
|
|
const runs = currentAgentState.value?.subagent_runs
|
|
|
|
|
|
return Array.isArray(runs) ? runs : []
|
|
|
|
|
|
})
|
|
|
|
|
|
const currentSubagentRunById = computed(() => {
|
|
|
|
|
|
const runById = new Map()
|
|
|
|
|
|
currentSubagentRuns.value.forEach((run) => {
|
|
|
|
|
|
if (run?.id) runById.set(String(run.id), run)
|
|
|
|
|
|
})
|
|
|
|
|
|
return runById
|
|
|
|
|
|
})
|
|
|
|
|
|
const currentStateFiles = computed(() => {
|
|
|
|
|
|
const files = []
|
|
|
|
|
|
const seenPaths = new Set()
|
|
|
|
|
|
const pushFile = (entry, fallbackName = '文件') => {
|
|
|
|
|
|
const path = String(entry?.path || entry?.file_path || entry?.file_name || entry?.name || '')
|
|
|
|
|
|
if (!path || seenPaths.has(path)) return
|
|
|
|
|
|
seenPaths.add(path)
|
|
|
|
|
|
const name = entry?.file_name || entry?.name || getPanelFileName({ path }) || fallbackName
|
|
|
|
|
|
const sizeLabel = formatFileSize(entry?.file_size ?? entry?.size)
|
|
|
|
|
|
const status = entry?.status || ''
|
|
|
|
|
|
files.push({
|
|
|
|
|
|
key: path,
|
|
|
|
|
|
path,
|
|
|
|
|
|
name,
|
|
|
|
|
|
meta: [status, sizeLabel === '-' ? '' : sizeLabel, path].filter(Boolean).join(' · '),
|
|
|
|
|
|
icon: getFileIcon(name || path),
|
|
|
|
|
|
iconColor: getFileIconColor(name || path)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const rawFiles = currentAgentState.value?.files || {}
|
|
|
|
|
|
if (typeof rawFiles === 'object' && !Array.isArray(rawFiles)) {
|
|
|
|
|
|
Object.entries(rawFiles).forEach(([path, fileData]) => pushFile({ path, ...fileData }))
|
|
|
|
|
|
}
|
|
|
|
|
|
currentThreadAttachments.value.forEach((attachment) => pushFile(attachment, '附件'))
|
|
|
|
|
|
|
|
|
|
|
|
return files
|
|
|
|
|
|
})
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const totalTodoCount = computed(() => currentTodos.value.length)
|
|
|
|
|
|
const completedTodoCount = computed(
|
|
|
|
|
|
() => currentTodos.value.filter((todo) => todo?.status === 'completed').length
|
|
|
|
|
|
)
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const showStateEntry = computed(() => Boolean(currentChatId.value))
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const todoProgress = computed(() => {
|
|
|
|
|
|
if (!totalTodoCount.value) return 0
|
|
|
|
|
|
return Math.round((completedTodoCount.value / totalTodoCount.value) * 100)
|
|
|
|
|
|
})
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const stateSummaryLabel = computed(() => {
|
|
|
|
|
|
const total =
|
|
|
|
|
|
totalTodoCount.value +
|
|
|
|
|
|
currentStateFiles.value.length +
|
|
|
|
|
|
currentArtifactFiles.value.length +
|
|
|
|
|
|
currentSubagentRuns.value.length
|
|
|
|
|
|
return total ? `${total} 项` : '暂无内容'
|
|
|
|
|
|
})
|
2025-11-17 12:01:59 +08:00
|
|
|
|
|
2026-03-20 17:51:12 +08:00
|
|
|
|
const { mentionConfig } = useAgentMentionConfig({
|
|
|
|
|
|
currentAgentState,
|
2026-03-25 05:26:00 +08:00
|
|
|
|
currentThreadAttachments,
|
2026-03-20 17:51:12 +08:00
|
|
|
|
configurableItems,
|
2026-05-21 19:33:00 +08:00
|
|
|
|
agentConfig
|
2026-02-04 17:05:26 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const currentThreadMessages = computed(() => threadMessages.value[currentChatId.value] || [])
|
2026-04-19 18:13:18 +08:00
|
|
|
|
const currentThreadHasHistory = computed(() => currentThreadMessages.value.length > 0)
|
|
|
|
|
|
const currentThreadConfigNotice = computed(() => {
|
|
|
|
|
|
if (!currentChatId.value) return null
|
|
|
|
|
|
return threadConfigNoticeMap.value[currentChatId.value] || null
|
|
|
|
|
|
})
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-11-01 21:34:16 +08:00
|
|
|
|
// 计算是否显示Refs组件的条件
|
|
|
|
|
|
const shouldShowRefs = computed(() => {
|
|
|
|
|
|
return (conv) => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return (
|
|
|
|
|
|
getLastMessage(conv) &&
|
|
|
|
|
|
conv.status !== 'streaming' &&
|
|
|
|
|
|
!approvalState.showModal &&
|
|
|
|
|
|
!(
|
|
|
|
|
|
approvalState.threadId &&
|
|
|
|
|
|
chatState.currentThreadId === approvalState.threadId &&
|
|
|
|
|
|
isProcessing.value
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-11-01 21:34:16 +08:00
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const shouldShowArtifacts = computed(() => {
|
|
|
|
|
|
return (conv) => {
|
|
|
|
|
|
if (!currentArtifacts.value.length || conv.status === 'streaming') return false
|
|
|
|
|
|
const latestConv = conversations.value[conversations.value.length - 1]
|
|
|
|
|
|
return latestConv === conv
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
// 当前线程状态的computed属性
|
|
|
|
|
|
const currentThreadState = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return getThreadState(currentChatId.value)
|
|
|
|
|
|
})
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const getThreadOngoingMessages = (threadId) => {
|
|
|
|
|
|
const threadState = getThreadState(threadId)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!threadState || !threadState.onGoingConv) return []
|
2025-09-03 03:00:25 +08:00
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const msgs = Object.values(threadState.onGoingConv.msgChunks)
|
|
|
|
|
|
.map(MessageProcessor.mergeMessageChunk)
|
|
|
|
|
|
.filter(Boolean)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
return msgs.length > 0
|
2026-01-15 06:01:34 +08:00
|
|
|
|
? MessageProcessor.convertToolResultToMessages(msgs).filter((msg) => msg.type !== 'tool')
|
|
|
|
|
|
: []
|
2026-06-01 22:29:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onGoingConvMessages = computed(() => getThreadOngoingMessages(currentChatId.value))
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-12-19 14:41:23 +08:00
|
|
|
|
const historyConversations = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return MessageProcessor.convertServerHistoryToMessages(currentThreadMessages.value)
|
|
|
|
|
|
})
|
2025-12-19 14:41:23 +08:00
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const conversations = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const historyConvs = historyConversations.value
|
2026-04-19 23:44:46 +08:00
|
|
|
|
const mergedOngoingMessages = stripDuplicatedOngoingHumanMessage(
|
|
|
|
|
|
historyConvs,
|
|
|
|
|
|
onGoingConvMessages.value
|
|
|
|
|
|
)
|
2025-10-15 02:37:42 +08:00
|
|
|
|
|
|
|
|
|
|
// 如果有进行中的消息且线程状态显示正在流式处理,添加进行中的对话
|
2026-04-19 23:44:46 +08:00
|
|
|
|
if (mergedOngoingMessages.length > 0) {
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const onGoingConv = {
|
2026-04-19 23:44:46 +08:00
|
|
|
|
messages: mergedOngoingMessages,
|
2025-08-31 14:39:28 +08:00
|
|
|
|
status: 'streaming'
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return [...historyConvs, onGoingConv]
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return historyConvs
|
|
|
|
|
|
})
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
const conversationRows = computed(() => {
|
|
|
|
|
|
const rows = conversations.value.map((conv, index) => ({
|
|
|
|
|
|
type: 'conversation',
|
|
|
|
|
|
key: conv.status === 'streaming' ? 'ongoing-conversation' : `history-${index}`,
|
2026-06-02 00:08:38 +08:00
|
|
|
|
conv,
|
|
|
|
|
|
displayItems: getConversationDisplayItems(conv)
|
2026-04-19 18:13:18 +08:00
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
if (currentThreadConfigNotice.value) {
|
|
|
|
|
|
const insertAfterCount = Math.max(
|
|
|
|
|
|
0,
|
2026-04-26 18:51:38 +08:00
|
|
|
|
Math.min(
|
|
|
|
|
|
Number(currentThreadConfigNotice.value.insertAfterConversationCount) || 0,
|
|
|
|
|
|
rows.length
|
|
|
|
|
|
)
|
2026-04-19 18:13:18 +08:00
|
|
|
|
)
|
|
|
|
|
|
rows.splice(insertAfterCount, 0, {
|
|
|
|
|
|
type: 'notice',
|
|
|
|
|
|
key: currentThreadConfigNotice.value.id,
|
|
|
|
|
|
notice: currentThreadConfigNotice.value
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return rows
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const isLoadingMessages = computed(() => chatUIStore.isLoadingMessages)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const isStreaming = computed(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadState = currentThreadState.value
|
|
|
|
|
|
return threadState ? threadState.isStreaming : false
|
|
|
|
|
|
})
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const shouldRefreshStateWhileStreaming = computed(
|
|
|
|
|
|
() => Boolean(currentChatId.value) && isStreaming.value && sideActive.value === 'state'
|
|
|
|
|
|
)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const isProcessing = computed(() => isStreaming.value)
|
2026-04-19 23:44:46 +08:00
|
|
|
|
const isReplyLoading = computed(() => {
|
|
|
|
|
|
const threadState = currentThreadState.value
|
|
|
|
|
|
return Boolean(threadState?.replyLoadingVisible)
|
|
|
|
|
|
})
|
2026-03-24 21:42:37 +08:00
|
|
|
|
const isSendButtonDisabled = computed(() => {
|
2026-03-24 22:37:03 +08:00
|
|
|
|
return (
|
2026-05-25 21:02:23 +08:00
|
|
|
|
sendCooldownActive.value ||
|
|
|
|
|
|
(props.sendDisabled && !isProcessing.value) ||
|
|
|
|
|
|
((!userInput.value || !currentAgent.value) && !isProcessing.value)
|
2026-03-24 22:37:03 +08:00
|
|
|
|
)
|
2026-03-24 21:42:37 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const startSendCooldown = () => {
|
|
|
|
|
|
sendCooldownActive.value = true
|
|
|
|
|
|
if (sendCooldownTimer) {
|
|
|
|
|
|
clearTimeout(sendCooldownTimer)
|
|
|
|
|
|
}
|
|
|
|
|
|
sendCooldownTimer = setTimeout(() => {
|
|
|
|
|
|
sendCooldownActive.value = false
|
|
|
|
|
|
sendCooldownTimer = null
|
|
|
|
|
|
}, 2000)
|
|
|
|
|
|
}
|
2025-08-10 21:58:41 +08:00
|
|
|
|
|
2026-04-19 23:44:46 +08:00
|
|
|
|
const createClientRequestId = () => {
|
|
|
|
|
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
|
|
|
|
return crypto.randomUUID()
|
|
|
|
|
|
}
|
|
|
|
|
|
return `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const buildOptimisticHumanMessage = ({
|
|
|
|
|
|
requestId,
|
|
|
|
|
|
text,
|
|
|
|
|
|
imageContent = null,
|
|
|
|
|
|
attachments = []
|
|
|
|
|
|
}) => {
|
2026-04-19 23:44:46 +08:00
|
|
|
|
const message = {
|
|
|
|
|
|
id: requestId,
|
|
|
|
|
|
role: 'user',
|
|
|
|
|
|
type: 'human',
|
|
|
|
|
|
content: text,
|
|
|
|
|
|
message_type: imageContent ? 'multimodal_image' : 'text',
|
|
|
|
|
|
extra_metadata: {
|
2026-05-24 00:47:08 +08:00
|
|
|
|
request_id: requestId,
|
|
|
|
|
|
attachments
|
2026-04-19 23:44:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (imageContent) {
|
|
|
|
|
|
message.image_content = imageContent
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return message
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getMessageRequestId = (message) => {
|
|
|
|
|
|
if (!message || typeof message !== 'object') return null
|
|
|
|
|
|
|
|
|
|
|
|
const metadataRequestId = message.extra_metadata?.request_id
|
|
|
|
|
|
if (typeof metadataRequestId === 'string' && metadataRequestId.trim()) {
|
|
|
|
|
|
return metadataRequestId.trim()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.type === 'human' && typeof message.id === 'string' && message.id.trim()) {
|
|
|
|
|
|
return message.id.trim()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 历史消息已落库时,ongoing 里仍会保留当前轮的本地 user message;
|
|
|
|
|
|
// 切回线程后按 request_id 去掉这条重复消息,只保留仍在流式更新的部分。
|
|
|
|
|
|
const stripDuplicatedOngoingHumanMessage = (historyConvs, ongoingMessages) => {
|
|
|
|
|
|
if (!Array.isArray(historyConvs) || !historyConvs.length || !Array.isArray(ongoingMessages)) {
|
|
|
|
|
|
return ongoingMessages
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const firstOngoingMessage = ongoingMessages[0]
|
|
|
|
|
|
if (!firstOngoingMessage || firstOngoingMessage.type !== 'human') {
|
|
|
|
|
|
return ongoingMessages
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const lastHistoryConv = historyConvs[historyConvs.length - 1]
|
|
|
|
|
|
const historyMessages = Array.isArray(lastHistoryConv?.messages) ? lastHistoryConv.messages : []
|
|
|
|
|
|
const lastHistoryHuman = historyMessages.find((message) => message?.type === 'human')
|
|
|
|
|
|
if (!lastHistoryHuman) {
|
|
|
|
|
|
return ongoingMessages
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const historyRequestId = getMessageRequestId(lastHistoryHuman)
|
|
|
|
|
|
const ongoingRequestId = getMessageRequestId(firstOngoingMessage)
|
|
|
|
|
|
if (!historyRequestId || !ongoingRequestId || historyRequestId !== ongoingRequestId) {
|
|
|
|
|
|
return ongoingMessages
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ongoingMessages.slice(1)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 发送 runs 前先在前端插入一条用户消息,避免等待 worker 轮询后消息才出现。
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const insertOptimisticHumanMessage = (
|
|
|
|
|
|
threadState,
|
|
|
|
|
|
{ requestId, text, imageContent = null, attachments = [] }
|
|
|
|
|
|
) => {
|
2026-04-19 23:44:46 +08:00
|
|
|
|
if (!threadState || !requestId) return
|
|
|
|
|
|
threadState.pendingRequestId = requestId
|
|
|
|
|
|
threadState.replyLoadingVisible = false
|
|
|
|
|
|
threadState.onGoingConv.msgChunks[requestId] = [
|
2026-05-24 00:47:08 +08:00
|
|
|
|
buildOptimisticHumanMessage({ requestId, text, imageContent, attachments })
|
2026-04-19 23:44:46 +08:00
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const markAttachmentsRequestId = (threadId, attachments, requestId) => {
|
|
|
|
|
|
if (!threadId || !attachments.length) return null
|
|
|
|
|
|
const previousAttachments = threadAttachmentsMap.value[threadId] || []
|
|
|
|
|
|
const fileIds = new Set(attachments.map((attachment) => attachment.file_id).filter(Boolean))
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = previousAttachments.map((attachment) =>
|
|
|
|
|
|
fileIds.has(attachment.file_id) ? { ...attachment, request_id: requestId } : attachment
|
|
|
|
|
|
)
|
|
|
|
|
|
return previousAttachments
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const rollbackAttachments = (threadId, previousAttachments) => {
|
|
|
|
|
|
if (!threadId || !Array.isArray(previousAttachments)) return
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = previousAttachments
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
const CONFIG_CHANGE_NOTICE_MESSAGE =
|
|
|
|
|
|
'在运行过程中切换或修改配置可能会影响最终效果,建议新建一个对话。'
|
|
|
|
|
|
|
|
|
|
|
|
const withConfigNoticeSync = async (task) => {
|
|
|
|
|
|
configNoticeSyncDepth.value += 1
|
|
|
|
|
|
try {
|
|
|
|
|
|
return await task()
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
configNoticeSyncDepth.value = Math.max(0, configNoticeSyncDepth.value - 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const buildThreadConfigSnapshot = () => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
agentId: currentAgentId.value || '',
|
|
|
|
|
|
configJson: JSON.stringify(agentConfig.value || {})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const syncThreadConfigSnapshot = (threadId, options = {}) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
|
|
|
|
|
|
const { overwrite = true } = options
|
|
|
|
|
|
if (!overwrite && threadConfigSnapshotMap.value[threadId]) return
|
|
|
|
|
|
if (threadPendingConfigNoticeMap.value[threadId]) return
|
|
|
|
|
|
|
|
|
|
|
|
// 线程切换时先记录当前 UI 的配置快照,避免同步 thread 绑定配置时误报。
|
|
|
|
|
|
threadConfigSnapshotMap.value = {
|
|
|
|
|
|
...threadConfigSnapshotMap.value,
|
|
|
|
|
|
[threadId]: buildThreadConfigSnapshot()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const upsertThreadConfigNotice = (threadId, insertAfterConversationCount) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
|
|
|
|
|
|
const existingNotice = threadConfigNoticeMap.value[threadId]
|
|
|
|
|
|
const nextNotice = {
|
|
|
|
|
|
id: existingNotice?.id || `config-change-notice-${threadId}`,
|
|
|
|
|
|
message: existingNotice?.message || CONFIG_CHANGE_NOTICE_MESSAGE,
|
|
|
|
|
|
insertAfterConversationCount
|
|
|
|
|
|
}
|
|
|
|
|
|
const shouldScroll =
|
|
|
|
|
|
!existingNotice || existingNotice.insertAfterConversationCount !== insertAfterConversationCount
|
|
|
|
|
|
|
|
|
|
|
|
threadConfigNoticeMap.value = {
|
|
|
|
|
|
...threadConfigNoticeMap.value,
|
|
|
|
|
|
[threadId]: nextNotice
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (threadPendingConfigNoticeMap.value[threadId]) {
|
|
|
|
|
|
const nextPendingNotices = { ...threadPendingConfigNoticeMap.value }
|
|
|
|
|
|
delete nextPendingNotices[threadId]
|
|
|
|
|
|
threadPendingConfigNoticeMap.value = nextPendingNotices
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (shouldScroll) {
|
|
|
|
|
|
configNoticeScrollVersion.value += 1
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const queuePendingThreadConfigNotice = (threadId) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
threadPendingConfigNoticeMap.value = {
|
|
|
|
|
|
...threadPendingConfigNoticeMap.value,
|
|
|
|
|
|
[threadId]: {
|
|
|
|
|
|
id: `config-change-notice-${threadId}`,
|
|
|
|
|
|
message: CONFIG_CHANGE_NOTICE_MESSAGE
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const flushPendingThreadConfigNotice = (threadId) => {
|
2026-04-26 18:51:38 +08:00
|
|
|
|
if (
|
|
|
|
|
|
!threadId ||
|
|
|
|
|
|
!currentThreadHasHistory.value ||
|
|
|
|
|
|
!threadPendingConfigNoticeMap.value[threadId]
|
|
|
|
|
|
) {
|
2026-04-19 18:13:18 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
upsertThreadConfigNotice(threadId, conversations.value.length)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const maybeInsertThreadConfigNotice = () => {
|
|
|
|
|
|
const threadId = currentChatId.value
|
|
|
|
|
|
if (!threadId || configNoticeSyncDepth.value > 0) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const previousSnapshot = threadConfigSnapshotMap.value[threadId]
|
|
|
|
|
|
const currentSnapshot = buildThreadConfigSnapshot()
|
|
|
|
|
|
|
|
|
|
|
|
if (!previousSnapshot) {
|
|
|
|
|
|
threadConfigSnapshotMap.value = {
|
|
|
|
|
|
...threadConfigSnapshotMap.value,
|
|
|
|
|
|
[threadId]: currentSnapshot
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
previousSnapshot.agentId === currentSnapshot.agentId &&
|
|
|
|
|
|
previousSnapshot.configJson === currentSnapshot.configJson
|
|
|
|
|
|
) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (currentThreadHasHistory.value) {
|
|
|
|
|
|
upsertThreadConfigNotice(threadId, conversations.value.length)
|
|
|
|
|
|
} else if (chatUIStore.isLoadingMessages) {
|
|
|
|
|
|
// 历史线程仍在加载时先挂起提示,避免消息返回后把变更误当成新的基线。
|
|
|
|
|
|
queuePendingThreadConfigNotice(threadId)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
threadConfigSnapshotMap.value = {
|
|
|
|
|
|
...threadConfigSnapshotMap.value,
|
|
|
|
|
|
[threadId]: currentSnapshot
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== SCROLL & RESIZE HANDLING ====================
|
2026-01-24 15:24:25 +08:00
|
|
|
|
const scrollController = new ScrollController('.chat-main')
|
2026-03-21 16:41:32 +08:00
|
|
|
|
const chatMainRef = ref(null)
|
|
|
|
|
|
let chatMainResizeObserver = null
|
2026-04-19 23:04:36 +08:00
|
|
|
|
// 初始化延迟标志,避免首次挂载时 ResizeObserver 立即触发导致侧边栏意外关闭
|
|
|
|
|
|
let isResizeObserverReady = false
|
2026-04-20 23:55:51 +08:00
|
|
|
|
let resizeObserverReadyTimer = null
|
|
|
|
|
|
|
|
|
|
|
|
const armResizeObserver = () => {
|
|
|
|
|
|
if (resizeObserverReadyTimer) {
|
|
|
|
|
|
clearTimeout(resizeObserverReadyTimer)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isResizeObserverReady = false
|
|
|
|
|
|
// keep-alive 切页回来时等布局稳定后再恢复宽度判断,避免隐藏态宽度污染侧边栏状态。
|
|
|
|
|
|
resizeObserverReadyTimer = setTimeout(() => {
|
|
|
|
|
|
isResizeObserverReady = true
|
|
|
|
|
|
}, 50)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const stopChatMainResizeObserver = () => {
|
|
|
|
|
|
if (resizeObserverReadyTimer) {
|
|
|
|
|
|
clearTimeout(resizeObserverReadyTimer)
|
|
|
|
|
|
resizeObserverReadyTimer = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isResizeObserverReady = false
|
|
|
|
|
|
|
|
|
|
|
|
if (chatMainResizeObserver) {
|
|
|
|
|
|
chatMainResizeObserver.disconnect()
|
|
|
|
|
|
chatMainResizeObserver = null
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const stopStreamingStateRefresh = () => {
|
|
|
|
|
|
if (streamingStateRefreshTimer) {
|
|
|
|
|
|
clearInterval(streamingStateRefreshTimer)
|
|
|
|
|
|
streamingStateRefreshTimer = null
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const startStreamingStateRefresh = () => {
|
|
|
|
|
|
stopStreamingStateRefresh()
|
|
|
|
|
|
streamingStateRefreshTimer = setInterval(() => {
|
|
|
|
|
|
if (!shouldRefreshStateWhileStreaming.value) return
|
|
|
|
|
|
void handleAgentStateRefresh()
|
|
|
|
|
|
}, 5000)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 23:55:51 +08:00
|
|
|
|
const startChatMainResizeObserver = () => {
|
|
|
|
|
|
if (!window.ResizeObserver || !chatMainRef.value || chatMainResizeObserver) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
localUIState.chatMainWidth = chatMainRef.value.clientWidth || window.innerWidth
|
|
|
|
|
|
chatMainResizeObserver = new ResizeObserver((entries) => {
|
|
|
|
|
|
// 初始化期间跳过检查,等待 layout 稳定
|
|
|
|
|
|
if (!isResizeObserverReady) return
|
|
|
|
|
|
|
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
|
const width = entry.contentRect.width
|
|
|
|
|
|
if (!width) continue
|
|
|
|
|
|
|
|
|
|
|
|
localUIState.chatMainWidth = width
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
chatMainResizeObserver.observe(chatMainRef.value)
|
|
|
|
|
|
armResizeObserver()
|
|
|
|
|
|
}
|
2025-05-15 22:34:32 +08:00
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
nextTick(() => {
|
2026-01-24 15:24:25 +08:00
|
|
|
|
const chatMainContainer = document.querySelector('.chat-main')
|
|
|
|
|
|
if (chatMainContainer) {
|
|
|
|
|
|
chatMainContainer.addEventListener('scroll', scrollController.handleScroll, { passive: true })
|
2025-06-24 00:15:51 +08:00
|
|
|
|
}
|
2026-03-21 16:41:32 +08:00
|
|
|
|
|
2026-04-20 23:55:51 +08:00
|
|
|
|
startChatMainResizeObserver()
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
2025-05-15 22:34:32 +08:00
|
|
|
|
|
2026-04-20 23:55:51 +08:00
|
|
|
|
onActivated(() => {
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
startChatMainResizeObserver()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onDeactivated(() => {
|
|
|
|
|
|
stopChatMainResizeObserver()
|
2026-06-01 22:29:18 +08:00
|
|
|
|
stopStreamingStateRefresh()
|
2026-04-20 23:55:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
onUnmounted(() => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
scrollController.cleanup()
|
2026-04-20 23:55:51 +08:00
|
|
|
|
stopChatMainResizeObserver()
|
2026-06-01 22:29:18 +08:00
|
|
|
|
stopStreamingStateRefresh()
|
2026-03-24 21:42:37 +08:00
|
|
|
|
if (sendCooldownTimer) {
|
|
|
|
|
|
clearTimeout(sendCooldownTimer)
|
|
|
|
|
|
sendCooldownTimer = null
|
|
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
// 清理所有线程状态
|
|
|
|
|
|
resetOnGoingConv()
|
|
|
|
|
|
})
|
2025-08-25 01:46:31 +08:00
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
// ==================== 线程管理方法 ====================
|
|
|
|
|
|
// 获取当前智能体的线程列表
|
|
|
|
|
|
const fetchThreads = async (agentId = null) => {
|
2026-03-16 21:39:49 +08:00
|
|
|
|
const targetAgentId = props.singleMode ? agentId || currentAgentId.value : agentId
|
|
|
|
|
|
if (props.singleMode && !targetAgentId) return
|
2025-05-15 22:34:32 +08:00
|
|
|
|
|
2026-04-24 22:42:51 +08:00
|
|
|
|
await chatThreadsStore.loadThreads(targetAgentId)
|
2026-03-06 10:14:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
// 创建新线程
|
|
|
|
|
|
const createThread = async (agentId, title = '新的对话') => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!agentId) return null
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
|
|
|
|
|
try {
|
2026-04-24 22:42:51 +08:00
|
|
|
|
const thread = await chatThreadsStore.createThread(agentId, title)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
if (thread) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
threadMessages.value[thread.id] = []
|
2026-03-04 08:53:50 +08:00
|
|
|
|
threadFilesMap.value[thread.id] = []
|
|
|
|
|
|
threadAttachmentsMap.value[thread.id] = []
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return thread
|
2025-08-31 14:39:28 +08:00
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
console.error('Failed to create thread:', error)
|
|
|
|
|
|
handleChatError(error, 'create')
|
|
|
|
|
|
throw error
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取线程消息
|
2025-11-12 11:00:39 +08:00
|
|
|
|
const fetchThreadMessages = async ({ agentId, threadId, delay = 0 }) => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!threadId || !agentId) return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-11-12 11:00:39 +08:00
|
|
|
|
// 如果指定了延迟,等待指定时间(用于确保后端数据库事务提交)
|
|
|
|
|
|
if (delay > 0) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, delay))
|
2025-11-12 11:00:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
try {
|
2026-03-27 00:20:33 +08:00
|
|
|
|
const response = await agentApi.getAgentHistory(threadId)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
threadMessages.value[threadId] = response.history || []
|
2025-08-31 14:39:28 +08:00
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
handleChatError(error, 'load')
|
|
|
|
|
|
throw error
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-03-04 08:53:50 +08:00
|
|
|
|
const fetchThreadFiles = async (threadId) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
try {
|
2026-05-21 23:06:33 +08:00
|
|
|
|
const response = await threadApi.listThreadFiles(threadId, '/home/gem/user-data', false)
|
2026-03-14 23:54:52 +08:00
|
|
|
|
const entries = Array.isArray(response?.files) ? response.files : []
|
2026-03-04 08:53:50 +08:00
|
|
|
|
threadFilesMap.value[threadId] = entries
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.warn('Failed to fetch thread files:', error)
|
|
|
|
|
|
threadFilesMap.value[threadId] = []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const fetchThreadAttachments = async (threadId) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await threadApi.getThreadAttachments(threadId)
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = Array.isArray(response?.attachments)
|
|
|
|
|
|
? response.attachments
|
|
|
|
|
|
: []
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.warn('Failed to fetch thread attachments:', error)
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const refreshThreadFilesAndAttachments = async (threadId) => {
|
|
|
|
|
|
if (!threadId) return
|
|
|
|
|
|
await Promise.all([fetchThreadFiles(threadId), fetchThreadAttachments(threadId)])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-31 20:18:22 +08:00
|
|
|
|
const handleArtifactSaved = async () => {
|
|
|
|
|
|
if (!currentChatId.value) return
|
|
|
|
|
|
await refreshThreadFilesAndAttachments(currentChatId.value)
|
2026-05-29 22:19:58 +08:00
|
|
|
|
showFileTreePanel()
|
2026-03-31 20:18:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-17 12:01:59 +08:00
|
|
|
|
const fetchAgentState = async (agentId, threadId) => {
|
2026-03-27 00:20:33 +08:00
|
|
|
|
if (!threadId) return
|
2025-11-17 12:01:59 +08:00
|
|
|
|
try {
|
2026-03-27 00:20:33 +08:00
|
|
|
|
const res = await agentApi.getAgentState(threadId)
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const targetState = getThreadState(threadId)
|
|
|
|
|
|
if (!targetState) return
|
|
|
|
|
|
targetState.agentState = res.agent_state || null
|
2026-02-24 14:22:11 +08:00
|
|
|
|
} catch {
|
2026-06-01 22:29:18 +08:00
|
|
|
|
// agent state is optional UI state
|
2026-02-24 14:22:11 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-17 12:01:59 +08:00
|
|
|
|
|
2026-03-20 17:51:12 +08:00
|
|
|
|
const ensureActiveThread = async (title = '新的对话') => {
|
|
|
|
|
|
if (currentChatId.value) return currentChatId.value
|
2026-02-25 16:26:09 +08:00
|
|
|
|
try {
|
2026-03-20 17:51:12 +08:00
|
|
|
|
const newThread = await createThread(currentAgentId.value, title || '新的对话')
|
|
|
|
|
|
if (newThread) {
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(newThread.id)
|
2026-03-20 17:51:12 +08:00
|
|
|
|
return newThread.id
|
|
|
|
|
|
}
|
2026-02-25 16:26:09 +08:00
|
|
|
|
} catch {
|
2026-03-20 17:51:12 +08:00
|
|
|
|
// createThread 已处理错误提示
|
2026-02-25 16:26:09 +08:00
|
|
|
|
}
|
2026-03-20 17:51:12 +08:00
|
|
|
|
return null
|
2026-02-25 16:26:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
const handleAttachmentUpload = async () => {
|
2026-03-24 21:48:28 +08:00
|
|
|
|
if (
|
|
|
|
|
|
!AgentValidator.validateAgentIdWithError(
|
|
|
|
|
|
currentAgentId.value,
|
|
|
|
|
|
'上传附件',
|
|
|
|
|
|
handleValidationError
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
2026-02-25 16:26:09 +08:00
|
|
|
|
return
|
|
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
attachmentUploadModalOpen.value = true
|
|
|
|
|
|
}
|
2026-02-25 16:26:09 +08:00
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
const ensureAttachmentThread = async () => {
|
|
|
|
|
|
if (currentChatId.value) return currentChatId.value
|
|
|
|
|
|
return await ensureActiveThread('新的对话')
|
|
|
|
|
|
}
|
2026-02-25 16:26:09 +08:00
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
const handleTmpAttachmentsAdded = async () => {
|
|
|
|
|
|
const threadId = currentChatId.value
|
|
|
|
|
|
if (!threadId) return
|
2026-02-25 16:26:09 +08:00
|
|
|
|
|
2026-05-27 18:22:29 +08:00
|
|
|
|
await Promise.all([
|
|
|
|
|
|
fetchAgentState(currentAgentId.value, threadId),
|
|
|
|
|
|
refreshThreadFilesAndAttachments(threadId)
|
|
|
|
|
|
])
|
2026-05-29 22:19:58 +08:00
|
|
|
|
showFileTreePanel()
|
2026-02-25 16:26:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const handleAttachmentRemove = async (attachment) => {
|
|
|
|
|
|
const threadId = currentChatId.value
|
|
|
|
|
|
const fileId = attachment?.file_id
|
|
|
|
|
|
if (!threadId || !fileId) return
|
|
|
|
|
|
|
|
|
|
|
|
const previousAttachments = threadAttachmentsMap.value[threadId] || []
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = previousAttachments.filter(
|
|
|
|
|
|
(item) => item.file_id !== fileId
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
await threadApi.deleteThreadAttachment(threadId, fileId)
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
fetchAgentState(currentAgentId.value, threadId),
|
|
|
|
|
|
refreshThreadFilesAndAttachments(threadId)
|
|
|
|
|
|
])
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
threadAttachmentsMap.value[threadId] = previousAttachments
|
|
|
|
|
|
handleChatError(error, 'delete')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-01 21:34:16 +08:00
|
|
|
|
// ==================== 审批功能管理 ====================
|
2026-05-28 12:53:29 +08:00
|
|
|
|
const { approvalState, processApprovalInStream } = useApproval({
|
2025-11-01 21:34:16 +08:00
|
|
|
|
getThreadState,
|
|
|
|
|
|
fetchThreadMessages
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2025-11-01 21:34:16 +08:00
|
|
|
|
|
2026-05-28 12:53:29 +08:00
|
|
|
|
const { handleStreamChunk } = useAgentStreamHandler({
|
2025-12-19 04:04:48 +08:00
|
|
|
|
getThreadState,
|
|
|
|
|
|
processApprovalInStream,
|
|
|
|
|
|
currentAgentId,
|
2026-03-25 13:46:52 +08:00
|
|
|
|
supportsFiles,
|
|
|
|
|
|
streamSmoother
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2026-03-20 17:51:12 +08:00
|
|
|
|
const { startRunStream, resumeActiveRunForThread, stopRunStreamSubscription } = useAgentRunStream({
|
|
|
|
|
|
getThreadState,
|
|
|
|
|
|
currentAgentId,
|
|
|
|
|
|
handleStreamChunk,
|
|
|
|
|
|
fetchThreadMessages,
|
|
|
|
|
|
fetchAgentState,
|
|
|
|
|
|
resetOnGoingConv,
|
2026-03-25 13:46:52 +08:00
|
|
|
|
onScrollToBottom: () => scrollController.scrollToBottom(),
|
|
|
|
|
|
streamSmoother
|
2026-03-20 17:51:12 +08:00
|
|
|
|
})
|
2025-12-19 04:04:48 +08:00
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
// ==================== CHAT ACTIONS ====================
|
2026-03-08 22:33:24 +08:00
|
|
|
|
// 获取第一个非置顶的对话
|
|
|
|
|
|
const getFirstNonPinnedChat = (chatList) => {
|
2026-03-09 01:23:15 +08:00
|
|
|
|
if (!chatList || chatList.length === 0) return null
|
2026-03-08 22:33:24 +08:00
|
|
|
|
return chatList.find((chat) => !chat.is_pinned) || chatList[0]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
const selectChat = async (chatId) => {
|
2026-03-16 21:39:49 +08:00
|
|
|
|
const targetChat = threads.value.find((chat) => chat.id === chatId) || null
|
|
|
|
|
|
const targetAgentId = targetChat?.agent_id || currentAgentId.value
|
|
|
|
|
|
const previousThreadId = chatState.currentThreadId
|
|
|
|
|
|
|
|
|
|
|
|
if (!targetAgentId) {
|
|
|
|
|
|
handleValidationError('选择对话失败:缺少智能体信息')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!AgentValidator.validateAgentIdWithError(targetAgentId, '选择对话', handleValidationError))
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2025-11-01 21:34:16 +08:00
|
|
|
|
// 中断之前线程的流式输出(如果存在)
|
|
|
|
|
|
if (previousThreadId && previousThreadId !== chatId) {
|
2026-03-20 17:51:12 +08:00
|
|
|
|
stopThreadStream(previousThreadId)
|
2026-02-25 16:26:09 +08:00
|
|
|
|
// run 模式下仅断开 SSE 订阅,不取消后台运行任务
|
|
|
|
|
|
stopRunStreamSubscription(previousThreadId)
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 21:48:28 +08:00
|
|
|
|
if (previousThreadId !== chatId) {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
resetAgentPanelState()
|
2026-03-24 21:48:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
try {
|
|
|
|
|
|
await withConfigNoticeSync(async () => {
|
|
|
|
|
|
// 先更新当前线程,确保底部智能体名称与选中项即时同步。
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(chatId)
|
2026-03-16 21:39:49 +08:00
|
|
|
|
|
2026-04-26 18:51:38 +08:00
|
|
|
|
if (
|
|
|
|
|
|
!props.singleMode &&
|
|
|
|
|
|
targetChat?.agent_id &&
|
|
|
|
|
|
targetChat.agent_id !== currentAgentId.value
|
|
|
|
|
|
) {
|
2026-04-19 18:13:18 +08:00
|
|
|
|
await agentStore.selectAgent(targetChat.agent_id)
|
|
|
|
|
|
}
|
2026-03-16 21:39:49 +08:00
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
syncThreadConfigSnapshot(chatId)
|
|
|
|
|
|
})
|
2026-03-27 01:15:42 +08:00
|
|
|
|
} catch (error) {
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(previousThreadId)
|
2026-03-27 01:15:42 +08:00
|
|
|
|
handleChatError(error, 'load')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
chatUIStore.isLoadingMessages = true
|
2025-08-31 14:39:28 +08:00
|
|
|
|
try {
|
2026-03-16 21:39:49 +08:00
|
|
|
|
await fetchThreadMessages({ agentId: targetAgentId, threadId: chatId })
|
2025-08-31 14:39:28 +08:00
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
handleChatError(error, 'load')
|
2025-08-31 14:39:28 +08:00
|
|
|
|
} finally {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
chatUIStore.isLoadingMessages = false
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await nextTick()
|
|
|
|
|
|
scrollController.scrollToBottomStaticForce()
|
2026-03-20 21:07:48 +08:00
|
|
|
|
// await fetchAgentState(targetAgentId, chatId)
|
2026-03-04 08:53:50 +08:00
|
|
|
|
await handleAgentStateRefresh(chatId)
|
2026-04-19 18:13:18 +08:00
|
|
|
|
syncThreadConfigSnapshot(chatId, { overwrite: false })
|
2026-02-25 16:26:09 +08:00
|
|
|
|
await resumeActiveRunForThread(chatId)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2026-03-24 02:32:35 +08:00
|
|
|
|
const selectThreadFromRoute = async (threadId) => {
|
|
|
|
|
|
if (!agentStore.isInitialized) {
|
|
|
|
|
|
await initAll()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!threadId) {
|
|
|
|
|
|
const previousThreadId = chatState.currentThreadId
|
|
|
|
|
|
if (previousThreadId) {
|
|
|
|
|
|
stopThreadStream(previousThreadId)
|
|
|
|
|
|
stopRunStreamSubscription(previousThreadId)
|
|
|
|
|
|
}
|
2026-05-22 00:59:05 +08:00
|
|
|
|
resetAgentPanelState()
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(null)
|
2026-03-24 02:32:35 +08:00
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (chatState.currentThreadId === threadId) {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!threads.value.length || !threads.value.find((thread) => thread.id === threadId)) {
|
|
|
|
|
|
await loadChatsList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const targetThread = threads.value.find((thread) => thread.id === threadId)
|
|
|
|
|
|
if (!targetThread) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await selectChat(threadId)
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-19 04:04:48 +08:00
|
|
|
|
const handleSendMessage = async ({ image } = {}) => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const text = userInput.value.trim()
|
2026-04-19 23:44:46 +08:00
|
|
|
|
const imageContent = image?.imageContent || null
|
2026-05-25 21:02:23 +08:00
|
|
|
|
if (
|
|
|
|
|
|
(!text && !image) ||
|
|
|
|
|
|
!currentAgent.value ||
|
|
|
|
|
|
isProcessing.value ||
|
|
|
|
|
|
sendCooldownActive.value ||
|
|
|
|
|
|
props.sendDisabled
|
|
|
|
|
|
)
|
2026-03-24 21:42:37 +08:00
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
// 发送后进入短暂冷却,防止连续触发停止
|
|
|
|
|
|
startSendCooldown()
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
let threadId = currentChatId.value
|
2025-11-08 10:51:30 +08:00
|
|
|
|
if (!threadId) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
threadId = await ensureActiveThread(text)
|
2025-11-08 10:51:30 +08:00
|
|
|
|
if (!threadId) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
message.error('创建对话失败,请重试')
|
|
|
|
|
|
return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
userInput.value = ''
|
2025-11-12 14:04:34 +08:00
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await nextTick()
|
|
|
|
|
|
scrollController.scrollToBottom(true)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadState = getThreadState(threadId)
|
|
|
|
|
|
if (!threadState) return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const pendingAttachments = [...currentPendingThreadAttachments.value]
|
|
|
|
|
|
const pendingAttachmentFileIds = pendingAttachments
|
|
|
|
|
|
.map((attachment) => attachment.file_id)
|
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
|
|
2026-03-24 21:48:28 +08:00
|
|
|
|
if ((threadMessages.value[threadId] || []).length === 0) {
|
|
|
|
|
|
const autoTitle = text.replace(/\s+/g, ' ').trim().slice(0, 2000)
|
|
|
|
|
|
if (autoTitle) {
|
|
|
|
|
|
void (async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const generatedTitle = await agentApi.generateTitle(
|
|
|
|
|
|
autoTitle,
|
|
|
|
|
|
configStore.config?.fast_model
|
|
|
|
|
|
)
|
|
|
|
|
|
if (generatedTitle) {
|
|
|
|
|
|
const finalTitle = generatedTitle.slice(0, 30).replace(/\s+/g, ' ').trim()
|
|
|
|
|
|
if (finalTitle) {
|
2026-04-24 22:42:51 +08:00
|
|
|
|
void chatThreadsStore.updateThread(threadId, finalTitle).catch(() => {})
|
2026-03-24 21:48:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error('Title generation failed:', e)
|
2026-04-24 22:42:51 +08:00
|
|
|
|
void chatThreadsStore.updateThread(threadId, autoTitle.slice(0, 30)).catch(() => {})
|
2026-03-24 21:48:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
})()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
resetOnGoingConv(threadId)
|
2026-05-10 18:39:36 +08:00
|
|
|
|
const requestId = createClientRequestId()
|
2026-05-24 00:47:08 +08:00
|
|
|
|
const previousAttachments = markAttachmentsRequestId(threadId, pendingAttachments, requestId)
|
2026-05-10 18:39:36 +08:00
|
|
|
|
insertOptimisticHumanMessage(threadState, {
|
|
|
|
|
|
requestId,
|
|
|
|
|
|
text,
|
2026-05-24 00:47:08 +08:00
|
|
|
|
imageContent,
|
2026-05-28 12:53:29 +08:00
|
|
|
|
attachments: pendingAttachments.map((attachment) => ({
|
|
|
|
|
|
...attachment,
|
|
|
|
|
|
request_id: requestId
|
|
|
|
|
|
}))
|
2026-05-10 18:39:36 +08:00
|
|
|
|
})
|
2026-05-28 12:53:29 +08:00
|
|
|
|
threadState.isStreaming = true
|
2025-05-15 22:57:23 +08:00
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
try {
|
2026-05-28 12:53:29 +08:00
|
|
|
|
const runResp = await agentApi.createAgentRun({
|
|
|
|
|
|
query: text,
|
|
|
|
|
|
agent_id: currentAgentId.value,
|
|
|
|
|
|
thread_id: threadId,
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
request_id: requestId,
|
|
|
|
|
|
attachment_file_ids: pendingAttachmentFileIds
|
|
|
|
|
|
},
|
|
|
|
|
|
image_content: imageContent
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2026-05-28 12:53:29 +08:00
|
|
|
|
const runId = runResp?.run_id
|
|
|
|
|
|
if (!runId) {
|
|
|
|
|
|
throw new Error('创建 run 失败:缺少 run_id')
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2026-05-28 12:53:29 +08:00
|
|
|
|
await startRunStream(threadId, runId, 0)
|
|
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
threadState.isStreaming = false
|
2026-05-28 12:53:29 +08:00
|
|
|
|
threadState.replyLoadingVisible = false
|
|
|
|
|
|
threadState.pendingRequestId = null
|
|
|
|
|
|
rollbackAttachments(threadId, previousAttachments)
|
|
|
|
|
|
resetOnGoingConv(threadId)
|
|
|
|
|
|
handleChatError(error, 'send')
|
2025-05-15 22:34:32 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2025-10-06 21:44:17 +08:00
|
|
|
|
// 发送或中断
|
2025-12-19 04:04:48 +08:00
|
|
|
|
const handleSendOrStop = async (payload) => {
|
2026-03-24 21:42:37 +08:00
|
|
|
|
if (sendCooldownActive.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadId = currentChatId.value
|
|
|
|
|
|
const threadState = getThreadState(threadId)
|
2026-05-28 12:53:29 +08:00
|
|
|
|
if (isProcessing.value && threadState?.activeRunId) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await agentApi.cancelAgentRun(threadState.activeRunId)
|
|
|
|
|
|
message.info('已发送取消请求')
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
handleChatError(error, 'stop')
|
2025-10-06 21:44:17 +08:00
|
|
|
|
}
|
2026-05-28 12:53:29 +08:00
|
|
|
|
return
|
2025-10-06 21:44:17 +08:00
|
|
|
|
}
|
2026-05-25 21:02:23 +08:00
|
|
|
|
if (props.sendDisabled) return
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await handleSendMessage(payload)
|
|
|
|
|
|
}
|
2025-10-06 21:44:17 +08:00
|
|
|
|
|
2025-11-01 21:34:16 +08:00
|
|
|
|
// ==================== 人工审批处理 ====================
|
2026-03-07 23:28:25 +08:00
|
|
|
|
const handleApprovalWithStream = async (answer) => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadId = approvalState.threadId
|
2025-11-01 21:34:16 +08:00
|
|
|
|
if (!threadId) {
|
2026-03-07 23:28:25 +08:00
|
|
|
|
message.error('无效的提问请求')
|
2026-01-15 06:01:34 +08:00
|
|
|
|
approvalState.showModal = false
|
|
|
|
|
|
return
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const threadState = getThreadState(threadId)
|
2025-11-01 21:34:16 +08:00
|
|
|
|
if (!threadState) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
message.error('无法找到对应的对话线程')
|
|
|
|
|
|
approvalState.showModal = false
|
|
|
|
|
|
return
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-28 12:53:29 +08:00
|
|
|
|
if (!approvalState.parentRunId) {
|
|
|
|
|
|
message.error('无法找到需要恢复的运行任务')
|
|
|
|
|
|
approvalState.showModal = false
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-12-19 02:22:29 +08:00
|
|
|
|
|
2026-05-28 12:53:29 +08:00
|
|
|
|
try {
|
|
|
|
|
|
approvalState.showModal = false
|
|
|
|
|
|
threadState.isStreaming = true
|
|
|
|
|
|
resetOnGoingConv(threadId)
|
|
|
|
|
|
const resumeRequestId = createClientRequestId()
|
|
|
|
|
|
const runResp = await agentApi.createAgentRun({
|
|
|
|
|
|
query: null,
|
|
|
|
|
|
agent_id: currentAgentId.value,
|
|
|
|
|
|
thread_id: threadId,
|
|
|
|
|
|
meta: { request_id: resumeRequestId },
|
|
|
|
|
|
resume: answer,
|
|
|
|
|
|
parent_run_id: approvalState.parentRunId,
|
|
|
|
|
|
resume_request_id: resumeRequestId
|
2026-03-04 04:13:05 +08:00
|
|
|
|
})
|
2026-05-28 12:53:29 +08:00
|
|
|
|
const runId = runResp?.run_id
|
|
|
|
|
|
if (!runId) {
|
|
|
|
|
|
throw new Error('创建 resume run 失败:缺少 run_id')
|
|
|
|
|
|
}
|
|
|
|
|
|
await startRunStream(threadId, runId, '0-0')
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
threadState.isStreaming = false
|
|
|
|
|
|
threadState.replyLoadingVisible = false
|
|
|
|
|
|
handleChatError(error, 'resume')
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-01 21:34:16 +08:00
|
|
|
|
|
2026-03-07 23:28:25 +08:00
|
|
|
|
const handleQuestionSubmit = (answer) => {
|
|
|
|
|
|
handleApprovalWithStream(answer)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-01 21:34:16 +08:00
|
|
|
|
|
2026-03-07 23:28:25 +08:00
|
|
|
|
const handleQuestionCancel = () => {
|
|
|
|
|
|
handleApprovalWithStream('reject')
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-01 21:34:16 +08:00
|
|
|
|
|
2025-10-13 11:12:25 +08:00
|
|
|
|
const buildExportPayload = () => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const agentId = currentAgentId.value
|
|
|
|
|
|
let agentDescription = ''
|
2025-11-07 12:28:58 +08:00
|
|
|
|
if (agentId && agents.value && agents.value.length > 0) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
const agent = agents.value.find((a) => a.id === agentId)
|
|
|
|
|
|
agentDescription = agent ? agent.description || '' : ''
|
2025-11-07 12:28:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-13 11:12:25 +08:00
|
|
|
|
const payload = {
|
|
|
|
|
|
chatTitle: currentThread.value?.title || '新对话',
|
|
|
|
|
|
agentName: currentAgentName.value || currentAgent.value?.name || '智能助手',
|
2025-11-07 12:28:58 +08:00
|
|
|
|
agentDescription: agentDescription || currentAgent.value?.description || '',
|
2025-10-13 11:12:25 +08:00
|
|
|
|
messages: conversations.value ? JSON.parse(JSON.stringify(conversations.value)) : [],
|
2026-01-15 06:01:34 +08:00
|
|
|
|
onGoingMessages: onGoingConvMessages.value
|
|
|
|
|
|
? JSON.parse(JSON.stringify(onGoingConvMessages.value))
|
|
|
|
|
|
: []
|
|
|
|
|
|
}
|
2025-10-13 11:12:25 +08:00
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return payload
|
|
|
|
|
|
}
|
2025-06-27 01:48:09 +08:00
|
|
|
|
|
2025-10-13 11:12:25 +08:00
|
|
|
|
defineExpose({
|
2026-03-24 02:32:35 +08:00
|
|
|
|
getExportPayload: buildExportPayload,
|
|
|
|
|
|
selectThreadFromRoute
|
2026-01-15 06:01:34 +08:00
|
|
|
|
})
|
2025-10-13 11:12:25 +08:00
|
|
|
|
|
2026-02-13 22:16:11 +08:00
|
|
|
|
const handleAgentStateRefresh = async (threadId = null) => {
|
|
|
|
|
|
if (!currentAgentId.value) return
|
2026-02-25 16:26:09 +08:00
|
|
|
|
const chatId = threadId || currentChatId.value
|
2026-02-13 22:16:11 +08:00
|
|
|
|
if (!chatId) return
|
2026-03-04 08:53:50 +08:00
|
|
|
|
await Promise.all([
|
|
|
|
|
|
fetchAgentState(currentAgentId.value, chatId),
|
|
|
|
|
|
refreshThreadFilesAndAttachments(chatId)
|
|
|
|
|
|
])
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-17 12:01:59 +08:00
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const toggleStatePanel = async () => {
|
|
|
|
|
|
const nextOpen = sideActive.value !== 'state'
|
|
|
|
|
|
sideActive.value = nextOpen ? 'state' : ''
|
|
|
|
|
|
if (nextOpen && currentChatId.value && !currentAgentState.value) {
|
|
|
|
|
|
await handleAgentStateRefresh()
|
|
|
|
|
|
}
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 21:48:28 +08:00
|
|
|
|
const toggleAgentPanel = async () => {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
const nextOpen = sideActive.value !== 'file'
|
2026-03-24 21:48:28 +08:00
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
if (!nextOpen) {
|
|
|
|
|
|
sideActive.value = ''
|
|
|
|
|
|
return
|
2026-03-24 21:48:28 +08:00
|
|
|
|
}
|
2026-05-29 22:19:58 +08:00
|
|
|
|
|
|
|
|
|
|
showFileTreePanel()
|
|
|
|
|
|
await handleAgentStateRefresh()
|
2026-01-24 15:24:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 21:44:10 +08:00
|
|
|
|
// 处理面板宽度调整(使用比例)
|
|
|
|
|
|
// 向右拖动(deltaX > 0)让面板变窄,向左拖动(deltaX < 0)让面板变宽
|
2026-03-26 06:07:18 +08:00
|
|
|
|
const handlePanelResize = (clientX) => {
|
2026-02-02 21:44:10 +08:00
|
|
|
|
if (!panelWrapperRef.value) return
|
|
|
|
|
|
|
|
|
|
|
|
if (!panelContainerWidth) {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
panelContainerWidth = getPanelContainerWidth()
|
2026-02-02 21:44:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-26 06:07:18 +08:00
|
|
|
|
const deltaX = clientX - resizeStartX
|
2026-05-22 00:59:05 +08:00
|
|
|
|
const rawWidth = resizeStartWidth - deltaX
|
|
|
|
|
|
const minWidth = minPanelRatio * panelContainerWidth
|
|
|
|
|
|
const maxWidth = getMaxPanelRatio(panelContainerWidth) * panelContainerWidth
|
|
|
|
|
|
const nextWidth = Math.max(minWidth, Math.min(rawWidth, maxWidth))
|
|
|
|
|
|
|
|
|
|
|
|
panelWrapperRef.value.style.setProperty('flex', `0 0 ${nextWidth}px`, 'important')
|
2026-02-02 21:44:10 +08:00
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
if (nextWidth !== rawWidth) {
|
|
|
|
|
|
resizeStartX = clientX
|
|
|
|
|
|
resizeStartWidth = nextWidth
|
2026-02-02 21:44:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 拖拽状态变化时,同步最终状态到 Vue 响应式数据
|
2026-03-26 06:07:18 +08:00
|
|
|
|
const handleResizingChange = (isResizingState, clientX = 0) => {
|
2026-02-02 21:44:10 +08:00
|
|
|
|
isResizing.value = isResizingState
|
|
|
|
|
|
|
2026-03-26 06:07:18 +08:00
|
|
|
|
if (isResizingState && panelWrapperRef.value) {
|
|
|
|
|
|
resizeStartX = clientX
|
|
|
|
|
|
resizeStartWidth = panelWrapperRef.value.offsetWidth
|
|
|
|
|
|
if (!panelContainerWidth) {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
panelContainerWidth = getPanelContainerWidth()
|
2026-03-26 06:07:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 21:44:10 +08:00
|
|
|
|
if (!isResizingState && panelWrapperRef.value && panelContainerWidth) {
|
|
|
|
|
|
const finalWidth = panelWrapperRef.value.offsetWidth
|
2026-05-22 00:59:05 +08:00
|
|
|
|
panelRatio.value = clampPanelRatio(finalWidth / panelContainerWidth, panelContainerWidth)
|
2026-03-26 06:07:18 +08:00
|
|
|
|
panelWrapperRef.value.style.removeProperty('flex')
|
|
|
|
|
|
resizeStartX = 0
|
|
|
|
|
|
resizeStartWidth = 0
|
2026-02-02 21:44:10 +08:00
|
|
|
|
panelContainerWidth = 0 // 重置,供下次使用
|
|
|
|
|
|
}
|
2026-01-31 17:04:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== HELPER FUNCTIONS ====================
|
2026-04-13 18:06:25 +08:00
|
|
|
|
const hasVisibleAssistantBody = (message) => {
|
|
|
|
|
|
if (!message || message.type !== 'ai') return true
|
|
|
|
|
|
|
2026-06-02 00:08:38 +08:00
|
|
|
|
const { content, reasoningContent } = MessageProcessor.parseAssistantMessageBody(message)
|
2026-04-13 18:06:25 +08:00
|
|
|
|
return Boolean(
|
|
|
|
|
|
content ||
|
2026-05-25 23:35:00 +08:00
|
|
|
|
reasoningContent ||
|
|
|
|
|
|
message.error_type ||
|
|
|
|
|
|
message.extra_metadata?.error_type ||
|
|
|
|
|
|
message.isStoppedByUser
|
2026-04-13 18:06:25 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getMessageToolCalls = (message) => {
|
2026-06-02 00:08:38 +08:00
|
|
|
|
return normalizeToolCalls(message?.tool_calls, {
|
|
|
|
|
|
mapToolCall: (toolCall) => {
|
2026-06-01 22:29:18 +08:00
|
|
|
|
const subagentRun = toolCall.id ? currentSubagentRunById.value.get(String(toolCall.id)) : null
|
|
|
|
|
|
if (!subagentRun) return toolCall
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
...toolCall,
|
|
|
|
|
|
subagent_run: subagentRun,
|
|
|
|
|
|
display_label: subagentRun.subagent_name || subagentRun.subagent_type || undefined
|
|
|
|
|
|
}
|
2026-06-02 00:08:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2026-04-13 18:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 将 AI 消息拆成“正文块”和“工具块”,再跨消息合并相邻工具块。
|
|
|
|
|
|
const getConversationDisplayItems = (conv) => {
|
|
|
|
|
|
if (!Array.isArray(conv?.messages) || conv.messages.length === 0) return []
|
|
|
|
|
|
|
|
|
|
|
|
const items = []
|
|
|
|
|
|
let pendingToolGroup = null
|
|
|
|
|
|
|
|
|
|
|
|
const flushToolGroup = () => {
|
|
|
|
|
|
if (pendingToolGroup && pendingToolGroup.toolCalls.length > 0) {
|
|
|
|
|
|
items.push(pendingToolGroup)
|
|
|
|
|
|
}
|
|
|
|
|
|
pendingToolGroup = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
conv.messages.forEach((message, index) => {
|
|
|
|
|
|
if (message.type !== 'ai') {
|
|
|
|
|
|
flushToolGroup()
|
|
|
|
|
|
items.push({
|
|
|
|
|
|
type: 'message',
|
|
|
|
|
|
key: message.id || `message-${index}`,
|
|
|
|
|
|
message,
|
|
|
|
|
|
sourceIndex: index
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (hasVisibleAssistantBody(message)) {
|
|
|
|
|
|
flushToolGroup()
|
|
|
|
|
|
items.push({
|
|
|
|
|
|
type: 'message',
|
|
|
|
|
|
key: message.id || `message-${index}`,
|
|
|
|
|
|
message,
|
|
|
|
|
|
sourceIndex: index
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const toolCalls = getMessageToolCalls(message)
|
|
|
|
|
|
if (toolCalls.length === 0) return
|
|
|
|
|
|
|
|
|
|
|
|
if (!pendingToolGroup) {
|
|
|
|
|
|
pendingToolGroup = {
|
|
|
|
|
|
type: 'tool-group',
|
|
|
|
|
|
key: `tool-group-${message.id || index}`,
|
|
|
|
|
|
toolCalls: []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
pendingToolGroup.toolCalls.push(...toolCalls)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
flushToolGroup()
|
|
|
|
|
|
return items
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isDisplayMessageProcessing = (conv, displayItem) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
displayItem?.type === 'message' &&
|
2026-04-19 23:44:46 +08:00
|
|
|
|
isReplyLoading.value &&
|
2026-04-13 18:06:25 +08:00
|
|
|
|
conv?.status === 'streaming' &&
|
|
|
|
|
|
displayItem.sourceIndex === conv.messages.length - 1
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isToolGroupActive = (conv, itemIndex, displayItems) => {
|
|
|
|
|
|
return (
|
2026-04-26 18:51:38 +08:00
|
|
|
|
isReplyLoading.value && conv?.status === 'streaming' && itemIndex === displayItems.length - 1
|
2026-04-13 18:06:25 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
const getLastMessage = (conv) => {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (!conv?.messages?.length) return null
|
2025-08-25 13:57:47 +08:00
|
|
|
|
for (let i = conv.messages.length - 1; i >= 0; i--) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (conv.messages[i].type === 'ai') return conv.messages[i]
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return null
|
|
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
const showMsgRefs = (msg) => {
|
2025-11-01 21:34:16 +08:00
|
|
|
|
// 如果正在审批中,不显示 refs
|
|
|
|
|
|
if (approvalState.showModal) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return false
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前线程ID与审批线程ID匹配,但审批框已关闭(说明刚刚处理完审批)
|
|
|
|
|
|
// 且当前有新的流式处理正在进行,则不显示之前被中断的消息的 refs
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (
|
|
|
|
|
|
approvalState.threadId &&
|
|
|
|
|
|
chatState.currentThreadId === approvalState.threadId &&
|
|
|
|
|
|
!approvalState.showModal &&
|
|
|
|
|
|
isProcessing
|
|
|
|
|
|
) {
|
|
|
|
|
|
return false
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 只有真正完成的消息才显示 refs
|
|
|
|
|
|
if (msg.isLast && msg.status === 'finished') {
|
2026-03-02 21:01:37 +08:00
|
|
|
|
return ['copy', 'sources']
|
2025-11-01 21:34:16 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return false
|
|
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2026-02-24 14:22:11 +08:00
|
|
|
|
const getConversationSources = (conv) => {
|
|
|
|
|
|
return MessageProcessor.extractSourcesFromConversation(conv, availableKnowledgeBases.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 13:57:47 +08:00
|
|
|
|
// ==================== LIFECYCLE & WATCHERS ====================
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const loadChatsList = async () => {
|
2026-03-16 21:39:49 +08:00
|
|
|
|
const agentId = props.singleMode ? currentAgentId.value : null
|
|
|
|
|
|
if (props.singleMode && !agentId) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
console.warn('No agent selected, cannot load chats list')
|
|
|
|
|
|
threads.value = []
|
2026-05-22 00:59:05 +08:00
|
|
|
|
resetAgentPanelState()
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(null)
|
2026-03-04 08:53:50 +08:00
|
|
|
|
threadFilesMap.value = {}
|
|
|
|
|
|
threadAttachmentsMap.value = {}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
2025-04-02 22:20:56 +08:00
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
try {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await fetchThreads(agentId)
|
2026-03-16 21:39:49 +08:00
|
|
|
|
if (props.singleMode && currentAgentId.value !== agentId) return
|
2025-08-31 14:39:28 +08:00
|
|
|
|
|
|
|
|
|
|
// 如果当前线程不在线程列表中,清空当前线程
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (
|
|
|
|
|
|
chatState.currentThreadId &&
|
|
|
|
|
|
!threads.value.find((t) => t.id === chatState.currentThreadId)
|
|
|
|
|
|
) {
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(null)
|
2025-08-31 14:39:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 02:32:35 +08:00
|
|
|
|
// singleMode 保持旧行为:自动选择首个可用对话
|
|
|
|
|
|
if (props.singleMode && threads.value.length > 0 && !chatState.currentThreadId) {
|
2026-03-08 22:33:24 +08:00
|
|
|
|
await selectChat(getFirstNonPinnedChat(threads.value).id)
|
2025-08-25 01:46:31 +08:00
|
|
|
|
}
|
2025-05-15 22:34:32 +08:00
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
handleChatError(error, 'load')
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-11-14 12:50:32 +08:00
|
|
|
|
|
2025-08-31 14:39:28 +08:00
|
|
|
|
const initAll = async () => {
|
2025-03-31 22:32:19 +08:00
|
|
|
|
try {
|
2025-08-31 14:39:28 +08:00
|
|
|
|
if (!agentStore.isInitialized) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
await agentStore.initialize()
|
2025-05-15 22:34:32 +08:00
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
} catch (error) {
|
2026-01-15 06:01:34 +08:00
|
|
|
|
handleChatError(error, 'load')
|
2025-04-02 13:00:25 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
}
|
2025-04-02 13:00:25 +08:00
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
onMounted(async () => {
|
2026-05-21 23:06:33 +08:00
|
|
|
|
await initAll()
|
2026-01-15 06:01:34 +08:00
|
|
|
|
scrollController.enableAutoScroll()
|
|
|
|
|
|
})
|
2025-08-31 12:22:49 +08:00
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
watch(showStateEntry, (visible) => {
|
|
|
|
|
|
if (!visible && sideActive.value === 'state') {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
sideActive.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
shouldRefreshStateWhileStreaming,
|
|
|
|
|
|
(shouldRefresh) => {
|
|
|
|
|
|
if (shouldRefresh) {
|
|
|
|
|
|
void handleAgentStateRefresh()
|
|
|
|
|
|
startStreamingStateRefresh()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
stopStreamingStateRefresh()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
currentAgentId,
|
|
|
|
|
|
async (newAgentId, oldAgentId) => {
|
2026-03-16 21:39:49 +08:00
|
|
|
|
if (!props.singleMode) {
|
|
|
|
|
|
if (oldAgentId === undefined) {
|
|
|
|
|
|
await loadChatsList()
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
if (newAgentId !== oldAgentId) {
|
|
|
|
|
|
// 清理当前线程状态
|
2026-04-24 22:42:51 +08:00
|
|
|
|
setCurrentThreadId(null)
|
2026-01-15 06:01:34 +08:00
|
|
|
|
threadMessages.value = {}
|
2026-03-04 08:53:50 +08:00
|
|
|
|
threadFilesMap.value = {}
|
|
|
|
|
|
threadAttachmentsMap.value = {}
|
2026-05-22 00:59:05 +08:00
|
|
|
|
resetAgentPanelState()
|
2026-01-15 06:01:34 +08:00
|
|
|
|
// 清理所有线程状态
|
|
|
|
|
|
resetOnGoingConv()
|
|
|
|
|
|
|
|
|
|
|
|
if (newAgentId) {
|
|
|
|
|
|
await loadChatsList()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
threads.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
currentThreadMessages,
|
|
|
|
|
|
() => {
|
|
|
|
|
|
if (currentThreadHasHistory.value) {
|
|
|
|
|
|
flushPendingThreadConfigNotice(currentChatId.value)
|
|
|
|
|
|
syncThreadConfigSnapshot(currentChatId.value, { overwrite: false })
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ deep: false }
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
watch(currentAgentId, (newAgentId, oldAgentId) => {
|
|
|
|
|
|
if (oldAgentId === undefined || newAgentId === oldAgentId) return
|
|
|
|
|
|
maybeInsertThreadConfigNotice()
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => JSON.stringify(agentConfig.value || {}),
|
|
|
|
|
|
(newConfigJson, oldConfigJson) => {
|
|
|
|
|
|
if (oldConfigJson === undefined || newConfigJson === oldConfigJson) return
|
|
|
|
|
|
maybeInsertThreadConfigNotice()
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
conversations,
|
|
|
|
|
|
() => {
|
|
|
|
|
|
if (isProcessing.value) {
|
|
|
|
|
|
scrollController.scrollToBottom()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ deep: true, flush: 'post' }
|
|
|
|
|
|
)
|
2026-03-24 02:32:35 +08:00
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
configNoticeScrollVersion,
|
|
|
|
|
|
() => {
|
|
|
|
|
|
if (!currentChatId.value) return
|
|
|
|
|
|
scrollController.scrollToBottom(true)
|
|
|
|
|
|
},
|
|
|
|
|
|
{ flush: 'post' }
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-03-24 02:32:35 +08:00
|
|
|
|
watch(currentChatId, (threadId, oldThreadId) => {
|
|
|
|
|
|
if (threadId === oldThreadId) return
|
|
|
|
|
|
emit('thread-change', threadId || '')
|
|
|
|
|
|
})
|
2025-03-31 22:32:19 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
2025-06-30 22:29:23 +08:00
|
|
|
|
@import '@/assets/css/main.css';
|
2025-12-19 04:04:48 +08:00
|
|
|
|
@import '@/assets/css/animations.less';
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
|
|
|
|
|
.chat-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
position: relative;
|
2025-05-15 22:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-31 22:32:19 +08:00
|
|
|
|
.chat {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
overflow: hidden; /* Changed from overflow-x: hidden to overflow: hidden */
|
2025-03-31 22:32:19 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
box-sizing: border-box;
|
2025-05-15 22:34:32 +08:00
|
|
|
|
transition: all 0.3s ease;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
|
|
|
|
|
.chat-header {
|
|
|
|
|
|
user-select: none;
|
|
|
|
|
|
z-index: 10;
|
|
|
|
|
|
height: var(--header-height);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
2025-08-08 22:57:14 +08:00
|
|
|
|
padding: 1rem 8px;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
flex-shrink: 0; /* Prevent header from shrinking */
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
2026-01-15 06:01:34 +08:00
|
|
|
|
.header__left,
|
|
|
|
|
|
.header__right {
|
2025-03-31 22:32:19 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-03-17 00:58:56 +08:00
|
|
|
|
gap: 8px;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
2025-11-23 19:42:51 +08:00
|
|
|
|
|
|
|
|
|
|
.switch-icon {
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-nav-btn:hover .switch-icon {
|
|
|
|
|
|
color: var(--main-500);
|
|
|
|
|
|
}
|
2026-03-17 00:58:56 +08:00
|
|
|
|
|
2026-03-23 09:43:04 +08:00
|
|
|
|
.conversation-title {
|
2026-03-26 03:24:24 +08:00
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 400;
|
2026-03-23 09:43:04 +08:00
|
|
|
|
color: var(--text-primary);
|
|
|
|
|
|
max-width: 200px;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
.chat-content-container {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 100%;
|
2026-02-02 21:44:10 +08:00
|
|
|
|
contain: layout;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chat-main {
|
2026-02-02 21:44:10 +08:00
|
|
|
|
flex: 1 1 0;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
overflow-y: auto; /* Scroll is here now */
|
|
|
|
|
|
position: relative;
|
2026-02-02 21:44:10 +08:00
|
|
|
|
transition:
|
|
|
|
|
|
flex-basis 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
|
|
|
|
width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
2026-01-31 14:16:53 +08:00
|
|
|
|
min-width: 0; /* Prevent flex item from overflowing */
|
2026-02-03 02:28:51 +08:00
|
|
|
|
|
|
|
|
|
|
scrollbar-width: none;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel {
|
2026-01-31 17:04:30 +08:00
|
|
|
|
flex: 0 0 auto;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
background: var(--gray-0);
|
2026-02-25 12:10:50 +08:00
|
|
|
|
border: 1px solid var(--gray-150);
|
2026-05-29 22:19:58 +08:00
|
|
|
|
border-radius: 16px;
|
|
|
|
|
|
box-shadow:
|
2026-05-31 13:36:42 +08:00
|
|
|
|
0 16px 40px var(--shadow-1),
|
|
|
|
|
|
0 2px 10px var(--shadow-0);
|
2026-05-29 22:19:58 +08:00
|
|
|
|
z-index: 20;
|
|
|
|
|
|
margin: 0 8px 8px;
|
|
|
|
|
|
margin-left: -16px;
|
2026-01-31 17:04:30 +08:00
|
|
|
|
min-width: 0;
|
2026-02-02 21:44:10 +08:00
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transform: translateX(10px);
|
2026-05-29 22:19:58 +08:00
|
|
|
|
will-change: flex-basis;
|
|
|
|
|
|
transition:
|
|
|
|
|
|
flex-basis 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
|
|
|
|
opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
|
|
|
|
transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
|
|
|
|
margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
2026-01-25 23:00:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel.is-visible {
|
2026-02-02 21:44:10 +08:00
|
|
|
|
opacity: 1;
|
|
|
|
|
|
transform: translateX(0);
|
|
|
|
|
|
margin-left: 0;
|
2026-01-25 23:00:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel.no-transition {
|
2026-02-02 21:44:10 +08:00
|
|
|
|
transition: none !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel--file {
|
|
|
|
|
|
align-self: stretch;
|
|
|
|
|
|
height: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.side-panel--file.is-visible {
|
|
|
|
|
|
min-width: 320px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.side-panel--state {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
align-self: flex-start;
|
2026-06-01 22:29:18 +08:00
|
|
|
|
height: auto;
|
|
|
|
|
|
max-height: calc(100% - 8px);
|
|
|
|
|
|
max-width: min(340px, calc(100vw - 24px));
|
2026-05-29 22:19:58 +08:00
|
|
|
|
box-shadow: 0 4px 16px var(--shadow-0);
|
2026-06-01 22:29:18 +08:00
|
|
|
|
overflow: auto;
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.side-panel--state.is-visible {
|
|
|
|
|
|
min-width: 300px;
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-panel {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 00:47:08 +08:00
|
|
|
|
.chat-greeting-input {
|
2026-03-24 22:48:32 +08:00
|
|
|
|
padding: 24px 0;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
h1 {
|
2026-03-24 22:48:32 +08:00
|
|
|
|
font-size: 1.4rem;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
color: var(--gray-1000);
|
2026-02-02 21:44:10 +08:00
|
|
|
|
margin: 0;
|
2025-09-09 20:25:48 +08:00
|
|
|
|
}
|
2025-12-19 04:04:48 +08:00
|
|
|
|
}
|
2025-09-09 20:25:48 +08:00
|
|
|
|
|
2026-03-16 21:39:49 +08:00
|
|
|
|
.agent-segment-wrapper {
|
|
|
|
|
|
width: fit-content;
|
|
|
|
|
|
max-width: 100%;
|
2026-03-24 22:48:32 +08:00
|
|
|
|
margin: 0 auto 18px;
|
2026-03-16 21:39:49 +08:00
|
|
|
|
overflow-x: auto;
|
|
|
|
|
|
scrollbar-width: none;
|
|
|
|
|
|
|
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.ant-segmented) {
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
background: var(--gray-50);
|
|
|
|
|
|
border: 1px solid var(--gray-150);
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.ant-segmented-group) {
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.ant-segmented-item) {
|
|
|
|
|
|
flex: 0 0 auto;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.ant-segmented-item-label) {
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-18 13:32:27 +08:00
|
|
|
|
.agent-switcher-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
margin: 0 auto 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-switcher-btn {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
|
border: 1px solid var(--gray-150);
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition:
|
|
|
|
|
|
background-color 0.2s ease,
|
|
|
|
|
|
border-color 0.2s ease,
|
|
|
|
|
|
color 0.2s ease;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
border-color: var(--gray-200);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-switcher-icon,
|
|
|
|
|
|
.agent-switcher-chevron {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
color: var(--gray-600);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-switcher-text {
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-switcher-menu) {
|
|
|
|
|
|
min-width: 220px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-switcher-menu-item) {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-switcher-menu-icon) {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
color: var(--gray-600);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-switcher-menu-text) {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-switcher-menu-badge) {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
padding: 1px 8px;
|
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
|
background: var(--main-30);
|
|
|
|
|
|
color: var(--main-700);
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
.chat-loading {
|
|
|
|
|
|
padding: 0 50px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 20%;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
z-index: 9;
|
|
|
|
|
|
animation: slideInUp 0.5s ease-out;
|
2025-11-05 09:20:58 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
gap: 12px;
|
2025-05-15 22:34:32 +08:00
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
|
color: var(--gray-700);
|
2025-11-05 09:20:58 +08:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-spinner {
|
|
|
|
|
|
width: 20px;
|
|
|
|
|
|
height: 20px;
|
|
|
|
|
|
border: 2px solid var(--gray-200);
|
|
|
|
|
|
border-top-color: var(--main-color);
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
animation: spin 0.8s linear infinite;
|
2025-05-15 22:34:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-31 22:32:19 +08:00
|
|
|
|
.chat-box {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
flex-grow: 1;
|
2026-05-31 13:36:42 +08:00
|
|
|
|
padding: 1rem var(--page-padding);
|
2025-03-31 22:32:19 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
.conv-box {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-19 18:13:18 +08:00
|
|
|
|
.chat-inline-notice {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
padding: 6px 16px 12px;
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-31 22:32:19 +08:00
|
|
|
|
.bottom {
|
|
|
|
|
|
position: sticky;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 0 auto;
|
2026-01-24 15:24:25 +08:00
|
|
|
|
padding: 4px 1rem 0 1rem;
|
2025-10-12 23:45:17 +08:00
|
|
|
|
z-index: 1000;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
|
|
|
|
|
|
.message-input-wrapper {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
.bottom-actions {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
2026-03-29 10:55:00 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
background: var(--gray-0);
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.note {
|
|
|
|
|
|
font-size: small;
|
2025-11-23 01:39:44 +08:00
|
|
|
|
color: var(--gray-300);
|
2025-03-31 22:32:19 +08:00
|
|
|
|
margin: 4px 0;
|
|
|
|
|
|
user-select: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-19 04:04:48 +08:00
|
|
|
|
|
|
|
|
|
|
&.start-screen {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 45%;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
|
bottom: auto;
|
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
|
width: 90%;
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
border-top: none;
|
|
|
|
|
|
z-index: 100; /* Ensure it's above other elements */
|
|
|
|
|
|
}
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-dots {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
gap: 3px;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-dots div {
|
2025-08-09 23:18:19 +08:00
|
|
|
|
width: 6px;
|
|
|
|
|
|
height: 6px;
|
|
|
|
|
|
background: linear-gradient(135deg, var(--main-color), var(--main-700));
|
2025-03-31 22:32:19 +08:00
|
|
|
|
border-radius: 50%;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
animation: dotPulse 1.4s infinite ease-in-out both;
|
2025-03-31 22:32:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-dots div:nth-child(1) {
|
|
|
|
|
|
animation-delay: -0.32s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-dots div:nth-child(2) {
|
|
|
|
|
|
animation-delay: -0.16s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-09 23:18:19 +08:00
|
|
|
|
.loading-dots div:nth-child(3) {
|
|
|
|
|
|
animation-delay: 0s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-24 00:15:51 +08:00
|
|
|
|
.generating-status {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-start;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
padding: 1rem 0;
|
|
|
|
|
|
animation: fadeInUp 0.4s ease-out;
|
|
|
|
|
|
transition: all 0.2s;
|
2025-06-24 00:15:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.generating-indicator {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
padding: 0.75rem 0rem;
|
2025-06-24 00:15:51 +08:00
|
|
|
|
|
|
|
|
|
|
.generating-text {
|
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
|
font-size: 14px;
|
2025-08-09 23:18:19 +08:00
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
letter-spacing: 0.025em;
|
2025-12-30 19:40:09 +08:00
|
|
|
|
/* 恢复灰色调:深灰 -> 亮灰(高光) -> 深灰 */
|
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
|
90deg,
|
|
|
|
|
|
var(--gray-700) 0%,
|
|
|
|
|
|
var(--gray-700) 40%,
|
|
|
|
|
|
var(--gray-300) 45%,
|
|
|
|
|
|
var(--gray-200) 50%,
|
|
|
|
|
|
var(--gray-300) 55%,
|
|
|
|
|
|
var(--gray-700) 60%,
|
|
|
|
|
|
var(--gray-700) 100%
|
|
|
|
|
|
);
|
|
|
|
|
|
background-size: 200% auto;
|
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
|
background-clip: text;
|
|
|
|
|
|
color: transparent;
|
|
|
|
|
|
animation: waveFlash 2s linear infinite;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes waveFlash {
|
|
|
|
|
|
0% {
|
|
|
|
|
|
background-position: 200% center;
|
|
|
|
|
|
}
|
|
|
|
|
|
100% {
|
|
|
|
|
|
background-position: -200% center;
|
2025-06-24 00:15:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-22 00:59:05 +08:00
|
|
|
|
@media (max-width: 1024px) {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.chat-content-container.has-file-panel .chat-main,
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.chat-content-container.has-state-panel .chat-main {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
min-width: 350px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel--file.is-visible,
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.side-panel--state.is-visible {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
max-width: calc(100% - 350px);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
@media (max-width: 768px) {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.chat-content-container.has-file-panel .chat-main,
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.chat-content-container.has-state-panel .chat-main {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
min-width: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel--file.is-visible {
|
2026-05-22 00:59:05 +08:00
|
|
|
|
min-width: 280px;
|
|
|
|
|
|
max-width: 80%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.side-panel--state.is-visible {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
min-width: 260px;
|
|
|
|
|
|
max-width: 80%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-16 21:39:49 +08:00
|
|
|
|
.agent-segment-wrapper {
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.ant-segmented-item-label) {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-18 13:32:27 +08:00
|
|
|
|
.agent-switcher-wrapper {
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-switcher-btn {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:34:32 +08:00
|
|
|
|
.chat-header {
|
|
|
|
|
|
.header__left {
|
|
|
|
|
|
.text {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-24 22:48:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 智能体选择器的图标对齐
|
|
|
|
|
|
.agent-segment-wrapper {
|
|
|
|
|
|
:deep(.ant-segmented-item-label) {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-option-label) {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.agent-option-icon) {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
color: var(--gray-600);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-25 13:57:47 +08:00
|
|
|
|
</style>
|
2025-10-13 11:12:25 +08:00
|
|
|
|
|
|
|
|
|
|
<style lang="less">
|
2025-11-08 17:14:54 +08:00
|
|
|
|
.agent-nav-btn {
|
2025-10-13 11:12:25 +08:00
|
|
|
|
display: flex;
|
2026-01-22 12:15:46 +08:00
|
|
|
|
gap: 6px;
|
2026-01-15 04:54:53 +08:00
|
|
|
|
padding: 6px 8px;
|
|
|
|
|
|
height: 32px;
|
2025-10-13 11:12:25 +08:00
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
2026-01-22 11:16:15 +08:00
|
|
|
|
border-radius: 6px;
|
2025-10-13 11:12:25 +08:00
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
transition: background-color 0.3s;
|
2025-11-08 17:14:54 +08:00
|
|
|
|
border: none;
|
|
|
|
|
|
background: transparent;
|
2025-10-13 11:12:25 +08:00
|
|
|
|
|
2025-11-08 17:14:54 +08:00
|
|
|
|
&:hover:not(.is-disabled) {
|
2026-01-15 04:54:53 +08:00
|
|
|
|
background-color: var(--gray-100);
|
2025-10-13 11:12:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-08 17:14:54 +08:00
|
|
|
|
&.is-disabled {
|
2025-11-08 13:59:56 +08:00
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
opacity: 0.7;
|
2025-11-08 17:14:54 +08:00
|
|
|
|
pointer-events: none;
|
2025-11-08 13:59:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-13 11:12:25 +08:00
|
|
|
|
.nav-btn-icon {
|
2026-01-15 04:54:53 +08:00
|
|
|
|
height: 18px;
|
2025-10-13 11:12:25 +08:00
|
|
|
|
}
|
2025-11-08 13:59:56 +08:00
|
|
|
|
|
|
|
|
|
|
.loading-icon {
|
|
|
|
|
|
animation: spin 1s linear infinite;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-29 22:19:58 +08:00
|
|
|
|
.side-panel__header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
min-height: 44px;
|
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
|
background: var(--gray-25);
|
|
|
|
|
|
border-bottom: 1px solid var(--gray-100);
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-entry-btn.active {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
color: var(--main-700);
|
|
|
|
|
|
background-color: var(--main-20);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-panel-header {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
padding: 10px 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-panel-title {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
min-width: 0;
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-panel-summary,
|
|
|
|
|
|
.state-section-meta {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-panel-body {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-height: 0;
|
|
|
|
|
|
padding: 12px 14px 14px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-06-01 22:29:18 +08:00
|
|
|
|
gap: 12px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-section {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-section-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-section-title {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--gray-800);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-section-empty {
|
|
|
|
|
|
padding: 10px 12px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
background: var(--gray-25);
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
font-size: 13px;
|
2026-05-29 22:19:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-panel-list {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
min-height: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
padding: 9px 0;
|
|
|
|
|
|
border-bottom: 1px solid var(--gray-100);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-item:last-child {
|
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-item-icon {
|
|
|
|
|
|
width: 22px;
|
|
|
|
|
|
height: 22px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
background: var(--gray-50);
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
|
|
|
|
|
|
&.completed {
|
|
|
|
|
|
background: var(--color-success-10);
|
|
|
|
|
|
color: var(--color-success-700);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.in_progress {
|
|
|
|
|
|
background: var(--color-info-10);
|
|
|
|
|
|
color: var(--color-info-700);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.pending {
|
|
|
|
|
|
background: var(--color-warning-10);
|
|
|
|
|
|
color: var(--color-warning-700);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.cancelled {
|
|
|
|
|
|
background: var(--color-error-10);
|
|
|
|
|
|
color: var(--color-error-700);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-item-body {
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.todo-item-text {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
color: var(--gray-800);
|
|
|
|
|
|
word-break: break-word;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 22:29:18 +08:00
|
|
|
|
.state-list {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
padding: 9px 10px;
|
|
|
|
|
|
border: 1px solid var(--gray-100);
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
background: var(--gray-25);
|
|
|
|
|
|
color: inherit;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item--button {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item--button:hover {
|
|
|
|
|
|
border-color: var(--main-200);
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item-icon {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
font-size: 17px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item-body {
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item-title {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-list-item-meta {
|
|
|
|
|
|
margin-top: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 1.3;
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-subagent-icon {
|
|
|
|
|
|
width: 28px;
|
|
|
|
|
|
height: 28px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
border: 1px solid var(--gray-150);
|
|
|
|
|
|
border-radius: 7px;
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-subagent-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-subagent-title span {
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.state-subagent-completed-icon {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
color: var(--color-success-700);
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-24 15:24:25 +08:00
|
|
|
|
.hide-text {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (min-width: 769px) {
|
|
|
|
|
|
.hide-text {
|
|
|
|
|
|
display: inline;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 12:50:32 +08:00
|
|
|
|
/* AgentState 按钮有内容时的样式 */
|
2025-12-17 23:39:53 +08:00
|
|
|
|
.agent-nav-btn.agent-state-btn.has-content:hover:not(.is-disabled) {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
background-color: var(--gray-100);
|
2025-11-14 12:50:32 +08:00
|
|
|
|
}
|
2026-01-24 15:24:25 +08:00
|
|
|
|
|
|
|
|
|
|
.agent-nav-btn.agent-state-btn.active {
|
2026-05-29 22:19:58 +08:00
|
|
|
|
color: var(--gray-900);
|
|
|
|
|
|
background-color: var(--gray-100);
|
2026-01-24 15:24:25 +08:00
|
|
|
|
}
|
2026-01-15 06:01:34 +08:00
|
|
|
|
</style>
|