feat: route mode cards through AI assistant

This commit is contained in:
vee
2026-09-09 08:32:51 +08:00
parent 93103c2579
commit 2af8b8f9ac
8 changed files with 145 additions and 22 deletions
+23 -11
View File
@@ -6417,22 +6417,34 @@ async function executeSavedModeProfile(mode) {
}
function applyModeCommand(command, modeProfileId = null) {
if (!command) return;
if ($("#runButton").disabled) {
const modeCommand = String(command || "").trim();
if (!modeCommand) return false;
const assistant = window.CognitiveAgentAssistant;
if (assistant?.isPending?.()) {
showToast("AI助手正在处理上一条指令,请稍候");
return false;
}
if ($("#runButton")?.disabled) {
showToast("上一条指令仍在执行,请稍候");
return;
return false;
}
const mode = modeProfiles().find((item) => item.id === modeProfileId);
setModeRailSelection(mode);
if (mode?.command_flow?.source_request_id) {
void executeSavedModeProfile(mode);
return;
}
closeModeGallery({ restoreFocus: false });
state.pendingModeProfileId = modeProfileId;
if (modeProfileId) setModeExecutionState(modeProfileId, "running");
$("#utterance").value = command;
$("#requestForm").requestSubmit();
assistant?.open?.();
const input = $("#utterance");
const form = $("#requestForm");
if (!input || !form) {
showToast("AI助手暂时不可用,请稍后重试");
return false;
}
input.value = modeCommand;
delete input.dataset.speechStage;
delete input.dataset.speechUtteranceId;
delete input.dataset.speechValue;
input.dispatchEvent(new Event("input", { bubbles: true }));
form.requestSubmit();
return true;
}
function applyRuntimeTargetPolicy(runtime) {