dashboard: show a pending submit while its run spins up; retune codegen defaults

Submitting from the dashboard cleared the input and then showed nothing until
the next poll, so a slow submit looked like a no-op. POST /api/submit now
returns the new request_id alongside status/detail (Scheduler.submit_request),
and the front end keeps a `pendingSubmit` entry: it immediately renders a
synthetic "submitted" node plus an in-flight spinner, then swaps to the real
run once its trace row appears (matching by request_id) and clears the pending
state. A run that has landed but has no decisions yet also gets the spinner
instead of an empty flow. Adds a test asserting the returned request_id matches
a trace run.

Also flip config.example.json codegen defaults to stream:true and
temperature 1 / top_p 0.95 / presence_penalty 0 / frequency_penalty 1.
This commit is contained in:
gabby committed 2026-10-01 20:35:38 +00:00
1 parent da53e1eefc
commit 8751e7c08e
5 files changed
+113 -8

No files matched your search

+5 -5
View File
@@ -48,7 +48,7 @@
"api_key_env": "", "api_key_env": "",
"user_agent": "", "user_agent": "",
"timeout": 1200, "timeout": 1200,
"stream": false, "stream": true,
"idle_warn": 60, "idle_warn": 60,
"idle_timeout": 180, "idle_timeout": 180,
"context_window": 0, "context_window": 0,
@@ -58,10 +58,10 @@
"warn_fill_ratio": 0.7, "warn_fill_ratio": 0.7,
"max_output": 0.85, "max_output": 0.85,
"chars_per_token": 4.0, "chars_per_token": 4.0,
"temperature": 0.7, "temperature": 1,
"top_p": 0.85, "top_p": 0.95,
"presence_penalty": 1.5, "presence_penalty": 0,
"frequency_penalty": 0.2, "frequency_penalty": 1,
"max_attempts": 3, "max_attempts": 3,
"elicitation": { "elicitation": {
"_comment": "Ask the product owner implementation questions before the body is written: which service/account, how to connect, where the credential comes from, what success looks like. Every front end defers questions to the questions panel and the single-slot writer waits up to wait_timeout seconds. Questions never ask for operational data values (collected at first fire) or config-vs-input cadence (the config step owns that).", "_comment": "Ask the product owner implementation questions before the body is written: which service/account, how to connect, where the credential comes from, what success looks like. Every front end defers questions to the questions panel and the single-slot writer waits up to wait_timeout seconds. Questions never ask for operational data values (collected at first fire) or config-vs-input cadence (the config step owns that).",
+2 -2
View File
@@ -236,13 +236,13 @@ class DashboardHandler(BaseHTTPRequestHandler):
with self.lock: with self.lock:
try: try:
body = self._read_json() body = self._read_json()
status, detail = self.scheduler.submit( status, detail, request_id = self.scheduler.submit_request(
str(body.get("text", "")), source=str(body.get("source", "dashboard")) str(body.get("text", "")), source=str(body.get("source", "dashboard"))
) )
except Exception as exc: except Exception as exc:
self._send_error(500, str(exc)) self._send_error(500, str(exc))
return return
self._send(200, {"status": status, "detail": detail}) self._send(200, {"status": status, "detail": detail, "request_id": request_id})
return return
if path == "/api/relabel": if path == "/api/relabel":
with self.lock: with self.lock:
+63 -1
View File
@@ -13,6 +13,7 @@ const state = {
scrub: 0, scrub: 0,
flowSteps: [], flowSteps: [],
answerFeedback: null, answerFeedback: null,
pendingSubmit: null,
}; };
async function getJSON(url, opts) { async function getJSON(url, opts) {
@@ -36,6 +37,13 @@ async function refreshAll() {
state.selectedRunId = null; state.selectedRunId = null;
state.selectedDecisionId = null; state.selectedDecisionId = null;
} }
const pending = state.pendingSubmit;
if (pending && pending.requestId && state.runs.some((r) => r.run_id === pending.requestId)) {
state.selectedRunId = pending.requestId;
state.selectedDecisionId = null;
state.scrub = 0;
state.pendingSubmit = null;
}
render(); render();
} }
@@ -214,6 +222,10 @@ function renderFlow() {
el.innerHTML = ""; el.innerHTML = "";
if (!run) { if (!run) {
if (state.pendingSubmit) {
renderPendingFlow(el);
return;
}
const empty = document.createElement("div"); const empty = document.createElement("div");
empty.className = "muted"; empty.className = "muted";
empty.textContent = "select a run from the timeline"; empty.textContent = "select a run from the timeline";
@@ -233,6 +245,45 @@ function renderFlow() {
if (i > state.scrub) node.classList.add("dim"); if (i > state.scrub) node.classList.add("dim");
el.appendChild(node); el.appendChild(node);
} }
if (run.decisions.length === 0 && runInFlight(run)) {
if (steps.length) el.appendChild(edge(steps[steps.length - 1].data));
el.appendChild(pendingIndicatorNode("decisions in process…"));
}
}
const RESTING_EVENTS = ["ran", "rejected", "dropped", "error", "assessed", "needs_input", "pending_abandoned"];
function runInFlight(run) {
return !run.events.some((evt) => RESTING_EVENTS.includes(evt.kind));
}
function renderPendingFlow(el) {
const node = document.createElement("div");
node.className = "node event-node pending-request";
const kind = document.createElement("div");
kind.className = "evt-kind";
kind.textContent = "submitted";
node.appendChild(kind);
const body = document.createElement("div");
body.className = "node-question";
body.textContent = state.pendingSubmit.text;
node.appendChild(body);
el.appendChild(node);
el.appendChild(edge({ kind: "event" }));
el.appendChild(pendingIndicatorNode("decisions in process…"));
}
function pendingIndicatorNode(text) {
const node = document.createElement("div");
node.className = "node pending-indicator";
const dot = document.createElement("span");
dot.className = "spinner";
node.appendChild(dot);
const label = document.createElement("span");
label.textContent = text;
node.appendChild(label);
return node;
} }
function edge(prev) { function edge(prev) {
@@ -776,6 +827,12 @@ $("#submit-form").addEventListener("submit", async (e) => {
e.preventDefault(); e.preventDefault();
const text = $("#query-input").value.trim(); const text = $("#query-input").value.trim();
if (!text) return; if (!text) return;
$("#query-input").value = "";
state.pendingSubmit = { text, requestId: null };
state.selectedRunId = null;
state.selectedDecisionId = null;
state.scrub = 0;
render();
try { try {
const res = await getJSON("/api/submit", { const res = await getJSON("/api/submit", {
method: "POST", method: "POST",
@@ -783,10 +840,15 @@ $("#submit-form").addEventListener("submit", async (e) => {
body: JSON.stringify({ text }), body: JSON.stringify({ text }),
}); });
flash(`[${res.status}] ${res.detail}`); flash(`[${res.status}] ${res.detail}`);
if (res.request_id) {
state.pendingSubmit.requestId = res.request_id;
} else {
state.pendingSubmit = null;
}
} catch (err) { } catch (err) {
flash(`submit failed: ${err.message}`); flash(`submit failed: ${err.message}`);
state.pendingSubmit = null;
} }
$("#query-input").value = "";
await refreshAll(); await refreshAll();
}); });
+25
View File
@@ -317,6 +317,31 @@ select {
50% { opacity: 0.35; } 50% { opacity: 0.35; }
} }
/* ---------- pending submit ---------- */
.node.pending-indicator {
display: flex;
align-items: center;
gap: 8px;
width: auto;
color: var(--warn);
font-size: 12px;
border-style: dashed;
cursor: default;
}
.node.pending-indicator:hover { border-color: var(--line); }
.pending-indicator .spinner {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--warn);
animation: writing-pulse 1.2s ease-in-out infinite;
}
.node.event-node.pending-request { border-left: 3px solid var(--accent); }
/* ---------- inspector / tree / status ---------- */ /* ---------- inspector / tree / status ---------- */
.right { border-right: none; } .right { border-right: none; }
+18
View File
@@ -156,6 +156,24 @@ def test_submit_without_engine_returns_fatal_json(tmp_path):
server.close() server.close()
def test_submit_returns_request_id_matching_trace(tmp_path):
"""Submit hands the front end the request id so it can open the new run's
flow container and follow it as decisions land."""
scheduler = build_scheduler(tmp_path)
server = Server(scheduler)
try:
status, payload = server.post("/api/submit", {"text": "hello"})
assert status == 200
request_id = payload["request_id"]
assert request_id
status, trace = server.get("/api/trace")
assert status == 200
assert any(run["run_id"] == request_id for run in trace["runs"])
finally:
server.close()
def test_relabel_roundtrip(tmp_path): def test_relabel_roundtrip(tmp_path):
scheduler = build_scheduler(tmp_path) scheduler = build_scheduler(tmp_path)
seed_decision(scheduler.log) seed_decision(scheduler.log)