feat(ui): implement explicit chat modes for collaborate, delegate, and vibe coding

This commit is contained in:
2026-05-19 15:18:30 -07:00
parent 096ebc278a
commit 63b64d5fc2

View File

@@ -788,6 +788,7 @@ export function ChatPanel({
const [activeThread, setActiveThread] = useState<string | null>(null); const [activeThread, setActiveThread] = useState<string | null>(null);
const [messages, setMessages] = useState<Message[]>([]); const [messages, setMessages] = useState<Message[]>([]);
const [input, setInput] = useState(""); const [input, setInput] = useState("");
const [chatMode, setChatMode] = useState<"collaborate" | "vibe" | "delegate">("collaborate");
const [sending, setSending] = useState(false); const [sending, setSending] = useState(false);
const [showThreads, setShowThreads] = useState(false); const [showThreads, setShowThreads] = useState(false);
const [mcpToken, setMcpToken] = useState<string | null>(null); const [mcpToken, setMcpToken] = useState<string | null>(null);
@@ -1029,6 +1030,33 @@ export function ChatPanel({
abortRef.current = controller; abortRef.current = controller;
try { try {
// If Delegate mode is selected, route to the background runner instead of streaming chat!
if (chatMode === "delegate") {
const r = await fetch(
`/api/projects/${projectId}/agent/sessions`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
appName: "frontend",
appPath: ".",
task: text,
}),
},
);
if (!r.ok) {
const err = await r.json().catch(() => ({}));
throw new Error(err.error || `HTTP ${r.status}`);
}
setMessages((prev) => [
...prev,
{ role: "assistant", content: "I have started a background runner for this task. You can safely close this browser or work on something else. I will commit and ship the code when I am finished!" },
]);
setSending(false);
return;
}
const res = await fetch("/api/chat", { const res = await fetch("/api/chat", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
@@ -1037,6 +1065,7 @@ export function ChatPanel({
message: text, message: text,
workspace, workspace,
mcp_token: mcpToken, mcp_token: mcpToken,
chatMode,
}), }),
signal: controller.signal, signal: controller.signal,
}); });