From 927f66b696a71c06d8dc4d2e508a77de56db7102 Mon Sep 17 00:00:00 2001 From: Denton Social Date: Fri, 25 Sep 2026 12:10:40 -0500 Subject: [PATCH] dashboard: show answer feedback and auto-select the resumed run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The answer flow ran the whole resume + LLM assessment synchronously before the frontend cleared the input or flashed anything, so a slow answer looked like a no-op. Make it optimistic: clear input, disable the button, and show an in-flight 'answering…' state immediately; then persist a consumed-feedback line (with a hint when the skill re-asks the same question) and auto-select the run in the timeline so the answered/assessed/needs_input events are visible. build_status now carries the pending run_id to drive that selection. --- semif_agent/dashboard.py | 6 +++- semif_agent/static/app.js | 59 ++++++++++++++++++++++++++++++++++- semif_agent/static/index.html | 3 +- semif_agent/static/style.css | 25 +++++++++++++++ tests/test_dashboard_api.py | 4 ++- 5 files changed, 93 insertions(+), 4 deletions(-) diff --git a/semif_agent/dashboard.py b/semif_agent/dashboard.py index e5412d9..f652fb3 100644 --- a/semif_agent/dashboard.py +++ b/semif_agent/dashboard.py @@ -100,7 +100,11 @@ def build_status(scheduler: Scheduler) -> dict: else None ) pending = ( - {"skill": scheduler.pending.skill.name, "question": scheduler.pending.question} + { + "skill": scheduler.pending.skill.name, + "question": scheduler.pending.question, + "run_id": scheduler.pending.request.id, + } if scheduler.pending else None ) diff --git a/semif_agent/static/app.js b/semif_agent/static/app.js index 8f70f0e..311b398 100644 --- a/semif_agent/static/app.js +++ b/semif_agent/static/app.js @@ -12,6 +12,7 @@ const state = { phaseFilter: "", scrub: 0, flowSteps: [], + answerFeedback: null, }; async function getJSON(url, opts) { @@ -553,7 +554,41 @@ function renderStatus() { $("#answer-form").classList.toggle("hidden", !pending); if (pending) { $("#answer-input").placeholder = `${pending.skill}: ${pending.question}`; + const p = document.createElement("div"); + p.className = "pending-line"; + p.textContent = `awaiting input (${pending.run_id || pending.skill}): ${pending.question}`; + el.appendChild(p); } + renderAnswerFeedback(); +} + +function renderAnswerFeedback() { + const el = $("#answer-feedback"); + const fb = state.answerFeedback; + el.className = "hidden"; + if (!fb) return; + if (fb.inflight) { + el.className = ""; + el.textContent = "answering…"; + return; + } + if (fb.status === "error") { + el.className = "feedback-error"; + el.textContent = `✗ ${fb.detail}`; + return; + } + let line = `✓ consumed "${fb.text}"`; + if (fb.status === "needs_input") { + el.className = "feedback-awaiting"; + line += ` → awaiting: ${fb.detail}`; + if (fb.askedQuestion && fb.detail === fb.askedQuestion) { + line += " (answer received; the skill asked again)"; + } + } else { + el.className = ""; + line += ` → ${fb.detail}`; + } + el.textContent = line; } function stat(k, v) { @@ -632,6 +667,14 @@ $("#answer-form").addEventListener("submit", async (e) => { e.preventDefault(); const text = $("#answer-input").value.trim(); if (!text) return; + const btn = $("#answer-btn"); + const pending = state.status.pending || {}; + const runId = pending.run_id || null; + const askedQuestion = pending.question || null; + $("#answer-input").value = ""; + btn.disabled = true; + state.answerFeedback = { inflight: true }; + renderAnswerFeedback(); try { const res = await getJSON("/api/answer", { method: "POST", @@ -639,11 +682,25 @@ $("#answer-form").addEventListener("submit", async (e) => { body: JSON.stringify({ text }), }); flash(`[${res.status}] ${res.detail}`); + state.answerFeedback = { status: res.status, detail: res.detail, text, askedQuestion }; } catch (err) { flash(`answer failed: ${err.message}`); + state.answerFeedback = { + status: "error", + detail: `answer failed: ${err.message}`, + text, + askedQuestion, + }; + } finally { + btn.disabled = false; } - $("#answer-input").value = ""; await refreshAll(); + if (runId && state.runs.some((r) => r.run_id === runId)) { + state.selectedRunId = runId; + state.selectedDecisionId = null; + state.scrub = 0; + render(); + } }); $("#refresh-btn").addEventListener("click", async () => { diff --git a/semif_agent/static/index.html b/semif_agent/static/index.html index 0c562e4..02c3506 100644 --- a/semif_agent/static/index.html +++ b/semif_agent/static/index.html @@ -21,8 +21,9 @@ + diff --git a/semif_agent/static/style.css b/semif_agent/static/style.css index 25905f5..8f8e06b 100644 --- a/semif_agent/static/style.css +++ b/semif_agent/static/style.css @@ -48,6 +48,7 @@ html, body { .inputbar { display: flex; + flex-wrap: wrap; gap: 8px; padding: 10px 16px; background: var(--panel-2); @@ -56,6 +57,19 @@ html, body { .inputbar form { display: flex; flex: 1; gap: 8px; } +#answer-feedback { + flex: 1 1 100%; + padding: 6px 12px; + font-size: 12px; + color: var(--ok); + background: var(--bg); + border: 1px solid var(--line); + border-radius: 6px; +} + +#answer-feedback.feedback-error { color: var(--fail); border-color: var(--fail); } +#answer-feedback.feedback-awaiting { color: var(--warn); border-color: var(--warn); } + #query-input { flex: 1; background: var(--bg); @@ -346,6 +360,17 @@ pre.json { .stat-grid .stat { background: var(--panel-2); border-radius: 4px; padding: 4px 6px; } .stat-grid .stat .v { font-weight: 700; } +.pending-line { + margin: 8px 0 4px; + padding: 6px 8px; + background: var(--panel-2); + border-radius: 4px; + border-left: 3px solid var(--warn); + color: var(--warn); + white-space: pre-wrap; + word-break: break-word; +} + /* ---------- scrubber ---------- */ .scrub-label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); } diff --git a/tests/test_dashboard_api.py b/tests/test_dashboard_api.py index 0dd7bc9..420e652 100644 --- a/tests/test_dashboard_api.py +++ b/tests/test_dashboard_api.py @@ -273,13 +273,15 @@ def test_answer_without_pending_returns_error_json(tmp_path): def test_status_includes_pending(tmp_path): scheduler = build_scheduler(tmp_path) - scheduler._run_skill(need_input_skill([]), Request("track my package")) + request = Request("track my package") + scheduler._run_skill(need_input_skill([]), request) server = Server(scheduler) try: status, payload = server.get("/api/status") assert status == 200 assert payload["pending"]["skill"] == "track.manual" assert payload["pending"]["question"] == "What's the tracking number?" + assert payload["pending"]["run_id"] == request.id finally: server.close()