An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:revert: Restore supplemental text for agent single-choice answers
Danielb14786647228
diff --git a/app/src/assets/scss/business/_ai_agent.scss b/app/src/assets/scss/business/_ai_agent.scssindex ebc368d88e..1bdce9700a 100644--- a/app/src/assets/scss/business/_ai_agent.scss+++ b/app/src/assets/scss/business/_ai_agent.scss@@ -1043,19 +1043,6 @@line-height: 1.5;}-.agent-chat__question-custom-option {- display: flex;- align-items: center;- gap: 8px;- padding: 0 8px;- margin-top: 8px;-- .agent-chat__question-custom {- min-width: 0;- margin-top: 0;- }-}-.agent-chat__question-custom {width: 100%;box-sizing: border-box;diff --git a/app/src/layout/dock/agent/AgentChat.ts b/app/src/layout/dock/agent/AgentChat.tsindex f7cacee598..c8ba4b7d02 100644--- a/app/src/layout/dock/agent/AgentChat.ts+++ b/app/src/layout/dock/agent/AgentChat.ts@@ -2099,19 +2099,14 @@ export class AgentChat extends Model {});// 恢复已提交的选中状态(answers 中存的是选项 value)。if (entry.answers && entry.answers.length > 0) {- el.querySelectorAll(".agent-chat__question-option input").forEach((inp) => {+ el.querySelectorAll("input[type=radio], input[type=checkbox]").forEach((inp) => {(inp as HTMLInputElement).checked = entry.answers!.includes((inp as HTMLInputElement).value);});const customInput = el.querySelector(".agent-chat__question-custom") as HTMLInputElement | null;if (customInput) {- const optionInputs = Array.from(el.querySelectorAll(".agent-chat__question-option input")) as HTMLInputElement[];- const customAnswer = entry.answers.find(a => !optionInputs.some(input => input.value === a));+ const customAnswer = entry.answers.find(a => el.querySelector('input[value="' + a + '"]') === null);if (customAnswer) {customInput.value = customAnswer;- const customRadio = customInput.parentElement.querySelector(".agent-chat__question-custom-radio") as HTMLInputElement;- if (customRadio) {- customRadio.checked = true;- }}}}@@ -4173,18 +4168,21 @@ export class AgentChat extends Model {status: "pending",});- el.querySelectorAll(".agent-chat__question-custom-option").forEach((option) => {- const radio = option.querySelector(".agent-chat__question-custom-radio") as HTMLInputElement;- const input = option.querySelector(".agent-chat__question-custom") as HTMLInputElement;- const selectCustom = () => {- if (!input.disabled) {- radio.checked = true;+ el.querySelectorAll(".agent-chat__question-option").forEach((option) => {+ const input = option.querySelector("input") as HTMLInputElement;+ if (!input) return;+ let wasChecked = false;+ option.addEventListener("mousedown", () => {+ wasChecked = input.checked;+ });+ option.addEventListener("click", (e) => {+ if (el.classList.contains("agent-chat__msg--confirmed")) {+ return;+ }+ if (input.type === "radio" && wasChecked) {+ e.preventDefault();+ input.checked = false;}- };- input.addEventListener("focus", selectCustom);- input.addEventListener("input", selectCustom);- radio.addEventListener("click", () => {- input.focus();});});@@ -4195,14 +4193,13 @@ export class AgentChat extends Model {for (let qi = 0; qi < rawQuestions.length; qi++) {const optEl = el.querySelector('.agent-chat__question-options[data-qi="' + qi + '"]');if (optEl) {- const selected = optEl.querySelectorAll(".agent-chat__question-option input:checked") as NodeListOf<HTMLInputElement>;+ const selected = optEl.querySelectorAll("input:checked") as NodeListOf<HTMLInputElement>;for (let si = 0; si < selected.length; si++) {answers.push(selected[si].value);}}const customInput = el.querySelector('.agent-chat__question-custom[data-qi="' + qi + '"]') as HTMLInputElement;- const customRadio = optEl?.querySelector(".agent-chat__question-custom-radio") as HTMLInputElement;- if (customInput && customInput.value.trim() && (!customRadio || customRadio.checked)) {+ if (customInput && customInput.value.trim()) {answers.push(customInput.value.trim());}}diff --git a/app/src/layout/dock/agent/AgentMessageRenderer.ts b/app/src/layout/dock/agent/AgentMessageRenderer.tsindex 05afd6ffaa..6035098221 100644--- a/app/src/layout/dock/agent/AgentMessageRenderer.ts+++ b/app/src/layout/dock/agent/AgentMessageRenderer.ts@@ -109,15 +109,7 @@ export const renderQuestionCardHTML = (rawQuestions: Array<Record<string, unknowhtml += "</label>";}if (custom) {- const customLabel = escapeHtml(L.agentQuestionCustom || "Type your own answer...");- if (!multiple) {- html += '<div class="agent-chat__question-custom-option">' +- '<input type="radio" name="' + inputName + '" class="agent-chat__question-custom-radio" aria-label="' + customLabel + '">';- }- html += '<input class="agent-chat__question-custom" aria-label="' + customLabel + '" placeholder="' + customLabel + '" data-qi="' + qi + '">';- if (!multiple) {- html += "</div>";- }+ html += '<input class="agent-chat__question-custom" placeholder="' + (L.agentQuestionCustom || "Type your own answer...") + '" data-qi="' + qi + '">';}html += "</div></div>";}