Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
0.6.13 mobile cards: approval, question, live line, engine chip, inline code (C1–C5, A3) (#309)
Oleksandr Ivanchenkoe13601cde0d7
diff --git a/frontend/src/approvals.ts b/frontend/src/approvals.tsindex 1de535bc..cb6fc01d 100644--- a/frontend/src/approvals.ts+++ b/frontend/src/approvals.ts@@ -2,7 +2,7 @@// reconnect, by `GET /api/away`'s waiting items, so a card never depends on the page having been// open when the bot asked. Pure helpers, shared by the app and the node tests.-import type { PendingApproval } from './components/ModernApprovalCard';+import { approvalAction, type PendingApproval } from './components/ModernApprovalCard';import type { AwayItem, AwayLink } from './away';/** A card plus where it belongs: the asking bot and, when the server knows it, the conversation. */@@ -16,7 +16,7 @@ const str = (v: unknown) => (typeof v === 'string' && v ? v : null);/** From the live SSE event's data. */export function approvalFromEvent(data: { id: string; tool_name: string; details?: Record<string, unknown> }): ChatApproval {const details = data.details ?? {};- return { id: data.id, tool_name: data.tool_name, details, kwant_id: str(details.kwant_id), link: null };+ return { id: data.id, tool_name: data.tool_name, details, kwant_id: str(details.kwant_id), link: null, asked_at: new Date().toISOString() };}/**@@ -34,9 +34,20 @@ export function approvalFromAway(item: AwayItem): ChatApproval {const link = item.link && (item.link.thread_id || item.link.channel_id || item.link.direct_kwant_id) ? item.link : null;const approval: ChatApproval = { id: item.id, tool_name: tool, details, kwant_id: item.kwant_id || str(details.kwant_id), link };if (item.status === 'waiting') approval.waiting = true;+ if (str(item.timestamp)) approval.asked_at = item.timestamp;return approval;}+/**+ * An Inbox item's title in words. An approval reads like its card ("Open a pull request on+ * GitHub"), never the server's raw "Use create_pull_request (github)"; other items keep theirs.+ */+export function awayTitle(item: AwayItem): string {+ if (item.kind !== 'approval') return item.title;+ const action = approvalAction(approvalFromAway(item));+ return action.charAt(0).toUpperCase() + action.slice(1);+}+/*** What to tell the person after they answered a card. A late Allow on a still-open card starts* the bot again (`resumed: "new_turn"`); otherwise null (nothing worth saying).diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsxindex cfa6ac9d..86a1123a 100644--- a/frontend/src/components/ActivityList.tsx+++ b/frontend/src/components/ActivityList.tsx@@ -11,13 +11,14 @@ import {statusLabel,thinkingText,} from '../activity';+import { readableStepTitle } from '../toolLabel';/** "Running `cargo test`" with the quoted part in mono. */const Title: React.FC<{ text: string }> = ({ text }) => (<>{text.split(/(`[^`]*`)/g).map((part, i) =>part.startsWith('`') && part.endsWith('`') && part.length > 1 ? (- <code key={i} className="font-mono text-[11px] px-1 py-px rounded bg-zinc-800/80 text-zinc-100 break-all">+ <code key={i} className="font-mono text-[11px] px-1 py-px rounded bg-zinc-800/80 text-zinc-100 [overflow-wrap:anywhere] [box-decoration-break:clone] [-webkit-box-decoration-break:clone]">{part.slice(1, -1)}</code>) : (@@ -123,7 +124,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;<><StatusIcon step={step} /><span className={`min-w-0 flex-1 break-words ${step.status === 'stopped' ? 'text-zinc-400' : waiting ? 'text-amber-100' : 'text-zinc-200'}`}>- {step.kind === 'thinking' ? (running ? 'Thinking…' : 'Thought') : <Title text={step.title} />}+ {step.kind === 'thinking' ? (running ? 'Thinking…' : 'Thought') : <Title text={readableStepTitle(step.title)} />}</span>{time && <span className="flex-shrink-0 font-mono text-[10px] text-zinc-400 tabular-nums">{time}</span>}</>@@ -190,12 +191,75 @@ const Steps: React.FC<{ steps: ActivityStep[]; live?: LiveActivity; dropped?: nu);};-/** While the bot works: every step so far, newest last. */-export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string }> = ({ live, idBase }) => {+/**+ * While the bot works: every step so far, newest last. `compact` (phone, 0.6.13 spec C2) folds it to+ * one 44 px row, "Steps · 2 ▸", that opens to the same list; the engine's note (what it can't show of+ * its thinking) moves behind an ⓘ in that row, since the working strip already says the bot works.+ */+export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string; compact?: boolean }> = ({ live, idBase, compact = false }) => {const { steps } = live;+ const [open, setOpen] = useState(false);+ const [noteOpen, setNoteOpen] = useState(false);if (steps.length === 0) return null;const work = steps.filter((s) => s.kind !== 'note').length;const current = [...steps].reverse().find(isOpenStep);+ // Only waits are announced; a stream of tool names would be noise.+ const announce = (+ <p className="sr-only" role="status" aria-live="polite">+ {current?.status === 'waiting' ? readableStepTitle(plainTitle(current.title)) : ''}+ </p>+ );+ if (compact) {+ const notes = steps.filter((s) => s.kind === 'note');+ const workSteps = steps.filter((s) => s.kind !== 'note');+ const listId = `${idBase}-live`;+ const noteId = `${idBase}-note`;+ return (+ <section aria-label="What the bot is doing" data-steps-compact="" className="mb-2 w-full max-w-2xl rounded-xl border border-zinc-700/60 bg-zinc-900/60 overflow-hidden">+ <div className="flex items-center">+ <button+ type="button"+ onClick={() => setOpen((o) => !o)}+ aria-expanded={open}+ aria-controls={open ? listId : undefined}+ disabled={work === 0}+ className="min-w-0 flex-1 flex items-center gap-2 min-h-[44px] px-3 text-left text-sm text-zinc-300 disabled:cursor-default focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b8adff]"+ >+ <ListTree size={14} className="shrink-0 text-sky-400/80" aria-hidden="true" />+ <span className="truncate">Steps · {work}</span>+ {work > 0 && (+ <ChevronRight size={14} className={`shrink-0 text-zinc-400 transition-transform duration-150 motion-reduce:transition-none ${open ? 'rotate-90' : ''}`} aria-hidden="true" />+ )}+ </button>+ {notes.length > 0 && (+ <button+ type="button"+ onClick={() => setNoteOpen((o) => !o)}+ aria-expanded={noteOpen}+ aria-controls={noteOpen ? noteId : undefined}+ aria-label="About this engine's steps"+ className="shrink-0 inline-flex items-center justify-center w-11 h-11 text-zinc-400 hover:text-zinc-200 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b8adff]"+ >+ <Info size={16} aria-hidden="true" />+ </button>+ )}+ </div>+ {announce}+ {noteOpen && notes.length > 0 && (+ <div id={noteId} className="border-t border-zinc-700/40 px-3 py-2 space-y-1 text-xs leading-5 text-zinc-400">+ {notes.map((n) => (+ <p key={n.id} className="break-words">{n.title}</p>+ ))}+ </div>+ )}+ {open && work > 0 && (+ <div className="border-t border-zinc-700/40 max-h-[22rem] overflow-y-auto">+ <Steps steps={workSteps} live={live} id={listId} />+ </div>+ )}+ </section>+ );+ }return (<section aria-label="What the bot is doing" className="mb-2 w-full max-w-2xl rounded-xl border border-zinc-700/60 bg-zinc-900/60 overflow-hidden shadow-[var(--kws-shadow)]"><p className="flex items-center gap-1.5 px-3 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-zinc-400">@@ -206,10 +270,7 @@ export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string }>· {work} {work === 1 ? 'step' : 'steps'}</span></p>- {/* Only waits are announced; a stream of tool names would be noise. */}- <p className="sr-only" role="status" aria-live="polite">- {current?.status === 'waiting' ? plainTitle(current.title) : ''}- </p>+ {announce}<div className="max-h-[22rem] overflow-y-auto"><Steps steps={steps} live={live} id={`${idBase}-live`} /></div>diff --git a/frontend/src/components/AwayView.tsx b/frontend/src/components/AwayView.tsxindex 0dacf9fc..d44a1b9e 100644--- a/frontend/src/components/AwayView.tsx+++ b/frontend/src/components/AwayView.tsx@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';import { AlertTriangle, CheckCircle2, ChevronLeft, Inbox, Loader2, RefreshCw } from 'lucide-react';import { ModernAvatar } from './ModernAvatar';import { ModernApprovalCard } from './ModernApprovalCard';-import { approvalFromAway, lateAnswerText } from '../approvals';+import { approvalFromAway, awayTitle, lateAnswerText } from '../approvals';import {AWAY_SECTIONS,ApprovalDecision,@@ -62,13 +62,14 @@ export const AwayView: React.FC<AwayViewProps> = ({ data, loading, error, noticeconst { label, tone } = itemLabel(item);const when = relativeTime(item.timestamp, now);const disabled = busy !== null;+ const title = awayTitle(item);return (<li key={`${item.kind}:${item.id}`} className="rounded-xl border border-zinc-800 bg-zinc-900/60 hover:border-zinc-700 transition-colors"><buttontype="button"onClick={() => onOpen(item)}className="w-full flex items-start gap-3 p-3 text-left rounded-xl focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"- aria-label={`${item.title}, ${label}, from ${item.kwant_name}, ${when}. Open the chat.`}+ aria-label={`${title}, ${label}, from ${item.kwant_name}, ${when}. Open the chat.`}><ModernAvatar role={item.kwant_name} name={item.kwant_name} size={30} kwantId={item.kwant_id} /><div className="flex-1 min-w-0">@@ -79,14 +80,15 @@ export const AwayView: React.FC<AwayViewProps> = ({ data, loading, error, notice{when}</time></div>- <p className="mt-0.5 text-sm font-medium text-zinc-100 truncate">{item.title}</p>+ {/* The question is the point of the card: up to 3 lines on a phone (0.6.13 spec C3), one line on desktop. */}+ <p className="mt-0.5 text-sm font-medium text-zinc-100 break-words max-md:line-clamp-6 md:truncate">{title}</p>{/* A question's summary just lists its choices, which are buttons below. */}{awaySummary(item) && item.kind !== 'approval' && !(item.kind === 'question' && item.choices?.length) && <p className="text-xs text-zinc-400 truncate">{awaySummary(item)}</p>}</div></button>{item.kind === 'question' && (item.choices?.length ?? 0) > 0 && (- <div role="group" aria-label={`Answer: ${item.title}`} className="px-3 pb-3 sm:pl-[54px] flex flex-wrap gap-2">+ <div role="group" aria-label={`Answer: ${title}`} className="px-3 pb-3 sm:pl-[54px] flex flex-wrap gap-2">{item.choices!.map((c, i) => (<buttonkey={i}@@ -284,10 +286,10 @@ export const AwayPage: React.FC<AwayPageProps> = ({ since = null, onSince, onOpesetData((d) => (d ? withoutItem(d, 'waiting', item.id) : d));const late = item.kind === 'approval' && !denied ? lateAnswerText(reply, item.kwant_name) : null;const done = denied ? 'Denied, nothing ran:' : late ?? `Sent to ${item.kwant_name}:`;- setNotice({ text: `${done} “${item.title}”`, error: false });+ setNotice({ text: `${done} “${awayTitle(item)}”`, error: false });} catch (err) {const status = err instanceof AwayError ? err.status : 0;- setNotice(actionFailureNotice(status, err instanceof Error ? err.message : 'Something went wrong.', item.title));+ setNotice(actionFailureNotice(status, err instanceof Error ? err.message : 'Something went wrong.', awayTitle(item)));} finally {setBusy(null);}diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex 01a092e2..0aef2fb2 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -59,6 +59,7 @@ import { RouteChoiceMeta, parseRouteChoiceMeta, questionsOfReplies } from '../roimport { SmartActionsSlot, actionClass } from './results/SmartActions';import { WorkingStrip } from './WorkingStrip';import { ScrollRow } from './ScrollRow';+import { waitingOn } from '../workingStrip';import { COMPOSE_PREFILL_EVENT, withPrefill } from './results/SmartResult';import { FilesPreviewOnly } from './results/Files';import { ReactionButtons, ReplyButton, ReplyChip, ReplyQuote } from './MessageReactions';@@ -626,6 +627,18 @@ export const ChatView: React.FC<ChatViewProps> = ({}checkApprovalVisible();};+ // Phone (0.6.13 spec A3/C2): the working strip is the one live line, so the stream drops what repeats it.+ // (`phone` is the A1 PHONE_QUERY flag above).+ const stripWaitsOn = isStreaming ? waitingOn({ live: liveActivity, queued: !!queued, awaitingAnswer: !!awaitingAnswer, awaitingBrowser: !!awaitingBrowser }) : null;+ // The strip's "Answer ↑": the open question card, else the approval card, fully in view.+ const showWaitingCard = (on: 'question' | 'approval') => {+ if (on === 'approval') return showApproval();+ const cards = scrollRef.current?.querySelectorAll<HTMLElement>('[data-question-card="open"]');+ const card = cards?.[cards.length - 1];+ if (!card) return;+ const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;+ card.scrollIntoView({ block: 'nearest', behavior: reduce ? 'auto' : 'smooth' });+ };const showApproval = () => {const cards = scrollRef.current?.querySelectorAll<HTMLElement>('[data-approval-card]');const card = cards?.[cards.length - 1];@@ -1573,7 +1586,7 @@ export const ChatView: React.FC<ChatViewProps> = ({<span className="w-1.5 h-1.5 rounded-full bg-amber-300" aria-hidden="true" />Queued</span>- ) : awaitingAnswer ? (+ ) : awaitingAnswer && !phone ? (<span className="inline-flex items-center gap-1 text-amber-300 text-[10px]"><span className="w-1.5 h-1.5 rounded-full bg-amber-300" aria-hidden="true" />{awaitingBrowser ? 'Waiting for you in the browser' : 'Waiting for your answer'}@@ -1588,7 +1601,7 @@ export const ChatView: React.FC<ChatViewProps> = ({{liveNote && <FailoverNote text={liveNote} />}- {liveActivity && <LiveActivityList live={liveActivity} idBase={`live-${liveActivity.turnId}`} />}+ {liveActivity && <LiveActivityList live={liveActivity} idBase={`live-${liveActivity.turnId}`} compact={phone} />}{streamingThinking && (<div className="mb-2 p-2.5 rounded-xl bg-violet-950/20 border border-violet-500/20 text-xs text-violet-300/90 flex items-center gap-2 animate-pulse motion-reduce:animate-none max-w-full">@@ -1597,6 +1610,8 @@ export const ChatView: React.FC<ChatViewProps> = ({</div>)}+ {/* On a phone the strip says "working" and "waiting": no skeleton, no "Paused on…" bubble. */}+ {(!phone || queued || streamingText) && (<div className="p-4 sm:p-5 min-h-[3.5rem] rounded-2xl rounded-tl-sm bg-zinc-900/60 text-zinc-200 border border-zinc-800/80 text-sm leading-relaxed shadow-sm w-full">{queued ? (<p className="text-zinc-300" role="status">@@ -1621,6 +1636,7 @@ export const ChatView: React.FC<ChatViewProps> = ({</div>)}</div>+ )}</div></div>)}@@ -1663,6 +1679,7 @@ export const ChatView: React.FC<ChatViewProps> = ({awaitingAnswer={!!awaitingAnswer}awaitingBrowser={!!awaitingBrowser}writing={!!streamingText}+ onAnswer={showWaitingCard}/>{/* Modern Composer Input Bar */}@@ -1698,7 +1715,8 @@ export const ChatView: React.FC<ChatViewProps> = ({</ScrollRow>)}- {approvalOffscreen && pendingApprovals.length > 0 && (+ {/* On a phone the strip's "Answer ↑" stands in for this pill while the bot waits on the card. */}+ {approvalOffscreen && pendingApprovals.length > 0 && !(phone && stripWaitsOn === 'approval') && (<div role="status" className="max-w-4xl mx-auto mb-2 flex justify-center"><buttontype="button"diff --git a/frontend/src/components/MarkdownRenderer.tsx b/frontend/src/components/MarkdownRenderer.tsxindex 7b9c1675..9b80a336 100644--- a/frontend/src/components/MarkdownRenderer.tsx+++ b/frontend/src/components/MarkdownRenderer.tsx@@ -182,7 +182,9 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({// Pre element pass-through to let CodeBlock handle layoutpre: ({ children }) => <>{children}</>,- // Code rendering: CodeBlock for blocks, styled pill for inline+ // Code rendering: CodeBlock for blocks, styled pill for inline. A long inline run (a 46-character+ // identifier, `--test-threads=1`) may break anywhere rather than run past the bubble, and each+ // wrapped line keeps its own padding and radius (clone) instead of one box cut in two.code: ({ className: codeClassName, children, ...props }) => {const match = /language-(\w+)/.exec(codeClassName || '');const strVal = String(children).replace(/\n$/, '');@@ -199,7 +201,7 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({return (<code- className="px-1.5 py-0.5 rounded-md font-mono text-[12px] bg-zinc-800/80 text-sky-300 border border-zinc-700/50"+ className="px-1.5 py-0.5 rounded-md font-mono text-[12px] bg-zinc-800/80 text-sky-300 border border-zinc-700/50 [overflow-wrap:anywhere] [box-decoration-break:clone] [-webkit-box-decoration-break:clone]"{...props}>{children}diff --git a/frontend/src/components/ModernApprovalCard.tsx b/frontend/src/components/ModernApprovalCard.tsxindex 51b8a026..3a0e7a8d 100644--- a/frontend/src/components/ModernApprovalCard.tsx+++ b/frontend/src/components/ModernApprovalCard.tsx@@ -1,8 +1,11 @@-import React from 'react';-import { ShieldAlert, Check, CheckCheck, X, Plug, FileText, Terminal, Clock, CreditCard, GraduationCap } from 'lucide-react';+import React, { useId, useState } from 'react';+import { ShieldAlert, Check, CheckCheck, X, FileText, Clock, CreditCard, GraduationCap, ChevronDown } from 'lucide-react';import { playSfx } from '../audio/chiptune';-import { formatArgs, humanizeToolName, parseMcpToolName } from '../mcp';+import { formatArgs, parseMcpToolName } from '../mcp';import { tierReason } from '../flightSchool';+import { toolAction } from '../toolLabel';+import { localClock } from '../clock';+import { isPhoneLayout } from '../layout';export interface PendingApproval {id: string;@@ -13,6 +16,8 @@ export interface PendingApproval {* starts the bot again to make that call, Deny closes it.*/waiting?: boolean;+ /** When the bot asked (ISO time), for the card's header; left out when unknown. */+ asked_at?: string;}interface ModernApprovalCardProps {@@ -20,6 +25,8 @@ interface ModernApprovalCardProps {onResolve: (id: string, decision: 'allow_once' | 'always_allow' | 'deny') => void;/** While an answer is being sent. */disabled?: boolean;+ /** Forces the phone or desktop look (tests); by default it follows the window when the card appears. */+ phone?: boolean;}/** Server/tool/arguments of an MCP approval, or null for other tools. */@@ -32,9 +39,30 @@ const mcpView = (approval: PendingApproval) => {tool: typeof d.tool === 'string' ? d.tool : fromName?.tool ?? approval.tool_name,kwant: typeof d.kwant_name === 'string' ? d.kwant_name : null,args: formatArgs(d.arguments),+ raw: d.arguments,};};+/** Arguments worth a line of their own on the card, in this order (0.6.13 spec C1). */+const KEY_FACTS = ['title', 'name', 'path', 'url', 'repo', 'command'];++/**+ * Up to two short "key: value" lines from a tool's arguments, so the card says what the call is+ * about without opening the details. Only text and numbers; everything else stays in the details.+ */+export function keyFacts(args: unknown, max = 2): Array<[string, string]> {+ if (!args || typeof args !== 'object' || Array.isArray(args)) return [];+ const a = args as Record<string, unknown>;+ const out: Array<[string, string]> = [];+ for (const k of KEY_FACTS) {+ const v = a[k];+ const text = typeof v === 'string' ? v.trim() : typeof v === 'number' ? String(v) : '';+ if (text) out.push([k, text]);+ if (out.length >= max) break;+ }+ return out;+}+/** Command and folder of a kwant shell command on this computer, or null for other tools. */export const localShellView = (approval: PendingApproval) => {const d = approval.details ?? {};@@ -107,10 +135,56 @@ export const paymentReason = (approval: PendingApproval) => {export const waitingNote = (bot: string | null) =>`${bot ?? 'The bot'} stopped waiting for an answer and nothing ran. Allow starts it again to make this call; Deny closes the card.`;+/**+ * What the bot asks to do, in words, after "<Bot> wants to": "open a pull request on GitHub".+ * The card's sentence and the Inbox title both use it, so they always say the same thing.+ */+export function approvalAction(approval: PendingApproval): string {+ if (localShellView(approval)) return 'run a command on your computer';+ const mcp = mcpView(approval);+ const builtin = mcp ? null : builtinView(approval);+ if (builtin?.kind === 'shell') return 'run a command';+ if (builtin?.kind === 'file') return `${builtin.tool === 'Write' ? 'write a file' : 'change a file'}${builtin.outsideFolder ? ' outside its own folder' : ''}`;+ if (builtin) return toolAction(builtin.tool);+ const summary = summaryView(approval);+ if (summary) return toolAction(summary.tool);+ return mcp ? toolAction(mcp.tool, mcp.server || null) : toolAction(approval.tool_name);+}++/** The pre/JSON style inside a card: wraps between words, and only splits a word too long for the line. */+/** "Show details": closed on a phone, so Allow is on screen with the card's top; open on desktop. */+const ApprovalDetails: React.FC<{ phone?: boolean; children: React.ReactNode }> = ({ phone, children }) => {+ const [open, setOpen] = useState(() => !(phone ?? isPhoneLayout()));+ const id = useId();+ return (+ <div className="mt-1.5">+ <button+ type="button"+ aria-expanded={open}+ aria-controls={id}+ onClick={() => setOpen((o) => !o)}+ data-approval-details-toggle=""+ className="-ml-2 inline-flex items-center gap-1 min-h-[44px] sm:min-h-[32px] px-2 rounded-lg text-sm text-[#a39dcc] hover:text-zinc-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#b8adff]"+ >+ {open ? 'Hide details' : 'Show details'}+ <ChevronDown size={14} aria-hidden="true" className={`transition-transform motion-reduce:transition-none ${open ? 'rotate-180' : ''}`} />+ </button>+ {open && (+ <div id={id} className="mt-1 space-y-1.5" data-approval-details="">+ {children}+ </div>+ )}+ </div>+ );+};++const PRE = 'font-mono text-xs leading-[18px] whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-[240px] overflow-y-auto rounded-md border border-zinc-800 bg-zinc-950/70 p-2';+export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({approval,onResolve,disabled = false,+ phone,}) => {const handleDecision = (decision: 'allow_once' | 'always_allow' | 'deny') => {if (disabled) return;@@ -122,12 +196,71 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({const builtin = shell || mcp ? null : builtinView(approval);const summary = summaryView(approval);const name = builtin?.kwant ?? summary?.kwant;- const who = name ? <span className="font-medium text-zinc-100">{name}</span> : 'A bot';const perSession = !!builtin || !!summary?.builtin;const waiting = approval.waiting === true;const botName = name ?? mcp?.kwant ?? null;const payment = paymentReason(approval);const tier = payment ? null : tierReason(approval.details);+ const time = localClock(approval.asked_at);+ const offerAlways = !shell && !waiting && !payment;++ const bot = botName ? <strong className="font-semibold text-zinc-50">{botName}</strong> : 'A bot';+ // "<Bot> wants to open a pull request on <Server>", the server in bold.+ const action = approvalAction(approval);+ const on = mcp && !summary ? / on (.+)$/.exec(action) : null;+ const what: React.ReactNode = on ? <>{action.slice(0, on.index)} on <strong className="font-semibold text-zinc-50">{on[1]}</strong></> : action;++ const facts: Array<[string, string]> = mcp+ ? keyFacts(mcp.raw)+ : builtin?.kind === 'file' && builtin.path+ ? [['path', builtin.path]]+ : builtin && 'args' in builtin+ ? keyFacts((approval.details?.arguments ?? approval.details?.input) as unknown)+ : [];++ // What the details disclosure holds: the raw call, for the person who wants to check it.+ const details: React.ReactNode = shell ? (+ shell.cwd ? (+ <p className="text-xs leading-[18px] text-[#a39dcc] break-words [overflow-wrap:anywhere]">+ In folder: <span className="font-mono text-zinc-200">{shell.cwd}</span>+ </p>+ ) : null+ ) : summary ? (+ summary.summary ? <p className="text-xs leading-[18px] text-zinc-300 break-words">{summary.summary}</p> : null+ ) : builtin?.kind === 'shell' ? (+ builtin.cwd ? (+ <p className="text-xs leading-[18px] text-[#a39dcc] break-words [overflow-wrap:anywhere]">+ In folder: <span className="font-mono text-zinc-200">{builtin.cwd}</span>+ </p>+ ) : null+ ) : builtin?.kind === 'file' ? (+ <p className="text-xs leading-[18px] text-zinc-300 break-words">+ {builtin.change}+ {builtin.cwd && (+ <>+ {' · '}+ <span className="text-[#a39dcc]">Its folder:</span> <span className="font-mono text-zinc-200 [overflow-wrap:anywhere]">{builtin.cwd}</span>+ </>+ )}+ </p>+ ) : builtin ? (+ 'args' in builtin && builtin.args ? <pre className={`${PRE} text-zinc-300`}>{builtin.args}</pre> : <p className="text-xs text-zinc-500">No arguments.</p>+ ) : mcp ? (+ <>+ <p className="font-mono text-xs leading-[18px] text-zinc-500 break-words [overflow-wrap:anywhere]">+ {mcp.server} · {mcp.tool}+ </p>+ {mcp.args ? <pre className={`${PRE} text-zinc-300`}>{mcp.args}</pre> : <p className="text-xs text-zinc-500">No arguments.</p>}+ </>+ ) : (+ <>+ <p className="font-mono text-xs leading-[18px] text-zinc-500 break-words [overflow-wrap:anywhere]">{approval.tool_name}</p>+ <pre className={`${PRE} text-zinc-300`}>{JSON.stringify(approval.details, null, 2)}</pre>+ </>+ );++ const secondary =+ 'inline-flex items-center justify-center gap-1.5 min-h-[44px] sm:min-h-[36px] px-3 rounded-lg border border-[#3f3868] bg-[#231d4b] text-sm font-medium text-[#ecebfa] hover:bg-[#2c2552] transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b8adff] disabled:opacity-50 disabled:cursor-not-allowed';return (<div@@ -136,185 +269,110 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({waiting ? 'border-sky-500/30 bg-sky-950/20' : 'border-amber-500/30 bg-amber-950/20'}`}>- {waiting ? (- <div className="mb-2 space-y-1">- <div className="flex items-center gap-2 text-sky-300 font-semibold text-xs tracking-wide">- <Clock size={16} aria-hidden="true" />- <span>Still open: you can still Allow</span>- </div>- <p className="text-[11px] text-zinc-400">{waitingNote(botName)}</p>- </div>- ) : (- <div className="flex items-center gap-2 mb-2 text-amber-400 font-semibold text-xs tracking-wide">- <ShieldAlert size={16} />- <span>Action Approval Required</span>- </div>+ <div className="flex items-center gap-2.5" data-approval-header="">+ <span+ className={`shrink-0 inline-flex h-7 w-7 items-center justify-center rounded-full ${waiting ? 'bg-sky-500/15 text-sky-300' : 'bg-amber-500/15 text-amber-400'}`}+ aria-hidden="true"+ >+ {waiting ? <Clock size={16} /> : <ShieldAlert size={16} />}+ </span>+ <h3 className="min-w-0 flex-1 text-[15px] leading-5 font-semibold text-zinc-50">{waiting ? 'Still open: you can still allow' : 'Approval needed'}</h3>+ {time && (+ <time dateTime={approval.asked_at} className="shrink-0 text-xs leading-4 text-[#a39dcc] tabular-nums">+ {time}+ </time>+ )}+ </div>+ {waiting && <p className="mt-1.5 text-xs leading-[18px] text-zinc-400">{waitingNote(botName)}</p>}++ <p className="mt-2.5 text-base leading-6 text-zinc-200 break-words" data-approval-summary="">+ {bot} wants to {what}+ </p>++ {(shell || builtin?.kind === 'shell') && (+ <>+ {builtin?.kind === 'shell' && builtin.description && <p className="mt-1 text-sm leading-5 text-zinc-400 break-words">{builtin.description}</p>}+ <pre className={`${PRE} mt-2 text-zinc-100`} aria-label="Command">+ {(shell ? shell.command : builtin?.command) || '(empty command)'}+ </pre>+ </>+ )}++ {facts.length > 0 && (+ <dl className="mt-2 space-y-1" data-approval-facts="">+ {facts.map(([k, v]) => (+ <div key={k} className="flex gap-2 text-sm leading-5 min-w-0">+ <dt className="shrink-0 text-[#a39dcc]">+ {builtin?.kind === 'file' && <FileText size={12} className="inline mr-1 -mt-0.5" aria-hidden="true" />}+ {k}+ </dt>+ <dd className="min-w-0 text-[#ecebfa] break-words [overflow-wrap:anywhere] line-clamp-2" title={v}>+ {v}+ </dd>+ </div>+ ))}+ </dl>)}{payment && (- <div role="note" className="flex items-start gap-2 mb-2 rounded-lg border border-rose-500/30 bg-rose-950/30 px-3 py-2 text-xs">+ <div role="note" className="flex items-start gap-2 mt-2.5 rounded-lg border border-rose-500/30 bg-rose-950/30 px-3 py-2 text-sm leading-5"><CreditCard size={14} className="mt-0.5 shrink-0 text-rose-300" aria-hidden="true" /><div className="min-w-0 space-y-0.5"><p className="text-rose-100 break-words"><span className="font-semibold">This looks like a payment:</span> {payment}.</p>- <p className="text-[11px] text-zinc-400">Payments always ask you, even with approvals off. Allowing covers this one payment.</p>+ <p className="text-xs leading-[18px] text-zinc-400">Payments always ask you, even with approvals off. Allowing covers this one payment.</p></div></div>)}{tier && (- <div role="note" data-tier-reason className="flex items-start gap-2 mb-2 rounded-lg border border-sky-500/30 bg-sky-950/30 px-3 py-2 text-xs">+ <div role="note" data-tier-reason className="flex items-start gap-2 mt-2.5 rounded-lg border border-sky-500/30 bg-sky-950/30 px-3 py-2 text-sm leading-5"><GraduationCap size={14} className="mt-0.5 shrink-0 text-sky-300" aria-hidden="true" /><div className="min-w-0 space-y-0.5"><p className="text-sky-100 break-words"><span className="font-semibold">Flight School:</span> {tier}.</p>- <p className="text-[11px] text-zinc-400">This bot’s tier asks you here, even with approvals off.</p>- </div>- </div>- )}-- {shell ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="text-zinc-300">A bot wants to run a command on your computer.</p>- <pre className="font-mono text-[11px] text-zinc-100 bg-zinc-950/70 border border-zinc-800 rounded-md p-2 whitespace-pre-wrap break-all max-h-64 overflow-y-auto">- {shell.command || '(empty command)'}- </pre>- {shell.cwd && (- <p className="text-[11px] text-zinc-400 break-all">- <span className="text-zinc-500">In folder:</span> <span className="font-mono text-zinc-300">{shell.cwd}</span>- </p>- )}- </div>- ) : summary ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="text-zinc-300">- {who} wants to use <span className="font-medium text-sky-200">{summary.tool}</span>.- </p>- {summary.summary && <p className="text-[11px] text-zinc-400 break-words">{summary.summary}</p>}- </div>- ) : builtin?.kind === 'shell' ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="flex items-center gap-1.5 text-zinc-300">- <Terminal size={13} className="shrink-0 text-sky-400" aria-hidden="true" />- <span>{who} wants to run a command.</span>- </p>- {builtin.description && <p className="text-zinc-400 break-words">{builtin.description}</p>}- <pre className="font-mono text-[11px] text-zinc-100 bg-zinc-950/70 border border-zinc-800 rounded-md p-2 whitespace-pre-wrap break-all max-h-64 overflow-y-auto">- {builtin.command || '(empty command)'}- </pre>- {builtin.cwd && (- <p className="text-[11px] text-zinc-400 break-all">- <span className="text-zinc-500">In folder:</span> <span className="font-mono text-zinc-300">{builtin.cwd}</span>- </p>- )}- </div>- ) : builtin?.kind === 'file' ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="flex items-center gap-1.5 text-zinc-300">- <FileText size={13} className="shrink-0 text-sky-400" aria-hidden="true" />- <span>- {who} wants to {builtin.tool === 'Write' ? 'write a file' : 'change a file'}- {builtin.outsideFolder ? ' outside its own folder' : ''}.- </span>- </p>- <p className="font-mono text-[11px] text-zinc-100 bg-zinc-950/70 border border-zinc-800 rounded-md p-2 break-all">- {builtin.path || '(no file given)'}- </p>- <p className="text-[11px] text-zinc-400 break-words">- {builtin.change}- {builtin.cwd && (- <>- {' · '}- <span className="text-zinc-500">Its folder:</span> <span className="font-mono text-zinc-300 break-all">{builtin.cwd}</span>- </>- )}- </p>- </div>- ) : builtin ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="text-zinc-300">- {who} wants to use <span className="font-medium text-sky-200">{builtin.tool}</span>.- </p>- {'args' in builtin && builtin.args ? (- <pre className="font-mono text-[11px] text-zinc-300 bg-zinc-950/70 border border-zinc-800 rounded-md p-2 whitespace-pre-wrap break-all max-h-48 overflow-y-auto">- {builtin.args}- </pre>- ) : (- <p className="text-[11px] text-zinc-500">No arguments.</p>- )}- </div>- ) : mcp ? (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3">- <p className="text-zinc-300">- {mcp.kwant ? <span className="font-medium text-zinc-100">{mcp.kwant}</span> : 'A bot'} wants to use{' '}- <span className="font-medium text-sky-200">{humanizeToolName(mcp.tool)}</span>- {mcp.server && (- <>- {' '}from <span className="inline-flex items-center gap-1 font-medium text-zinc-100"><Plug size={11} className="text-sky-400" />{mcp.server}</span>- </>- )}- .- </p>- <p className="font-mono text-[11px] text-zinc-500">- {mcp.server} · {mcp.tool}- </p>- {mcp.args ? (- <pre className="font-mono text-[11px] text-zinc-300 bg-zinc-950/70 border border-zinc-800 rounded-md p-2 whitespace-pre-wrap break-all max-h-48 overflow-y-auto">- {mcp.args}- </pre>- ) : (- <p className="text-[11px] text-zinc-500">No arguments.</p>- )}- </div>- ) : (- <div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs font-mono space-y-1 mb-3">- <div className="text-zinc-400">- <span className="text-sky-400 font-semibold">Tool:</span> {approval.tool_name}- </div>- <div className="text-zinc-300 break-all overflow-x-auto max-h-36 py-1">- {JSON.stringify(approval.details, null, 2)}+ <p className="text-xs leading-[18px] text-zinc-400">This bot’s tier asks you here, even with approvals off.</p></div></div>)}- <div data-approval-actions className="flex flex-wrap items-center justify-end gap-2">- <button- type="button"- disabled={disabled}- onClick={() => handleDecision('deny')}- className="flex items-center gap-1.5 px-3 py-1.5 min-h-[40px] sm:min-h-0 rounded-lg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-400 text-xs font-medium text-zinc-300 bg-zinc-800 hover:bg-zinc-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"- >- <X size={14} />- <span>Deny</span>- </button>+ {details && <ApprovalDetails phone={phone}>{details}</ApprovalDetails>}+ {/* Allow on a row of its own, first; Deny and Always allow share the row under it. On a wider+ screen they sit in one row, right-aligned, with Allow last. Local shell approvals are never+ remembered, a late answer only lets that one call run, and a payment always asks again,+ so none of them gets an "always". */}+ <div data-approval-actions className="mt-3 flex flex-col gap-2 sm:flex-row-reverse sm:items-center sm:justify-start"><buttontype="button"disabled={disabled}onClick={() => handleDecision('allow_once')}- className="flex items-center gap-1.5 px-3 py-1.5 min-h-[40px] sm:min-h-0 rounded-lg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-400 text-xs font-medium text-white bg-emerald-600 hover:bg-emerald-500 transition-colors shadow-sm disabled:opacity-50 disabled:cursor-not-allowed"+ data-approval-allow=""+ className="w-full sm:w-auto inline-flex items-center justify-center gap-1.5 min-h-[48px] max-sm:!min-h-[48px] sm:min-h-[36px] px-4 rounded-lg bg-[#059669] hover:bg-emerald-500 text-[15px] sm:text-sm font-semibold text-white shadow-sm transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b8adff] disabled:opacity-50 disabled:cursor-not-allowed">- <Check size={14} />- <span>{waiting ? 'Allow and continue' : 'Allow Once'}</span>+ <Check size={16} aria-hidden="true" />+ <span>{waiting ? 'Allow and continue' : 'Allow once'}</span></button>-- {/* Local shell approvals are never remembered, so only offer a one-off answer. A late- answer only lets that one call run, and a payment always asks again, so neither gets- an "always" either. */}- {!shell && !waiting && !payment && (- <button- type="button"- disabled={disabled}- onClick={() => handleDecision('always_allow')}- title={perSession ? 'Allow this tool for this bot in this conversation' : mcp ? 'Allow this tool for this bot until the app restarts' : undefined}- className="flex items-center gap-1.5 px-3 py-1.5 min-h-[40px] sm:min-h-0 rounded-lg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-400 text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors shadow-sm disabled:opacity-50 disabled:cursor-not-allowed"- >- <CheckCheck size={14} />- <span>{perSession ? 'Always this session' : 'Always Allow'}</span>+ <div className={`grid gap-2 sm:flex ${offerAlways ? 'grid-cols-2' : 'grid-cols-1'}`}>+ <button type="button" disabled={disabled} onClick={() => handleDecision('deny')} className={secondary}>+ <X size={14} aria-hidden="true" />+ <span>Deny</span></button>- )}+ {offerAlways && (+ <button+ type="button"+ disabled={disabled}+ onClick={() => handleDecision('always_allow')}+ title={perSession ? 'Allow this tool for this bot in this conversation' : mcp ? 'Allow this tool for this bot until the app restarts' : undefined}+ className={secondary}+ >+ <CheckCheck size={14} aria-hidden="true" />+ <span>{perSession ? 'Always this session' : 'Always allow'}</span>+ </button>+ )}+ </div></div></div>);diff --git a/frontend/src/components/QuestionCard.tsx b/frontend/src/components/QuestionCard.tsxindex afbb9255..ee54fb4a 100644--- a/frontend/src/components/QuestionCard.tsx+++ b/frontend/src/components/QuestionCard.tsx@@ -84,7 +84,8 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwa<CheckCircle2 size={13} aria-hidden="true" /> Answered{view.status === 'open' ? ', sending…' : ''}</span>) : waiting ? (- <span className="inline-flex items-center gap-1.5 text-amber-300">+ // Not on a phone: the working strip under the chat already says the bot waits, and says it once (spec C2).+ <span className="inline-flex items-center gap-1.5 text-amber-300 max-md:hidden" data-question-waiting=""><Clock size={13} aria-hidden="true" /> {kwantName} is waiting for your answer. You can keep chatting meanwhile.</span>) : (@@ -96,6 +97,7 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwareturn (<sectiondata-message-id={messageId}+ data-question-card={open ? 'open' : 'closed'}aria-labelledby={headingId}className={`flex items-start gap-3.5 w-full max-w-5xl rounded-xl ${flash ? 'kw-flash' : ''}`}>@@ -129,7 +131,7 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwaaria-pressed={chosen}onClick={() => submit({ choice: i })}onKeyDown={(e) => onChoiceKey(e, i)}- className={`inline-flex items-center justify-center sm:justify-start gap-1.5 min-h-[40px] sm:min-h-[34px] px-3 py-1.5 rounded-xl text-sm text-left border transition-colors break-words focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400 ${+ className={`w-full sm:w-auto inline-flex items-center justify-center sm:justify-start gap-1.5 min-h-[48px] max-sm:!min-h-[48px] sm:min-h-[34px] px-3 py-1.5 rounded-xl text-base leading-[22px] sm:text-sm sm:leading-normal text-left border transition-colors break-words focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400 ${chosen? 'bg-emerald-500/15 border-emerald-500/40 text-emerald-100': open@@ -157,9 +159,9 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwa}}><label htmlFor={`${headingId}-text`} className="sr-only">- Or type your own answer+ Your own answer</label>- <div className="flex items-end gap-2 rounded-xl bg-zinc-950 border border-zinc-800 focus-within:border-amber-500/50 p-1.5">+ <div className="flex items-center sm:items-end gap-2 min-h-[44px] rounded-xl bg-zinc-950 border border-zinc-800 focus-within:border-amber-500/50 pl-1.5 sm:p-1.5"><textareaid={`${headingId}-text`}rows={1}@@ -177,14 +179,14 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwasubmit({ text });}}}- placeholder="Or type your own answer…"- className="flex-1 bg-transparent px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none resize-none leading-relaxed"+ placeholder="Your own answer…"+ className="flex-1 min-w-0 bg-transparent px-2 py-2.5 sm:py-1 text-base leading-6 sm:text-sm sm:leading-relaxed text-zinc-100 placeholder-zinc-500 placeholder:whitespace-nowrap placeholder:overflow-hidden placeholder:text-ellipsis focus:outline-none resize-none"/><buttontype="submit"disabled={!text.trim() || busy !== null}aria-label="Send answer"- className="w-7 h-7 shrink-0 rounded-lg flex items-center justify-center bg-amber-500 text-zinc-950 hover:bg-amber-400 disabled:bg-zinc-800 disabled:text-zinc-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400"+ className="w-11 h-11 sm:w-7 sm:h-7 shrink-0 rounded-lg flex items-center justify-center bg-amber-500 text-zinc-950 hover:bg-amber-400 disabled:bg-zinc-800 disabled:text-zinc-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400">{busy === 'text' ? <Loader2 size={13} className="animate-spin motion-reduce:animate-none" aria-hidden="true" /> : <ArrowUp size={14} strokeWidth={2.4} aria-hidden="true" />}</button>@@ -200,7 +202,7 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwa))}- <div className="px-4 pb-3 pt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]">+ <div className="px-4 pb-1 sm:pb-3 pt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]"><p role="status" aria-live="polite" className="min-w-0">{status}</p>@@ -209,7 +211,7 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ meta, messageId, kwatype="button"onClick={dismiss}disabled={busy !== null}- className="ml-auto text-zinc-500 hover:text-zinc-300 underline-offset-2 hover:underline disabled:opacity-50 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-zinc-500"+ className="ml-auto inline-flex items-center min-h-[44px] sm:min-h-0 px-2 -mr-2 sm:px-0 sm:mr-0 text-sm sm:text-[11px] text-[#a39dcc] sm:text-zinc-500 hover:text-zinc-300 underline-offset-2 hover:underline disabled:opacity-50 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-zinc-500">{busy === 'dismiss' ? 'Skipping…' : 'Skip question'}</button>diff --git a/frontend/src/components/ReplyMeta.tsx b/frontend/src/components/ReplyMeta.tsxindex 92ff8c24..00276e29 100644--- a/frontend/src/components/ReplyMeta.tsx+++ b/frontend/src/components/ReplyMeta.tsx@@ -52,13 +52,15 @@ export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, aconst hasDetails = facts.length > 0 || hasContent(children);return (<div className="w-full max-w-full min-w-0">- <div className="mb-1.5 flex min-w-0 max-w-full flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium">+ <div className="mb-1.5 flex min-w-0 max-w-full flex-nowrap sm:flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium">{avatar && <span className="sm:hidden shrink-0 inline-flex">{avatar}</span>}<span className="shrink-0 text-[13px] font-semibold text-zinc-50">{name}</span>{why.chip}- {(ranOn || handoff) && <EngineChip label={[ranOn, account].filter(Boolean).join(' · ')} handoff={handoff} />}+ {(ranOn || handoff) && (+ <EngineChip label={[ranOn, account].filter(Boolean).join(' · ')} short={ranOn ? ranOn.split(' · ').pop() : null} handoff={handoff} />+ )}{time && (- <span className="min-w-0 truncate text-zinc-400" data-reply-time="">+ <span className="shrink-0 whitespace-nowrap text-zinc-400" data-reply-time=""><span aria-hidden="true" className="sm:hidden">· </span>{time}</span>diff --git a/frontend/src/components/Signature.tsx b/frontend/src/components/Signature.tsxindex 86262f4f..8861dd83 100644--- a/frontend/src/components/Signature.tsx+++ b/frontend/src/components/Signature.tsx@@ -100,15 +100,29 @@ const PixelBaton: React.FC = () => ();/** The engine that answered (ranOn + account, spec §4); after a failover, "Claude → Codex" with a pixel baton and the reason on hover. */-export const EngineChip: React.FC<{ label: string; handoff?: { from: string; to: string; why: string } | null }> = ({ label, handoff }) =>+export const EngineChip: React.FC<{+ label: string;+ handoff?: { from: string; to: string; why: string } | null;+ /** On a phone only this shows (the model), cut at 160 px; the full label stays on desktop, in the tooltip and in Details (0.6.13 spec C4). */+ short?: string | null;+}> = ({ label, handoff, short }) =>handoff ? (<span className="kws-chip kws-chip-failover kws-tip min-w-0 max-w-full" data-tip={handoff.why} tabIndex={0} aria-label={`${handoff.from} to ${handoff.to}. ${handoff.why}`} data-engine-chip="" data-failover=""><PixelBaton /><span className="truncate" aria-hidden="true">{`${handoff.from} → ${handoff.to}`}</span></span>) : (- <span className="kws-chip kws-chip-engine min-w-0 max-w-full" data-engine-chip="">+ <span className="kws-chip kws-chip-engine min-w-0 max-w-full" data-engine-chip="" title={short && short !== label ? label : undefined}><Cpu size={12} className="shrink-0" aria-hidden="true" />- <span className="truncate">{label}</span>+ {short && short !== label ? (+ <>+ <span className="truncate hidden sm:inline">{label}</span>+ <span className="truncate sm:hidden max-w-[160px]" data-engine-short="">+ {short}+ </span>+ </>+ ) : (+ <span className="truncate">{label}</span>+ )}</span>);diff --git a/frontend/src/components/WorkingStrip.tsx b/frontend/src/components/WorkingStrip.tsxindex 4df033c7..5b88423c 100644--- a/frontend/src/components/WorkingStrip.tsx+++ b/frontend/src/components/WorkingStrip.tsx@@ -1,7 +1,8 @@import React, { useEffect, useRef, useState } from 'react';-import { Square } from 'lucide-react';+import { ArrowUp, Square } from 'lucide-react';import type { LiveActivity } from '../activity';-import { formatElapsed, turnStart, workingLabel } from '../workingStrip';+import { formatElapsed, turnStart, waitingOn, workingLabel } from '../workingStrip';+import { usePhoneLayout } from '../usePhoneLayout';import { ModernAvatar } from './ModernAvatar';interface WorkingStripProps {@@ -15,12 +16,25 @@ interface WorkingStripProps {awaitingBrowser?: boolean;writing?: boolean;onStop?: () => void;+ /**+ * Phone only: brings the card the bot waits on (its question, or an approval) into view. With it,+ * a waiting strip shows "Answer ↑", which stands in for the separate "Approval waiting" pill.+ */+ onAnswer?: (on: 'question' | 'approval') => void;+ /** Forces the phone or desktop look (tests); by default it follows the window. */+ phone?: boolean;}-/** Summary of the running turn (the composer holds the one Stop; onStop is unused there), kept in view above the composer; the card in the stream holds the step details. */-export const WorkingStrip: React.FC<WorkingStripProps> = ({ active, name, title, live, queued, awaitingAnswer, awaitingBrowser, writing, onStop }) => {+/**+ * Summary of the running turn (the composer holds the one Stop; onStop is unused there), kept in view+ * above the composer; the card in the stream holds the step details. On a phone it is the one live+ * line (0.6.13 spec A3): 44 px tall, 14 px text, and "Answer ↑" while the bot waits on the person.+ */+export const WorkingStrip: React.FC<WorkingStripProps> = ({ active, name, title, live, queued, awaitingAnswer, awaitingBrowser, writing, onStop, onAnswer, phone: forcePhone }) => {const mountedAt = useRef(Date.now());const [now, setNow] = useState(() => Date.now());+ const phoneLayout = usePhoneLayout();+ const phone = forcePhone ?? phoneLayout;useEffect(() => {if (!active) return;mountedAt.current = Date.now();@@ -30,22 +44,47 @@ export const WorkingStrip: React.FC<WorkingStripProps> = ({ active, name, title,}, [active]);if (!active) return null;- const label = workingLabel({ live, queued, awaitingAnswer, awaitingBrowser, writing });+ const state = { live, queued, awaitingAnswer, awaitingBrowser, writing };+ const label = workingLabel(state);const elapsed = formatElapsed(now - turnStart(live, mountedAt.current));- const waiting = !!queued || !!awaitingAnswer;+ const on = waitingOn(state);+ const waiting = !!queued || !!awaitingAnswer || on !== null;+ const answer = phone && on && onAnswer ? on : null;return (- <div className="kws-strip px-3 sm:px-6 pt-2" data-working-strip="">- <div className="mx-auto flex max-w-4xl items-center gap-3 rounded-xl border border-zinc-700/60 bg-zinc-900/80 px-3 py-1.5 shadow-[var(--kws-shadow)]">+ <div className="kws-strip px-3 sm:px-6 pt-2" data-working-strip="" data-waiting-on={on ?? undefined}>+ <div+ className={`mx-auto flex max-w-4xl items-center rounded-xl border border-zinc-700/60 bg-zinc-900/80 shadow-[var(--kws-shadow)] ${+ phone ? 'min-h-[44px] gap-2.5 pl-3 pr-1' : 'gap-3 px-3 py-1.5'+ }`}+ ><span className={`shrink-0 inline-flex ${waiting ? '' : 'kw-avatar-working'}`}>- <ModernAvatar role={title} name={name} size={24} />+ <ModernAvatar role={title} name={name} size={phone ? 20 : 24} /></span>- <p className="min-w-0 flex-1 truncate text-xs text-zinc-300" role="status" aria-live="polite">+ <p className={`min-w-0 flex-1 truncate ${phone ? 'text-sm leading-5 text-zinc-200' : 'text-xs text-zinc-300'}`} role="status" aria-live="polite"><span className="font-semibold text-zinc-100">{name}</span> is {label}</p>- {/* Own box, so a long step name never cuts the time off at 390 px. */}- <span className="shrink-0 tabular-nums text-meta text-zinc-400" aria-hidden="true" data-working-elapsed="">- {elapsed}- </span>+ {/* Own box, so a long step name never cuts the time off at 390 px. Hidden behind Answer on a+ phone: the line is short there, and what to do next matters more than for how long. */}+ {!answer && (+ <span+ className={`shrink-0 tabular-nums ${phone ? 'pr-2 text-sm leading-5 text-[#a39dcc]' : 'text-meta text-zinc-400'}`}+ aria-hidden="true"+ data-working-elapsed=""+ >+ {elapsed}+ </span>+ )}+ {answer && (+ <button+ type="button"+ onClick={() => onAnswer?.(answer)}+ data-strip-answer=""+ className="shrink-0 inline-flex items-center gap-1 min-h-[44px] min-w-[44px] rounded-lg px-3 text-sm font-semibold text-amber-200 hover:bg-amber-500/10 active:bg-amber-500/15 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b8adff]"+ >+ Answer+ <ArrowUp size={14} aria-hidden="true" />+ </button>+ )}{onStop && (<buttontype="button"diff --git a/frontend/src/toolLabel.ts b/frontend/src/toolLabel.tsnew file mode 100644index 00000000..7c32d686--- /dev/null+++ b/frontend/src/toolLabel.ts@@ -0,0 +1,100 @@+// Readable verbs for tool names (0.6.13 spec C2). The working strip, the step rows and the approval+// card say what a bot does in words ("opening a pull request on GitHub"), never the raw+// `create_pull_request (github)`. A tool we don't know falls back to its name with spaces.++/** How a few well-known servers are written. Others are shown as they come. */+const SERVERS: Record<string, string> = {+ github: 'GitHub',+ gitlab: 'GitLab',+ linear: 'Linear',+ slack: 'Slack',+ notion: 'Notion',+ jira: 'Jira',+ stripe: 'Stripe',+ gmail: 'Gmail',+ googlecalendar: 'Google Calendar',+ google_calendar: 'Google Calendar',+ googledrive: 'Google Drive',+ google_drive: 'Google Drive',+};++/** [the "-ing" form after "<Bot> is", the plain form after "<Bot> wants to", whether "on <server>" follows]. */+type Verb = [ing: string, base: string, onServer?: boolean];++const VERBS: Record<string, Verb> = {+ create_pull_request: ['opening a pull request', 'open a pull request', true],+ merge_pull_request: ['merging a pull request', 'merge a pull request', true],+ create_issue: ['opening an issue', 'open an issue', true],+ add_issue_comment: ['commenting on an issue', 'comment on an issue', true],+ create_branch: ['creating a branch', 'create a branch', true],+ push_files: ['pushing files', 'push files', true],+ create_or_update_file: ['changing a file', 'change a file', true],+ send_message: ['sending a message', 'send a message', true],+ send_email: ['sending an email', 'send an email', true],+ browser_navigate: ['opening a page', 'open a page'],+ browser_open: ['opening a page', 'open a page'],+ open_url: ['opening a page', 'open a page'],+ web_fetch: ['opening a page', 'open a page'],+ webfetch: ['opening a page', 'open a page'],+ browser_click: ['using the browser', 'use the browser'],+ browser_type: ['using the browser', 'use the browser'],+ browser_act: ['using the browser', 'use the browser'],+ browser_snapshot: ['reading the browser page', 'read the browser page'],+ browser_screenshot: ['looking at the browser page', 'look at the browser page'],+ ask_user: ['asking you a question', 'ask you a question'],+ request_human_step: ['asking you to do a step in the browser', 'ask you to do a step in the browser'],+ web_search: ['searching the web', 'search the web'],+ websearch: ['searching the web', 'search the web'],+ bash: ['running a command', 'run a command'],+ execute_shell: ['running a command on your computer', 'run a command on your computer'],+ read_file: ['reading a file', 'read a file'],+ write_file: ['writing a file', 'write a file'],+ edit_file: ['changing a file', 'change a file'],+};++/** `mcp__github__create_pull_request` → the tool and its server; other names as given. */+function split(name: string, server?: string | null): { tool: string; server: string | null } {+ const m = /^mcp__(.+?)__(.+)$/.exec(name ?? '');+ if (m) return { tool: m[2], server: server || m[1] };+ return { tool: name ?? '', server: server || null };+}++const serverName = (s: string) => SERVERS[s.toLowerCase()] ?? s;+const spaced = (t: string) => t.replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();++function verb(name: string, server: string | null | undefined, form: 0 | 1): string {+ const p = split(name, server);+ const known = VERBS[p.tool.toLowerCase()];+ if (known) {+ const words = known[form];+ return known[2] && p.server ? `${words} on ${serverName(p.server)}` : words;+ }+ const head = form === 0 ? 'using' : 'use';+ const tool = spaced(p.tool) || 'a tool';+ return p.server ? `${head} ${tool} (${p.server})` : `${head} ${tool}`;+}++/** What a bot is doing with a tool, after "<Bot> is": "opening a pull request on GitHub". */+export const toolLabel = (name: string, server?: string | null): string => verb(name, server, 0);++/** What a bot asks to do with a tool, after "<Bot> wants to": "open a pull request on GitHub". */+export const toolAction = (name: string, server?: string | null): string => verb(name, server, 1);++const cap = (t: string) => (t ? t.charAt(0).toUpperCase() + t.slice(1) : t);++/**+ * A step title from the server, with a raw tool name made readable. The server writes an unknown+ * tool as "Using create_pull_request (github)", and an approval as "Waiting for your approval: <that>";+ * every other title (already in words) comes back unchanged.+ */+export function readableStepTitle(title: string): string {+ const using = /^Using `?([A-Za-z0-9_.:-]+)`?(?: \(([^)]+)\))?$/;+ const approval = /^Waiting for your approval: (.+)$/.exec(title);+ if (approval) {+ const inner = using.exec(approval[1].trim());+ const rest = approval[1].trim();+ return inner ? `Waiting for your OK to ${toolAction(inner[1], inner[2])}` : `Waiting for your OK: ${rest.charAt(0).toLowerCase()}${rest.slice(1)}`;+ }+ const m = using.exec(title.trim());+ return m ? cap(toolLabel(m[1], m[2])) : title;+}diff --git a/frontend/src/usePhoneLayout.ts b/frontend/src/usePhoneLayout.tsnew file mode 100644index 00000000..53227a6f--- /dev/null+++ b/frontend/src/usePhoneLayout.ts@@ -0,0 +1,16 @@+import { useEffect, useState } from 'react';+import { PHONE_QUERY, isPhoneLayout } from './layout';++/** Whether the phone layout (below 768 px) is on, following the window as it resizes or rotates. */+export function usePhoneLayout(): boolean {+ const [phone, setPhone] = useState(isPhoneLayout);+ useEffect(() => {+ const mq = typeof window !== 'undefined' ? window.matchMedia?.(PHONE_QUERY) : undefined;+ if (!mq) return;+ const on = () => setPhone(mq.matches);+ on();+ mq.addEventListener?.('change', on);+ return () => mq.removeEventListener?.('change', on);+ }, []);+ return phone;+}diff --git a/frontend/src/workingStrip.ts b/frontend/src/workingStrip.tsindex ac46cf80..9116b04c 100644--- a/frontend/src/workingStrip.ts+++ b/frontend/src/workingStrip.ts@@ -1,5 +1,6 @@// The slim "Bot is <step> · 0:42" strip above the composer. Pure helpers; the component only draws them.import { ActivityStep, LiveActivity, formatClock, isOpenStep, plainTitle } from './activity';+import { readableStepTitle } from './toolLabel';export interface WorkingState {live?: LiveActivity | null;@@ -17,8 +18,10 @@ export function workingLabel(s: WorkingState): string {if (s.queued) return 'waiting in line';if (s.awaitingAnswer) return s.awaitingBrowser ? 'waiting for you in the browser' : 'waiting for your answer';const open: ActivityStep | undefined = [...(s.live?.steps ?? [])].reverse().find(isOpenStep);+ // An approval: the card says what it is for; the strip only says whose move it is.+ if (open?.kind === 'approval' && open.status === 'waiting') return 'waiting for your OK';if (open) {- const t = plainTitle(open.title).trim();+ const t = readableStepTitle(plainTitle(open.title).trim());if (t) return lower(t);}if (s.writing) return 'writing the reply';@@ -27,6 +30,17 @@ export function workingLabel(s: WorkingState): string {return 'getting started';}+/**+ * What the bot waits on the person for, so the phone strip can offer "Answer ↑" (spec A3): a question,+ * an approval card, or null (working, in line, or a browser step, which has its own card and button).+ */+export function waitingOn(s: WorkingState): 'question' | 'approval' | null {+ if (s.queued) return null;+ if (s.awaitingAnswer) return s.awaitingBrowser ? null : 'question';+ const open = [...(s.live?.steps ?? [])].reverse().find(isOpenStep);+ return open?.kind === 'approval' && open.status === 'waiting' ? 'approval' : null;+}+/** The strip's clock; the saved card header uses the same one. */export const formatElapsed = formatClock;diff --git a/frontend/tests/activity.test.mjs b/frontend/tests/activity.test.mjsindex ddb07515..862768f0 100644--- a/frontend/tests/activity.test.mjs+++ b/frontend/tests/activity.test.mjs@@ -105,7 +105,7 @@ test('a page opened mid-turn seeds the open step from /api/turns (ticket 4)', as// Fresh load: nothing came live yet.const seeded = a.seedActivity(undefined, 't1', fromServer);assert.deepEqual(seeded.steps.map((s) => s.id), ['a', 'b']);- assert.equal(w.workingLabel({ live: seeded }), 'using web_search');+ assert.equal(w.workingLabel({ live: seeded }), 'searching the web');// Reconnect: a step that already settled live stays settled; live order is kept.const live = { turnId: 't1', thinking: { x: 'hm' }, steps: [step({ id: 'b', status: 'ok', title: 'Using `web_search`' })] };const merged = a.seedActivity(live, 't1', fromServer);diff --git a/frontend/tests/approvalCard.test.mjs b/frontend/tests/approvalCard.test.mjsindex 1fc0cf2a..6866c038 100644--- a/frontend/tests/approvalCard.test.mjs+++ b/frontend/tests/approvalCard.test.mjs@@ -20,14 +20,14 @@ const shellTicket = (command, cwd = '/Users/alex/project') => ({const render = (approval) =>m.renderToStaticMarkup(m.createElement(m.ModernApprovalCard, { approval, onResolve: () => {} }));-test('a local shell ticket shows the command and folder, without Always Allow', () => {+test('a local shell ticket shows the command and folder, without Always allow', () => {const html = render(shellTicket('ls -la && git status'));assert.match(html, /run a command on your computer/);assert.match(html, /<pre[^>]*whitespace-pre-wrap[^>]*>ls -la && git status<\/pre>/);assert.match(html, /In folder:.*\/Users\/alex\/project/);- assert.match(html, /Allow Once/);+ assert.match(html, /Allow once/);assert.match(html, /Deny/);- assert.doesNotMatch(html, /Always Allow/);+ assert.doesNotMatch(html, /Always allow/);assert.doesNotMatch(html, /kwant_id|"source"/, 'no raw JSON dump');});@@ -47,11 +47,11 @@ test('localShellView tolerates missing fields and ignores other tools', () => {assert.doesNotMatch(html, /In folder:/);});-test('a normal ticket keeps the raw details and Always Allow', () => {+test('a normal ticket keeps the raw details and Always allow', () => {const html = render({ id: 'n1', tool_name: 'write_file', details: { path: '/tmp/a.txt' } });- assert.match(html, /Tool:<\/span> write_file/);+ assert.match(html, /write_file/);assert.match(html, /"path": "\/tmp\/a.txt"/);- assert.match(html, /Always Allow/);+ assert.match(html, /Always allow/);assert.doesNotMatch(html, /run a command on your computer/);});@@ -70,13 +70,13 @@ const stripeTicket = (extra = {}) => ({},});-test('a payment card says why it is a payment and offers only Allow Once and Deny', () => {+test('a payment card says why it is a payment and offers only Allow once and Deny', () => {const html = render(stripeTicket());assert.match(html, /This looks like a payment:<\/span> composio STRIPE_CREATE_PAYMENT_INTENT is a write action of Stripe, a money app\./);assert.match(html, /Payments always ask you, even with approvals off/);- assert.match(html, /Allow Once/);+ assert.match(html, /Allow once/);assert.match(html, /Deny/);- assert.doesNotMatch(html, /Always Allow|Always this session/);+ assert.doesNotMatch(html, /Always allow|Always this session/);assert.match(html, /role="note"/);});@@ -87,7 +87,7 @@ test('a payment shown as a Claude tool card also drops Always this session', ()details: { source: 'claude_builtin', tool: 'Bash', arguments: { command: 'stripe charges create --amount 1' }, payment_reason: 'stripe CLI changes something.' },});assert.match(html, /This looks like a payment:<\/span> stripe CLI changes something\./, 'one full stop, not two');- assert.doesNotMatch(html, /Always this session|Always Allow/);+ assert.doesNotMatch(html, /Always this session|Always allow/);});test('a payment by local shell keeps its command and shows the reason', () => {@@ -96,7 +96,7 @@ test('a payment by local shell keeps its command and shows the reason', () => {const html = render(t);assert.match(html, /This looks like a payment:<\/span> POST to a payment host \(api.stripe.com\)\./);assert.match(html, /run a command on your computer/);- assert.doesNotMatch(html, /Always Allow/);+ assert.doesNotMatch(html, /Always allow/);});test('cards without payment_reason are unchanged: no payment line, Always buttons as before', () => {@@ -108,7 +108,7 @@ test('cards without payment_reason are unchanged: no payment line, Always button]) {const html = render(t);assert.doesNotMatch(html, /looks like a payment|role="note"/, t.id);- assert.match(html, /Always Allow|Always this session/, t.id);+ assert.match(html, /Always allow|Always this session/, t.id);}});@@ -125,10 +125,10 @@ test('a payment card in its summary form (after a reload) shows the reason and ntool_name: 'Bash',details: { source: 'summary', tool: 'Bash', summary: 'command: stripe charges create', kwant_name: 'Ledger', payment_reason: 'stripe CLI changes something' },});- assert.match(html, /Ledger<\/span> wants to use <span[^>]*>Bash<\/span>/);+ assert.match(html, /Ledger<\/strong> wants to run a command/);assert.match(html, /This looks like a payment:<\/span> stripe CLI changes something\./);- assert.match(html, /Allow Once/);- assert.doesNotMatch(html, /Always this session|Always Allow/);+ assert.match(html, /Allow once/);+ assert.doesNotMatch(html, /Always this session|Always allow/);// The same summary card without a reason still offers Always this session.const plain = render({ id: 'n4', tool_name: 'Bash', details: { source: 'summary', tool: 'Bash', summary: 'command: ls' } });assert.match(plain, /Always this session/);diff --git a/frontend/tests/approvalVisibility.test.mjs b/frontend/tests/approvalVisibility.test.mjsindex 247b2777..04d501fa 100644--- a/frontend/tests/approvalVisibility.test.mjs+++ b/frontend/tests/approvalVisibility.test.mjs@@ -47,7 +47,7 @@ test('a card marks itself and its button row so the chat can find them', () => {}),);assert.match(html, /data-approval-card="pay-1"/);- assert.match(html, /data-approval-actions="true"[^>]*>[\s\S]*Deny[\s\S]*Allow Once/);+ assert.match(html, /data-approval-actions="true"[^>]*>[\s\S]*Allow once[\s\S]*Deny/);});test('only scrolling up stops following; a card growing under a pinned view does not', () => {diff --git a/frontend/tests/approvals.test.mjs b/frontend/tests/approvals.test.mjsindex b2364973..b52c70ce 100644--- a/frontend/tests/approvals.test.mjs+++ b/frontend/tests/approvals.test.mjs@@ -43,10 +43,10 @@ test('a Bash approval loaded after a reload renders as the built-in card inlineconst here = a.approvalsForChat(loaded, { kind: 'kwant', kwantId: 'k-dev', threadId: null });assert.equal(here.length, 1);const html = ui.chat(chatProps(here));- assert.match(html, /Dev<\/span> wants to run a command/);+ assert.match(html, /Dev<\/strong> wants to run a command/);assert.match(html, /<pre[^>]*>touch x<\/pre>/);assert.match(html, /In folder:.*\/tmp\/bots\/dev/);- assert.match(html, /Allow Once/);+ assert.match(html, /Allow once/);assert.match(html, /Always this session/);assert.match(html, /Deny/);assert.doesNotMatch(html, /command: touch x/, 'not the old raw summary');@@ -82,7 +82,7 @@ test('an older server without details still gets a card with the summary and sesassert.equal(card.tool_name, 'Bash');assert.equal(card.kwant_id, 'k-dev');const html = ui.chat(chatProps([card]));- assert.match(html, /Dev<\/span> wants to use <span[^>]*>Bash<\/span>/);+ assert.match(html, /Dev<\/strong> wants to run a command/);assert.match(html, /command: touch x, description: Create x/);assert.match(html, /Always this session/);});@@ -114,7 +114,7 @@ test('a reloaded payment keeps its reason in every form the server sends, so noonRefresh: () => {}, onOpen: () => {}, onAnswer: () => {}, onResolve: () => {},});assert.match(html, /This looks like a payment:<\/span> POST to a payment host \(api.stripe.com\)\./);- assert.doesNotMatch(html, /Always this session|Always Allow/);+ assert.doesNotMatch(html, /Always this session|Always allow/);}// An old summary item without a reason is unchanged.const plain = a.approvalFromAway(bashItem({ tool_name: undefined, details: undefined }));diff --git a/frontend/tests/autonomyUi.test.mjs b/frontend/tests/autonomyUi.test.mjsindex 09868701..e74cff42 100644--- a/frontend/tests/autonomyUi.test.mjs+++ b/frontend/tests/autonomyUi.test.mjs@@ -49,15 +49,15 @@ test('the server decides waiting: a live card turns waiting on sync, and back',test('a still-open card says so, keeps Allow and Deny, and drops Always', () => {const html = m.card({ ...m.approvalFromAway(awayItem('waiting')), details: { ...awayItem('waiting').details, kwant_name: 'Architect' } });- assert.match(html, /Still open: you can still Allow/);+ assert.match(html, /Still open: you can still allow/);assert.match(html, /Architect stopped waiting for an answer and nothing ran/);assert.match(html, /Allow and continue/);assert.match(html, />Deny</);assert.doesNotMatch(html, /Always/);- assert.doesNotMatch(html, /Action Approval Required/);+ assert.doesNotMatch(html, /Approval needed/);// A normal card is unchanged.const normal = m.card(m.approvalFromAway(awayItem('pending')));- assert.match(normal, /Action Approval Required/);+ assert.match(normal, /Approval needed/);assert.match(normal, /Always this session/);assert.doesNotMatch(normal, /Still open/);});@@ -75,7 +75,7 @@ test('Allow and Deny on a still-open card answer with allow_once and deny', () =walk(el);assert.equal(buttons.length, 2);for (const b of buttons) b.props.onClick();- assert.deepEqual(calls, [['ap1', 'deny'], ['ap1', 'allow_once']]);+ assert.deepEqual(calls, [['ap1', 'allow_once'], ['ap1', 'deny']]);// Disabled while sending: no answer goes out.const busy = [];const el2 = m.ModernApprovalCard({ approval: m.approvalFromAway(awayItem('waiting')), disabled: true, onResolve: (...a) => busy.push(a) });diff --git a/frontend/tests/away.test.mjs b/frontend/tests/away.test.mjsindex 1291f2b0..774adb10 100644--- a/frontend/tests/away.test.mjs+++ b/frontend/tests/away.test.mjs@@ -122,8 +122,8 @@ test('three sections with agent, title, summary and time; one-tap actions', () =assert.match(html, />Yes<\/button>/);assert.match(html, />No<\/button>/);// An approval is the same card as in the chat, with its labels.- for (const b of ['Allow Once', 'Always Allow', 'Deny']) assert.match(html, new RegExp(b));- assert.match(html, /Lead<\/span> wants to use <span[^>]*>send<\/span>/);+ for (const b of ['Allow once', 'Always allow', 'Deny']) assert.match(html, new RegExp(b));+ assert.match(html, /Lead<\/strong> wants to use send/);assert.match(html, /Handoff done/);assert.match(html, /Stuck/);assert.doesNotMatch(html, /all caught up/);diff --git a/frontend/tests/botCapabilities.test.mjs b/frontend/tests/botCapabilities.test.mjsindex 1224759e..0a0c7279 100644--- a/frontend/tests/botCapabilities.test.mjs+++ b/frontend/tests/botCapabilities.test.mjs@@ -36,18 +36,18 @@ const bash = { id: 'b1', tool_name: 'Bash', details: { source: 'claude_builtin',test('a Bash approval shows who, the command and the folder, with the three choices, and no raw JSON', () => {const html = m.approval(bash);const t = text(html);- assert.match(t, /Frontend wants to run a command\./);+ assert.match(t, /Frontend wants to run a command/);assert.match(t, /Run the strategy tests/);assert.match(html, /<pre[^>]*>go test \.\/internal\/strategy\/<\/pre>/);assert.match(t, /In folder: \/Users\/alex\/trader/);- assert.deepEqual(buttons(html), ['Deny', 'Allow Once', 'Always this session']);+ assert.deepEqual(buttons(html), ['Hide details', 'Allow once', 'Deny', 'Always this session']);assert.doesNotMatch(html, /"source"|claude_builtin|kwant_name/);});test('a Write outside its folder names the file, the size and its own folder', () => {const html = m.approval({ id: 'w1', tool_name: 'Write', details: { source: 'claude_builtin', tool: 'Write', kwant_name: 'Frontend', cwd: '/Users/alex/bots/frontend', outside_folder: true, arguments: { file_path: '/Users/alex/trader/internal/strategy/smacross.go', content: 'package strategy\n\nfunc x() {}\n' } } });const t = text(html);- assert.match(t, /Frontend wants to write a file outside its own folder\./);+ assert.match(t, /Frontend wants to write a file outside its own folder/);assert.match(t, /\/Users\/alex\/trader\/internal\/strategy\/smacross\.go/);assert.match(t, /Write 4 lines/);assert.match(t, /Its folder: \/Users\/alex\/bots\/frontend/);diff --git a/frontend/tests/mobileCards.test.mjs b/frontend/tests/mobileCards.test.mjsnew file mode 100644index 00000000..f61bb1dc--- /dev/null+++ b/frontend/tests/mobileCards.test.mjs@@ -0,0 +1,271 @@+// 0.6.13 slice C (+ A3): the cards and the live line on a phone. Each test here fails on 3ca2bf7.+import assert from 'node:assert/strict';+import test from 'node:test';+import { loadBundled } from './bundle.mjs';++// The sound effects module reads its mute flag on load.+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };++const m = await loadBundled(`+ import React from 'react';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { ModernApprovalCard } from './src/components/ModernApprovalCard';+ import { WorkingStrip } from './src/components/WorkingStrip';+ import { LiveActivityList } from './src/components/ActivityList';+ import { MarkdownRenderer } from './src/components/MarkdownRenderer';+ import { QuestionCard } from './src/components/QuestionCard';+ import { EngineChip } from './src/components/Signature';+ import { ReplyMeta } from './src/components/ReplyMeta';+ export * from './src/toolLabel';+ export { keyFacts } from './src/components/ModernApprovalCard';+ export { parseQuestionMeta } from './src/questions';+ export { awayTitle } from './src/approvals';+ import { AwayView } from './src/components/AwayView';+ const r = (C) => (props) => renderToStaticMarkup(React.createElement(C, props));+ export const card = r(ModernApprovalCard);+ export const strip = r(WorkingStrip);+ export const steps = r(LiveActivityList);+ export const md = (content) => renderToStaticMarkup(React.createElement(MarkdownRenderer, { content }));+ export const question = r(QuestionCard);+ export const chip = r(EngineChip);+ export const meta = r(ReplyMeta);+ export const away = r(AwayView);+`);++const text = (html) => html.replace(/<[^>]+>/g, '').replace(/&/g, '&').replace(/'/g, "'").replace(/\s+/g, ' ').trim();+const buttons = (html) => [...html.matchAll(/<button([^>]*)>([\s\S]*?)<\/button>/g)].map(([, attrs, inner]) => ({ attrs, label: text(inner) }));++// --- C2: tool names in words ----------------------------------------------------------------++test('toolLabel: the spec mappings, an MCP-prefixed name, and the fallback', () => {+ assert.equal(m.toolLabel('create_pull_request', 'github'), 'opening a pull request on GitHub');+ assert.equal(m.toolLabel('mcp__github__create_pull_request'), 'opening a pull request on GitHub');+ assert.equal(m.toolLabel('browser_navigate'), 'opening a page');+ assert.equal(m.toolLabel('ask_user', 'kwant'), 'asking you a question');+ assert.equal(m.toolLabel('web_search'), 'searching the web');+ assert.equal(m.toolLabel('list_open_tickets', 'linear'), 'using list open tickets (linear)');+ assert.equal(m.toolLabel('list_open_tickets'), 'using list open tickets');+ assert.equal(m.toolAction('create_pull_request', 'github'), 'open a pull request on GitHub');+ assert.equal(m.toolAction('list_open_tickets', 'linear'), 'use list open tickets (linear)');+});++test('step titles from the server lose their underscores', () => {+ assert.equal(m.readableStepTitle('Using `web_search`'), 'Searching the web');+ assert.equal(m.readableStepTitle('Using create_pull_request (github)'), 'Opening a pull request on GitHub');+ assert.equal(m.readableStepTitle('Using list_open_tickets (linear)'), 'Using list open tickets (linear)');+ assert.equal(m.readableStepTitle('Waiting for your approval: Using create_pull_request (github)'), 'Waiting for your OK to open a pull request on GitHub');+ assert.equal(m.readableStepTitle('Running `cargo test`'), 'Running `cargo test`', 'titles already in words stay');+ for (const t of ['Using a_b_c (x_y)', 'Using `send_email`', 'Waiting for your approval: Using push_files (github)']) {+ assert.doesNotMatch(m.readableStepTitle(t).replace(/\([^)]*\)$/, ''), /_/, t);+ }+});++// --- C1: the approval card ------------------------------------------------------------------++const pr = (over = {}) => ({+ id: 'ap1',+ tool_name: 'mcp__github__create_pull_request',+ details: {+ source: 'mcp',+ server: 'github',+ tool: 'create_pull_request',+ kwant_name: 'TechLead',+ arguments: { repo: 'acme/site', title: 'Behind the seat: timed checkout', body: 'Behind the seat, timed.', head: 'tl-checkout', base: 'main' },+ },+ ...over,+});+const noop = () => {};++test('approval card on a phone: header, one sentence, two key facts, details closed, Allow once alone on top', () => {+ const html = m.card({ approval: pr(), onResolve: noop, phone: true });+ assert.match(html, /<h3[^>]*>Approval needed<\/h3>/);+ assert.doesNotMatch(html, /Action Approval Required|Allow Once|Always Allow/, 'sentence case only');+ assert.match(text(html), /TechLead wants to open a pull request on GitHub/);+ assert.match(html, /<strong[^>]*>GitHub<\/strong>/);+ // title comes before repo in the spec's order; body/head/base stay in the details.+ assert.deepEqual(m.keyFacts(pr().details.arguments), [['title', 'Behind the seat: timed checkout'], ['repo', 'acme/site']]);+ assert.match(html, /data-approval-facts/);+ // Details start closed: the JSON is not in the markup, the toggle says so.+ assert.doesNotMatch(html, /data-approval-details=""/);+ assert.doesNotMatch(html, /"head"/);+ const b = buttons(html);+ assert.deepEqual(b.map((x) => x.label), ['Show details', 'Allow once', 'Deny', 'Always allow']);+ assert.match(b[0].attrs, /aria-expanded="false"/);+ assert.match(b[0].attrs, /min-h-\[44px\]/);+ assert.match(b[1].attrs, /w-full/);+ assert.match(b[1].attrs, /min-h-\[48px\]/);+ assert.match(b[1].attrs, /bg-\[#059669\]/);+ for (const x of b.slice(2)) assert.match(x.attrs, /min-h-\[44px\]/, x.label);+ // Allow once is the only child of its row; Deny and Always allow share the next one.+ assert.match(html, /data-approval-actions[^>]*>\s*<button[^>]*data-approval-allow[\s\S]*?<\/button>\s*<div class="grid gap-2 sm:flex grid-cols-2">/);+});++test('approval card on desktop: details open, the JSON wraps between words, never break-all', () => {+ const html = m.card({ approval: pr(), onResolve: noop, phone: false });+ assert.match(html, /aria-expanded="true"[^>]*>Hide details/);+ const pre = /<pre class="([^"]*)"[^>]*>([\s\S]*?)<\/pre>/.exec(html);+ assert.ok(pre, 'the arguments are shown');+ assert.match(pre[2], /Behind the seat/);+ assert.doesNotMatch(pre[1], /break-all/);+ assert.match(pre[1], /whitespace-pre-wrap/);+ assert.match(pre[1], /\[overflow-wrap:anywhere\]/);+ assert.match(pre[1], /max-h-\[240px\]/);+ assert.match(pre[1], /text-xs leading-\[18px\]/);+});++test('a payment card offers no Always allow on a phone either: its second row is just Deny', () => {+ const payment = pr({ details: { ...pr().details, payment_reason: 'stripe create payment is a money action' } });+ const html = m.card({ approval: payment, onResolve: noop, phone: true });+ assert.deepEqual(buttons(html).map((x) => x.label), ['Show details', 'Allow once', 'Deny']);+ assert.match(html, /<div class="grid gap-2 sm:flex grid-cols-1">/);+ assert.doesNotMatch(html, /Always/);+});++test('a still-open card keeps its note and puts Allow and continue on the first row', () => {+ const html = m.card({ approval: pr({ waiting: true }), onResolve: noop, phone: true });+ assert.match(html, /stopped waiting for an answer/);+ const b = buttons(html).map((x) => x.label);+ assert.deepEqual(b, ['Show details', 'Allow and continue', 'Deny']);+});++test('the header shows when the bot asked, when known', () => {+ const html = m.card({ approval: pr({ asked_at: new Date().toISOString() }), onResolve: noop, phone: true });+ assert.match(html, /<time[^>]*text-\[#a39dcc\][^>]*>[^<]+<\/time>/);+ assert.doesNotMatch(m.card({ approval: pr(), onResolve: noop, phone: true }), /<time/);+});++// --- C5: inline code ------------------------------------------------------------------------++test('inline code wraps anywhere and keeps its box on every line', () => {+ const html = m.md('Set `KWANT_SUPERCALIFRAGILISTIC_EXPIALIDOCIOUS_TIMEOUT_SECONDS` to 30.');+ const code = /<code class="([^"]*)"[^>]*>KWANT_SUPER/.exec(html);+ assert.ok(code, 'inline code rendered');+ for (const c of ['[overflow-wrap:anywhere]', '[box-decoration-break:clone]', '[-webkit-box-decoration-break:clone]']) assert.ok(code[1].includes(c), c);+});++// --- A3 + C2: one live line -----------------------------------------------------------------++const live = (steps) => ({ turnId: 't1', thinking: {}, steps });+const step = (over = {}) => ({ id: 's1', kind: 'tool', status: 'running', title: 'Using `web_search`', started_at: '2026-11-05T10:00:00Z', ...over });++test('on a phone the strip is the one live line: 44 px, 14 px text, words not tool names', () => {+ const html = m.strip({ active: true, name: 'Architect', title: 'Architect', live: live([step()]), phone: true });+ assert.match(html, /min-h-\[44px\]/);+ assert.match(html, /text-sm leading-5/);+ assert.match(html, /tabular-nums[^"]*text-\[#a39dcc\]|text-\[#a39dcc\][^"]*tabular-nums/);+ assert.match(text(html), /Architect is searching the web/);+ assert.doesNotMatch(text(html), /_/);+});++test('waiting on a question, the strip says so and offers Answer, which goes to the card', () => {+ const calls = [];+ const html = m.strip({ active: true, name: 'QA', title: 'QA', awaitingAnswer: true, phone: true, onAnswer: (on) => calls.push(on) });+ assert.match(text(html), /QA is waiting for your answer/);+ assert.match(html, /data-waiting-on="question"/);+ const answer = buttons(html).find((b) => b.label === 'Answer');+ assert.ok(answer, 'Answer button');+ assert.match(answer.attrs, /min-h-\[44px\]/);+ assert.match(answer.attrs, /data-strip-answer/);+ // Desktop keeps its old strip: no Answer button there.+ assert.ok(!buttons(m.strip({ active: true, name: 'QA', title: 'QA', awaitingAnswer: true, phone: false, onAnswer: noop })).some((b) => b.label === 'Answer'));+});++test('on a phone the steps panel is one 44 px row, the engine note behind an info button', () => {+ const note = step({ id: 'n', kind: 'note', status: 'ok', title: 'This engine doesn’t share its thinking.' });+ const html = m.steps({ live: live([step(), note]), idBase: 'x', compact: true });+ assert.match(html, /data-steps-compact/);+ assert.doesNotMatch(text(html), /doesn’t share its thinking/, 'the disclaimer is not on screen');+ assert.doesNotMatch(text(html), /Working ·/);+ const b = buttons(html);+ assert.match(b[0].label, /^Steps · 1/);+ assert.match(b[0].attrs, /min-h-\[44px\]|h-11/);+ assert.match(b[0].attrs, /aria-expanded="false"/);+ const info = b.find((x) => /aria-label="About this engine/.test(x.attrs));+ assert.ok(info, 'info button');+ assert.match(info.attrs, /w-11 h-11|h-11 w-11/);+});++// --- C3 and C4 ------------------------------------------------------------------------------++test('question card: a short placeholder on one line, a 16 px field and 44 px targets', () => {+ const meta = m.parseQuestionMeta({ kind: 'ask_user', question_id: 'q1', question: 'Which hotel?', choices: ['Rifugio', 'Hotel'], status: 'open', answer: null });+ const html = m.question({ meta, messageId: 'm1', kwantName: 'QA', waiting: true, onAnswer: async () => {}, onDismiss: async () => {} });+ const field = /<textarea([^>]*)>/.exec(html)[1];+ assert.match(field, /placeholder="Your own answer…"/);+ assert.match(field, /text-base/);+ assert.match(field, /placeholder:whitespace-nowrap/);+ const b = buttons(html);+ for (const c of b.filter((x) => /aria-pressed/.test(x.attrs))) {+ assert.match(c.attrs, /w-full/, c.label);+ assert.match(c.attrs, /min-h-\[48px\]/, c.label);+ assert.match(c.attrs, /text-base leading-\[22px\]/, c.label);+ }+ const skip = b.find((x) => x.label === 'Skip question');+ assert.match(skip.attrs, /min-h-\[44px\]/);+ assert.match(skip.attrs, /text-sm/);+ assert.match(skip.attrs, /text-\[#a39dcc\]/);+ assert.match(html, /w-11 h-11/, 'a 44 px send button');+ // The strip already says the bot waits: on a phone the card does not say it again (C2: at most twice).+ assert.match(html, /<span class="[^"]*max-md:hidden[^"]*" data-question-waiting="">/);+});++test('engine chip: the model alone on a phone, the full label from sm up and on hover', () => {+ const html = m.chip({ label: 'Claude · claude-opus-5-5 · Booktuning', short: 'claude-opus-5-5' });+ assert.match(html, /title="Claude · claude-opus-5-5 · Booktuning"/);+ assert.match(html, /<span class="[^"]*sm:hidden[^"]*max-w-\[160px\][^"]*"[^>]*>claude-opus-5-5<\/span>/);+ assert.match(html, /<span class="[^"]*hidden sm:inline[^"]*">Claude · claude-opus-5-5 · Booktuning<\/span>/);+});++test('reply header on a phone: one row, the time never shrinks, the chip gives way', () => {+ const html = m.meta({ name: 'Architect', at: '2026-11-02T11:42:00Z', now: Date.parse('2026-11-02T12:00:00Z'), ranOn: 'Custom API · claude-opus-5-5', account: 'Anthropic API' });+ assert.match(html, /<div class="[^"]*flex-nowrap sm:flex-wrap[^"]*">/);+ assert.match(html, /<span class="[^"]*shrink-0 whitespace-nowrap[^"]*" data-reply-time="">/);+ assert.match(html, /<span class="[^"]*sm:hidden[^"]*max-w-\[160px\][^"]*"[^>]*>claude-opus-5-5<\/span>/);+});++// --- Rigel's #309 HOLD on b48683c ------------------------------------------------------------++import { readFileSync } from 'node:fs';+const src = (p) => readFileSync(new URL(`../${p}`, import.meta.url), 'utf8');++test('C1.5d, C3.1c: Allow once and the choices beat the 44 px coarse-pointer rule with an important 48 px', () => {+ // modern.css's phone rule is (0,2,0) and stays as it is; a plain .min-h-[48px] (0,1,0) loses to it.+ assert.match(src('src/styles/modern.css'), /\(pointer: coarse\)[\s\S]*?:is\(button[\s\S]*?min-height: 44px/);+ const allow = buttons(m.card({ approval: pr(), onResolve: noop, phone: true })).find((x) => x.label === 'Allow once');+ assert.match(allow.attrs, /max-sm:!min-h-\[48px\]/);+ assert.match(allow.attrs, /sm:min-h-\[36px\]/, 'desktop keeps its compact button');+ const meta = m.parseQuestionMeta({ kind: 'ask_user', question_id: 'q1', question: 'Which hotel?', choices: ['Rifugio', 'Hotel'], status: 'open', answer: null });+ const choices = buttons(m.question({ meta, messageId: 'm1', kwantName: 'QA', waiting: true, onAnswer: async () => {}, onDismiss: async () => {} })).filter((x) => /aria-pressed/.test(x.attrs));+ assert.equal(choices.length, 2);+ for (const c of choices) assert.match(c.attrs, /max-sm:!min-h-\[48px\]/, c.label);+});++const awayApproval = (over = {}) => ({+ kind: 'approval', id: 'ap1', kwant_id: 'k1', kwant_name: 'TechLead', title: 'Use create_pull_request (github)',+ summary: 'acme/site', status: 'pending', timestamp: '2026-11-05T08:00:00Z',+ link: { thread_id: 't1', channel_id: null, direct_kwant_id: null },+ tool_name: 'mcp__github__create_pull_request', details: pr().details, ...over,+});++test('C2.3: an Inbox approval is titled like its card, never by the raw tool name', () => {+ assert.equal(m.awayTitle(awayApproval()), 'Open a pull request on GitHub');+ // An older server: only the title and a summary.+ assert.equal(m.awayTitle(awayApproval({ tool_name: undefined, details: undefined, title: 'Use Bash' })), 'Run a command');+ const q = { ...awayApproval(), kind: 'question', title: 'Which hotel?' };+ assert.equal(m.awayTitle(q), 'Which hotel?', 'other items keep their title');+ const data = { since: '2026-11-05T07:00:00Z', last_seen: null, now: '2026-11-05T08:05:00Z', stuck_after_minutes: 30, waiting: [awayApproval()], finished: [], failed: [], unseen: { waiting: 1, finished: 0, failed: 0, total: 1 } };+ const html = m.away({ data, loading: false, error: null, now: Date.parse('2026-11-05T08:05:00Z'), onRefresh: noop, onOpen: noop, onAnswer: noop, onResolve: noop });+ // The item's title line and its accessible name; the card's own "Show details" may still show the raw call.+ const titles = [...html.matchAll(/<p class="mt-0\.5 [^"]*">([^<]*)<\/p>/g)].map((x) => x[1]);+ assert.deepEqual(titles, ['Open a pull request on GitHub']);+ assert.match(html, /aria-label="Open a pull request on GitHub, /);+ assert.doesNotMatch(html, /Use create_pull_request/);+ // The card says the same words.+ assert.match(text(m.card({ approval: pr(), onResolve: noop, phone: true })), /wants to open a pull request on GitHub/);+});++test('ChatView keeps one phone flag after the rebase on #307: useMedia(PHONE_QUERY)', () => {+ const chat = src('src/components/ChatView.tsx');+ assert.deepEqual([...chat.matchAll(/const phone\b[^;\n]*/g)].map((x) => x[0]), ['const phone = useMedia(PHONE_QUERY)']);+ assert.doesNotMatch(chat, /usePhoneLayout/);+});diff --git a/frontend/tests/questions.test.mjs b/frontend/tests/questions.test.mjsindex 6e4e27cf..5e62884f 100644--- a/frontend/tests/questions.test.mjs+++ b/frontend/tests/questions.test.mjs@@ -75,7 +75,7 @@ test('an open card offers the choices, a typed answer and skip; the agent is waiassert.match(html, /Which region\?/);assert.equal((html.match(/aria-pressed="false"/g) || []).length, 2);assert.doesNotMatch(html, /<button[^>]*disabled=""[^>]*aria-pressed/);- assert.match(html, /Or type your own answer/);+ assert.match(html, /Your own answer/);assert.match(html, /Skip question/);assert.match(html, /CTO is waiting for your answer\. You can keep chatting meanwhile\./);assert.doesNotMatch(html, /busy|elsewhere/i);diff --git a/frontend/tests/signature.test.mjs b/frontend/tests/signature.test.mjsindex 7f6fb906..9beb4f94 100644--- a/frontend/tests/signature.test.mjs+++ b/frontend/tests/signature.test.mjs@@ -132,7 +132,7 @@ test('working strip: never "getting started" once the turn has steps (ticket 2)'// Between steps (a finished tool, nothing open yet) the bot is still working, not starting.assert.equal(w.workingLabel({ live: done }), 'working on it');// An open step still wins, and so does the reply once it streams.- assert.equal(w.workingLabel({ live: { ...done, steps: [...done.steps, step({ id: 's3', status: 'running', title: 'Using `web_search`' })] } }), 'using web_search');+ assert.equal(w.workingLabel({ live: { ...done, steps: [...done.steps, step({ id: 's3', status: 'running', title: 'Using `web_search`' })] } }), 'searching the web');assert.equal(w.workingLabel({ live: done, writing: true }), 'writing the reply');// No steps at all: the turn really is just starting.assert.equal(w.workingLabel({ live: { turnId: 't', thinking: {}, steps: [] } }), 'getting started');