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:
1 parent
da53e1eefc
commit
8751e7c08e
5 files changed
+113
-8
No files matched your search
@@ -236,13 +236,13 @@ class DashboardHandler(BaseHTTPRequestHandler):
|
||||
with self.lock:
|
||||
try:
|
||||
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"))
|
||||
)
|
||||
except Exception as exc:
|
||||
self._send_error(500, str(exc))
|
||||
return
|
||||
self._send(200, {"status": status, "detail": detail})
|
||||
self._send(200, {"status": status, "detail": detail, "request_id": request_id})
|
||||
return
|
||||
if path == "/api/relabel":
|
||||
with self.lock:
|
||||
|
||||
@@ -13,6 +13,7 @@ const state = {
|
||||
scrub: 0,
|
||||
flowSteps: [],
|
||||
answerFeedback: null,
|
||||
pendingSubmit: null,
|
||||
};
|
||||
|
||||
async function getJSON(url, opts) {
|
||||
@@ -36,6 +37,13 @@ async function refreshAll() {
|
||||
state.selectedRunId = 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();
|
||||
}
|
||||
|
||||
@@ -214,6 +222,10 @@ function renderFlow() {
|
||||
el.innerHTML = "";
|
||||
|
||||
if (!run) {
|
||||
if (state.pendingSubmit) {
|
||||
renderPendingFlow(el);
|
||||
return;
|
||||
}
|
||||
const empty = document.createElement("div");
|
||||
empty.className = "muted";
|
||||
empty.textContent = "select a run from the timeline";
|
||||
@@ -233,6 +245,45 @@ function renderFlow() {
|
||||
if (i > state.scrub) node.classList.add("dim");
|
||||
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) {
|
||||
@@ -776,6 +827,12 @@ $("#submit-form").addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const text = $("#query-input").value.trim();
|
||||
if (!text) return;
|
||||
$("#query-input").value = "";
|
||||
state.pendingSubmit = { text, requestId: null };
|
||||
state.selectedRunId = null;
|
||||
state.selectedDecisionId = null;
|
||||
state.scrub = 0;
|
||||
render();
|
||||
try {
|
||||
const res = await getJSON("/api/submit", {
|
||||
method: "POST",
|
||||
@@ -783,10 +840,15 @@ $("#submit-form").addEventListener("submit", async (e) => {
|
||||
body: JSON.stringify({ text }),
|
||||
});
|
||||
flash(`[${res.status}] ${res.detail}`);
|
||||
if (res.request_id) {
|
||||
state.pendingSubmit.requestId = res.request_id;
|
||||
} else {
|
||||
state.pendingSubmit = null;
|
||||
}
|
||||
} catch (err) {
|
||||
flash(`submit failed: ${err.message}`);
|
||||
state.pendingSubmit = null;
|
||||
}
|
||||
$("#query-input").value = "";
|
||||
await refreshAll();
|
||||
});
|
||||
|
||||
|
||||
@@ -317,6 +317,31 @@ select {
|
||||
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 ---------- */
|
||||
|
||||
.right { border-right: none; }
|
||||
|
||||
Reference in new issue
Block a user