Skip to content

Commit 9bca760

Browse files
author
jojo
committed
Format current query markdown in deep view and clean enhance output for textarea
1 parent 49e6b92 commit 9bca760

4 files changed

Lines changed: 44 additions & 4 deletions

File tree

assets/js/app-research.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ ${turns.map((turn, idx) => `<section class="turn"><div class="q">[${idx + 1}] ${
352352
const followups = (state.followups || []).slice(0, 8);
353353
const answerText = String($("answer")?.textContent || "").trim();
354354
const summary = answerText.split("\n").map((x) => x.trim()).filter(Boolean).slice(0, 5).join(" ");
355+
const currentQueryRaw = String($("userQuery")?.value || "-").trim();
356+
const currentQueryHtml = (typeof markdownToSafeHtml === "function")
357+
? markdownToSafeHtml(currentQueryRaw || "-")
358+
: `<pre class="mono" style="white-space:pre-wrap; margin:0; color:#d5e2eb;">${escapeHtml(currentQueryRaw || "-")}</pre>`;
355359

356360
body.innerHTML = `
357361
<div class="deep-grid">
@@ -360,7 +364,7 @@ ${turns.map((turn, idx) => `<section class="turn"><div class="q">[${idx + 1}] ${
360364
<p class="deep-exec-text" style="margin:0; line-height:1.6;">${escapeHtml(summary || "No summary available yet.")}</p>
361365
<hr style="border-color: rgba(255,255,255,0.08)" />
362366
<div class="section-title">Current Query</div>
363-
<pre class="mono" style="white-space:pre-wrap; margin:0; color:#d5e2eb;">${escapeHtml($("userQuery")?.value || "-")}</pre>
367+
<div class="answer-body" style="margin:0; color:#d5e2eb;">${currentQueryHtml}</div>
364368
</section>
365369
<section class="card">
366370
<div class="section-title">Agent Relay Brief</div>

assets/js/app-ui.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,22 @@
361361
return out.replace(/\s+/g, " ").trim();
362362
}
363363

364+
function normalizeEnhancedPromptForTextarea(text) {
365+
let out = String(text || "");
366+
if (!out) return "";
367+
// Keep textarea clean/editable: strip markdown wrappers while preserving content.
368+
out = out
369+
.replace(/^#{1,6}\s+/gm, "")
370+
.replace(/\*\*(.*?)\*\*/g, "$1")
371+
.replace(/\*(.*?)\*/g, "$1")
372+
.replace(/`([^`]+)`/g, "$1")
373+
.replace(/^\s*[-*+]\s+/gm, "")
374+
.replace(/^\s*\d+\.\s+/gm, "")
375+
.replace(/\n{3,}/g, "\n\n")
376+
.trim();
377+
return clampEnhancedPrompt(out);
378+
}
379+
364380
function looksLikeClarificationQuestions(text) {
365381
const src = String(text || "").trim();
366382
if (!src) return false;
@@ -563,7 +579,7 @@
563579
targetLang
564580
});
565581
if (!improved) throw new Error("No improved prompt returned.");
566-
input.value = improved;
582+
input.value = normalizeEnhancedPromptForTextarea(improved);
567583
input.style.height = "auto";
568584
input.style.height = (input.scrollHeight) + "px";
569585
updateInpState();

hf-space/assets/js/app-research.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ ${turns.map((turn, idx) => `<section class="turn"><div class="q">[${idx + 1}] ${
352352
const followups = (state.followups || []).slice(0, 8);
353353
const answerText = String($("answer")?.textContent || "").trim();
354354
const summary = answerText.split("\n").map((x) => x.trim()).filter(Boolean).slice(0, 5).join(" ");
355+
const currentQueryRaw = String($("userQuery")?.value || "-").trim();
356+
const currentQueryHtml = (typeof markdownToSafeHtml === "function")
357+
? markdownToSafeHtml(currentQueryRaw || "-")
358+
: `<pre class="mono" style="white-space:pre-wrap; margin:0; color:#d5e2eb;">${escapeHtml(currentQueryRaw || "-")}</pre>`;
355359

356360
body.innerHTML = `
357361
<div class="deep-grid">
@@ -360,7 +364,7 @@ ${turns.map((turn, idx) => `<section class="turn"><div class="q">[${idx + 1}] ${
360364
<p class="deep-exec-text" style="margin:0; line-height:1.6;">${escapeHtml(summary || "No summary available yet.")}</p>
361365
<hr style="border-color: rgba(255,255,255,0.08)" />
362366
<div class="section-title">Current Query</div>
363-
<pre class="mono" style="white-space:pre-wrap; margin:0; color:#d5e2eb;">${escapeHtml($("userQuery")?.value || "-")}</pre>
367+
<div class="answer-body" style="margin:0; color:#d5e2eb;">${currentQueryHtml}</div>
364368
</section>
365369
<section class="card">
366370
<div class="section-title">Agent Relay Brief</div>

hf-space/assets/js/app-ui.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,22 @@
361361
return out.replace(/\s+/g, " ").trim();
362362
}
363363

364+
function normalizeEnhancedPromptForTextarea(text) {
365+
let out = String(text || "");
366+
if (!out) return "";
367+
// Keep textarea clean/editable: strip markdown wrappers while preserving content.
368+
out = out
369+
.replace(/^#{1,6}\s+/gm, "")
370+
.replace(/\*\*(.*?)\*\*/g, "$1")
371+
.replace(/\*(.*?)\*/g, "$1")
372+
.replace(/`([^`]+)`/g, "$1")
373+
.replace(/^\s*[-*+]\s+/gm, "")
374+
.replace(/^\s*\d+\.\s+/gm, "")
375+
.replace(/\n{3,}/g, "\n\n")
376+
.trim();
377+
return clampEnhancedPrompt(out);
378+
}
379+
364380
function looksLikeClarificationQuestions(text) {
365381
const src = String(text || "").trim();
366382
if (!src) return false;
@@ -563,7 +579,7 @@
563579
targetLang
564580
});
565581
if (!improved) throw new Error("No improved prompt returned.");
566-
input.value = improved;
582+
input.value = normalizeEnhancedPromptForTextarea(improved);
567583
input.style.height = "auto";
568584
input.style.height = (input.scrollHeight) + "px";
569585
updateInpState();

0 commit comments

Comments
 (0)