feat(webui): chat from the dashboard

Brings the chat surface to the Web UI: /api/chat with its own handlers
and tests, a self-contained ui/src/chat feature folder, and the shared
plumbing to reach the same router Telegram uses.

Includes a dangerous-command approval path (internal/gateway/dangerous.go,
internal/webui/dangerous.go, and the Telegram counterpart) so /rollback
and /stop are gated the same way on both surfaces, persona handling for
web sessions, and release-update formatting split out of the Telegram
service so both can render it.

web_parity_test.go pins that the two surfaces expose the same commands.

Authored in a parallel session; committed here so it lands with the rest
rather than sitting uncommitted while other work builds on top of it.
task check passes with it in place.

Screenshots used while building are gitignored (*.png) rather than
committed, matching the call made on the earlier design reference.
This commit is contained in:
sam committed 2026-08-05 10:48:51 +10:00
1 parent 8ae21f25db
commit 68ba3456ee
29 files changed
+2616 -112

No files matched your search

+61
View File
@@ -71,6 +71,67 @@ export const api = {
config: () => req("/api/config"),
logs: (params) => req("/api/logs" + qs(params)),
memory: () => req("/api/memory"),
chatSessions: () => req("/api/chat/sessions"),
chatMessages: (id) => req(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
chatCancel: async (sessionID) => {
const res = await fetch("/api/chat/cancel", {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ session_id: sessionID }), signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatMessage: async (channelID, text) => {
const res = await fetch("/api/chat/message", {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ channel_id: channelID, source_id: crypto.randomUUID(), text }),
signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatPersona: async (sessionID, name) => {
const res = await fetch("/api/chat/persona", {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ session_id: sessionID, name }), signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatUpdate: () => req("/api/chat/update"),
chatUpdateDefer: async (snapshot) => {
const res = await fetch("/api/chat/update/defer", {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ snapshot }), signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatUpdateInstall: async (snapshot) => {
const res = await fetch("/api/chat/update/install", {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ snapshot }), signal: AbortSignal.timeout(120000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatDangerous: () => req("/api/chat/dangerous"),
chatDangerousRequest: async (kind, spec) => {
const res = await fetch(`/api/chat/dangerous/${encodeURIComponent(kind)}`, {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ spec }), signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
chatDangerousDecision: async (id, decision) => {
const res = await fetch(`/api/chat/dangerous/${encodeURIComponent(id)}/decision`, {
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({ decision }), signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return res.json();
},
};
/**
+1
View File
@@ -9,6 +9,7 @@
const paths = {
dashboard: '<rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/>',
chat: '<path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4.5 4v-4.1A2.5 2.5 0 0 1 4 12.5z"/><path d="M8 8h8M8 11h5"/>',
tasks: '<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>',
logs: '<path d="M4 5h16M4 10h16M4 15h10M4 20h7"/>',
skills: '<path d="M12 3l2.6 5.6 6.1.8-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6L3.3 9.4l6.1-.8z"/>',