Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(web): dashboard chat permission prompts render and resolve
Frank Arena1aeb10cbe741
diff --git a/src/web/api/chat.ts b/src/web/api/chat.tsindex 38a3253a..d20fab72 100644--- a/src/web/api/chat.ts+++ b/src/web/api/chat.ts@@ -200,12 +200,14 @@ chat.post('/api/chat/permission/:id', async (c) => {}const permId = c.req.param('id');- const body = await c.req.json<{ action: string }>();+ const body = await c.req.json<{ action: string; targetId?: string }>();if (!body.action) {return c.json({ error: 'Action required' }, 400);}- const resolved = webChannel.resolveApproval(permId, body.action);+ // Prompts are bound to the chat session that raised them; without the+ // targetId the session check in resolveInteraction always fails.+ const resolved = webChannel.resolveApproval(permId, body.action, body.targetId);if (resolved) {return c.json({ resolved: true });}diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.tsindex bddaab29..496aff7f 100644--- a/ui/src/lib/api.ts+++ b/ui/src/lib/api.ts@@ -113,8 +113,8 @@ export const chat = {update: (data: Partial<ChatSettings>) =>put<ChatSettings>("/api/chat/settings", data),},- permission: (id: string, action: string) =>- post<{ resolved: boolean }>(`/api/chat/permission/${id}`, { action }),+ permission: (id: string, action: string, targetId?: string) =>+ post<{ resolved: boolean }>(`/api/chat/permission/${id}`, { action, targetId }),models: {list: () => get<ModelsResponse>("/api/chat/models"),switch: (provider: string) =>diff --git a/ui/src/pages/Chat.tsx b/ui/src/pages/Chat.tsxindex 91ae6710..ff4ed7ff 100644--- a/ui/src/pages/Chat.tsx+++ b/ui/src/pages/Chat.tsx@@ -110,16 +110,29 @@ function WaitingIndicator() {function PermissionPrompt({data,}: {- data: { id: string; tool?: string; description?: string };+ data: {+ id: string;+ tool?: string;+ description?: string;+ prompt?: string;+ options?: string[];+ targetId?: string;+ };}) {const [resolving, setResolving] = useState(false);+ const [outcome, setOutcome] = useState<string | null>(null);++ // The server offers yes / always / no (see WebChannel.askPermission).+ const options = data.options?.length ? data.options : ["yes", "always", "no"];+ const labels: Record<string, string> = { yes: "Allow", always: "Always allow", no: "Deny" };async function handle(action: string) {setResolving(true);try {- await api.chat.permission(data.id, action);+ const res = await api.chat.permission(data.id, action, data.targetId);+ setOutcome(res.resolved ? labels[action] ?? action : "expired");} catch {- // ignore+ setOutcome("expired");} finally {setResolving(false);}@@ -137,34 +150,38 @@ function PermissionPrompt({Tool: <span className="font-medium text-foreground">{data.tool}</span></p>)}- {data.description && (- <p className="mt-1 text-sm text-foreground">{data.description}</p>+ {(data.description || data.prompt) && (+ <p className="mt-1 whitespace-pre-wrap text-sm text-foreground">+ {data.description ?? data.prompt}+ </p>+ )}+ {outcome ? (+ <p className="mt-3 text-xs text-muted-foreground">+ {outcome === "expired" ? "This request expired or was already answered." : `Answered: ${outcome}`}+ </p>+ ) : (+ <div className="mt-3 flex items-center gap-2">+ {options.map((opt) => (+ <Button+ key={opt}+ size="sm"+ variant={opt === "no" ? "outline" : "default"}+ className="h-7 gap-1 text-xs"+ disabled={resolving}+ onClick={() => handle(opt)}+ >+ {resolving ? (+ <Loader2 className="h-3 w-3 animate-spin" />+ ) : opt === "no" ? (+ <X className="h-3 w-3" />+ ) : (+ <Check className="h-3 w-3" />+ )}+ {labels[opt] ?? opt}+ </Button>+ ))}+ </div>)}- <div className="mt-3 flex items-center gap-2">- <Button- size="sm"- className="h-7 gap-1 text-xs"- disabled={resolving}- onClick={() => handle("allow")}- >- {resolving ? (- <Loader2 className="h-3 w-3 animate-spin" />- ) : (- <Check className="h-3 w-3" />- )}- Allow- </Button>- <Button- size="sm"- variant="outline"- className="h-7 gap-1 text-xs"- disabled={resolving}- onClick={() => handle("deny")}- >- <X className="h-3 w-3" />- Deny- </Button>- </div></div></div>);@@ -703,7 +720,7 @@ export function ChatPage() {if (msg.role === "system") {try {const parsed = JSON.parse(msg.content);- if (parsed.id && (parsed.tool || parsed.description)) {+ if (parsed.id && (parsed.tool || parsed.description || parsed.prompt)) {return <PermissionPrompt key={msg.id} data={parsed} />;}} catch {