Skip to content

Commit 803929d

Browse files
authored
Merge pull request #20 from aimed-lab/fix/copilot-current-network
Copilot: analyze the current network; route analyze→copilot
2 parents 966c620 + d24ac19 commit 803929d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/spinner/web/app.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,10 @@ function isLocalUiCommand(text) {
19831983
// contain a UI keyword ("analyze this network and rank targets…").
19841984
const t = text.trim().toLowerCase();
19851985
if (t.length > 60 || t.includes("?") || t.split(/\s+/).length > 8) return false;
1986-
return /^(show|top|set|use|plan|route|trip|generate|geneterrain|analyze|rescore|filter|layout|dema|force|organic|wiper1|wiper2|raw)\b/.test(t)
1986+
// "analyze", "geneterrain", "rescore" intentionally NOT here — those read as
1987+
// analysis / drug-target / cross-tool intent and belong to the copilot (which
1988+
// can also explain and rank). Only pure UI toggles / routing stay local.
1989+
return /^(show|top|set|use|plan|route|trip|generate|filter|layout|dema|force|organic|wiper1|wiper2)\b/.test(t)
19871990
|| /\btop\s+\d+\b/.test(t) || /\d+\s*%/.test(t) || /\d+\s+(nodes?|edges?|iterations?)\b/.test(t);
19881991
}
19891992

@@ -2001,11 +2004,17 @@ async function runCopilot(text) {
20012004
let bubble = null;
20022005
let removedThinking = false;
20032006
const dropThinking = () => { if (thinking && !removedThinking) { thinking.remove(); removedThinking = true; } };
2007+
// Give the copilot the network currently loaded in the UI, so "analyze the
2008+
// network / this network / the current network" operates on what's on screen.
2009+
const edges = ((els.edgeText && els.edgeText.value) || "").trim();
2010+
const message = edges
2011+
? `[Currently loaded SPINNER network — when I refer to "the network", "this network", or "the current network", call spinner_analyze with exactly these edges:\n${edges}\n]\n\n${text}`
2012+
: text;
20042013
try {
20052014
const resp = await fetch(`${AGENT_BASE}/agent/chat`, {
20062015
method: "POST",
20072016
headers: { "Content-Type": "application/json" },
2008-
body: JSON.stringify({ session_id: AGENT_SESSION, message: text }),
2017+
body: JSON.stringify({ session_id: AGENT_SESSION, message }),
20092018
});
20102019
if (!resp.ok || !resp.body) throw new Error("HTTP " + resp.status);
20112020
const reader = resp.body.getReader();

0 commit comments

Comments
 (0)