|
|
@@ -47,8 +47,21 @@
|
|
|
{{ sidebarCollapsed ? '显示任务列表' : '隐藏任务列表' }}
|
|
|
</a-button>
|
|
|
</div>
|
|
|
- <div v-if="messages.length" class="chat-context-bar">
|
|
|
+ <div v-if="currentSessionId" class="chat-context-bar">
|
|
|
<span class="chat-context-bar__title" :title="currentSessionTitle">{{ currentSessionTitle }}</span>
|
|
|
+ <button
|
|
|
+ v-if="artifactSupported"
|
|
|
+ type="button"
|
|
|
+ class="chat-context-bar__artifact-toggle"
|
|
|
+ :class="{ 'is-active': artifactPanelOpen }"
|
|
|
+ :aria-expanded="artifactPanelOpen"
|
|
|
+ aria-label="产物"
|
|
|
+ title="产物"
|
|
|
+ @click="toggleArtifactPanel()"
|
|
|
+ >
|
|
|
+ <Icon icon="i-mdi:folder-open-outline" />
|
|
|
+ <span v-if="artifacts.length" class="chat-context-bar__artifact-count">{{ artifacts.length }}</span>
|
|
|
+ </button>
|
|
|
</div>
|
|
|
<div ref="messageContainerRef" class="message-area" :class="{ 'message-area--empty': !messages.length }">
|
|
|
<template v-for="msg in messages" :key="String(msg.id)">
|
|
|
@@ -580,6 +593,140 @@
|
|
|
</div>
|
|
|
</section>
|
|
|
|
|
|
+ <!-- 右侧产物面板:直接扫描本会话工作区磁盘,按会话隔离 -->
|
|
|
+ <aside v-if="currentSessionId && artifactSupported && artifactPanelOpen" class="chat-artifact-panel">
|
|
|
+ <div class="chat-artifact-panel__header">
|
|
|
+ <div class="chat-artifact-panel__heading">
|
|
|
+ <span class="chat-artifact-panel__title">产物</span>
|
|
|
+ <span class="chat-artifact-panel__count">{{ artifacts.length }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="chat-artifact-panel__actions">
|
|
|
+ <a-tooltip title="刷新">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="chat-artifact-panel__icon-btn"
|
|
|
+ aria-label="刷新产物"
|
|
|
+ :disabled="artifactLoading"
|
|
|
+ @click="loadArtifacts()"
|
|
|
+ >
|
|
|
+ <Icon icon="i-mdi:refresh" :class="{ 'is-spinning': artifactLoading }" />
|
|
|
+ </button>
|
|
|
+ </a-tooltip>
|
|
|
+ <a-tooltip title="收起">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="chat-artifact-panel__icon-btn"
|
|
|
+ aria-label="收起产物"
|
|
|
+ @click="toggleArtifactPanel(false)"
|
|
|
+ >
|
|
|
+ <Icon icon="i-mdi:chevron-right" />
|
|
|
+ </button>
|
|
|
+ </a-tooltip>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="chat-artifact-panel__body">
|
|
|
+ <a-spin :spinning="artifactLoading">
|
|
|
+ <div v-if="artifactError" class="chat-artifact-panel__error">
|
|
|
+ <span>{{ artifactError }}</span>
|
|
|
+ <a-button type="link" size="small" @click="loadArtifacts()">重试</a-button>
|
|
|
+ </div>
|
|
|
+ <a-empty v-else-if="!artifacts.length" description="本会话暂无产物" />
|
|
|
+ <template v-else>
|
|
|
+ <div v-for="item in artifacts" :key="item.path" class="chat-artifact-item">
|
|
|
+ <span class="chat-artifact-item__icon"><Icon :icon="artifactIcon(item)" /></span>
|
|
|
+ <div class="chat-artifact-item__main">
|
|
|
+ <div class="chat-artifact-item__name" :title="item.path">{{ item.name }}</div>
|
|
|
+ <div class="chat-artifact-item__meta">
|
|
|
+ <span>{{ formatArtifactSize(item.size) }}</span>
|
|
|
+ <span>{{ formatArtifactTime(item.lastModified) }}</span>
|
|
|
+ </div>
|
|
|
+ <div v-if="item.path !== item.name" class="chat-artifact-item__path">{{ item.path }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="chat-artifact-item__actions">
|
|
|
+ <a-tooltip v-if="item.previewable" title="预览">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="chat-artifact-item__action"
|
|
|
+ :aria-label="`预览 ${item.name}`"
|
|
|
+ @click="previewArtifact(item)"
|
|
|
+ >
|
|
|
+ <Icon icon="i-mdi:eye-outline" />
|
|
|
+ </button>
|
|
|
+ </a-tooltip>
|
|
|
+ <a-tooltip title="下载">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="chat-artifact-item__action"
|
|
|
+ :aria-label="`下载 ${item.name}`"
|
|
|
+ @click="handleDownloadArtifact(item)"
|
|
|
+ >
|
|
|
+ <Icon icon="i-mdi:download-outline" />
|
|
|
+ </button>
|
|
|
+ </a-tooltip>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="artifactTruncated" class="chat-artifact-panel__truncated">
|
|
|
+ 文件较多,仅显示最近 {{ artifacts.length }} 个
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </a-spin>
|
|
|
+ </div>
|
|
|
+ </aside>
|
|
|
+
|
|
|
+ <!-- 产物预览:文本 / Markdown / CSV / 图片 / PDF / HTML(同源 iframe) -->
|
|
|
+ <BasicModal
|
|
|
+ v-model:open="artifactPreview.visible"
|
|
|
+ :title="artifactPreview.item?.name || '产物预览'"
|
|
|
+ :footer="null"
|
|
|
+ :width="920"
|
|
|
+ :min-height="320"
|
|
|
+ :can-fullscreen="true"
|
|
|
+ :destroy-on-close="true"
|
|
|
+ wrap-class-name="artifact-preview-modal"
|
|
|
+ @cancel="closeArtifactPreview"
|
|
|
+ >
|
|
|
+ <div class="artifact-preview">
|
|
|
+ <a-spin v-if="artifactPreview.loading" class="artifact-preview__loading" />
|
|
|
+ <div v-else-if="artifactPreview.error" class="artifact-preview__error">{{ artifactPreview.error }}</div>
|
|
|
+ <template v-else-if="artifactPreview.item">
|
|
|
+ <iframe
|
|
|
+ v-if="artifactPreview.item.kind === 'html'"
|
|
|
+ class="artifact-preview__html"
|
|
|
+ :srcdoc="artifactPreview.content"
|
|
|
+ ></iframe>
|
|
|
+ <img
|
|
|
+ v-else-if="artifactPreview.item.kind === 'image'"
|
|
|
+ class="artifact-preview__image"
|
|
|
+ :src="artifactPreview.objectUrl"
|
|
|
+ :alt="artifactPreview.item.name"
|
|
|
+ @error="handleArtifactImageError"
|
|
|
+ />
|
|
|
+ <iframe
|
|
|
+ v-else-if="artifactPreview.item.kind === 'pdf'"
|
|
|
+ class="artifact-preview__pdf"
|
|
|
+ :src="artifactPreview.objectUrl"
|
|
|
+ ></iframe>
|
|
|
+ <div v-else-if="artifactPreview.item.kind === 'csv'" class="artifact-preview__table-wrap">
|
|
|
+ <table v-if="artifactPreview.csvRows.length" class="artifact-preview__table">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th v-for="(cell, index) in artifactPreview.csvHeader" :key="index">{{ cell }}</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr v-for="(row, rowIndex) in artifactPreview.csvRows" :key="rowIndex">
|
|
|
+ <td v-for="(cell, cellIndex) in row" :key="cellIndex">{{ cell }}</td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <pre v-else class="artifact-preview__text">{{ artifactPreview.content }}</pre>
|
|
|
+ </div>
|
|
|
+ <pre v-else class="artifact-preview__text">{{ artifactPreview.content }}</pre>
|
|
|
+ <div v-if="artifactPreview.truncated" class="artifact-preview__hint"> 内容较大,仅预览前一部分。 </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </BasicModal>
|
|
|
+
|
|
|
<!-- 原图预览:点击附件时先换一个新签地址再打开,避免预签名 URL 过期后 403 -->
|
|
|
<a-modal
|
|
|
v-if="previewVisible"
|
|
|
@@ -724,8 +871,17 @@
|
|
|
import { getDocumentChunkContext, getDocumentContent } from '@/workbench/api/kb';
|
|
|
import { getOnboardingChecklist } from '@/workbench/api/audit';
|
|
|
import { aiUpload } from '@/workbench/api/http';
|
|
|
+ import {
|
|
|
+ downloadArtifact,
|
|
|
+ fetchArtifactBlob,
|
|
|
+ getArtifactContent,
|
|
|
+ listArtifacts,
|
|
|
+ type ArtifactItem,
|
|
|
+ } from '@/workbench/api/artifact';
|
|
|
+ import { formatSize } from '@/core/components/Upload/src/helper';
|
|
|
import { scenarioPackMcpOptions, scenarioPackOptions } from '@/workbench/api/pack';
|
|
|
import { visibleSkillOptions } from '@/workbench/api/skill';
|
|
|
+ import { BasicModal } from '@/core/components/Modal';
|
|
|
import { useAccountStore } from '@/core/store/modules/account';
|
|
|
import { useUserStore } from '@/core/store/modules/case';
|
|
|
import { Icon } from '@/core/components/Icon';
|
|
|
@@ -1025,12 +1181,250 @@
|
|
|
/** 工作台内联样式(仅在实测到高度时生效) */
|
|
|
const workbenchStyle = computed(() => (workbenchHeight.value ? { height: workbenchHeight.value } : {}));
|
|
|
|
|
|
+ /** 当前会话(用于标题栏与产物面板判断) */
|
|
|
+ const currentSession = computed(() =>
|
|
|
+ sessions.value.find((item) => String(item.id) === String(currentSessionId.value)),
|
|
|
+ );
|
|
|
+
|
|
|
/** 当前会话标题(用于聊天区顶部上下文栏) */
|
|
|
- const currentSessionTitle = computed(() => {
|
|
|
- const current = sessions.value.find((item) => String(item.id) === String(currentSessionId.value));
|
|
|
- return current?.sessionTitle || '当前会话';
|
|
|
+ const currentSessionTitle = computed(() => currentSession.value?.sessionTitle || '当前会话');
|
|
|
+
|
|
|
+ /** 产物面板只支持智能工作台会话(source=workbench,按会话隔离工作区) */
|
|
|
+ const artifactSupported = computed(() => currentSession.value?.source === 'workbench');
|
|
|
+
|
|
|
+ // ==================== 产物面板(直接扫描会话工作区磁盘) ====================
|
|
|
+
|
|
|
+ /** 面板开关(持久化;默认收起) */
|
|
|
+ const artifactPanelOpen = ref(localStorage.getItem('chat.artifactPanelOpen') === '1');
|
|
|
+ const artifacts = ref<ArtifactItem[]>([]);
|
|
|
+ const artifactLoading = ref(false);
|
|
|
+ const artifactError = ref('');
|
|
|
+ const artifactTruncated = ref(false);
|
|
|
+ let artifactRefreshTimer: ReturnType<typeof setTimeout> | undefined;
|
|
|
+
|
|
|
+ /** 产物预览弹窗状态 */
|
|
|
+ const artifactPreview = reactive<{
|
|
|
+ visible: boolean;
|
|
|
+ loading: boolean;
|
|
|
+ error: string;
|
|
|
+ item: ArtifactItem | null;
|
|
|
+ content: string;
|
|
|
+ truncated: boolean;
|
|
|
+ objectUrl: string;
|
|
|
+ csvHeader: string[];
|
|
|
+ csvRows: string[][];
|
|
|
+ }>({
|
|
|
+ visible: false,
|
|
|
+ loading: false,
|
|
|
+ error: '',
|
|
|
+ item: null,
|
|
|
+ content: '',
|
|
|
+ truncated: false,
|
|
|
+ objectUrl: '',
|
|
|
+ csvHeader: [],
|
|
|
+ csvRows: [],
|
|
|
});
|
|
|
|
|
|
+ /** 展开 / 收起产物面板 */
|
|
|
+ const toggleArtifactPanel = (open?: boolean) => {
|
|
|
+ const next = typeof open === 'boolean' ? open : !artifactPanelOpen.value;
|
|
|
+ artifactPanelOpen.value = next;
|
|
|
+ localStorage.setItem('chat.artifactPanelOpen', next ? '1' : '0');
|
|
|
+ if (next && artifactSupported.value) {
|
|
|
+ void loadArtifacts();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 加载当前会话产物列表 */
|
|
|
+ const loadArtifacts = async () => {
|
|
|
+ const sessionId = currentSessionId.value;
|
|
|
+ if (!sessionId || !artifactSupported.value) {
|
|
|
+ artifacts.value = [];
|
|
|
+ artifactTruncated.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ artifactLoading.value = true;
|
|
|
+ artifactError.value = '';
|
|
|
+ try {
|
|
|
+ const res = await listArtifacts(sessionId);
|
|
|
+ if (String(currentSessionId.value) !== String(sessionId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ artifacts.value = res?.items ?? [];
|
|
|
+ artifactTruncated.value = !!res?.truncated;
|
|
|
+ } catch (error) {
|
|
|
+ if (String(currentSessionId.value) === String(sessionId)) {
|
|
|
+ artifactError.value = (error as Error)?.message || '产物加载失败';
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (String(currentSessionId.value) === String(sessionId)) {
|
|
|
+ artifactLoading.value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 工具完成后防抖刷新(write_file / edit_file / execute 等) */
|
|
|
+ const scheduleArtifactRefresh = () => {
|
|
|
+ if (!currentSessionId.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (artifactRefreshTimer) {
|
|
|
+ clearTimeout(artifactRefreshTimer);
|
|
|
+ }
|
|
|
+ artifactRefreshTimer = setTimeout(() => {
|
|
|
+ artifactRefreshTimer = undefined;
|
|
|
+ if (artifactPanelOpen.value) {
|
|
|
+ void loadArtifacts();
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 产物文件图标(全部使用已 safelist 的 mdi 图标) */
|
|
|
+ const artifactIcon = (item: ArtifactItem) => {
|
|
|
+ if (item.kind === 'image') {
|
|
|
+ return 'i-mdi:image-outline';
|
|
|
+ }
|
|
|
+ if (item.kind === 'pdf') {
|
|
|
+ return 'i-mdi:file-pdf-box';
|
|
|
+ }
|
|
|
+ if (item.kind === 'csv') {
|
|
|
+ return 'i-mdi:file-delimited-outline';
|
|
|
+ }
|
|
|
+ return 'i-mdi:file-document-outline';
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 文件大小展示 */
|
|
|
+ const formatArtifactSize = (size?: number) => {
|
|
|
+ if (size === undefined || size === null) {
|
|
|
+ return '-';
|
|
|
+ }
|
|
|
+ return size <= 0 ? '0B' : formatSize(size);
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 修改时间展示 */
|
|
|
+ const formatArtifactTime = (value?: string) => {
|
|
|
+ if (!value) {
|
|
|
+ return '-';
|
|
|
+ }
|
|
|
+ const date = new Date(value);
|
|
|
+ if (Number.isNaN(date.getTime())) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ const pad = (num: number) => String(num).padStart(2, '0');
|
|
|
+ return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 简单 CSV 解析(支持引号与逗号转义;仅用于预览) */
|
|
|
+ const parseArtifactCsv = (text: string): string[][] => {
|
|
|
+ const rows: string[][] = [];
|
|
|
+ let row: string[] = [];
|
|
|
+ let cell = '';
|
|
|
+ let quoted = false;
|
|
|
+ for (let i = 0; i < text.length; i += 1) {
|
|
|
+ const ch = text[i];
|
|
|
+ if (quoted) {
|
|
|
+ if (ch === '"' && text[i + 1] === '"') {
|
|
|
+ cell += '"';
|
|
|
+ i += 1;
|
|
|
+ } else if (ch === '"') {
|
|
|
+ quoted = false;
|
|
|
+ } else {
|
|
|
+ cell += ch;
|
|
|
+ }
|
|
|
+ } else if (ch === '"') {
|
|
|
+ quoted = true;
|
|
|
+ } else if (ch === ',') {
|
|
|
+ row.push(cell);
|
|
|
+ cell = '';
|
|
|
+ } else if (ch === '\n') {
|
|
|
+ row.push(cell.replace(/\r$/, ''));
|
|
|
+ rows.push(row);
|
|
|
+ row = [];
|
|
|
+ cell = '';
|
|
|
+ } else {
|
|
|
+ cell += ch;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cell || row.length) {
|
|
|
+ row.push(cell.replace(/\r$/, ''));
|
|
|
+ rows.push(row);
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 预览产物 */
|
|
|
+ const previewArtifact = async (item: ArtifactItem) => {
|
|
|
+ const sessionId = currentSessionId.value;
|
|
|
+ if (!sessionId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ closeArtifactPreview();
|
|
|
+ artifactPreview.visible = true;
|
|
|
+ artifactPreview.item = item;
|
|
|
+ artifactPreview.loading = true;
|
|
|
+ try {
|
|
|
+ if (item.kind === 'image' || item.kind === 'pdf') {
|
|
|
+ let blob = await fetchArtifactBlob(sessionId, item.path);
|
|
|
+ // 部分运行环境返回的 blob 不带 type:按列表元信息补上,图片/PDF 才能正确解码
|
|
|
+ if (!blob.type && item.mime) {
|
|
|
+ blob = new Blob([blob], { type: item.mime });
|
|
|
+ }
|
|
|
+ artifactPreview.objectUrl = URL.createObjectURL(blob);
|
|
|
+ } else {
|
|
|
+ const res = await getArtifactContent(sessionId, item.path);
|
|
|
+ artifactPreview.content = res?.text ?? '';
|
|
|
+ artifactPreview.truncated = !!res?.truncated;
|
|
|
+ if (item.kind === 'csv') {
|
|
|
+ const rows = parseArtifactCsv(artifactPreview.content);
|
|
|
+ artifactPreview.csvHeader = rows[0] ?? [];
|
|
|
+ artifactPreview.csvRows = rows.slice(1, 201);
|
|
|
+ if (rows.length > 201) {
|
|
|
+ artifactPreview.truncated = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ artifactPreview.error = (error as Error)?.message || '预览加载失败';
|
|
|
+ } finally {
|
|
|
+ artifactPreview.loading = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 图片解码失败:给出可读原因并保留下载入口(如 HEIC/损坏文件) */
|
|
|
+ const handleArtifactImageError = () => {
|
|
|
+ artifactPreview.error = '图片加载失败:文件可能已损坏或当前浏览器不支持该图片格式,请下载后查看。';
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 关闭预览并释放 blob URL */
|
|
|
+ const closeArtifactPreview = () => {
|
|
|
+ if (artifactPreview.objectUrl) {
|
|
|
+ URL.revokeObjectURL(artifactPreview.objectUrl);
|
|
|
+ artifactPreview.objectUrl = '';
|
|
|
+ }
|
|
|
+ artifactPreview.visible = false;
|
|
|
+ artifactPreview.loading = false;
|
|
|
+ artifactPreview.error = '';
|
|
|
+ artifactPreview.item = null;
|
|
|
+ artifactPreview.content = '';
|
|
|
+ artifactPreview.truncated = false;
|
|
|
+ artifactPreview.csvHeader = [];
|
|
|
+ artifactPreview.csvRows = [];
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 下载产物:桌面端走现有下载管理器,浏览器端走 blob 另存 */
|
|
|
+ const handleDownloadArtifact = async (item: ArtifactItem) => {
|
|
|
+ const sessionId = currentSessionId.value;
|
|
|
+ if (!sessionId) {
|
|
|
+ antMessage.warning('请先选择会话');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await downloadArtifact(sessionId, item);
|
|
|
+ } catch (error) {
|
|
|
+ antMessage.error((error as Error)?.message || '产物下载失败');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* 按父容器实测可用高度:视口高度 − 容器顶部偏移 − 父容器底部内边距。
|
|
|
*
|
|
|
@@ -1088,6 +1482,11 @@
|
|
|
onBeforeUnmount(() => {
|
|
|
workbenchTimers.forEach((timer) => window.clearTimeout(timer));
|
|
|
workbenchTimers = [];
|
|
|
+ if (artifactRefreshTimer) {
|
|
|
+ clearTimeout(artifactRefreshTimer);
|
|
|
+ artifactRefreshTimer = undefined;
|
|
|
+ }
|
|
|
+ closeArtifactPreview();
|
|
|
window.removeEventListener('resize', syncWorkbenchHeight);
|
|
|
workbenchResizeObserver?.disconnect();
|
|
|
workbenchResizeObserver = undefined;
|
|
|
@@ -1957,6 +2356,10 @@
|
|
|
currentSessionId.value = undefined;
|
|
|
messages.value = [];
|
|
|
expandedToolKeys.value = [];
|
|
|
+ artifacts.value = [];
|
|
|
+ artifactError.value = '';
|
|
|
+ artifactTruncated.value = false;
|
|
|
+ closeArtifactPreview();
|
|
|
inputText.value = '';
|
|
|
regenerateCheck.value = null;
|
|
|
regenerateCheckMessageId.value = undefined;
|
|
|
@@ -2075,6 +2478,14 @@
|
|
|
// 最后一轮的重新生成可用性由后端预检决定(写操作轮次置灰)
|
|
|
void refreshRegenerateCheck();
|
|
|
scrollToBottomSoon();
|
|
|
+ // 产物面板按会话隔离:切换会话时清空旧列表,面板打开则立即加载新会话产物
|
|
|
+ artifacts.value = [];
|
|
|
+ artifactError.value = '';
|
|
|
+ artifactTruncated.value = false;
|
|
|
+ closeArtifactPreview();
|
|
|
+ if (artifactPanelOpen.value && artifactSupported.value) {
|
|
|
+ void loadArtifacts();
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
/** 会话「更多操作」:置顶 / 重命名 / 结束任务 */
|
|
|
@@ -2347,6 +2758,8 @@
|
|
|
msg.status = '3';
|
|
|
}
|
|
|
finishStream();
|
|
|
+ // 中止时已落盘的部分产物也要展示
|
|
|
+ scheduleArtifactRefresh();
|
|
|
};
|
|
|
|
|
|
/** 处置待确认的工具调用:写入结果后建立恢复流继续生成 */
|
|
|
@@ -2466,6 +2879,10 @@
|
|
|
part.toolName = event.toolName;
|
|
|
}
|
|
|
}
|
|
|
+ if (event.state === 'SUCCESS') {
|
|
|
+ // write_file / edit_file / execute 等工具完成后刷新产物列表(防抖)
|
|
|
+ scheduleArtifactRefresh();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case 'tool_confirm': {
|
|
|
@@ -2561,6 +2978,8 @@
|
|
|
// done 载荷与 references 事件同结构:兜底回填(防 references 事件丢失)
|
|
|
mergeMessageSources(msg, event.references);
|
|
|
finishStream();
|
|
|
+ // 本轮产物兜底刷新(tool_result 事件可能被截断或丢失)
|
|
|
+ scheduleArtifactRefresh();
|
|
|
// 重新生成成功:旧回答快照已无意义,刷新预检(新一轮回答可能含写操作)
|
|
|
regenerateBackup = null;
|
|
|
void refreshRegenerateCheck();
|
|
|
@@ -2579,6 +2998,7 @@
|
|
|
msg.durationMs = event.durationMs ?? msg.durationMs;
|
|
|
msg.status = '3';
|
|
|
finishStream();
|
|
|
+ scheduleArtifactRefresh();
|
|
|
regenerateBackup = null;
|
|
|
void refreshRegenerateCheck();
|
|
|
break;
|
|
|
@@ -2596,6 +3016,7 @@
|
|
|
msg.errorMsg = event.message || '对话失败';
|
|
|
antMessage.error(msg.errorMsg);
|
|
|
finishStream();
|
|
|
+ scheduleArtifactRefresh();
|
|
|
regenerateBackup = null;
|
|
|
break;
|
|
|
}
|
|
|
@@ -2648,6 +3069,10 @@
|
|
|
);
|
|
|
}
|
|
|
await getSessions();
|
|
|
+ // 新会话创建完成后按需加载产物(面板打开时立即显示空态/已有文件)
|
|
|
+ if (artifactPanelOpen.value && artifactSupported.value) {
|
|
|
+ void loadArtifacts();
|
|
|
+ }
|
|
|
return session.id;
|
|
|
};
|
|
|
|
|
|
@@ -2907,6 +3332,10 @@
|
|
|
finishStream();
|
|
|
currentSessionId.value = undefined;
|
|
|
messages.value = [];
|
|
|
+ artifacts.value = [];
|
|
|
+ artifactError.value = '';
|
|
|
+ artifactTruncated.value = false;
|
|
|
+ closeArtifactPreview();
|
|
|
sessionResources.value = [];
|
|
|
pinnedExpert.value = undefined;
|
|
|
planModeEnabled.value = false;
|
|
|
@@ -4747,6 +5176,329 @@
|
|
|
margin-top: 6px;
|
|
|
}
|
|
|
|
|
|
+ /* ==================== 产物面板 ==================== */
|
|
|
+
|
|
|
+ .chat-context-bar__artifact-toggle {
|
|
|
+ position: relative;
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 28px;
|
|
|
+ height: 28px;
|
|
|
+ padding: 0;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 18px;
|
|
|
+ cursor: pointer;
|
|
|
+ background: transparent;
|
|
|
+ border: 0;
|
|
|
+ border-radius: 6px;
|
|
|
+ transition:
|
|
|
+ background-color 0.15s,
|
|
|
+ color 0.15s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-context-bar__artifact-toggle:hover,
|
|
|
+ .chat-context-bar__artifact-toggle.is-active {
|
|
|
+ color: #2448c9;
|
|
|
+ background: #e8eeff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-context-bar__artifact-count {
|
|
|
+ position: absolute;
|
|
|
+ top: -2px;
|
|
|
+ right: -4px;
|
|
|
+ min-width: 14px;
|
|
|
+ height: 14px;
|
|
|
+ padding: 0 4px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 9px;
|
|
|
+ line-height: 14px;
|
|
|
+ text-align: center;
|
|
|
+ background: #2448c9;
|
|
|
+ border-radius: 999px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel {
|
|
|
+ display: flex;
|
|
|
+ flex: 0 0 320px;
|
|
|
+ flex-direction: column;
|
|
|
+ min-width: 260px;
|
|
|
+ max-width: 380px;
|
|
|
+ overflow: hidden;
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ border-radius: 12px;
|
|
|
+ box-shadow: 0 2px 8px rgb(15 23 42 / 3%);
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 12px 14px;
|
|
|
+ border-bottom: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__heading {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__title {
|
|
|
+ color: var(--wb-text, #111827);
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 600;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__count {
|
|
|
+ min-width: 20px;
|
|
|
+ padding: 0 6px;
|
|
|
+ color: #2448c9;
|
|
|
+ font-size: 11px;
|
|
|
+ line-height: 18px;
|
|
|
+ text-align: center;
|
|
|
+ background: #e8eeff;
|
|
|
+ border-radius: 999px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 2px;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__icon-btn {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 26px;
|
|
|
+ height: 26px;
|
|
|
+ padding: 0;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ background: transparent;
|
|
|
+ border: 0;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__icon-btn:hover {
|
|
|
+ color: #2448c9;
|
|
|
+ background: #e8eeff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__icon-btn:disabled {
|
|
|
+ cursor: not-allowed;
|
|
|
+ opacity: 0.5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__body {
|
|
|
+ flex: 1;
|
|
|
+ min-height: 0;
|
|
|
+ padding: 8px;
|
|
|
+ overflow-y: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__error {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 4px;
|
|
|
+ padding: 16px 8px;
|
|
|
+ color: #d92d20;
|
|
|
+ font-size: 12px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-panel__truncated {
|
|
|
+ padding: 8px;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 11px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ align-items: flex-start;
|
|
|
+ padding: 8px;
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item:hover {
|
|
|
+ background: #f6f8fc;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__icon {
|
|
|
+ display: inline-flex;
|
|
|
+ flex: 0 0 28px;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 28px;
|
|
|
+ height: 28px;
|
|
|
+ color: #2448c9;
|
|
|
+ font-size: 18px;
|
|
|
+ background: #eef3ff;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__main {
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__name {
|
|
|
+ overflow: hidden;
|
|
|
+ color: var(--wb-text, #111827);
|
|
|
+ font-size: 13px;
|
|
|
+ line-height: 18px;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__meta {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ margin-top: 2px;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 11px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__path {
|
|
|
+ margin-top: 2px;
|
|
|
+ overflow: hidden;
|
|
|
+ color: var(--wb-text-2, #98a2b3);
|
|
|
+ font-size: 11px;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__actions {
|
|
|
+ display: flex;
|
|
|
+ flex: 0 0 auto;
|
|
|
+ gap: 2px;
|
|
|
+ opacity: 0;
|
|
|
+ transition: opacity 0.15s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item:hover .chat-artifact-item__actions,
|
|
|
+ .chat-artifact-item__actions:focus-within {
|
|
|
+ opacity: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__action {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 26px;
|
|
|
+ height: 26px;
|
|
|
+ padding: 0;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ background: transparent;
|
|
|
+ border: 0;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-artifact-item__action:hover {
|
|
|
+ color: #2448c9;
|
|
|
+ background: #e8eeff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .is-spinning {
|
|
|
+ animation: artifact-spin 1s linear infinite;
|
|
|
+ }
|
|
|
+
|
|
|
+ @keyframes artifact-spin {
|
|
|
+ to {
|
|
|
+ transform: rotate(360deg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__loading {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ padding: 40px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__error {
|
|
|
+ padding: 24px;
|
|
|
+ color: #d92d20;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__html {
|
|
|
+ width: 100%;
|
|
|
+ height: 60vh;
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__image {
|
|
|
+ display: block;
|
|
|
+ max-width: 100%;
|
|
|
+ max-height: 65vh;
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__pdf {
|
|
|
+ width: 100%;
|
|
|
+ height: 65vh;
|
|
|
+ border: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__table-wrap {
|
|
|
+ max-height: 60vh;
|
|
|
+ overflow: auto;
|
|
|
+ border: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__table {
|
|
|
+ width: 100%;
|
|
|
+ border-collapse: collapse;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__table th,
|
|
|
+ .artifact-preview__table td {
|
|
|
+ padding: 6px 8px;
|
|
|
+ text-align: left;
|
|
|
+ white-space: nowrap;
|
|
|
+ border-bottom: 1px solid #eef1f6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__table th {
|
|
|
+ position: sticky;
|
|
|
+ top: 0;
|
|
|
+ font-weight: 600;
|
|
|
+ background: #f8fafc;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__text {
|
|
|
+ max-height: 60vh;
|
|
|
+ margin: 0;
|
|
|
+ padding: 12px;
|
|
|
+ overflow: auto;
|
|
|
+ font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
|
|
|
+ font-size: 12px;
|
|
|
+ line-height: 1.6;
|
|
|
+ white-space: pre-wrap;
|
|
|
+ word-break: break-word;
|
|
|
+ background: #f8fafc;
|
|
|
+ border: 1px solid var(--wb-border, #e7ebf3);
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .artifact-preview__hint {
|
|
|
+ margin-top: 8px;
|
|
|
+ color: var(--wb-text-2, #667085);
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
@media (max-width: 900px) {
|
|
|
.chat-workbench {
|
|
|
gap: 8px;
|
|
|
@@ -4776,5 +5528,16 @@
|
|
|
.message-area {
|
|
|
padding: 16px;
|
|
|
}
|
|
|
+
|
|
|
+ .chat-artifact-panel {
|
|
|
+ position: fixed;
|
|
|
+ top: 8px;
|
|
|
+ right: 8px;
|
|
|
+ bottom: 8px;
|
|
|
+ z-index: 1100;
|
|
|
+ width: min(360px, calc(100vw - 16px));
|
|
|
+ max-width: none;
|
|
|
+ box-shadow: 0 12px 32px rgb(15 23 42 / 18%);
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|