|
@@ -22,10 +22,6 @@
|
|
|
<span v-if="session?.title" class="insight-drawer__subtitle">{{ session.title }}</span>
|
|
<span v-if="session?.title" class="insight-drawer__subtitle">{{ session.title }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="insight-drawer__header-actions">
|
|
<div class="insight-drawer__header-actions">
|
|
|
- <Button size="small" :disabled="!canAnalyze || streaming || creating" @click="reanalyze">
|
|
|
|
|
- <Icon icon="i-mdi:refresh" :size="14" />
|
|
|
|
|
- <span>重新分析</span>
|
|
|
|
|
- </Button>
|
|
|
|
|
<InsightHistoryPopover
|
|
<InsightHistoryPopover
|
|
|
ref="historyRef"
|
|
ref="historyRef"
|
|
|
:case-id="caseId"
|
|
:case-id="caseId"
|
|
@@ -52,19 +48,32 @@
|
|
|
@reanalyze="reanalyze"
|
|
@reanalyze="reanalyze"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
|
|
+ <!-- 执行状态:模型思考 / 工具执行期间始终可见,避免暂时没有新输出时误以为已经停了 -->
|
|
|
|
|
+ <div v-if="creating || streaming" class="insight-drawer__running" role="status" aria-live="polite">
|
|
|
|
|
+ <span class="insight-drawer__running-dot"></span>
|
|
|
|
|
+ <span>{{ creating ? '正在创建分析会话' : 'AI 正在分析' }}</span>
|
|
|
|
|
+ <span class="insight-drawer__running-dots" aria-hidden="true">
|
|
|
|
|
+ <i></i>
|
|
|
|
|
+ <i></i>
|
|
|
|
|
+ <i></i>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<!-- ③ Report / ④ Chat(滚动区) -->
|
|
<!-- ③ Report / ④ Chat(滚动区) -->
|
|
|
- <div ref="scrollRef" class="insight-drawer__scroll">
|
|
|
|
|
|
|
+ <div ref="scrollRef" class="insight-drawer__scroll" @scroll.passive="onScroll">
|
|
|
<div v-if="error && !reportMessage" class="insight-drawer__error">
|
|
<div v-if="error && !reportMessage" class="insight-drawer__error">
|
|
|
<Icon icon="i-mdi:alert-circle-outline" :size="14" />
|
|
<Icon icon="i-mdi:alert-circle-outline" :size="14" />
|
|
|
<span>{{ error }}</span>
|
|
<span>{{ error }}</span>
|
|
|
<Button v-if="isModelError" size="small" type="link" @click="goModelSetting">去设置默认模型</Button>
|
|
<Button v-if="isModelError" size="small" type="link" @click="goModelSetting">去设置默认模型</Button>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+ <!-- 以首轮消息自身的 streaming 为准:首轮消息 local=true 且正在流式时为 true;
|
|
|
|
|
+ 追问流式时首轮报告不是流式目标,这里保持 false,不能拿全局 streaming 判断 -->
|
|
|
<InsightReport
|
|
<InsightReport
|
|
|
:message="reportMessage"
|
|
:message="reportMessage"
|
|
|
:payload="payload"
|
|
:payload="payload"
|
|
|
:creating="creating"
|
|
:creating="creating"
|
|
|
- :streaming="streaming && !reportMessage?.local"
|
|
|
|
|
|
|
+ :streaming="!!reportMessage?.streaming"
|
|
|
@action="onClueAction"
|
|
@action="onClueAction"
|
|
|
@navigate="onNextStep"
|
|
@navigate="onNextStep"
|
|
|
/>
|
|
/>
|
|
@@ -134,6 +143,8 @@
|
|
|
:base-query="transRecordBaseQuery"
|
|
:base-query="transRecordBaseQuery"
|
|
|
:z-index="1015"
|
|
:z-index="1015"
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <!-- 产物 CSV 预览:全站单例由 previewArtifact 驱动,智能工作台之外需要本地挂一份 -->
|
|
|
|
|
+ <ArtifactPreviewModal :z-index="1015" />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
@@ -152,6 +163,7 @@
|
|
|
import Icon from '@/core/components/Icon/src/Icon.vue';
|
|
import Icon from '@/core/components/Icon/src/Icon.vue';
|
|
|
import CallRecordModal from '@/call/views/components/CallRecordModal.vue';
|
|
import CallRecordModal from '@/call/views/components/CallRecordModal.vue';
|
|
|
import TransRecordModal from '@/trans/views/components/TransRecordModal.vue';
|
|
import TransRecordModal from '@/trans/views/components/TransRecordModal.vue';
|
|
|
|
|
+ import ArtifactPreviewModal from '@/ai/components/ArtifactPreviewModal.vue';
|
|
|
import InsightContextBar from './InsightContextBar.vue';
|
|
import InsightContextBar from './InsightContextBar.vue';
|
|
|
import InsightReport from './InsightReport.vue';
|
|
import InsightReport from './InsightReport.vue';
|
|
|
import InsightMessageList from './InsightMessageList.vue';
|
|
import InsightMessageList from './InsightMessageList.vue';
|
|
@@ -255,12 +267,20 @@
|
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
|
resizing = false;
|
|
resizing = false;
|
|
|
detachResize?.();
|
|
detachResize?.();
|
|
|
|
|
+ if (autoScrollRaf != null) {
|
|
|
|
|
+ cancelAnimationFrame(autoScrollRaf);
|
|
|
|
|
+ autoScrollRaf = null;
|
|
|
|
|
+ }
|
|
|
stop();
|
|
stop();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const topN = ref(DEFAULT_TOP_N);
|
|
const topN = ref(DEFAULT_TOP_N);
|
|
|
const draft = ref('');
|
|
const draft = ref('');
|
|
|
const scrollRef = ref<HTMLElement | null>(null);
|
|
const scrollRef = ref<HTMLElement | null>(null);
|
|
|
|
|
+ /** 是否吸底:用户没有手动上滑时自动跟随新内容;手动上滑后停止跟随 */
|
|
|
|
|
+ const stickToBottom = ref(true);
|
|
|
|
|
+ const STICK_BOTTOM_THRESHOLD = 48;
|
|
|
|
|
+ let autoScrollRaf: number | null = null;
|
|
|
const messageListRef = ref<InstanceType<typeof InsightMessageList> | null>(null);
|
|
const messageListRef = ref<InstanceType<typeof InsightMessageList> | null>(null);
|
|
|
const historyRef = ref<InstanceType<typeof InsightHistoryPopover> | null>(null);
|
|
const historyRef = ref<InstanceType<typeof InsightHistoryPopover> | null>(null);
|
|
|
|
|
|
|
@@ -276,15 +296,13 @@
|
|
|
snapshotSignature.value !== analyzedSignature.value,
|
|
snapshotSignature.value !== analyzedSignature.value,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- /** 画布上没有任何节点/关系时仍允许分析(模型会回答"无数据"),只拦未选案件 */
|
|
|
|
|
- const canAnalyze = computed(() => !!props.caseId);
|
|
|
|
|
-
|
|
|
|
|
const isModelError = computed(() => /默认模型/.test(error.value));
|
|
const isModelError = computed(() => /默认模型/.test(error.value));
|
|
|
|
|
|
|
|
async function reanalyze() {
|
|
async function reanalyze() {
|
|
|
if (!props.caseId) return;
|
|
if (!props.caseId) return;
|
|
|
if (streaming.value) stop();
|
|
if (streaming.value) stop();
|
|
|
reset();
|
|
reset();
|
|
|
|
|
+ stickToBottom.value = true;
|
|
|
analyzedSignature.value = snapshotSignature.value;
|
|
analyzedSignature.value = snapshotSignature.value;
|
|
|
try {
|
|
try {
|
|
|
await start(buildCreateParams, topN.value);
|
|
await start(buildCreateParams, topN.value);
|
|
@@ -297,9 +315,12 @@
|
|
|
() => props.open,
|
|
() => props.open,
|
|
|
async (value) => {
|
|
async (value) => {
|
|
|
if (value) {
|
|
if (value) {
|
|
|
|
|
+ stickToBottom.value = true;
|
|
|
// 打开即分析:已有会话(切案件后没重置)则不重复建
|
|
// 打开即分析:已有会话(切案件后没重置)则不重复建
|
|
|
if (!sessionId.value && !creating.value) {
|
|
if (!sessionId.value && !creating.value) {
|
|
|
await reanalyze();
|
|
await reanalyze();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await scrollToBottom();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 关闭时中止流,避免后台继续烧 token
|
|
// 关闭时中止流,避免后台继续烧 token
|
|
@@ -329,8 +350,9 @@
|
|
|
const text = draft.value.trim();
|
|
const text = draft.value.trim();
|
|
|
if (!text) return;
|
|
if (!text) return;
|
|
|
draft.value = '';
|
|
draft.value = '';
|
|
|
|
|
+ // 用户主动发问,重新进入跟随态;后续由 scheduleAutoScroll 按内容增长吸底
|
|
|
|
|
+ stickToBottom.value = true;
|
|
|
await followup(text);
|
|
await followup(text);
|
|
|
- await scrollToBottom();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function onEnter(event: KeyboardEvent) {
|
|
function onEnter(event: KeyboardEvent) {
|
|
@@ -344,10 +366,31 @@
|
|
|
send();
|
|
send();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 用户滚动:距底部超过阈值即视为手动上滑,暂停自动跟随;回到底部后恢复 */
|
|
|
|
|
+ function onScroll() {
|
|
|
|
|
+ const el = scrollRef.value;
|
|
|
|
|
+ if (!el) return;
|
|
|
|
|
+ stickToBottom.value = el.scrollHeight - el.scrollTop - el.clientHeight <= STICK_BOTTOM_THRESHOLD;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function scrollToBottom() {
|
|
async function scrollToBottom() {
|
|
|
await nextTick();
|
|
await nextTick();
|
|
|
const el = scrollRef.value;
|
|
const el = scrollRef.value;
|
|
|
- if (el) el.scrollTop = el.scrollHeight;
|
|
|
|
|
|
|
+ if (!el) return;
|
|
|
|
|
+ stickToBottom.value = true;
|
|
|
|
|
+ el.scrollTop = el.scrollHeight;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 同一帧内的多次 token/思考/工具更新只滚一次,避免每 token 强制回流 */
|
|
|
|
|
+ function scheduleAutoScroll() {
|
|
|
|
|
+ if (!stickToBottom.value || autoScrollRaf != null) return;
|
|
|
|
|
+ autoScrollRaf = requestAnimationFrame(async () => {
|
|
|
|
|
+ autoScrollRaf = null;
|
|
|
|
|
+ if (!stickToBottom.value) return;
|
|
|
|
|
+ await nextTick();
|
|
|
|
|
+ const el = scrollRef.value;
|
|
|
|
|
+ if (el && stickToBottom.value) el.scrollTop = el.scrollHeight;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* ---------------- 历史记录 ---------------- */
|
|
/* ---------------- 历史记录 ---------------- */
|
|
@@ -355,6 +398,7 @@
|
|
|
async function onSelectHistory(item: InsightSessionVO) {
|
|
async function onSelectHistory(item: InsightSessionVO) {
|
|
|
analyzedSignature.value = snapshotSignature.value;
|
|
analyzedSignature.value = snapshotSignature.value;
|
|
|
await openSession(item.id);
|
|
await openSession(item.id);
|
|
|
|
|
+ await scrollToBottom();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function onRemoveHistory(item: InsightSessionVO) {
|
|
async function onRemoveHistory(item: InsightSessionVO) {
|
|
@@ -411,12 +455,23 @@
|
|
|
await loadMore();
|
|
await loadMore();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 追问回答落地后滚到底(只在消息条数变化时触发,避免打断用户上滑)
|
|
|
|
|
|
|
+ // 首轮/追问的流式内容、思考、工具调用或消息条数变化时,未手动上滑就自动吸底。
|
|
|
|
|
+ // 只监听内容增长的信号,不监听滚动位置本身(由 onScroll 维护 stickToBottom)。
|
|
|
|
|
+ const lastFollowupMessage = computed(() => followupMessages.value[followupMessages.value.length - 1]);
|
|
|
watch(
|
|
watch(
|
|
|
- () => followupMessages.value.length,
|
|
|
|
|
- async (next, prev) => {
|
|
|
|
|
- if (next > prev) await scrollToBottom();
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ () => [
|
|
|
|
|
+ reportMessage.value?.streaming,
|
|
|
|
|
+ reportMessage.value?.content,
|
|
|
|
|
+ reportMessage.value?.thinking,
|
|
|
|
|
+ reportMessage.value?.toolSteps?.length,
|
|
|
|
|
+ payload.value,
|
|
|
|
|
+ followupMessages.value.length,
|
|
|
|
|
+ lastFollowupMessage.value?.content,
|
|
|
|
|
+ lastFollowupMessage.value?.thinking,
|
|
|
|
|
+ lastFollowupMessage.value?.toolSteps?.length,
|
|
|
|
|
+ ],
|
|
|
|
|
+ scheduleAutoScroll,
|
|
|
|
|
+ { flush: 'post' },
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
/** 供外部(页面)判断是否可关闭 */
|
|
/** 供外部(页面)判断是否可关闭 */
|
|
@@ -483,6 +538,50 @@
|
|
|
flex-shrink: 0;
|
|
flex-shrink: 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /* 执行中状态条:与滚动区分离,思考期间不随内容滚走 */
|
|
|
|
|
+ &__running {
|
|
|
|
|
+ flex: 0 0 auto;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 8px;
|
|
|
|
|
+ padding: 6px 14px;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+ color: #2a50ec;
|
|
|
|
|
+ background: #eef4ff;
|
|
|
|
|
+ border-bottom: 1px solid #dbe7ff;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__running-dot {
|
|
|
|
|
+ width: 7px;
|
|
|
|
|
+ height: 7px;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ background: #2a50ec;
|
|
|
|
|
+ animation: insight-running-pulse 1.2s ease-in-out infinite;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__running-dots {
|
|
|
|
|
+ display: inline-flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 3px;
|
|
|
|
|
+
|
|
|
|
|
+ i {
|
|
|
|
|
+ width: 4px;
|
|
|
|
|
+ height: 4px;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ background: #2a50ec;
|
|
|
|
|
+ animation: insight-running-bounce 1.2s ease-in-out infinite;
|
|
|
|
|
+
|
|
|
|
|
+ &:nth-child(2) {
|
|
|
|
|
+ animation-delay: 0.15s;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &:nth-child(3) {
|
|
|
|
|
+ animation-delay: 0.3s;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
&__scroll {
|
|
&__scroll {
|
|
|
flex: 1 1 auto;
|
|
flex: 1 1 auto;
|
|
|
min-height: 0;
|
|
min-height: 0;
|
|
@@ -556,12 +655,55 @@
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: flex-end;
|
|
align-items: flex-end;
|
|
|
gap: 8px;
|
|
gap: 8px;
|
|
|
|
|
+
|
|
|
|
|
+ /* 停止生成:全局 .ant-btn-default 会覆盖 AntD danger 的颜色,这里显式恢复红色 */
|
|
|
|
|
+ .ant-btn-dangerous {
|
|
|
|
|
+ color: #dc2626;
|
|
|
|
|
+ border-color: #fecaca;
|
|
|
|
|
+ background: #fef2f2;
|
|
|
|
|
+
|
|
|
|
|
+ &:hover,
|
|
|
|
|
+ &:focus,
|
|
|
|
|
+ &:not(:disabled):hover,
|
|
|
|
|
+ &:not(:disabled):focus {
|
|
|
|
|
+ color: #dc2626;
|
|
|
|
|
+ border-color: #fca5a5;
|
|
|
|
|
+ background: #fee2e2;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
&__input {
|
|
&__input {
|
|
|
flex: 1 1 auto;
|
|
flex: 1 1 auto;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @keyframes insight-running-pulse {
|
|
|
|
|
+ 0%,
|
|
|
|
|
+ 100% {
|
|
|
|
|
+ opacity: 1;
|
|
|
|
|
+ transform: scale(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 50% {
|
|
|
|
|
+ opacity: 0.35;
|
|
|
|
|
+ transform: scale(0.72);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @keyframes insight-running-bounce {
|
|
|
|
|
+ 0%,
|
|
|
|
|
+ 80%,
|
|
|
|
|
+ 100% {
|
|
|
|
|
+ opacity: 0.3;
|
|
|
|
|
+ transform: translateY(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 40% {
|
|
|
|
|
+ opacity: 1;
|
|
|
|
|
+ transform: translateY(-3px);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
</style>
|
|
</style>
|
|
|
|
|
|
|
|
<style lang="less">
|
|
<style lang="less">
|