108 lines
4.3 KiB
HTML
108 lines
4.3 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<style>
|
|
body { margin: 0; background: transparent; }
|
|
.wrap { padding: 0 0 12px; }
|
|
.banner { display: flex; align-items: center; gap: 6px; border: 1px solid hsl(var(--border)); border-radius: 6px;
|
|
background: hsl(var(--muted) / .3); padding: 8px 12px; font-size: 12px; color: hsl(var(--muted-foreground));
|
|
text-decoration: none; transition: background-color .15s; }
|
|
a.banner { cursor: pointer; }
|
|
a.banner:hover { background: hsl(var(--muted) / .6); }
|
|
.banner svg { width: 14px; height: 14px; flex: none; color: hsl(var(--primary)); }
|
|
.lead { flex: none; font-weight: 600; color: hsl(var(--foreground)); }
|
|
.what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
.on { flex: none; font-size: 11px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
<script>
|
|
/* Handoff — the top of a conversation that continues another one
|
|
* (conversation.threadHeader): "Continued from <its title> · model · harness",
|
|
* a link back. The data is this plugin's own on the conversation
|
|
* (`update.pluginData.from`, written by the `link` action); none → folds away. */
|
|
var A = window.aiAgentPlugin || null;
|
|
var root = document.getElementById("root");
|
|
var HARNESS = { claude: "Claude Code", pi: "pi.dev", opencode: "OpenCode", agy: "Antigravity" };
|
|
|
|
function modelLabel(id) {
|
|
if (!id) return "";
|
|
var tail = String(id).split("/").pop();
|
|
var q = tail.match(/qwen(\d+(?:\.\d+)?)/);
|
|
if (q) return "qwen " + q[1];
|
|
var c = String(id).match(/^claude-([a-z]+)((?:-\d+)*)/);
|
|
if (c) {
|
|
var v = c[2].split("-").filter(function (p) { return /^\d+$/.test(p) && p.length !== 8; }).join(".");
|
|
return v ? c[1] + " " + v : c[1];
|
|
}
|
|
return tail.replace(/-/g, " ");
|
|
}
|
|
function runsOn(model, harness) {
|
|
var h = harness ? (HARNESS[String(harness).toLowerCase()] || String(harness)) : "";
|
|
var m = modelLabel(model);
|
|
return m && h ? m + " · " + h : (m || h);
|
|
}
|
|
var convCid = String((A && A.init && A.init.conversationId) || "");
|
|
var convSid = String((A && A.init && A.init.sessionId) || "");
|
|
var lastSig = null, folded = null;
|
|
function fold() {
|
|
root.textContent = "";
|
|
lastSig = null;
|
|
if (folded !== true) {
|
|
folded = true;
|
|
if (A && A.setEmpty) A.setEmpty(true);
|
|
if (A && A.resize) A.resize(0);
|
|
}
|
|
}
|
|
function draw(f) {
|
|
root.textContent = "";
|
|
var id = f.id || f.sessionId;
|
|
var b = document.createElement(id ? "a" : "div");
|
|
b.className = "banner";
|
|
b.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" ' +
|
|
'stroke-linejoin="round" aria-hidden="true"><polyline points="15 10 20 15 15 20"/><path d="M4 4v7a4 4 0 0 0 4 4h12"/></svg>';
|
|
var lead = document.createElement("span"); lead.className = "lead"; lead.textContent = "Continued from";
|
|
var what = document.createElement("span"); what.className = "what";
|
|
what.textContent = f.title || "another conversation";
|
|
var on = document.createElement("span"); on.className = "on"; on.textContent = runsOn(f.model, f.harness);
|
|
b.appendChild(lead); b.appendChild(what); b.appendChild(on);
|
|
if (id) {
|
|
b.setAttribute("href", "#");
|
|
b.title = f.title || "";
|
|
b.addEventListener("click", function (e) {
|
|
e.preventDefault();
|
|
if (A && A.navigate) A.navigate("/conversation/" + encodeURIComponent(id));
|
|
});
|
|
}
|
|
var w = document.createElement("div"); w.className = "wrap"; w.appendChild(b);
|
|
root.appendChild(w);
|
|
folded = false;
|
|
if (A && A.setEmpty) A.setEmpty(false);
|
|
if (A && A.resize) A.resize(Math.ceil(document.body.scrollHeight));
|
|
}
|
|
function onUpdate(u) {
|
|
u = u && typeof u === "object" ? u : {};
|
|
var ncid = u.conversationId !== undefined ? String(u.conversationId || "") : convCid;
|
|
var nsid = u.sessionId !== undefined ? String(u.sessionId || "") : convSid;
|
|
if (ncid !== convCid || nsid !== convSid) {
|
|
convCid = ncid; convSid = nsid;
|
|
lastSig = null;
|
|
}
|
|
var d = u.pluginData;
|
|
var f = d && d.from;
|
|
if (f && (f.sessionId || f.id)) {
|
|
var sig = JSON.stringify([f.id || "", f.sessionId || "", f.title || "", f.model || "", f.harness || ""]);
|
|
if (sig !== lastSig || folded !== false) { lastSig = sig; draw(f); }
|
|
} else {
|
|
fold();
|
|
}
|
|
}
|
|
if (A && A.onUpdate) A.onUpdate(onUpdate);
|
|
else if (A && A.init && A.init.update) onUpdate(A.init.update);
|
|
else fold();
|
|
</script>
|
|
</body>
|
|
</html>
|