首页历史工作流会话解除工作流锁定,回显预选上次执行工作流可自由切换
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -88,7 +88,6 @@ import { getWorkflowList } from '/@/api/settings/creation';
|
||||
|
||||
interface Props {
|
||||
sendDisabled?: boolean;
|
||||
workflowLocked?: boolean;
|
||||
hideShortcuts?: boolean;
|
||||
generating?: boolean;
|
||||
// 当前会话模型名称,用于输入栏切换入口展示
|
||||
@@ -114,7 +113,6 @@ interface Workflow {
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
sendDisabled: false,
|
||||
workflowLocked: false,
|
||||
hideShortcuts: false,
|
||||
generating: false,
|
||||
currentModelName: '',
|
||||
@@ -126,15 +124,12 @@ const isFocused = ref(false);
|
||||
const selectedWorkflowId = ref<string | null>(null);
|
||||
const commonWorkflows = ref<Workflow[]>([]);
|
||||
|
||||
const visibleWorkflows = computed(() => {
|
||||
if (props.workflowLocked && selectedWorkflowId.value) {
|
||||
return commonWorkflows.value.filter((w) => w.id === selectedWorkflowId.value);
|
||||
}
|
||||
return commonWorkflows.value;
|
||||
});
|
||||
// 工作流胶囊始终展示全部工作流:历史工作流会话回显预选上次执行的工作流,
|
||||
// 但仍允许自由切换/取消(不锁定为单个工作流)
|
||||
const visibleWorkflows = computed(() => commonWorkflows.value);
|
||||
|
||||
// 输入框整体锁定:选择了工作流(不可取消)或正处于生成/工作流执行中
|
||||
const lockAll = computed(() => props.workflowLocked || props.isWorkflowRunning || props.generating);
|
||||
// 输入框整体锁定:正处于生成/工作流执行中(执行中禁止切换工作流)
|
||||
const lockAll = computed(() => props.isWorkflowRunning || props.generating);
|
||||
|
||||
// 输入框占位符:工作流执行中给出明确提示
|
||||
const inputPlaceholder = computed(() =>
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
<InputBar
|
||||
ref="inputBarRef"
|
||||
:send-disabled="isSendDisabled"
|
||||
:workflow-locked="isHistoryWorkflow"
|
||||
:hide-shortcuts="isPlaceholder"
|
||||
:generating="isGenerating"
|
||||
:is-workflow-running="isWorkflowRunning"
|
||||
@@ -389,7 +388,6 @@ let wsState: { ws: WebSocket; sid: string; sessionId: string; ready: Promise<Web
|
||||
// 当前进行中的一轮类型:true=工作流执行,false=普通对话(sendCancel 协议判断用)
|
||||
// ref 响应式:InputBar 依据它区分「工作流执行中」与「普通对话生成中」,决定禁用/停止按钮展示
|
||||
const activeRunIsWorkflow = ref(false);
|
||||
const isHistoryWorkflow = ref(false);
|
||||
|
||||
// 生成中:有活跃会话且该会话正处于发送状态(发送按钮切换为停止按钮)
|
||||
const isGenerating = computed(() => !!activeHistoryId.value && !!sendingSessions[activeHistoryId.value]);
|
||||
@@ -861,11 +859,9 @@ const handleDeleteMessage = async (msg: ChatMessage) => {
|
||||
// 仍含工作流结果:完整重建消息流(带值表单卡片 + 结果消息)
|
||||
const session = historyList.value.find((h) => h.id === sid);
|
||||
if (session) {
|
||||
isHistoryWorkflow.value = true;
|
||||
await loadWorkflowSessionMessages(sid, results);
|
||||
}
|
||||
} else {
|
||||
isHistoryWorkflow.value = false;
|
||||
inputBarRef.value?.clearWorkflow?.();
|
||||
loadSessionMessagesFromResults(sid, results);
|
||||
}
|
||||
@@ -1372,7 +1368,7 @@ const handleSelectHistory = async (id: string) => {
|
||||
teardownSession();
|
||||
activeHistoryId.value = id;
|
||||
activeMenu.value = 'chat';
|
||||
// 切换会话不继承工作流选择(回显的锁定标签由 InputBar 单独维护)
|
||||
// 切换会话不继承工作流选择(历史工作流会话回显时预选上次执行的工作流,可自由切换)
|
||||
selectedWorkflowDetail.value = null;
|
||||
const session = historyList.value.find((h) => h.id === id);
|
||||
// 加载会话内结果列表(session/get),用它判断会话类型:普通会话(无 workflow 结果)只依赖这一个接口,不再调 execution/get
|
||||
@@ -1380,11 +1376,9 @@ const handleSelectHistory = async (id: string) => {
|
||||
const hasWorkflow = Array.isArray(results) && results.some((r) => r.type === 'workflow');
|
||||
// 工作流会话:回显为消息流(带值表单卡片 + 结果消息),不再跳整页表单页
|
||||
if (hasWorkflow) {
|
||||
isHistoryWorkflow.value = true; // InputBar 锁定(禁止更换工作流)
|
||||
await loadWorkflowSessionMessages(id, results);
|
||||
} else {
|
||||
// 普通对话会话 / 虚拟会话:切回对话页,把 session/get 结果转换为正常对话消息流展示
|
||||
isHistoryWorkflow.value = false;
|
||||
inputBarRef.value?.clearWorkflow?.();
|
||||
loadSessionMessagesFromResults(id, results);
|
||||
}
|
||||
@@ -1402,7 +1396,7 @@ const handleSelectHistory = async (id: string) => {
|
||||
// 表单卡片直接用结果记录的 requestParams(完整 flowContent,含 __start__ outputConfig 值快照)构造,
|
||||
// 不再依赖 execution/get;chat 结果按原逻辑转消息流
|
||||
const loadWorkflowSessionMessages = async (sid: string, results: VOSessionInfoResult[]) => {
|
||||
// 最近一次 workflow 结果记录(results 时间倒序,第一条即最新):用于同步 InputBar 锁定标签展示
|
||||
// 最近一次 workflow 结果记录(results 时间倒序,第一条即最新):用于回显预选 InputBar 工作流
|
||||
const latestWf = Array.isArray(results) ? results.find((r) => r.type === 'workflow') : undefined;
|
||||
// 按 flowId 查工作流名(commonWorkflows 的 id 即工作流 id),每条记录用各自名称
|
||||
const flowNameOf = (flowId?: string): string => {
|
||||
@@ -1568,7 +1562,6 @@ const createNewSession = () => {
|
||||
activeHistoryId.value = sessionId;
|
||||
activeMenu.value = 'chat';
|
||||
selectedWorkflowDetail.value = null;
|
||||
isHistoryWorkflow.value = false;
|
||||
inputBarRef.value?.resetAll();
|
||||
sessionMessages.value.set(sessionId, []); // 清空消息
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user