Skip to content

armgit / kwant

Public Imported from GitHub
0

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.

UI refresh PR 2: conversation stream (stacked on pixel-ui-refresh) (#266)

Oleksandr Ivanchenkob49c4b19e387
diff --git a/frontend/src/activity.ts b/frontend/src/activity.ts
index 7406cfbd..137e3f58 100644
--- a/frontend/src/activity.ts
+++ b/frontend/src/activity.ts
@@ -132,12 +132,21 @@ export function formatDuration(msTotal: number): string {
/** Steps that count in the summary: notes explain a limit and aren't work. */
const counted = (steps: ActivityStep[]) => steps.filter((s) => s.kind !== 'note');
-/** "12 steps · 41s", "1 step", plus "· 2 failed" when any failed. */
+/** "0:42", "12:05", "1:02:09": the working strip's clock. Negative or non-finite input reads 0:00. */
+export function formatClock(ms: number): string {
+ const total = Number.isFinite(ms) && ms > 0 ? Math.floor(ms / 1000) : 0;
+ const h = Math.floor(total / 3600);
+ const m = Math.floor((total % 3600) / 60);
+ const sec = String(total % 60).padStart(2, '0');
+ return h > 0 ? `${h}:${String(m).padStart(2, '0')}:${sec}` : `${m}:${sec}`;
+}
+
+/** "Worked 0:41 · 12 steps" (the strip's last time, same start), "1 step", plus "· 2 failed" when any failed. */
export function activitySummary(a: SavedActivity): string {
const n = counted(a.steps).length + a.dropped;
- const parts = [`${n} ${n === 1 ? 'step' : 'steps'}`];
+ const steps = `${n} ${n === 1 ? 'step' : 'steps'}`;
const span = activitySpan(a.steps);
- if (span !== null && span >= 1000) parts.push(formatDuration(span));
+ const parts = span !== null && span >= 1000 ? [`Worked ${formatClock(span)}`, steps] : [steps];
const failed = a.steps.filter((s) => s.status === 'failed').length;
if (failed) parts.push(`${failed} failed`);
return parts.join(' · ');
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index 4d4c2960..cfa6ac9d 100644
--- a/frontend/src/components/ActivityList.tsx
+++ b/frontend/src/components/ActivityList.tsx
@@ -4,7 +4,6 @@ import {
ActivityStep,
LiveActivity,
SavedActivity,
- activitySpan,
activitySummary,
formatDuration,
isOpenStep,
@@ -113,7 +112,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
if (step.kind === 'note')
return (
- <li className="flex items-start gap-2 px-3 py-1.5 text-[11px] text-zinc-400">
+ <li className="flex items-start gap-2 px-3 py-1.5 text-xs text-zinc-400">
<Info size={13} className="mt-px flex-shrink-0 text-zinc-400" aria-hidden="true" />
<span className="min-w-0 break-words">{step.title}</span>
</li>
@@ -133,7 +132,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
if (step.kind === 'thinking') {
const boxId = `${listId}-${step.id}-text`;
return (
- <li className="px-3 py-1.5 text-[12px]">
+ <li className="px-3 py-1.5 text-xs">
<button
type="button"
onClick={() => setOpen((o) => !o)}
@@ -153,7 +152,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
}
return (
- <li className={`px-3 py-1.5 text-[12px] ${waiting ? 'bg-amber-500/[0.06]' : ''}`}>
+ <li className={`px-3 py-1.5 text-xs ${waiting ? 'bg-amber-500/[0.06]' : ''}`}>
{step.detail ? (
<details className="group">
<summary className="flex items-start gap-2 cursor-pointer list-none rounded [&::-webkit-details-marker]:hidden focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400">
@@ -178,12 +177,12 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
const Steps: React.FC<{ steps: ActivityStep[]; live?: LiveActivity; dropped?: number; id: string }> = ({ steps, live, dropped = 0, id }) => {
const now = useNow(steps.some(isOpenStep));
return (
- <ol id={id} aria-label="Steps" className="divide-y divide-zinc-800/60">
+ <ol id={id} aria-label="Steps" className="divide-y divide-zinc-700/40">
{steps.map((s) => (
<StepRow key={s.id} step={s} live={live} now={now} listId={id} />
))}
{dropped > 0 && (
- <li className="px-3 py-1.5 text-[11px] text-zinc-400">
+ <li className="px-3 py-1.5 text-xs text-zinc-400">
{dropped} more {dropped === 1 ? 'step' : 'steps'} not kept
</li>
)}
@@ -197,15 +196,14 @@ export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string }>
if (steps.length === 0) return null;
const work = steps.filter((s) => s.kind !== 'note').length;
const current = [...steps].reverse().find(isOpenStep);
- const span = activitySpan(steps);
return (
- <section aria-label="What the bot is doing" className="mb-2 w-full max-w-2xl rounded-xl border border-zinc-800 bg-zinc-950/50 overflow-hidden">
- <p className="flex items-center gap-1.5 px-3 pt-2 pb-1 text-[10px] font-medium uppercase tracking-wide text-zinc-400">
+ <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">
<ListTree size={11} className="text-sky-400/80" aria-hidden="true" />
Working
<span className="normal-case tracking-normal font-normal">
+ {/* No time while running: the working strip shows the whole turn's, the open step its own. */}
· {work} {work === 1 ? 'step' : 'steps'}
- {span !== null && span >= 1000 ? ` · ${formatDuration(span)}` : ''}
</span>
</p>
{/* Only waits are announced; a stream of tool names would be noise. */}
@@ -219,7 +217,7 @@ export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string }>
);
};
-/** On a saved reply: "12 steps · 41s", opening to the list. `children` go under the steps. */
+/** On a saved reply: "Worked 0:41 · 12 steps", opening to the list. `children` go under the steps. */
export const SavedActivityList: React.FC<{ activity: SavedActivity; idBase: string; children?: React.ReactNode }> = ({ activity, idBase, children }) => {
const [open, setOpen] = useState(false);
const listId = `${idBase}-steps`;
@@ -231,14 +229,14 @@ export const SavedActivityList: React.FC<{ activity: SavedActivity; idBase: stri
onClick={() => setOpen((o) => !o)}
aria-expanded={open}
aria-controls={open ? listId : undefined}
- className="max-w-full min-w-0 flex items-center gap-2 px-3 py-1.5 rounded-xl text-xs text-zinc-400 hover:text-zinc-200 bg-zinc-900/80 hover:bg-zinc-900 border border-zinc-800 hover:border-zinc-700/80 transition-colors cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"
+ className="max-w-full min-w-0 flex items-center gap-2 px-3 py-1.5 rounded-xl text-xs text-zinc-400 hover:text-zinc-200 bg-zinc-900/70 hover:bg-zinc-800/70 border border-zinc-700/60 hover:border-zinc-600/80 transition-colors cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"
>
<ListTree size={13} className={failed ? 'text-rose-300' : 'text-sky-400/80'} aria-hidden="true" />
<span className="truncate min-w-0">{activitySummary(activity)}</span>
<ChevronRight size={13} className={`flex-shrink-0 text-zinc-400 transition-transform motion-reduce:transition-none ${open ? 'rotate-90' : ''}`} aria-hidden="true" />
</button>
{open && (
- <div className="mt-1.5 w-full max-w-2xl rounded-xl border border-zinc-800 bg-zinc-950/50 overflow-hidden">
+ <div className="mt-1.5 w-full max-w-2xl rounded-xl border border-zinc-700/60 bg-zinc-900/60 overflow-hidden shadow-[var(--kws-shadow)]">
<Steps steps={activity.steps} dropped={activity.dropped} id={listId} />
{children}
</div>
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index f24adc0b..8df9ea3b 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect, useMemo } from 'react';
-import { ArrowDown, ArrowUp, AtSign, Paperclip, Sparkles, ChevronDown, ChevronRight, Copy, Check, ChevronLeft, Users, Square, Settings2, Folder, GitBranch, Pencil, Pin, Monitor, Loader2 } from 'lucide-react';
+import { ArrowDown, ArrowUp, AtSign, Paperclip, Sparkles, ChevronDown, ChevronRight, Copy, Check, ChevronLeft, Users, Square, Settings2, Folder, GitBranch, Pencil, Pin, Monitor } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
import { BotHome } from './BotHome';
import { ChatHome, answerTarget, goodAt, recipientsOf } from '../botHome';
@@ -21,7 +21,7 @@ import { LiveActivity, hasThinkingText, parseActivityMeta } from '../activity';
import { LiveActivityList, SavedActivityList } from './ActivityList';
import { FailoverNote, ReplyMeta } from './ReplyMeta';
import { assignSwitchNotes, liveSwitchNote, type SwitchNote } from '../failoverNotes';
-import { savedFailoverNotice } from '../failover';
+import { savedFailoverHandoff, savedFailoverNotice } from '../failover';
import { SuggestionMeta, parseSuggestionMeta } from '../mcpSuggestions';
import { BotActionMeta, HireMeta, parseBotActionMeta, parseHireMeta } from '../botActions';
import {
@@ -45,7 +45,7 @@ import { replyTokens } from '../modelUsage';
import { parseRoutingMeta, ranOnAccount, routingLine } from '../spaces';
import { SetupNeededCard, parseSetupMeta } from './SetupNeededCard';
import { ConnectionSuggestionMeta, parseConnectionMeta } from '../connectionSuggestions';
-import { routeReasonText } from '../routeReason';
+import { routeChipLabel, routeReasonText } from '../routeReason';
import { BudgetPausedNotice, HandoffCappedNotice, InterruptedNotice, SystemNotice } from './SystemNotice';
import { chainBudgetApi, parseBudgetPaused, parseHandoffCapped } from '../chainBudget';
import { isSystemNotice, parseInterruption, retryTargets } from '../interruptions';
@@ -53,7 +53,8 @@ import { consultedNames, hideStreamingDecisions, messageDecisions, parseWorkAhea
import { approvalScrollAction, fullyVisible, isNearBottom, nextFollowing } from '../approvalVisibility';
import { DecidingLine, DecisionChips, WorkAheadBody } from './Proactive';
import { RouteChoiceMeta, parseRouteChoiceMeta, questionsOfReplies } from '../routeChoice';
-import { SmartActionsSlot } from './results/SmartActions';
+import { SmartActionsSlot, actionClass } from './results/SmartActions';
+import { WorkingStrip } from './WorkingStrip';
import { COMPOSE_PREFILL_EVENT, withPrefill } from './results/SmartResult';
import { FilesPreviewOnly } from './results/Files';
@@ -281,117 +282,6 @@ export const renderFormattedText = (text: string): React.ReactNode => {
});
};
-interface Reroute {
- /** The reply's id, for element ids. */
- key: string;
- targets: Array<{ id: string; name: string; title: string }>;
- onPick: (kwantId: string) => Promise<string | void>;
-}
-
-/** Why Laya picked this bot. Phones show one line and open the rest on a tap. With `reroute`, a
- * "Wrong bot?" link opens the other bots here; picking one teaches routing and asks that bot. */
-const RoutingLine: React.FC<{ text: string; fallback: boolean; reroute?: Reroute }> = ({ text, fallback, reroute }) => {
- const [open, setOpen] = useState(false);
- const [picking, setPicking] = useState(false);
- const [busy, setBusy] = useState<string | null>(null);
- const [error, setError] = useState<string | null>(null);
- const [sentTo, setSentTo] = useState<string | null>(null);
- const tone = fallback ? 'text-amber-300/80' : 'text-violet-300/80';
- const icon = <Sparkles size={10} className="inline -mt-0.5 mr-1" aria-hidden="true" />;
- const panelId = reroute ? `reroute-${reroute.key}` : undefined;
- const canReroute = !!reroute && reroute.targets.length > 0;
-
- const pick = async (k: { id: string; name: string }) => {
- if (!reroute || busy) return;
- setBusy(k.id);
- setError(null);
- const err = await reroute.onPick(k.id);
- setBusy(null);
- if (err) setError(err);
- else {
- setSentTo(k.name);
- setPicking(false);
- }
- };
-
- const wrongBot = canReroute && !sentTo && (
- <button
- type="button"
- onClick={() => setPicking((v) => !v)}
- aria-expanded={picking}
- aria-controls={panelId}
- className="shrink-0 py-1 sm:py-0 text-[11px] text-zinc-500 hover:text-zinc-200 underline decoration-dotted underline-offset-2 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"
- >
- Wrong bot?
- </button>
- );
-
- return (
- <>
- <div className="hidden sm:flex items-baseline gap-2 -mt-1 mb-1.5 max-w-full min-w-0" data-routing-line>
- <p className={`text-[11px] ${tone} break-words min-w-0`}>
- {icon}
- {text}
- </p>
- {wrongBot}
- </div>
- <div className="sm:hidden flex items-center gap-2 -mt-3.5 -mb-1.5 max-w-full min-w-0">
- <button
- type="button"
- data-compact
- onClick={() => setOpen((v) => !v)}
- aria-expanded={open}
- title={open ? undefined : text}
- className={`py-3.5 min-w-0 flex-1 text-left text-[11px] ${tone} ${open ? 'break-words' : 'truncate'} rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500`}
- >
- {icon}
- {text}
- </button>
- {wrongBot}
- </div>
- {picking && reroute && (
- <div id={panelId} role="group" aria-label="Send to another bot" className="mt-1 sm:mt-0 mb-2 max-w-full rounded-xl border border-zinc-800 bg-zinc-950/70 px-3 py-2">
- <p className="text-[11px] text-zinc-400 mb-1.5">Send your message to:</p>
- <div className="flex flex-wrap gap-1.5">
- {reroute.targets.map((k) => (
- <button
- key={k.id}
- type="button"
- disabled={busy !== null}
- onClick={() => pick(k)}
- title={k.title}
- className="inline-flex items-center gap-1.5 min-h-[36px] sm:min-h-[28px] px-2.5 rounded-lg border border-zinc-700 bg-zinc-900 text-xs text-zinc-100 hover:bg-zinc-800 disabled:opacity-60 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"
- >
- {busy === k.id && <Loader2 size={12} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
- <span>{k.name}</span>
- {k.title && <span className="hidden sm:inline text-zinc-500">· {k.title}</span>}
- </button>
- ))}
- <button
- type="button"
- onClick={() => setPicking(false)}
- className="min-h-[36px] sm:min-h-[28px] px-2.5 rounded-lg text-xs text-zinc-400 hover:text-zinc-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"
- >
- Cancel
- </button>
- </div>
- <p className="mt-1.5 text-[11px] text-zinc-500">Messages like this will go to the bot you pick from now on.</p>
- {error && (
- <p role="alert" className="mt-1 text-[11px] text-rose-400 break-words">
- {error}
- </p>
- )}
- </div>
- )}
- {sentTo && (
- <p role="status" className="-mt-0.5 mb-1.5 text-[11px] text-emerald-300/90">
- Sent to {sentTo}. Messages like this will go to {sentTo} from now on.
- </p>
- )}
- </>
- );
-};
-
const LayaRoutingCard: React.FC<{ routing: RoutingState; spaceName?: string }> = ({ routing, spaceName }) => {
const deciding = routing.phase === 'deciding';
const isDiscuss = routing.mode === 'discuss';
@@ -970,6 +860,34 @@ export const ChatView: React.FC<ChatViewProps> = ({
);
const liveNote = isStreaming ? liveSwitchNote(switchNotes ?? [], switchNoteFor, streamingSpeakerName || title) : null;
+ // Replies that arrive while the chat is open slide in; the first load and a stream handing over to its saved copy do not
+ const freshTrack = useRef<{ key: string | undefined; seen: Set<string> | null; fresh: Set<string>; streamEnded: number; wasStreaming: boolean }>({
+ key: undefined,
+ seen: null,
+ fresh: new Set(),
+ streamEnded: 0,
+ wasStreaming: false,
+ });
+ {
+ const t = freshTrack.current;
+ if (isStreaming) t.wasStreaming = true;
+ else if (t.wasStreaming) {
+ t.wasStreaming = false;
+ t.streamEnded = Date.now();
+ }
+ if (t.key !== contextKey || t.seen === null) {
+ t.key = contextKey;
+ t.seen = new Set(messages.map((m) => m.id));
+ t.fresh = new Set();
+ } else {
+ for (const m of messages) {
+ if (t.seen.has(m.id)) continue;
+ t.seen.add(m.id);
+ if (!isStreaming && Date.now() - t.streamEnded > 2500) t.fresh.add(m.id);
+ }
+ }
+ }
+
const renderMessage = (msg: ChatMessage) => {
const interruption = parseInterruption(msg);
if (interruption)
@@ -1059,6 +977,11 @@ export const ChatView: React.FC<ChatViewProps> = ({
const text = shownDecisions ? shownDecisions.text : msg.text;
const workAhead = isUser ? null : parseWorkAhead(msg.meta);
const displayName = isUser ? 'You' : (msg.sender_id && msg.sender_id.length > 20 ? title : msg.sender_id);
+ // Whose mood the reply header shows (Pixel's AvatarMood, drawn by ModernAvatar given a kwantId):
+ // Laya's pick, else this bot chat's bot, else the team member with that name. Unknown: no mood.
+ const replyKwantId = isUser
+ ? undefined
+ : routed?.kwant_id ?? (home?.kind === 'bot' ? home.bot?.id : undefined) ?? activeKwants.find((k) => k.name === displayName)?.id;
return (
<div
@@ -1066,15 +989,19 @@ export const ChatView: React.FC<ChatViewProps> = ({
data-message-id={msg.id}
className={`flex items-start gap-3.5 w-full max-w-5xl rounded-xl ${isUser ? 'ml-auto flex-row-reverse justify-start' : ''} ${
flashId === msg.id ? 'kw-flash' : ''
- }`}
+ } ${freshTrack.current.fresh.has(msg.id) ? 'kws-in' : ''}`}
>
{/* Phones show the avatar inside the name line instead, so the bubble gets the full width */}
<span className="hidden sm:contents">
- <ModernAvatar
- role={isUser ? 'user' : title}
- name={displayName}
- size={34}
- />
+ {/* Laya hand-off: a reply she just routed brings the chosen bot's avatar up into the header */}
+ <span className={routed && freshTrack.current.fresh.has(msg.id) ? 'kws-handoff inline-flex' : 'contents'}>
+ <ModernAvatar
+ role={isUser ? 'user' : title}
+ name={displayName}
+ size={36}
+ kwantId={replyKwantId}
+ />
+ </span>
</span>
<div className={`flex flex-col min-w-0 ${isUser ? 'max-w-[85%] sm:max-w-2xl items-end' : 'flex-1 max-w-4xl items-start'}`}>
@@ -1087,12 +1014,30 @@ export const ChatView: React.FC<ChatViewProps> = ({
<ReplyMeta
name={displayName}
at={msg.created_at}
- avatar={<ModernAvatar role={title} name={displayName} size={20} />}
+ avatar={<span className={routed && freshTrack.current.fresh.has(msg.id) ? 'kws-handoff inline-flex' : 'inline-flex'}><ModernAvatar role={title} name={displayName} size={20} kwantId={replyKwantId} /></span>}
ranOn={ranOn}
account={account}
tokens={tokens}
failed={!!savedActivity?.steps.some((s) => s.status === 'failed')}
note={savedFailoverNotice(msg.meta) ?? switchNoteFor.get(msg.id)}
+ handoff={savedFailoverHandoff(msg.meta)}
+ route={
+ routed
+ ? {
+ label: routeChipLabel({ basis: routed.basis, fallback: routed.fallback }),
+ text: routingLine(routed, spaceName ?? 'this space', (id) => activeKwants.find((k) => k.id === id)?.name),
+ fallback: !!routed.fallback,
+ reroute:
+ onSendToOtherBot && questionOf.get(msg.id)
+ ? {
+ key: msg.id,
+ targets: rerouteTargets.filter((k) => k.id !== routed.kwant_id && k.name !== displayName),
+ onPick: (kwantId) => onSendToOtherBot(questionOf.get(msg.id)!, kwantId),
+ }
+ : undefined,
+ }
+ : undefined
+ }
>
{/* What the reply did: "12 steps · 41s", opening to the steps (tool calls go inside) */}
{savedActivity && (
@@ -1130,22 +1075,6 @@ export const ChatView: React.FC<ChatViewProps> = ({
</ReplyMeta>
)}
- {routed && (
- <RoutingLine
- text={routingLine(routed, spaceName ?? 'this space', (id) => activeKwants.find((k) => k.id === id)?.name)}
- fallback={!!routed.fallback}
- reroute={
- onSendToOtherBot && questionOf.get(msg.id)
- ? {
- key: msg.id,
- targets: rerouteTargets.filter((k) => k.id !== routed.kwant_id && k.name !== displayName),
- onPick: (kwantId) => onSendToOtherBot(questionOf.get(msg.id)!, kwantId),
- }
- : undefined
- }
- />
- )}
-
{/* Message Body Bubble */}
{!filesOnly && (text.trim() || !files.length) && (
<div
@@ -1189,23 +1118,23 @@ export const ChatView: React.FC<ChatViewProps> = ({
{!isUser && msg.tool_calls && !savedActivity && <ToolCallsList raw={msg.tool_calls} />}
- {/* Copy action */}
+ {/* Action row: icon chips; the smart-result actions portal in after Copy */}
{!isUser && !filesOnly && (
- <div className="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-zinc-500 text-xs max-w-full min-w-0">
+ <div className="mt-2 flex flex-wrap items-center gap-2 text-zinc-400 text-xs max-w-full min-w-0">
<button
type="button"
onClick={() => handleCopy(text, msg.id)}
- className="px-2 py-1 rounded-md hover:bg-zinc-900 hover:text-zinc-300 transition-colors flex items-center gap-1.5 text-[11px] cursor-pointer"
+ className={actionClass}
title="Copy response"
>
{copiedId === msg.id ? (
<>
- <Check size={12} className="text-emerald-400" />
- <span className="text-emerald-400 font-medium">Copied</span>
+ <Check size={14} className="text-emerald-400" aria-hidden="true" />
+ <span className="text-emerald-400">Copied</span>
</>
) : (
<>
- <Copy size={12} />
+ <Copy size={14} aria-hidden="true" />
<span className="sm:hidden">Copy</span>
<span className="hidden sm:inline">Copy markdown</span>
</>
@@ -1338,17 +1267,7 @@ export const ChatView: React.FC<ChatViewProps> = ({
</button>
)}
- {isStreaming && !discussionState?.inProgress && onCancelDiscussion && (
- <button
- type="button"
- onClick={onCancelDiscussion}
- className="flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium text-red-300 bg-red-500/10 hover:bg-red-500/20 border border-red-500/30 transition-colors shadow-sm cursor-pointer"
- title="Stop generation"
- >
- <Square size={10} fill="currentColor" />
- <span>Stop</span>
- </button>
- )}
+ {/* No header Stop while the working strip shows (always, when a reply runs): the composer's stop square is the one Stop. */}
{/* Sandbox VM & Live Browser Toggle Button */}
<button
type="button"
@@ -1509,12 +1428,12 @@ export const ChatView: React.FC<ChatViewProps> = ({
<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'}
</span>
- ) : (
+ ) : discussionState?.inProgress ? (
<span className="inline-flex items-center gap-1 text-sky-400 text-[10px]">
<span className="w-1.5 h-1.5 rounded-full bg-sky-400 animate-ping motion-reduce:animate-none" aria-hidden="true" />
- {discussionState?.inProgress ? 'Speaking...' : 'Generating...'}
+ Speaking...
</span>
- )}
+ ) : null /* "Generating" would repeat the working strip */}
</div>
{liveNote && <FailoverNote text={liveNote} />}
@@ -1545,15 +1464,11 @@ export const ChatView: React.FC<ChatViewProps> = ({
: 'Paused on the question above. Answer it there; this reply carries on from it.'}
</p>
) : (
- <span className="inline-flex gap-1 py-1.5" aria-label="Waiting for the first words">
- {[0, 1, 2].map((i) => (
- <span
- key={i}
- className="w-1.5 h-1.5 rounded-full bg-zinc-500 animate-bounce motion-reduce:animate-none"
- style={{ animationDelay: `${i * 150}ms` }}
- />
- ))}
- </span>
+ <div className="space-y-2.5 py-1" role="status" aria-label="Waiting for the first words">
+ <div className="kws-skel h-3 w-11/12 rounded-full bg-zinc-700/60" />
+ <div className="kws-skel h-3 w-9/12 rounded-full bg-zinc-700/60" style={{ animationDelay: '120ms' }} />
+ <div className="kws-skel h-3 w-6/12 rounded-full bg-zinc-700/60" style={{ animationDelay: '240ms' }} />
+ </div>
)}
</div>
</div>
@@ -1589,6 +1504,17 @@ export const ChatView: React.FC<ChatViewProps> = ({
</ScrollRow>
)}
+ <WorkingStrip
+ active={isStreaming}
+ name={discussionState?.inProgress && discussionState.currentSpeaker ? discussionState.currentSpeaker : streamingSpeakerName || title}
+ title={title}
+ live={liveActivity}
+ queued={!!queued}
+ awaitingAnswer={!!awaitingAnswer}
+ awaitingBrowser={!!awaitingBrowser}
+ writing={!!streamingText}
+ />
+
{/* Modern Composer Input Bar */}
<div className="px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:p-4 border-t border-hairline bg-surface-side/60">
{teamMembers && teamMembers.length > 0 && (
@@ -1765,23 +1691,25 @@ export const ChatView: React.FC<ChatViewProps> = ({
<AtSign size={17} aria-hidden="true" />
</button>
{/* "New" sits just above the field's top edge, over the "@" button: never on or inside the border.
- Each button after "@" (stop, send) is 44px on phones / 36px from sm, plus a 6px gap; 9px is the
- form's border + padding. Hidden while the mention picker is open, so it never peeks under it. */}
- <NewTag
- id="mention"
- className={`absolute bottom-full mb-1.5 [--kw-cbtn-step:50px] sm:[--kw-cbtn-step:42px] ${isMentionOpen ? 'hidden' : ''}`}
- style={{
- right: `calc(11px + var(--kw-cbtn-step) * ${(isStreaming ? 1 : 0) + (isStreaming && (discussionState?.inProgress || !canSend) ? 0 : 1)})`,
- }}
- />
+ Only the send button follows "@" when it shows: 44px on phones / 36px from sm, plus a 6px gap;
+ 11px is the form's border + padding. Hidden (not marked as seen) while a reply streams, so it
+ never sits on the working strip's edge and comes back after the turn; hidden while the mention
+ picker is open, so it never peeks under it. */}
+ {!isStreaming && (
+ <NewTag
+ id="mention"
+ className={`absolute bottom-full mb-1.5 [--kw-cbtn-step:50px] sm:[--kw-cbtn-step:42px] ${isMentionOpen ? 'hidden' : ''}`}
+ style={{ right: 'calc(11px + var(--kw-cbtn-step))' }}
+ />
+ )}
{isStreaming && (
<button
type="button"
onClick={onCancelDiscussion}
className="w-11 h-11 sm:w-9 sm:h-9 rounded-xl flex items-center justify-center transition-colors flex-shrink-0 bg-red-500/20 hover:bg-red-500/30 text-red-300 border border-red-400/30 cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-rose-400"
- title={discussionState?.inProgress ? 'Stop Discussion' : 'Stop generation'}
- aria-label={discussionState?.inProgress ? 'Stop discussion' : 'Stop the reply'}
+ title={discussionState?.inProgress ? 'Stop Discussion' : 'Stop'}
+ aria-label={discussionState?.inProgress ? 'Stop discussion' : 'Stop'}
>
<Square size={12} fill="currentColor" aria-hidden="true" />
</button>
diff --git a/frontend/src/components/CheckBurst.tsx b/frontend/src/components/CheckBurst.tsx
new file mode 100644
index 00000000..edc981ab
--- /dev/null
+++ b/frontend/src/components/CheckBurst.tsx
@@ -0,0 +1,14 @@
+import React from 'react';
+
+const ANGLES = [0, 60, 120, 180, 240, 300];
+
+/** A 200 ms ring and six dots over a button that just confirmed something. Give it a new `n` per press; 0 draws nothing. */
+export const CheckBurst: React.FC<{ n: number }> = ({ n }) =>
+ n > 0 ? (
+ <span key={n} className="kws-burst" aria-hidden="true" data-check-burst="">
+ <span className="kws-burst-ring" />
+ {ANGLES.map((a) => (
+ <span key={a} className="kws-burst-dot" style={{ ['--kws-a' as string]: `${a}deg` }} />
+ ))}
+ </span>
+ ) : null;
diff --git a/frontend/src/components/FirstMoment.tsx b/frontend/src/components/FirstMoment.tsx
new file mode 100644
index 00000000..1026f491
--- /dev/null
+++ b/frontend/src/components/FirstMoment.tsx
@@ -0,0 +1,56 @@
+import React, { useEffect, useRef, useState } from 'react';
+import { claimFirst, claimQuietly, FIRST_LINE, FIRST_STICKER, type FirstKind } from '../signature';
+import { ShieldCheck, Target } from 'lucide-react';
+import { Sticker } from './Sticker';
+
+/**
+ * Once per space: the first time one of these items reaches its goal state while this screen is open
+ * (a task verified, a goal met). A space that already had one at load is not new, so it is claimed
+ * without a celebration. Returns the item id to celebrate, or null. The moment is the S3 sticker plus one line
+ * (no confetti); under reduced motion it shows the same, static.
+ */
+export function useFirstMoment(kind: FirstKind, spaceId: string, items: Array<{ id: string; reached: boolean }> | null): string | null {
+ const seen = useRef<{ space: string; map: Map<string, boolean> } | null>(null);
+ const [shown, setShown] = useState<string | null>(null);
+ const key = items ? items.map((i) => `${i.id}:${i.reached ? 1 : 0}`).join(',') : null;
+ const latest = useRef(items);
+ latest.current = items;
+ useEffect(() => {
+ const list = latest.current;
+ if (!list) return;
+ const prev = seen.current;
+ if (!prev || prev.space !== spaceId) {
+ if (list.some((i) => i.reached)) claimQuietly(kind, spaceId);
+ seen.current = { space: spaceId, map: new Map(list.map((i) => [i.id, i.reached])) };
+ setShown(null);
+ return;
+ }
+ for (const i of list) {
+ const was = prev.map.get(i.id);
+ prev.map.set(i.id, i.reached);
+ if (i.reached && was === false && claimFirst(kind, spaceId, i.id)) setShown(i.id);
+ }
+ }, [key, spaceId, kind]);
+ return shown;
+}
+
+/** The one line that goes with the first-time sticker; dismissable, never a toast. */
+export const FirstMomentLine: React.FC<{ kind: FirstKind; onDone: () => void }> = ({ kind, onDone }) => (
+ <div
+ role="status"
+ data-first-moment={kind}
+ className="relative flex items-center gap-3 rounded-xl border border-hairline bg-surface-raised px-3 py-2 shadow-[var(--kws-shadow)]"
+ >
+ <span className="relative inline-flex kws-stamp">
+ <Sticker tone="holo" tilt={-3} icon={kind === 'verified' ? <ShieldCheck size={12} aria-hidden="true" /> : <Target size={12} aria-hidden="true" />}>{FIRST_STICKER[kind]}</Sticker>
+ </span>
+ <p className="min-w-0 flex-1 text-xs text-zinc-200">{FIRST_LINE[kind]}</p>
+ <button
+ type="button"
+ onClick={onDone}
+ className="shrink-0 min-h-8 rounded-lg px-2.5 text-xs font-medium text-zinc-300 hover:bg-zinc-800 hover:text-zinc-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400"
+ >
+ Got it
+ </button>
+ </div>
+);
diff --git a/frontend/src/components/GoalsStrip.tsx b/frontend/src/components/GoalsStrip.tsx
index c35051ad..19e14466 100644
--- a/frontend/src/components/GoalsStrip.tsx
+++ b/frontend/src/components/GoalsStrip.tsx
@@ -9,6 +9,10 @@
import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
import { AlertTriangle, CheckCircle2, ChevronDown, CircleHelp, FilePen, Hourglass, Loader2, LucideIcon, Pause, Play, Plus, RefreshCw, Target, Trash2, Wrench, X, XCircle } from 'lucide-react';
+import { GoalHeartbeat } from './Signature';
+import { Sticker } from './Sticker';
+import { FirstMomentLine, useFirstMoment } from './FirstMoment';
+import { firstHolder, heartbeatDots, heartbeatWord, type HeartDot } from '../signature';
import { Check, MissionError, Task, Tone, ago, checkKindLabel, checkTarget, newIdempotencyKey, onMission, stateLabel, missionStatusLabel } from '../missions';
import {
CheckFormRow,
@@ -386,11 +390,16 @@ export const GoalRow: React.FC<{
decision?: Extract<GoalDecision, { kind: 'run' | 'declined' }> | null;
/** Past the first three on a phone, until "Show all". */
hideOnPhone?: boolean;
+ /** The last few checks, once the goal's history is loaded. */
+ heartbeat?: HeartDot[];
onOpen: (g: Goal) => void;
onOpenTask?: (id: string) => void;
onAction?: (a: GoalAction) => void;
-}> = ({ goal: g, names, titles = {}, now = Date.now(), error = null, busy = false, decision = null, hideOnPhone = false, onOpen, onOpenTask, onAction }) => {
+}> = ({ goal: g, names, titles = {}, now = Date.now(), error = null, busy = false, decision = null, hideOnPhone = false, heartbeat = [], onOpen, onOpenTask, onAction }) => {
const id = useId();
+ const fixing = !!(g.open_fix_task || g.open_mission);
+ // Only beside a Steady OK: never next to Back to ok, Failing, Fixing or Can’t check.
+ const firstKept = g.status === 'met' && heartbeatWord(g.status, heartbeat, fixing) === 'Steady' && firstHolder('goal_met', g.space_id ?? '') === g.id;
const draft = g.status === 'draft';
const proposer = g.created_by && g.created_by !== 'person' ? names[g.created_by] ?? null : null;
const work = currentWorkText(g, titles);
@@ -421,6 +430,14 @@ export const GoalRow: React.FC<{
</button>
<GoalStatusPill status={g.status} />
</div>
+ {(heartbeat.length > 1 || firstKept) && (
+ <div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1.5">
+ {heartbeat.length > 1 && <GoalHeartbeat dots={heartbeat} status={g.status} fixing={fixing} className="min-w-0 flex-1" />}
+ {firstKept && (
+ <Sticker tone="holo" tilt={-3} icon={<Target size={12} aria-hidden="true" />} title="The first goal kept in this space" className="pointer-events-none">First goal kept</Sticker>
+ )}
+ </div>
+ )}
{wide ? null : draft ? (
<p className="mt-0.5 truncate text-[11px] text-zinc-400" data-goal-line="draft">
{proposer ? `${proposer} proposed this.` : 'A bot proposed this.'} Nothing runs until you approve it.
@@ -1112,6 +1129,7 @@ export const GoalDetailBody: React.FC<{
<div className="space-y-1.5">
<div className="flex flex-wrap items-center gap-2">
<GoalStatusPill status={g.status} />
+ <GoalHeartbeat dots={heartbeatDots(d.events)} status={g.status} fixing={!!(g.open_fix_task || g.open_mission)} />
{/* A draft's hint already says nothing runs yet. */}
{!draft && <span className="text-[11px] text-zinc-500">{scheduleText(g, now)}</span>}
</div>
@@ -1805,6 +1823,8 @@ export const GoalsStrip: React.FC<{
});
const eventsOf = (id: string) => reads[id]?.events ?? (detail && detail.goal.id === id ? detail.events : []);
const sorted = sortGoals(merged.map((g) => ({ ...g, raw_status: g.status, status: displayStatus(g, eventsOf(g.id), now, notNow[g.id] ?? null) })));
+ const firstMet = useFirstMoment('goal_met', spaceId ?? '', goals ? sorted.map((g) => ({ id: g.id, reached: g.status === 'met' })) : null);
+ const [firstDone, setFirstDone] = useState(false);
const drafts = sorted.filter((g) => g.status === 'draft').length;
const panelTitle =
panel?.kind === 'new'
@@ -1953,6 +1973,7 @@ export const GoalsStrip: React.FC<{
</p>
)}
{draftingLine}
+ {firstMet && !firstDone && <FirstMomentLine kind="goal_met" onDone={() => setFirstDone(true)} />}
{notice && (
<p role="status" className={`text-[11px] text-emerald-300 ${wrap}`} data-goals-notice>
{notice}
@@ -1974,6 +1995,7 @@ export const GoalsStrip: React.FC<{
error={errors[g.id] ?? null}
decision={decision}
hideOnPhone={i >= cap}
+ heartbeat={heartbeatDots(eventsOf(g.id))}
onOpen={(x) => setPanel({ kind: 'goal', id: x.id })}
onOpenTask={openTask}
onAction={(a) => void act(g, a)}
diff --git a/frontend/src/components/MarkdownRenderer.tsx b/frontend/src/components/MarkdownRenderer.tsx
index 51c47a21..7b9c1675 100644
--- a/frontend/src/components/MarkdownRenderer.tsx
+++ b/frontend/src/components/MarkdownRenderer.tsx
@@ -210,7 +210,7 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({
// Tables
table: ({ node, children }) => {
const plain = (
- <div className="my-3.5 overflow-x-auto rounded-xl border border-zinc-800 bg-zinc-950/70 shadow-sm">
+ <div className="my-3.5 overflow-x-auto rounded-xl border border-zinc-700/60 bg-zinc-900/60 shadow-[var(--kws-shadow)]">
<table className="w-full text-left border-collapse text-xs font-sans">
{children}
</table>
@@ -222,12 +222,12 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({
return raw && reply ? <SmartResult raw={raw} reply={reply} messageId={messageId as string} fallback={plain} /> : plain;
},
thead: ({ children }) => (
- <thead className="bg-zinc-900/90 text-zinc-200 border-b border-zinc-800 font-medium">
+ <thead className="bg-zinc-800/70 text-zinc-100 border-b border-zinc-700/60 font-medium">
{children}
</thead>
),
tbody: ({ children }) => (
- <tbody className="divide-y divide-zinc-800/60 font-normal text-zinc-300">
+ <tbody className="divide-y divide-zinc-700/40 font-normal text-zinc-300">
{children}
</tbody>
),
diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsx
index fbd24ed2..7b63d582 100644
--- a/frontend/src/components/MissionBoardView.tsx
+++ b/frontend/src/components/MissionBoardView.tsx
@@ -33,6 +33,10 @@ import {
} from 'lucide-react';
import { PERSON_SIGNED_IN_EVENT, requestPersonToken } from '../auth';
import { ModernAvatar } from './ModernAvatar';
+import { CheckBurst } from './CheckBurst';
+import { LessonsChip, VerifiedStamp } from './Signature';
+import { FirstMomentLine, useFirstMoment } from './FirstMoment';
+import { firstHolder, lessonsChip, stampLabel, stampText } from '../signature';
import { PerformancePanel } from './PerformancePanel';
import { TierRequests } from './TierProposals';
import { FactNeedsYouAction, FactsLedger } from './FactsLedger';
@@ -181,7 +185,7 @@ const dangerBtn = `${actionBtn} border border-rose-500/30 text-rose-200 hover:bg
const card = 'rounded-xl border border-zinc-800 bg-zinc-900/40';
// Card-sized buttons: compact on desktop, a full 40px tap target on the phone.
const cardBtn =
- 'inline-flex items-center justify-center gap-1 min-h-[40px] sm:min-h-[28px] px-2.5 rounded-lg text-[11px] font-medium disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500';
+ 'relative inline-flex items-center justify-center gap-1 min-h-[40px] sm:min-h-[28px] px-2.5 rounded-lg text-[11px] font-medium disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500';
const cardGoodBtn = 'bg-emerald-600/90 text-white hover:bg-emerald-500';
const cardPlainBtn = 'border border-zinc-700 bg-zinc-800/80 text-zinc-100 hover:bg-zinc-700';
const cardQuietBtn = 'text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800';
@@ -621,6 +625,7 @@ export const TaskCard: React.FC<{
const autofixLive = !!autofixCardText(t, now);
const quick = onQuick && columnOfTask(t) === 'review' ? quickActionsFor(t) : [];
const [sending, setSending] = useState(false);
+ const [burst, setBurst] = useState(0);
const [note, setNote] = useState('');
const noteId = useId();
return (
@@ -656,6 +661,14 @@ export const TaskCard: React.FC<{
</span>
)}
{t.state === 'verified' && flags.length > 0 && <Badge tone="emerald">Verified</Badge>}
+ {t.state === 'verified' && flags.length === 0 && (
+ <VerifiedStamp
+ text={stampText(t.checks_summary)}
+ label={stampLabel(t.checks_summary)}
+ first={firstHolder('verified', t.space_id) === t.id}
+ press={false}
+ />
+ )}
{t.priority >= 2 && <Badge tone={t.priority >= 3 ? 'rose' : 'amber'}>{priorityLabel(t.priority)}</Badge>}
{showsTier(t) && t.owner_tier !== 'act' && (
<span data-tier-badge={t.owner_tier} title={`Flight School: ${classLabel(t.task_class ?? DEFAULT_CLASS).toLowerCase()} work at ${tierLabel(t.owner_tier)}`}>
@@ -726,12 +739,17 @@ export const TaskCard: React.FC<{
key={a}
type="button"
disabled={busy}
- onClick={() => (a === 'reject' ? setSending(true) : onQuick!(t, a))}
+ onClick={() => {
+ if (a === 'verify') setBurst((n) => n + 1);
+ if (a === 'reject') setSending(true);
+ else onQuick!(t, a);
+ }}
className={`${cardBtn} ${a === 'verify' || a === 'retry' ? cardGoodBtn : a === 'cancel' ? cardQuietBtn : cardPlainBtn}`}
data-card-action={a}
>
{a === 'verify' ? <CheckCircle2 size={12} aria-hidden="true" /> : a === 'reject' ? <Undo2 size={12} aria-hidden="true" /> : a === 'retry' ? <RotateCcw size={12} aria-hidden="true" /> : <X size={12} aria-hidden="true" />}
{QUICK_LABELS[a]}
+ {a === 'verify' && <CheckBurst n={burst} />}
</button>
))}
{older.length > 0 && onDismissMany && (
@@ -1224,7 +1242,7 @@ export const EvidenceReceipt: React.FC<{
onApproveCheck?: (c: Check) => void;
}> = ({ receipt, names, busy = false, onApproveCheck }) => (
<section aria-labelledby="receipt-h" className="space-y-3" data-receipt>
- <h4 id="receipt-h" className="flex items-center gap-1.5 text-xs font-semibold text-zinc-200">
+ <h4 id="receipt-h" tabIndex={-1} className="flex items-center focus:outline-none gap-1.5 text-xs font-semibold text-zinc-200">
<ShieldCheck size={14} className="text-emerald-400" aria-hidden="true" /> Evidence receipt
</h4>
{receipt.verifiedBy && (
@@ -2007,7 +2025,9 @@ export const TaskDetailBody: React.FC<{
const [forkReason, setForkReason] = useState('');
const forkId = useId();
const receipt = useMemo(() => buildReceipt(detail, names), [detail, names]);
+ const learned = useMemo(() => lessonsChip(detail.events), [detail.events]);
const [asking, setAsking] = useState<TaskAction | null>(null);
+ const [burst, setBurst] = useState(0);
const [reason, setReason] = useState('');
const reasonId = useId();
const owner = (t.owner_kwant_id && names[t.owner_kwant_id]) || t.owner_name;
@@ -2031,6 +2051,7 @@ export const TaskDetailBody: React.FC<{
setAsking(a);
return;
}
+ if (a === 'verify') setBurst((n) => n + 1);
onAction(a);
};
@@ -2038,7 +2059,22 @@ export const TaskDetailBody: React.FC<{
<div className="space-y-5">
<div className="space-y-2">
<div className="flex flex-wrap items-center gap-1.5">
- <Badge tone={st.tone}>{st.label}</Badge>
+ {t.state === 'verified' ? (
+ <VerifiedStamp
+ text={stampText(t.checks_summary)}
+ label={stampLabel(t.checks_summary)}
+ first={firstHolder('verified', t.space_id) === t.id}
+ burst={burst}
+ onOpen={() => {
+ const h = document.getElementById('receipt-h');
+ h?.scrollIntoView?.({ block: 'center', behavior: 'auto' });
+ h?.focus?.({ preventScroll: true });
+ }}
+ />
+ ) : (
+ <Badge tone={st.tone}>{st.label}</Badge>
+ )}
+ {learned && <LessonsChip text={learned.text} title={learned.title} />}
{t.priority >= 2 && <Badge tone={t.priority >= 3 ? 'rose' : 'amber'}>{priorityLabel(t.priority)}</Badge>}
{t.mission_title && <span className="text-[11px] text-zinc-500 break-words">{t.mission_title}</span>}
</div>
@@ -2056,10 +2092,11 @@ export const TaskDetailBody: React.FC<{
type="button"
disabled={busy}
onClick={() => press(a)}
- className={a === 'verify' ? goodBtn : a === 'retry' || a === 'unblock' ? mainBtn : a === 'cancel' ? dangerBtn : quietBtn}
+ className={`relative ${a === 'verify' ? goodBtn : a === 'retry' || a === 'unblock' ? mainBtn : a === 'cancel' ? dangerBtn : quietBtn}`}
>
{a === 'verify' && <CheckCircle2 size={13} aria-hidden="true" />}
{ACTION_LABELS[a]}
+ {a === 'verify' && <CheckBurst n={burst} />}
</button>
))}
{busy && <Loader2 size={14} className="self-center animate-spin motion-reduce:animate-none text-zinc-400" aria-label="Working" />}
@@ -2648,6 +2685,9 @@ export const MissionBoardView: React.FC<MissionBoardViewProps> = ({
onCloseUndo,
}) => {
const selectId = useId();
+ // The first Verified task in a space: a one-line moment, once
+ const [firstDone, setFirstDone] = useState(false);
+ const firstVerified = useFirstMoment('verified', spaceId ?? '', tasks ? tasks.map((x) => ({ id: x.id, reached: x.state === 'verified' })) : null);
const [confirmClear, setConfirmClear] = useState(false);
const visibleMissions = missions.filter((m) => m.status !== 'cancelled');
const mission = missionId ? missions.find((m) => m.id === missionId) ?? null : null;
@@ -2741,6 +2781,7 @@ export const MissionBoardView: React.FC<MissionBoardViewProps> = ({
<>
{liveShown && <LiveStrip bots={liveShown} teams={teams} workingCards={workingCards} now={now} onOpen={onOpenLive} />}
+ {firstVerified && !firstDone && <FirstMomentLine kind="verified" onDone={() => setFirstDone(true)} />}
<InsightsStrip insights={insights} needsYou={needsYouCount(tasks)} />
<MeasuresPanel insights={insights} />
<FactsLedger names={names} taskTitles={taskTitles} onOpenTask={openTaskById} now={now} />
diff --git a/frontend/src/components/Proactive.tsx b/frontend/src/components/Proactive.tsx
index 51e23de6..0f492ece 100644
--- a/frontend/src/components/Proactive.tsx
+++ b/frontend/src/components/Proactive.tsx
@@ -1,5 +1,5 @@
import React, { useRef, useState } from 'react';
-import { CheckCircle2, ChevronDown, ChevronRight, Loader2, Moon, Users } from 'lucide-react';
+import { CheckCircle2, ChevronDown, ChevronRight, Loader2, Moon, Pencil, Users } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
import { MarkdownRenderer } from './MarkdownRenderer';
import { Decision, changeOptions, consultedLine, decidingDetail, decisionLabel, workAheadSummary } from '../decideFirst';
@@ -37,7 +37,7 @@ export const DecisionChips: React.FC<DecisionChipsProps> = ({ messageId, decisio
return (
<div role="group" aria-label="Decided by the team" data-decisions className="mt-2 w-full max-w-2xl space-y-2">
{consulted.length > 0 && (
- <p className="flex items-center gap-1.5 text-[11px] text-zinc-500">
+ <p className="flex items-center gap-1.5 text-xs text-zinc-400">
<Users size={12} aria-hidden="true" />
{consultedLine(consulted)}
</p>
@@ -48,12 +48,12 @@ export const DecisionChips: React.FC<DecisionChipsProps> = ({ messageId, decisio
const panelId = `dec-${messageId}-${d.index}`;
const changed = d.status === 'changed';
return (
- <div key={d.index} className="rounded-xl border border-zinc-800 bg-zinc-900/40 px-3 py-2">
+ <div key={d.index} className={`relative overflow-hidden rounded-xl border border-zinc-700/60 bg-zinc-900/60 py-2.5 pl-4 pr-3 shadow-[var(--kws-shadow)] before:absolute before:inset-y-0 before:left-0 before:w-1 ${changed ? 'before:bg-sky-400' : 'before:bg-emerald-400'}`}>
<div className="flex items-start gap-2 min-w-0">
<div className="flex flex-1 flex-wrap items-center gap-x-2 gap-y-1.5 min-w-0">
- {d.question && <span className="text-[11px] text-zinc-400 break-words min-w-0">{d.question}</span>}
+ {d.question && <span className="text-xs text-zinc-300 break-words min-w-0">{d.question}</span>}
<span
- className={`inline-flex items-center gap-1 max-w-full px-2 py-0.5 rounded-full border text-[11px] font-medium ${
+ className={`inline-flex items-center gap-1 max-w-full px-2.5 py-0.5 rounded-full border text-xs font-semibold ${
changed ? 'border-sky-500/40 bg-sky-500/10 text-sky-200' : 'border-emerald-500/35 bg-emerald-500/10 text-emerald-200'
}`}
>
@@ -70,16 +70,17 @@ export const DecisionChips: React.FC<DecisionChipsProps> = ({ messageId, decisio
setError(null);
setOpen(changing ? null : d.index);
}}
- className="shrink-0 -my-1 px-2.5 py-1.5 min-h-8 rounded-lg text-[11px] font-medium text-zinc-300 hover:text-zinc-100 hover:bg-zinc-800 border border-zinc-700/60 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"
+ className="shrink-0 -my-1 inline-flex items-center gap-1.5 px-2.5 py-1.5 min-h-9 rounded-lg text-xs font-medium text-zinc-200 hover:text-zinc-50 hover:bg-zinc-800 border border-zinc-700/70 active:scale-[0.97] motion-reduce:active:scale-100 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"
>
+ {!changing && <Pencil size={12} aria-hidden="true" />}
{changing ? 'Keep it' : 'Change'}
</button>
)}
</div>
- {d.why && <p className="mt-1 text-[11px] text-zinc-500 break-words">Why: {d.why}</p>}
+ {d.why && <p className="mt-1 text-xs text-zinc-400 break-words">Why: {d.why}</p>}
{changing && (
- <div id={panelId} className="mt-2 pt-2 border-t border-zinc-800 space-y-1.5">
- <p className="text-[11px] text-zinc-400">Pick another one. The bot redoes what depended on it.</p>
+ <div id={panelId} className="mt-2 pt-2 border-t border-zinc-700/50 space-y-1.5">
+ <p className="text-xs text-zinc-400">Pick another one. The bot redoes what depended on it.</p>
<div role="group" aria-label={`Other choices for: ${d.question || d.picked}`} className="flex flex-col sm:flex-row sm:flex-wrap gap-1.5">
{others.map((o) => (
<button
@@ -95,7 +96,7 @@ export const DecisionChips: React.FC<DecisionChipsProps> = ({ messageId, decisio
))}
</div>
{error && (
- <p role="alert" className="text-[11px] text-rose-300">
+ <p role="alert" className="text-xs text-rose-300">
{error}
</p>
)}
diff --git a/frontend/src/components/ReplyMeta.tsx b/frontend/src/components/ReplyMeta.tsx
index 7bf2a26f..92ff8c24 100644
--- a/frontend/src/components/ReplyMeta.tsx
+++ b/frontend/src/components/ReplyMeta.tsx
@@ -1,6 +1,8 @@
import React, { useId, useState } from 'react';
import { ChevronRight } from 'lucide-react';
import { localClock } from '../clock';
+import { RouteInfo, useRouteChip } from './RouteChip';
+import { EngineChip } from './Signature';
export interface ReplyFacts {
/** "Claude · Opus 5.5": the engine and model the reply ran on. */
@@ -19,6 +21,10 @@ export interface ReplyMetaProps extends ReplyFacts {
failed?: boolean;
/** One muted line under the name, e.g. "Claude is out until 03:00 · answered on Codex (GPT-6.1)". */
note?: string | null;
+ /** Why this bot answered: a chip beside the name that opens the full reason (and "Wrong bot?"). */
+ route?: RouteInfo | null;
+ /** Set after a failover: the engines the reply moved between, with the reason on hover. */
+ handoff?: { from: string; to: string; why: string } | null;
now?: number;
/** Steps and the reasoning item; shown with the facts when Details is open. */
children?: React.ReactNode;
@@ -26,7 +32,7 @@ export interface ReplyMetaProps extends ReplyFacts {
/** The quiet line for a reply that ran on another account. It wraps rather than clips, so it fits at 390 px. */
export const FailoverNote: React.FC<{ text: string }> = ({ text }) => (
- <p data-failover-note="" className="-mt-0.5 mb-1.5 max-w-full text-[11px] leading-snug text-zinc-500 break-words">
+ <p data-failover-note="" className="-mt-0.5 mb-1.5 max-w-full text-xs leading-snug text-zinc-500 break-words">
{text}
</p>
);
@@ -34,23 +40,26 @@ export const FailoverNote: React.FC<{ text: string }> = ({ text }) => (
const hasContent = (n: React.ReactNode) => React.Children.toArray(n).length > 0;
/** A bot reply's header: one line, "Name · 3:42 PM", and a Details toggle holding the rest. */
-export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, account, tokens, failed = false, note, now, children }) => {
+export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, account, tokens, failed = false, note, route, handoff, now, children }) => {
const [open, setOpen] = useState(false);
+ const why = useRouteChip(route);
const panelId = useId();
const time = localClock(at, now);
const facts: Array<[string, React.ReactNode]> = [];
if (ranOn) facts.push(['Model', ranOn]);
if (account) facts.push(['Account', account]);
- if (tokens) facts.push(['Tokens', <span title={tokens.detail}>{tokens.label}<span className="text-zinc-500"> · {tokens.detail}</span></span>]);
+ if (tokens) facts.push(['Tokens', <span title={tokens.detail}>{tokens.label}<span className="text-zinc-400"> · {tokens.detail}</span></span>]);
const hasDetails = facts.length > 0 || hasContent(children);
return (
<div className="w-full max-w-full min-w-0">
- <div className="flex items-center gap-2 mb-1.5 text-[11px] text-zinc-400 font-medium max-w-full min-w-0 whitespace-nowrap">
+ <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">
{avatar && <span className="sm:hidden shrink-0 inline-flex">{avatar}</span>}
- <span className="text-zinc-200 shrink-0">{name}</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} />}
{time && (
- <span className="text-zinc-500 truncate min-w-0" data-reply-time="">
- <span aria-hidden="true">· </span>
+ <span className="min-w-0 truncate text-zinc-400" data-reply-time="">
+ <span aria-hidden="true" className="sm:hidden">· </span>
{time}
</span>
)}
@@ -60,8 +69,8 @@ export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, a
onClick={() => setOpen((o) => !o)}
aria-expanded={open}
aria-controls={open ? panelId : undefined}
- className={`shrink-0 inline-flex items-center gap-0.5 rounded px-1 -mx-0.5 min-h-[24px] text-[11px] hover:text-zinc-200 hover:bg-zinc-900 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 ${
- failed && !open ? 'text-rose-300' : 'text-zinc-500'
+ className={`shrink-0 inline-flex items-center gap-0.5 rounded-md px-1.5 min-h-6 text-xs hover:text-zinc-100 hover:bg-zinc-800 transition-colors motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 ${
+ failed && !open ? 'text-rose-300' : 'text-zinc-400'
}`}
>
{failed && !open ? 'Details · a step failed' : 'Details'}
@@ -69,14 +78,15 @@ export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, a
</button>
)}
</div>
+ {why.panel}
{note && <FailoverNote text={note} />}
{open && hasDetails && (
<div id={panelId} className="mb-2 w-full max-w-2xl">
{facts.length > 0 && (
- <dl className="mb-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-[11px]">
+ <dl className="mb-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs">
{facts.map(([k, v]) => (
<React.Fragment key={k}>
- <dt className="text-zinc-500">{k}</dt>
+ <dt className="text-zinc-400">{k}</dt>
<dd className="text-zinc-300 min-w-0 break-words">{v}</dd>
</React.Fragment>
))}
diff --git a/frontend/src/components/RouteChip.tsx b/frontend/src/components/RouteChip.tsx
new file mode 100644
index 00000000..60bf78f4
--- /dev/null
+++ b/frontend/src/components/RouteChip.tsx
@@ -0,0 +1,136 @@
+import React, { useState } from 'react';
+import { Loader2, Sparkles } from 'lucide-react';
+
+export interface Reroute {
+ /** The reply's id, for element ids. */
+ key: string;
+ targets: Array<{ id: string; name: string; title: string }>;
+ onPick: (kwantId: string) => Promise<string | void>;
+}
+
+export interface RouteInfo {
+ /** The two or three words on the chip ("Matched skills"). */
+ label: string;
+ /** The whole reason, shown when the chip is opened and as the chip's tooltip. */
+ text: string;
+ fallback?: boolean;
+ reroute?: Reroute;
+}
+
+/**
+ * Why this bot answered, split in two so the header can put the chip on its own line next to the name
+ * while the opened reason and the "Send to another bot" picker sit under the header. With `reroute`,
+ * "Wrong bot?" opens the other bots; picking one teaches routing and asks that bot.
+ */
+export function useRouteChip(route: RouteInfo | null | undefined): { chip: React.ReactNode; panel: React.ReactNode } {
+ const [open, setOpen] = useState(false);
+ const [picking, setPicking] = useState(false);
+ const [busy, setBusy] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [sentTo, setSentTo] = useState<string | null>(null);
+ if (!route) return { chip: null, panel: null };
+
+ const { reroute } = route;
+ const warn = !!route.fallback;
+ const reasonId = `why-${reroute?.key ?? 'reply'}`;
+ const pickerId = reroute ? `reroute-${reroute.key}` : undefined;
+ const canReroute = !!reroute && reroute.targets.length > 0;
+
+ const pick = async (k: { id: string; name: string }) => {
+ if (!reroute || busy) return;
+ setBusy(k.id);
+ setError(null);
+ const err = await reroute.onPick(k.id);
+ setBusy(null);
+ if (err) setError(err);
+ else {
+ setSentTo(k.name);
+ setPicking(false);
+ }
+ };
+
+ const chip = (
+ <span className="inline-flex min-w-0 max-w-full items-center gap-1" data-routing-line>
+ <button
+ type="button"
+ data-compact
+ onClick={() => setOpen((v) => !v)}
+ aria-expanded={open}
+ aria-controls={open ? reasonId : undefined}
+ title={route.text}
+ className={`inline-flex min-h-6 max-w-full min-w-0 items-center gap-1 rounded-full border px-2 text-[11px] font-medium transition-colors motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 ${
+ warn
+ ? 'border-amber-400/40 bg-amber-400/10 text-amber-200 hover:bg-amber-400/15'
+ : 'border-sky-400/35 bg-sky-400/10 text-sky-200 hover:bg-sky-400/15'
+ }`}
+ >
+ <Sparkles size={11} className="shrink-0" aria-hidden="true" />
+ <span className="truncate">{route.label}</span>
+ <span className="sr-only">: why this bot answered</span>
+ </button>
+ {canReroute && !sentTo && (
+ <button
+ type="button"
+ data-compact
+ onClick={() => setPicking((v) => !v)}
+ aria-expanded={picking}
+ aria-controls={picking ? pickerId : undefined}
+ className="shrink-0 rounded-full px-2 min-h-6 text-[11px] text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 underline decoration-dotted underline-offset-2 transition-colors motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400"
+ >
+ Wrong bot?
+ </button>
+ )}
+ </span>
+ );
+
+ const panel = (
+ <>
+ {open && (
+ <p id={reasonId} className="mb-1.5 max-w-2xl break-words text-xs leading-snug text-zinc-300">
+ {route.text}
+ </p>
+ )}
+ {picking && reroute && (
+ <div id={pickerId} role="group" aria-label="Send to another bot" className="mb-2 max-w-full rounded-xl border border-zinc-700/70 bg-zinc-900/80 px-3 py-2.5 shadow-[var(--kws-shadow)]">
+ <p className="mb-2 text-xs text-zinc-300">Send your message to:</p>
+ <div className="flex flex-wrap gap-1.5">
+ {reroute.targets.map((k) => (
+ <button
+ key={k.id}
+ type="button"
+ disabled={busy !== null}
+ onClick={() => pick(k)}
+ title={k.title}
+ className="inline-flex min-h-[36px] items-center gap-1.5 rounded-lg border border-zinc-600 bg-zinc-800 px-3 text-xs text-zinc-100 hover:bg-zinc-700 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400"
+ >
+ {busy === k.id && <Loader2 size={12} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
+ <span>{k.name}</span>
+ {k.title && <span className="hidden text-zinc-400 sm:inline">· {k.title}</span>}
+ </button>
+ ))}
+ <button
+ type="button"
+ onClick={() => setPicking(false)}
+ className="min-h-[36px] rounded-lg px-3 text-xs text-zinc-300 hover:text-zinc-100 hover:bg-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400"
+ >
+ Cancel
+ </button>
+ </div>
+ <p className="mt-2 text-xs text-zinc-400">Messages like this will go to the bot you pick from now on.</p>
+ {error && (
+ <p role="alert" className="mt-1 break-words text-xs text-rose-300">
+ {error}
+ </p>
+ )}
+ </div>
+ )}
+ {sentTo && (
+ <p role="status" className="mb-1.5 text-xs text-emerald-300">
+ Sent to {sentTo}. Messages like this will go to {sentTo} from now on.
+ </p>
+ )}
+ </>
+ );
+
+ return { chip, panel };
+}
diff --git a/frontend/src/components/Signature.tsx b/frontend/src/components/Signature.tsx
new file mode 100644
index 00000000..86262f4f
--- /dev/null
+++ b/frontend/src/components/Signature.tsx
@@ -0,0 +1,114 @@
+import React from 'react';
+import { Lightbulb, ShieldCheck, Cpu } from 'lucide-react';
+import type { HeartDot, HeartWord } from '../signature';
+import { heartbeatCount, heartbeatText, heartbeatWord } from '../signature';
+import { Sticker } from './Sticker';
+import { CheckBurst } from './CheckBurst';
+
+/**
+ * "Verified · 3/3" (or "First verified") as Pixel's holo sticker, tilted −2° (S1) or −3° for the
+ * first-time sticker (S3), pressing in once when it appears (the wrapper scales, so the tilt stays).
+ */
+export const VerifiedStamp: React.FC<{ text: string; label: string; first?: boolean; press?: boolean; burst?: number; onOpen?: () => void; className?: string }> = ({
+ text,
+ label,
+ first = false,
+ press = true,
+ burst = 0,
+ onOpen,
+ className = '',
+}) => {
+ // Clickable: Pixel's Sticker puts it in its 44x44 .kw-sticker-hit button (spec §1).
+ return (
+ <span className={`relative inline-flex ${press ? 'kws-stamp' : ''} ${className}`} data-verified-stamp="">
+ <Sticker
+ tone="holo"
+ tilt={first ? -3 : -2}
+ icon={<ShieldCheck size={12} aria-hidden="true" />}
+ title={onOpen ? 'Open receipt' : label}
+ ariaLabel={onOpen ? (first ? `First verified task. ${label}` : label) : undefined}
+ onClick={onOpen ? () => onOpen() : undefined}
+ >
+ {first ? 'First verified' : text}
+ </Sticker>
+ <CheckBurst n={burst} />
+ </span>
+ );
+};
+
+/** "Learned from N": the 0.6.8 lessons a task started with (spec §4). Information, so never holo. */
+export const LessonsChip: React.FC<{ text: string; title: string }> = ({ text, title }) => (
+ <span className="kws-chip kws-chip-learned kws-tip" data-tip={title} tabIndex={0} aria-label={`${text}. ${title}`} data-lessons-chip="">
+ <Lightbulb size={12} aria-hidden="true" />
+ {text}
+ </span>
+);
+
+const WORD_TONE: Record<HeartWord, string> = {
+ Steady: 'text-ok',
+ 'Back to ok': 'text-ok',
+ Fixing: 'text-warn',
+ Failing: 'text-bad',
+ 'Can’t check': 'text-muted',
+};
+
+const when = (at?: string): string | undefined => {
+ if (!at) return undefined;
+ const d = new Date(at);
+ return Number.isNaN(d.getTime()) ? undefined : d.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });
+};
+
+/**
+ * The goal's last checks as 6×6 squares, oldest left, newest outlined (spec §3), then "5/7 ok" and a word.
+ * Phones show the last 5; with under 64 px free (or under 360 px wide) only the newest square and its
+ * "1/5 ok". One picture for screen readers; nothing at all when there is no check history.
+ */
+export const GoalHeartbeat: React.FC<{ dots: HeartDot[]; status: string; fixing?: boolean; className?: string }> = ({ dots, status, fixing = false, className = '' }) => {
+ if (!dots.length) return null;
+ const phone = dots.slice(-5);
+ const word = heartbeatWord(status, dots, fixing);
+ const square = (d: HeartDot, i: number, newest: boolean, extra = '') => (
+ <span key={i} className={`kws-beat kws-beat-${d.tone} ${newest ? 'kws-beat-newest' : ''} ${extra}`} title={[d.label, when(d.at)].filter(Boolean).join(' · ')} data-dot={d.tone} />
+ );
+ const older = dots.length - phone.length;
+ return (
+ <span className={`kws-heartbeat ${className}`} data-heartbeat="">
+ <span className="kws-heartbeat-full" role="img" aria-label={heartbeatText(dots)}>
+ <span className="kws-beats" aria-hidden="true">
+ {dots.map((d, i) => square(d, i, i === dots.length - 1, i < older ? 'kws-beat-desk' : ''))}
+ </span>
+ <span className="kws-beat-count kws-beat-count-desk" aria-hidden="true">{heartbeatCount(dots)}</span>
+ {word && <span className={`kws-beat-word ${WORD_TONE[word]}`} aria-hidden="true">{word}</span>}
+ </span>
+ <span className="kws-heartbeat-tight" role="img" aria-label={heartbeatText(phone)}>
+ <span className="kws-beats" aria-hidden="true">{square(phone[phone.length - 1], 0, true)}</span>
+ <span className="kws-beat-count" aria-hidden="true">{heartbeatCount(phone)}</span>
+ </span>
+ </span>
+ );
+};
+
+/** A 12×12 pixel baton (spec §4): the engine that took over carries it on. */
+const PixelBaton: React.FC = () => (
+ <svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true" style={{ shapeRendering: 'crispEdges' }} className="shrink-0">
+ <rect x="2" y="8" width="2" height="2" fill="#e8e4ff" />
+ <rect x="4" y="6" width="2" height="2" fill="#e8e4ff" />
+ <rect x="6" y="4" width="2" height="2" fill="#e8e4ff" />
+ <rect x="8" y="2" width="2" height="2" fill="#fcd34d" />
+ <rect x="9" y="1" width="2" height="2" fill="#fcd34d" />
+ </svg>
+);
+
+/** 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 }) =>
+ 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="">
+ <Cpu size={12} className="shrink-0" aria-hidden="true" />
+ <span className="truncate">{label}</span>
+ </span>
+ );
diff --git a/frontend/src/components/WorkingStrip.tsx b/frontend/src/components/WorkingStrip.tsx
new file mode 100644
index 00000000..4df033c7
--- /dev/null
+++ b/frontend/src/components/WorkingStrip.tsx
@@ -0,0 +1,63 @@
+import React, { useEffect, useRef, useState } from 'react';
+import { Square } from 'lucide-react';
+import type { LiveActivity } from '../activity';
+import { formatElapsed, turnStart, workingLabel } from '../workingStrip';
+import { ModernAvatar } from './ModernAvatar';
+
+interface WorkingStripProps {
+ active: boolean;
+ name: string;
+ /** Picks the avatar's creature. */
+ title: string;
+ live?: LiveActivity | null;
+ queued?: boolean;
+ awaitingAnswer?: boolean;
+ awaitingBrowser?: boolean;
+ writing?: boolean;
+ onStop?: () => void;
+}
+
+/** 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 }) => {
+ const mountedAt = useRef(Date.now());
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (!active) return;
+ mountedAt.current = Date.now();
+ setNow(Date.now());
+ const id = window.setInterval(() => setNow(Date.now()), 1000);
+ return () => window.clearInterval(id);
+ }, [active]);
+ if (!active) return null;
+
+ const label = workingLabel({ live, queued, awaitingAnswer, awaitingBrowser, writing });
+ const elapsed = formatElapsed(now - turnStart(live, mountedAt.current));
+ const waiting = !!queued || !!awaitingAnswer;
+ 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)]">
+ <span className={`shrink-0 inline-flex ${waiting ? '' : 'kw-avatar-working'}`}>
+ <ModernAvatar role={title} name={name} size={24} />
+ </span>
+ <p className="min-w-0 flex-1 truncate 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>
+ {onStop && (
+ <button
+ type="button"
+ onClick={onStop}
+ title="Stop"
+ className="shrink-0 inline-flex items-center gap-1.5 min-h-8 rounded-lg border border-zinc-600/70 px-2.5 text-xs font-medium text-zinc-200 hover:bg-zinc-800 hover:text-zinc-50 active:scale-[0.97] motion-reduce:active:scale-100 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400"
+ >
+ <Square size={12} className="fill-current" aria-hidden="true" />
+ Stop
+ </button>
+ )}
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/components/results/Cards.tsx b/frontend/src/components/results/Cards.tsx
index 4ff0dde8..e683d77a 100644
--- a/frontend/src/components/results/Cards.tsx
+++ b/frontend/src/components/results/Cards.tsx
@@ -38,17 +38,17 @@ export const Cards: React.FC<RendererProps<CardsBlock>> = ({ block }) => (
<li key={item.id} className="min-w-0">
<Wrapper
{...wrapperProps}
- className="block h-full rounded-xl border border-zinc-800 bg-zinc-950/70 p-3 shadow-sm transition-colors motion-reduce:transition-none hover:border-zinc-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/70"
+ className="block h-full rounded-xl border border-zinc-700/60 bg-zinc-900/60 p-3.5 shadow-[var(--kws-shadow)] transition duration-150 motion-reduce:transition-none motion-safe:hover:-translate-y-0.5 hover:border-sky-500/50 hover:bg-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/70"
>
<div className="flex items-start justify-between gap-2">
- <h4 className="text-[13px] font-semibold leading-snug text-zinc-100 [overflow-wrap:anywhere]">{item.title}</h4>
- {item.url && <ExternalLink size={12} className="mt-0.5 shrink-0 text-zinc-600" aria-hidden="true" />}
+ <h4 className="text-sm font-semibold leading-snug text-zinc-100 [overflow-wrap:anywhere]">{item.title}</h4>
+ {item.url && <ExternalLink size={12} className="mt-0.5 shrink-0 text-zinc-400" aria-hidden="true" />}
</div>
<p className="mt-1 text-xs leading-relaxed text-zinc-400 [overflow-wrap:anywhere]">{item.description}</p>
- <div className="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-zinc-500">
+ <div className="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-zinc-400">
{item.url && <span className="truncate">{urlDomain(item.url)}</span>}
{item.meta.map((m, i) => (
- <span key={i} className="rounded border border-zinc-800 px-1.5 py-0.5">
+ <span key={i} className="rounded-full border border-zinc-700 px-2 py-0.5">
{m}
</span>
))}
diff --git a/frontend/src/components/results/Chart.tsx b/frontend/src/components/results/Chart.tsx
index a593596f..c9e870a0 100644
--- a/frontend/src/components/results/Chart.tsx
+++ b/frontend/src/components/results/Chart.tsx
@@ -170,7 +170,7 @@ export const Chart: React.FC<RendererProps<ChartBlock>> = ({ block }) => {
const barWidth = isBar ? groupWidth / block.series.length : 0;
return (
- <div data-smart-result="chart" data-block-id={block.id} className="my-3.5 rounded-xl border border-zinc-800 bg-zinc-950/70 p-3.5 shadow-sm">
+ <div data-smart-result="chart" data-block-id={block.id} className="my-3.5 rounded-xl border border-zinc-700/60 bg-zinc-900/60 p-3.5 shadow-[var(--kws-shadow)]">
<div className="mb-2 flex items-center justify-between gap-2">
<div className="flex flex-wrap items-center gap-3 text-[11px]">
{block.series.map((s, i) => (
diff --git a/frontend/src/components/results/Comparison.tsx b/frontend/src/components/results/Comparison.tsx
index 6699234b..0c46dc46 100644
--- a/frontend/src/components/results/Comparison.tsx
+++ b/frontend/src/components/results/Comparison.tsx
@@ -1,7 +1,8 @@
import React, { useId, useMemo, useState } from 'react';
-import { ArrowDown, ArrowUp, ChevronsUpDown, MessageSquare, Minus, Plus } from 'lucide-react';
+import { Award, ArrowDown, ArrowUp, ChevronsUpDown, MessageSquare, Minus, Plus } from 'lucide-react';
import { ColumnRole, ComparisonBlock, Sort, nextSort, plainText, sortRows } from '../../smartResults';
import type { RendererProps } from './registry';
+import { Sticker } from '../Sticker';
// Pros and cons cells: split on ";", "•", "·" or a line break, else on commas when every part is short.
export function shortList(text: string): string[] | null {
@@ -16,13 +17,11 @@ export function shortList(text: string): string[] | null {
const ROLE_TINT: Partial<Record<ColumnRole, string>> = { pros: 'text-emerald-300', cons: 'text-rose-300' };
-const PickLabel: React.FC<{ reason: string | null; inline?: boolean; className?: string }> = ({ reason, inline, className = '' }) => (
- <span
- className={`${className} ${inline ? 'ml-1.5 ' : ''}rounded border border-sky-500/30 bg-sky-500/10 px-1 py-px align-[1px] text-[10px] font-medium leading-none text-sky-300 [box-decoration-break:clone]`}
- title={reason ?? undefined}
- >
- Pick in this reply
- </span>
+/** S2: the small holo Pick sticker (spec §1, tilt +3), the same in the table and on the phone card. Not interactive. */
+const PickSticker: React.FC<{ reason: string | null }> = ({ reason }) => (
+ <Sticker tone="holo" tilt={3} icon={<Award size={10} aria-hidden="true" />} title={reason ?? 'Pick in this reply'} className="kw-sticker-sm pointer-events-none">
+ Pick<span className="sr-only"> in this reply{reason ? `: ${reason}` : ''}</span>
+ </Sticker>
);
/** A pros or cons cell in a stacked card: a short list with + or −, else the reply's cell. */
@@ -74,9 +73,9 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
{/* 640 px and up: the reply's table with header sort buttons. */}
<div className="my-3.5 hidden sm:block">
- <div className="overflow-x-auto rounded-xl border border-zinc-800 bg-zinc-950/70 shadow-sm">
+ <div className="overflow-x-auto rounded-xl border border-zinc-700/60 bg-zinc-900/60 shadow-[var(--kws-shadow)]">
<table className="w-full text-left border-collapse text-xs font-sans">
- <thead className="bg-zinc-900/90 text-zinc-200 border-b border-zinc-800 font-medium">
+ <thead className="bg-zinc-800/70 text-zinc-100 border-b border-zinc-700/60 font-medium">
<tr>
{block.columns.map((col, j) => {
const dir = sort?.col === j ? sort.dir : null;
@@ -98,7 +97,7 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
<span className="inline-block w-0 align-[-1px]" aria-hidden="true">
<Icon
size={10}
- className={`ml-1 ${dir ? 'text-sky-400' : 'text-zinc-600 group-hover:text-zinc-400 group-focus-visible:text-zinc-400'}`}
+ className={`ml-1 ${dir ? 'text-sky-400' : 'text-zinc-400 group-hover:text-zinc-200 group-focus-visible:text-zinc-400'}`}
/>
</span>
</button>
@@ -107,7 +106,7 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
})}
</tr>
</thead>
- <tbody className="divide-y divide-zinc-800/60 font-normal text-zinc-300">
+ <tbody className="divide-y divide-zinc-700/40 font-normal text-zinc-300">
{order.map((i) => {
const row = block.rows[i];
const picked = row.id === block.highlight_row;
@@ -115,7 +114,7 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
<tr
key={row.id}
data-pick={picked ? '' : undefined}
- className={`group/row transition-colors ${picked ? 'bg-sky-500/[0.07] hover:bg-sky-500/10' : 'hover:bg-zinc-900/50'}`}
+ className={`group/row transition-colors ${picked ? 'bg-sky-500/[0.07] hover:bg-sky-500/10' : 'hover:bg-zinc-800/40'}`}
>
{block.columns.map((col, j) => (
<td
@@ -135,18 +134,12 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
</button>
)}
{picked && j === 0 ? (
- // The label only takes room left on the cell's first line, so the table keeps the
- // streamed reply's exact size (see .smart-pick in modern.css).
- <div className="flex items-baseline">
- <span>{body[i][j]}</span>
- <span className="smart-pick min-w-0 flex-1">
- <PickLabel reason={block.highlight_reason} inline className="smart-pick-full" />
- <span
- aria-hidden="true"
- title={block.highlight_reason ? `Pick in this reply: ${block.highlight_reason}` : 'Pick in this reply'}
- className="smart-pick-short ml-1.5 rounded border border-sky-500/30 bg-sky-500/10 px-1 py-px align-[1px] text-[10px] font-medium leading-none text-sky-300">
- Pick
- </span>
+ // 6 px after the name, centred on its line; in a narrow column it wraps under the name.
+ // Inside the cell padding, so it never touches the table border or the sky bar.
+ <div className="flex flex-wrap items-center gap-x-1.5 gap-y-1">
+ <span className="min-w-0">{body[i][j]}</span>
+ <span className="inline-flex shrink-0">
+ <PickSticker reason={block.highlight_reason} />
</span>
</div>
) : (
@@ -165,7 +158,7 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
{/* Below 640 px: one card per row, label: value pairs, nothing clipped. */}
<div className="my-3.5 space-y-2 sm:hidden">
<div className="flex items-center gap-2">
- <label htmlFor={`${uid}-sort`} className="shrink-0 text-[11px] text-zinc-500">
+ <label htmlFor={`${uid}-sort`} className="shrink-0 text-[11px] text-zinc-400">
Sort by
</label>
<select
@@ -198,16 +191,21 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
<li
key={row.id}
data-pick={picked ? '' : undefined}
- className={`rounded-xl border px-3 py-2.5 text-xs ${picked ? 'border-sky-500/40 bg-sky-500/[0.07]' : 'border-zinc-800 bg-zinc-950/70'}`}
+ className={`relative rounded-xl border px-3 py-2.5 text-xs ${picked ? 'border-sky-500/40 bg-sky-500/[0.07]' : 'border-zinc-800 bg-zinc-900/60'}`}
>
- <div className="text-[13px] font-semibold leading-snug text-zinc-100 [overflow-wrap:anywhere]">
+ {picked && (
+ // The wrapper places it (spec S2: top -8, right -6); .kw-sticker keeps its own position: relative.
+ <span className="absolute -top-2 -right-1.5 z-10 flex">
+ <PickSticker reason={block.highlight_reason} />
+ </span>
+ )}
+ <div className={`text-[13px] font-semibold leading-snug text-zinc-100 [overflow-wrap:anywhere] ${picked ? 'pr-16' : ''}`}>
{body[i][0]}
- {picked && <PickLabel reason={block.highlight_reason} inline />}
</div>
<dl className="mt-1.5 grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-3 gap-y-1">
{block.columns.slice(1).map((col, k) => (
<React.Fragment key={col.key}>
- <dt className="text-zinc-500 [overflow-wrap:anywhere]">{head[k + 1]}</dt>
+ <dt className="text-zinc-400 [overflow-wrap:anywhere]">{head[k + 1]}</dt>
<dd className="text-zinc-300 leading-relaxed [overflow-wrap:anywhere]">
<Cell role={col.role} text={row.cells[k + 1]} node={body[i][k + 1]} />
</dd>
@@ -217,7 +215,7 @@ export const Comparison: React.FC<RendererProps<ComparisonBlock>> = ({ block, re
<button
type="button"
onClick={() => askRow(i)}
- className="-mx-1 mt-1.5 flex items-center gap-1.5 rounded-md px-1 py-1 text-[11px] text-zinc-500 hover:text-zinc-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/70"
+ className="-mx-1 mt-1.5 flex items-center gap-1.5 rounded-md px-1 py-1 text-[11px] text-zinc-400 hover:text-zinc-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/70"
>
<MessageSquare size={12} aria-hidden="true" />
Ask about this
diff --git a/frontend/src/components/results/Facts.tsx b/frontend/src/components/results/Facts.tsx
index e8c667f1..65174b3f 100644
--- a/frontend/src/components/results/Facts.tsx
+++ b/frontend/src/components/results/Facts.tsx
@@ -17,10 +17,10 @@ export function validFacts(raw: unknown): FactsBlock | null {
/** A definition-list card for 3-12 label/value facts, mostly non-numeric. */
export const Facts: React.FC<RendererProps<FactsBlock>> = ({ block }) => (
<div data-smart-result="facts" data-block-id={block.id}>
- <dl className="my-3.5 divide-y divide-zinc-800/60 rounded-xl border border-zinc-800 bg-zinc-950/70 px-3.5 shadow-sm">
+ <dl className="my-3.5 divide-y divide-zinc-800/60 rounded-xl border border-zinc-700/60 bg-zinc-900/60 px-4 shadow-[var(--kws-shadow)]">
{block.items.map((item) => (
<div key={item.id} className="grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-3 gap-y-0.5 py-2.5 text-xs">
- <dt className="text-zinc-500 [overflow-wrap:anywhere]">{item.label}</dt>
+ <dt className="font-medium text-zinc-400 [overflow-wrap:anywhere]">{item.label}</dt>
<dd className="text-zinc-200 leading-relaxed [overflow-wrap:anywhere]">{item.value || '—'}</dd>
</div>
))}
diff --git a/frontend/src/components/results/Files.tsx b/frontend/src/components/results/Files.tsx
index c61a437d..b99d59e2 100644
--- a/frontend/src/components/results/Files.tsx
+++ b/frontend/src/components/results/Files.tsx
@@ -120,7 +120,7 @@ const TablePreview: React.FC<{ columns: string[]; rows: string[][] }> = ({ colum
const CutNote: React.FC<{ preview: FilePreview }> = ({ preview }) => {
const note = previewNote(preview);
return note ? (
- <p className="mt-1 text-[11px] text-zinc-500" data-preview-note>
+ <p className="mt-1 text-[11px] text-zinc-400" data-preview-note>
{note}
</p>
) : null;
@@ -149,7 +149,7 @@ const FilePreviewView: React.FC<{ item: FileItem }> = ({ item }) => {
// image previews have no renderable source in this contract yet; show a labelled placeholder
// rather than guessing at a URL (the attachment route isn't built — see the PR notes).
return (
- <div className="mt-2 flex items-center gap-2 rounded-lg border border-dashed border-zinc-800 bg-zinc-900/40 px-3 py-4 text-[11px] text-zinc-500">
+ <div className="mt-2 flex items-center gap-2 rounded-lg border border-dashed border-zinc-800 bg-zinc-900/40 px-3 py-4 text-[11px] text-zinc-400">
<ImageIcon size={14} aria-hidden="true" />
Image preview not available yet
</div>
@@ -173,7 +173,7 @@ export const Files: React.FC<RendererProps<FilesBlock>> = ({ block }) => {
<ul role="list" className="mt-2 min-w-0 max-w-full space-y-2">
{shown.map((item) => (
<li key={item.id} aria-label={`Preview of ${item.name}`} className="min-w-0">
- <div className="truncate text-[11px] text-zinc-500" title={item.name}>
+ <div className="truncate text-[11px] text-zinc-400" title={item.name}>
Preview of {item.name}
</div>
<FilePreviewView item={item} />
@@ -187,14 +187,14 @@ export const Files: React.FC<RendererProps<FilesBlock>> = ({ block }) => {
<div data-smart-result="files" data-block-id={block.id} className="min-w-0 max-w-full">
<ul role="list" className="my-3.5 min-w-0 max-w-full space-y-2">
{block.items.map((item) => (
- <li key={item.id} className="min-w-0 max-w-full rounded-xl border border-zinc-800 bg-zinc-950/70 p-3 shadow-sm">
+ <li key={item.id} className="min-w-0 max-w-full rounded-xl border border-zinc-700/60 bg-zinc-900/60 p-3 shadow-[var(--kws-shadow)]">
<div className="flex items-start gap-2">
- <FileIcon size={14} className="mt-0.5 shrink-0 text-zinc-500" aria-hidden="true" />
+ <FileIcon size={14} className="mt-0.5 shrink-0 text-zinc-400" aria-hidden="true" />
<div className="min-w-0 flex-1">
<div className="truncate text-xs font-medium text-zinc-200" title={item.name}>
{item.name}
</div>
- <div className="mt-0.5 text-[11px] text-zinc-500">
+ <div className="mt-0.5 text-[11px] text-zinc-400">
{item.mime} · {humanSize(item.size_bytes)}
</div>
<FilePreviewView item={item} />
diff --git a/frontend/src/components/results/Findings.tsx b/frontend/src/components/results/Findings.tsx
index 801d3a2b..ddf4222f 100644
--- a/frontend/src/components/results/Findings.tsx
+++ b/frontend/src/components/results/Findings.tsx
@@ -35,6 +35,14 @@ const DOT: Record<Severity, string> = {
info: 'bg-zinc-500',
};
+const STRIPE: Record<Severity, string> = {
+ critical: 'border-l-rose-500',
+ high: 'border-l-orange-500',
+ medium: 'border-l-amber-500',
+ low: 'border-l-sky-500',
+ info: 'border-l-zinc-500',
+};
+
const refLabel = (r: FindingItem['refs'][number]) => `${r.path}${r.line !== null ? `:${r.line}` : ''}`;
/** Findings grouped by severity, with counts; severity is text, refs are code. */
@@ -43,7 +51,7 @@ export const Findings: React.FC<RendererProps<FindingsBlock>> = ({ block }) => {
return (
<div data-smart-result="findings" data-block-id={block.id} className="my-3.5 space-y-3">
- <div className="flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-zinc-500">
+ <div className="flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-zinc-400">
{groups.map((g) => (
<span key={g.sev} className="flex items-center gap-1.5">
<span className={`h-1.5 w-1.5 rounded-full ${DOT[g.sev]}`} aria-hidden="true" />
@@ -53,13 +61,13 @@ export const Findings: React.FC<RendererProps<FindingsBlock>> = ({ block }) => {
</div>
{groups.map((g) => (
<div key={g.sev}>
- <h4 className="mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-zinc-500">
+ <h4 className="mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-zinc-400">
<span className={`h-1.5 w-1.5 rounded-full ${DOT[g.sev]}`} aria-hidden="true" />
{g.items[0].severity_text} ({g.items.length})
</h4>
<ul role="list" className="space-y-1.5">
{g.items.map((item) => (
- <li key={item.id} className="rounded-xl border border-zinc-800 bg-zinc-950/70 p-3 text-xs shadow-sm">
+ <li key={item.id} className={`rounded-xl border border-zinc-700/60 border-l-[3px] bg-zinc-900/60 p-3 text-xs shadow-[var(--kws-shadow)] ${STRIPE[g.sev]}`}>
<div className="font-semibold leading-snug text-zinc-100 [overflow-wrap:anywhere]">{item.title}</div>
{item.detail.trim() !== '' && <p className="mt-1 leading-relaxed text-zinc-400 [overflow-wrap:anywhere]">{item.detail}</p>}
{item.refs.length > 0 && (
diff --git a/frontend/src/components/results/Metrics.tsx b/frontend/src/components/results/Metrics.tsx
index 5849c1b8..58a8fa7e 100644
--- a/frontend/src/components/results/Metrics.tsx
+++ b/frontend/src/components/results/Metrics.tsx
@@ -22,15 +22,15 @@ export const Metrics: React.FC<RendererProps<MetricsBlock>> = ({ block }) => (
<div data-smart-result="metrics" data-block-id={block.id}>
<ul role="list" className="my-3.5 grid grid-cols-2 gap-2.5 sm:grid-cols-3">
{block.items.map((item) => (
- <li key={item.id} className="rounded-xl border border-zinc-800 bg-zinc-950/70 px-3 py-2.5 shadow-sm min-w-0">
- <div className="truncate text-[11px] text-zinc-500" title={item.label}>
+ <li key={item.id} className="relative overflow-hidden rounded-xl border border-zinc-700/60 bg-zinc-900/60 px-3.5 py-3 shadow-[var(--kws-shadow)] min-w-0 before:absolute before:inset-x-0 before:top-0 before:h-0.5 before:bg-gradient-to-r before:from-sky-400/80 before:to-sky-400/0">
+ <div className="truncate text-xs text-zinc-400" title={item.label}>
{item.label}
</div>
- <div className="mt-0.5 flex items-baseline gap-1 text-lg font-semibold text-zinc-100 [overflow-wrap:anywhere]">
+ <div className="mt-1 flex items-baseline gap-1 text-xl font-semibold tracking-tight text-zinc-100 [overflow-wrap:anywhere]">
<span>{item.value_text}</span>
- {item.unit && !item.value_text.includes(item.unit) && <span className="text-xs font-normal text-zinc-500">{item.unit}</span>}
+ {item.unit && !item.value_text.includes(item.unit) && <span className="text-xs font-normal text-zinc-400">{item.unit}</span>}
</div>
- {item.note && <div className="mt-0.5 text-[11px] leading-snug text-zinc-500 [overflow-wrap:anywhere]">{item.note}</div>}
+ {item.note && <div className="mt-1 text-xs leading-snug text-zinc-400 [overflow-wrap:anywhere]">{item.note}</div>}
</li>
))}
</ul>
diff --git a/frontend/src/components/results/SmartActions.tsx b/frontend/src/components/results/SmartActions.tsx
index 8cf562b2..4c780586 100644
--- a/frontend/src/components/results/SmartActions.tsx
+++ b/frontend/src/components/results/SmartActions.tsx
@@ -6,9 +6,15 @@ export const SmartActionsSlot: React.FC<{ messageId: string }> = ({ messageId })
<span data-smart-actions={messageId} className="contents" />
);
-/** Same look as the message's "Copy markdown" button. */
+/** The chip every action under a reply shares ("Copy markdown", "Show as text", "Copy data"): a hairline
+ * button with an icon, readable at rest and lifted on hover. 36 px tall, 44 px on touch screens. */
export const actionClass =
- 'px-2 py-1 rounded-md whitespace-nowrap shrink-0 hover:bg-zinc-900 hover:text-zinc-300 transition-colors flex items-center gap-1.5 text-[11px] cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/70';
+ 'inline-flex items-center gap-1.5 min-h-9 px-3 rounded-lg border border-hairline-strong bg-white/[0.04] text-xs font-medium whitespace-nowrap shrink-0 text-zinc-200 hover:text-zinc-50 hover:bg-white/[0.08] hover:border-white/20 active:scale-[0.97] transition duration-150 motion-reduce:transition-none motion-reduce:active:scale-100 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400';
+/** The same chip shape for a fact in the row ("From this reply"): an icon and text, no hover, since it does nothing. */
+export const evidenceClass =
+ 'inline-flex items-center gap-1.5 min-h-9 min-w-0 max-w-full px-3 rounded-lg border border-hairline bg-white/[0.03] text-xs font-medium text-zinc-300 [&>svg]:text-muted';
+/** A chip that is switched on (Show as text while showing text). */
+export const actionOnClass = 'border-sky-500/50 bg-sky-500/15 text-sky-100 hover:bg-sky-500/20';
/**
* A block's buttons go in its message's action row, so the reply itself keeps the streamed text's exact
@@ -21,6 +27,6 @@ export const SmartActions: React.FC<{ messageId: string; children: React.ReactNo
setSlot(found ?? null);
}, [messageId]);
if (slot) return createPortal(children, slot);
- if (slot === null) return <div className="mt-1.5 flex items-center gap-2 text-xs text-zinc-500">{children}</div>;
+ if (slot === null) return <div className="mt-2 flex flex-wrap items-center gap-2 text-xs text-zinc-400">{children}</div>;
return null;
};
diff --git a/frontend/src/components/results/SmartResult.tsx b/frontend/src/components/results/SmartResult.tsx
index 74a03304..d1fc9e6b 100644
--- a/frontend/src/components/results/SmartResult.tsx
+++ b/frontend/src/components/results/SmartResult.tsx
@@ -1,11 +1,13 @@
import React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
-import { Check, ChevronDown, Copy } from 'lucide-react';
+import { Check, ChevronDown, FileText, ListChecks, Paperclip, Quote, Table2 } from 'lucide-react';
import type { SmartBlock } from '../../smartResults';
import { readDoneSteps } from '../../smartResults';
import { playSfx } from '../../audio/chiptune';
import { ReplySource, resolveBlock } from './registry';
import { blockCsv, blockJson, blockMarkdown } from './exporters';
-import { SmartActions, actionClass } from './SmartActions';
+import { SmartActions, actionClass, actionOnClass, evidenceClass } from './SmartActions';
+import { VerifiedStamp } from '../Signature';
+import { stampText } from '../../signature';
/** "Ask about this": ChatView puts `text` in the composer and focuses it. Nothing is sent. */
export const COMPOSE_PREFILL_EVENT = 'kwnt:compose-prefill';
@@ -158,9 +160,9 @@ const CopyData: React.FC<{ block: SmartBlock; messageId: string }> = ({ block, m
}}
className={actionClass}
>
- {said?.ok ? <Check size={12} className="text-emerald-400" /> : <Copy size={12} />}
+ {said?.ok ? <Check size={14} className="text-emerald-400" aria-hidden="true" /> : <Table2 size={14} aria-hidden="true" />}
<span className={said?.ok ? 'font-medium text-emerald-400' : said ? 'text-rose-300' : ''}>{said?.ok ? 'Copied' : said ? 'Copy failed' : 'Copy data'}</span>
- <ChevronDown size={11} aria-hidden="true" />
+ <ChevronDown size={12} aria-hidden="true" />
</button>
<span className="sr-only" aria-live="polite">
{said?.text ?? ''}
@@ -172,7 +174,7 @@ const CopyData: React.FC<{ block: SmartBlock; messageId: string }> = ({ block, m
role="menu"
aria-label="Copy data as"
onKeyDown={onMenuKey}
- className={`absolute bottom-full ${flip ? 'right-0' : 'left-0'} z-20 mb-1 flex min-w-[8rem] flex-col rounded-lg border border-zinc-800 bg-zinc-900 p-1 shadow-lg`}
+ className={`absolute bottom-full ${flip ? 'right-0' : 'left-0'} z-20 mb-1 flex min-w-[8rem] flex-col rounded-xl border border-zinc-700 bg-zinc-900 p-1 shadow-[var(--kws-shadow)]`}
>
{FORMATS.map((f, i) => (
<button
@@ -182,7 +184,7 @@ const CopyData: React.FC<{ block: SmartBlock; messageId: string }> = ({ block, m
role="menuitem"
tabIndex={-1}
onClick={() => copy(f)}
- className="rounded-md px-2.5 py-1.5 text-left text-[11px] text-zinc-300 hover:bg-zinc-800 hover:text-zinc-100 focus:bg-zinc-800 focus:text-zinc-100 focus:outline-none"
+ className="rounded-md px-3 py-2 text-left text-xs text-zinc-200 hover:bg-zinc-800 hover:text-zinc-100 focus:bg-zinc-800 focus:text-zinc-100 focus:outline-none"
>
{f}
</button>
@@ -193,18 +195,45 @@ const CopyData: React.FC<{ block: SmartBlock; messageId: string }> = ({ block, m
);
};
-/** The footer every block shares, in the message's action row: Evidence, Show as text, Copy data. */
-const Footer: React.FC<{ block: SmartBlock; messageId: string; asText: boolean; onToggle: () => void }> = ({ block, messageId, asText, onToggle }) => (
- <SmartActions messageId={messageId}>
- <span className="min-w-0 max-w-full truncate px-1 text-[11px] text-zinc-500" data-evidence title={evidenceText(block)}>
- {evidenceText(block)}
- </span>
- <button type="button" aria-pressed={asText} onClick={onToggle} className={`${actionClass} ${asText ? 'bg-zinc-900 text-zinc-300' : ''}`}>
- Show as text
- </button>
- <CopyData block={block} messageId={messageId} />
- </SmartActions>
-);
+/** The icon for where the data came from: the reply itself, a task's checks, or an attachment. */
+const EvidenceIcon: React.FC<{ block: SmartBlock }> = ({ block }) => {
+ const p = block.provenance;
+ const Icon = p.kind !== 'kwant_data' ? Quote : p.ref.startsWith('task:') ? ListChecks : Paperclip;
+ return <Icon size={14} className="shrink-0" aria-hidden="true" />;
+};
+
+/** S1: a Checks block whose every check passed earns the holo "Verified · 3/3" at the head of the action row. */
+export function verifiedCounts(block: SmartBlock): { passed: number; total: number } | null {
+ if (block.type !== 'verification') return null;
+ const total = block.checks.length;
+ return total > 0 && block.checks.every((c) => c.status === 'passed') ? { passed: total, total } : null;
+}
+
+/** The footer every block shares, in the message's action row: (Verified), Show as text, Copy data, Evidence. */
+const Footer: React.FC<{ block: SmartBlock; messageId: string; asText: boolean; onToggle: () => void }> = ({ block, messageId, asText, onToggle }) => {
+ const verified = verifiedCounts(block);
+ return (
+ <SmartActions messageId={messageId}>
+ {verified && (
+ <VerifiedStamp
+ className="order-first"
+ text={stampText(verified)}
+ label={`All ${verified.total} ${verified.total === 1 ? 'check' : 'checks'} passed`}
+ />
+ )}
+ <button type="button" aria-pressed={asText} onClick={onToggle} className={`${actionClass} ${asText ? actionOnClass : ''}`}>
+ <FileText size={14} aria-hidden="true" />
+ Show as text
+ </button>
+ <CopyData block={block} messageId={messageId} />
+ {/* Where the numbers come from: a chip in the row's style, a fact rather than a button. */}
+ <span className={evidenceClass} data-evidence title={evidenceText(block)}>
+ <EvidenceIcon block={block} />
+ <span className="truncate">{evidenceText(block)}</span>
+ </span>
+ </SmartActions>
+ );
+};
export interface SmartResultProps {
/** The message's block for this place, unchecked. */
diff --git a/frontend/src/components/results/Steps.tsx b/frontend/src/components/results/Steps.tsx
index 38a2acd0..42bb2f4a 100644
--- a/frontend/src/components/results/Steps.tsx
+++ b/frontend/src/components/results/Steps.tsx
@@ -42,7 +42,7 @@ export const Steps: React.FC<RendererProps<StepsBlock>> = ({ block, messageId, r
<span className="font-medium text-zinc-200">{it.when}</span>
{': '}
{items[i]}
- {it.owner && <span className="text-zinc-500"> (owner: {it.owner})</span>}
+ {it.owner && <span className="text-zinc-400"> (owner: {it.owner})</span>}
</>
)}
</li>
@@ -65,9 +65,9 @@ export const Steps: React.FC<RendererProps<StepsBlock>> = ({ block, messageId, r
<input id={id} type="checkbox" checked={on} onChange={() => toggle(item.id)} className={boxClass} />
<label
htmlFor={id}
- className={`min-w-0 cursor-pointer [overflow-wrap:anywhere] motion-safe:transition-colors ${on ? 'text-zinc-500 line-through decoration-zinc-600' : ''}`}
+ className={`min-w-0 cursor-pointer [overflow-wrap:anywhere] motion-safe:transition-colors ${on ? 'text-zinc-400 line-through decoration-zinc-600' : ''}`}
>
- {numbered && <span className="mr-1 tabular-nums text-zinc-500">{start + i}.</span>}
+ {numbered && <span className="mr-1 tabular-nums text-zinc-400">{start + i}.</span>}
{items[i]}
</label>
</li>
diff --git a/frontend/src/components/results/Verification.tsx b/frontend/src/components/results/Verification.tsx
index 4724ee7d..c48ea789 100644
--- a/frontend/src/components/results/Verification.tsx
+++ b/frontend/src/components/results/Verification.tsx
@@ -40,7 +40,14 @@ const STATUS_COLOR: Record<CheckStatus, string> = {
passed: 'text-emerald-400',
failed: 'text-rose-400',
error: 'text-amber-400',
- pending: 'text-zinc-500',
+ pending: 'text-zinc-400',
+};
+
+const STATUS_PILL: Record<CheckStatus, string> = {
+ passed: 'border-emerald-500/40 bg-emerald-500/10 text-emerald-300',
+ failed: 'border-rose-500/40 bg-rose-500/10 text-rose-300',
+ error: 'border-amber-500/40 bg-amber-500/10 text-amber-300',
+ pending: 'border-zinc-600 bg-zinc-800/60 text-zinc-300',
};
function formatWhen(s: string | null): string | null {
@@ -51,14 +58,14 @@ function formatWhen(s: string | null): string | null {
/** A task's outcome checks: the summary line, then each check with status, an expandable excerpt, and time. */
export const Verification: React.FC<RendererProps<VerificationBlock>> = ({ block }) => (
- <div data-smart-result="verification" data-block-id={block.id} className="my-3.5 rounded-xl border border-zinc-800 bg-zinc-950/70 shadow-sm">
- <div className="border-b border-zinc-800 px-3.5 py-2.5">
- <p className="text-xs font-medium text-zinc-200">{block.summary}</p>
- <p className="mt-0.5 truncate text-[11px] text-zinc-500" title={block.target.title}>
+ <div data-smart-result="verification" data-block-id={block.id} className="my-3.5 rounded-xl border border-zinc-700/60 bg-zinc-900/60 shadow-[var(--kws-shadow)]">
+ <div className="border-b border-zinc-700/60 px-3.5 py-3">
+ <p className="text-sm font-semibold text-zinc-100">{block.summary}</p>
+ <p className="mt-0.5 truncate text-[11px] text-zinc-400" title={block.target.title}>
{block.target.title}
</p>
</div>
- <ul role="list" className="divide-y divide-zinc-800/60">
+ <ul role="list" className="divide-y divide-zinc-700/40">
{block.checks.map((check) => {
const Icon = STATUS_ICON[check.status];
const when = formatWhen(check.checked_at);
@@ -68,12 +75,12 @@ export const Verification: React.FC<RendererProps<VerificationBlock>> = ({ block
<Icon size={14} className={`mt-0.5 shrink-0 ${STATUS_COLOR[check.status]}`} aria-hidden="true" />
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5">
- <span className="text-xs font-medium text-zinc-200 [overflow-wrap:anywhere]">{check.label}</span>
- <span className={`text-[11px] font-medium ${STATUS_COLOR[check.status]}`}>{STATUS_TEXT[check.status]}</span>
- <span className="text-[11px] text-zinc-600">{check.kind}</span>
+ <span className="text-xs font-medium text-zinc-100 [overflow-wrap:anywhere]">{check.label}</span>
+ <span className={`rounded-full border px-2 py-px text-[11px] font-medium ${STATUS_PILL[check.status]}`}>{STATUS_TEXT[check.status]}</span>
+ <span className="text-[11px] text-zinc-400">{check.kind}</span>
</div>
{when && (
- <div className="mt-0.5 flex items-center gap-1 text-[11px] text-zinc-500">
+ <div className="mt-0.5 flex items-center gap-1 text-[11px] text-zinc-400">
<Clock size={10} aria-hidden="true" />
{when}
</div>
diff --git a/frontend/src/failover.ts b/frontend/src/failover.ts
index 6d6117ae..faf77a50 100644
--- a/frontend/src/failover.ts
+++ b/frontend/src/failover.ts
@@ -192,3 +192,16 @@ export function savedFailoverNotice(meta: unknown, now = Date.now()): string | n
const last = list[list.length - 1];
return failoverNotice({ ...first, to_name: last.to_name, to_engine: last.to_engine, to_model: last.to_model, to_model_label: last.to_model_label }, now);
}
+
+/** The engines a saved reply moved between ("Claude" to "Codex") and the notice line, for the engine chip. Null when none. */
+export function savedFailoverHandoff(meta: unknown, now = Date.now()): { from: string; to: string; why: string } | null {
+ const m = parseMetaObject(meta);
+ const raw = m?.failover;
+ const list = (Array.isArray(raw) ? raw : raw ? [raw] : []).map(savedSwitch).filter((s): s is FailoverEvent => !!s);
+ if (list.length === 0) return null;
+ const first = list[0];
+ const last = list[list.length - 1];
+ const why = savedFailoverNotice(meta, now);
+ if (!why) return null;
+ return { from: engineName(first.from_engine, first.from_name), to: engineName(last.to_engine, last.to_name), why };
+}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index aa01e0d6..c3823cf1 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -6,6 +6,7 @@ import { AuthGate } from './components/AuthGate';
import { captureInstallPrompt, registerServiceWorker, trackAppHeight } from './pwa';
import './styles/fonts.css';
import './styles/modern.css';
+import './styles/stream.css';
registerServiceWorker();
captureInstallPrompt();
diff --git a/frontend/src/routeReason.ts b/frontend/src/routeReason.ts
index ebccf811..323fcaa0 100644
--- a/frontend/src/routeReason.ts
+++ b/frontend/src/routeReason.ts
@@ -76,3 +76,37 @@ export function routeReasonText(r: RouteReasonInput): string | null {
return r.reason || null;
}
}
+
+/** The two or three words on the chip beside a reply's name: how this bot was picked. The full
+ * sentence (routeReasonText / routingLine) opens when the chip is tapped. */
+export function routeChipLabel(r: { basis?: string; fallback?: boolean }): string {
+ if (r.fallback) return 'By keywords';
+ switch (r.basis) {
+ case 'skills':
+ return 'Matched skills';
+ case 'keywords':
+ return 'Matched words';
+ case 'lead':
+ case 'team':
+ return 'Team lead';
+ case 'only':
+ return 'Only bot here';
+ case 'several':
+ return 'Best of several';
+ case 'discuss':
+ return 'Team discussion';
+ case 'asked':
+ case 'ask':
+ return 'You chose';
+ case 'last':
+ return 'Same as last time';
+ case 'concierge':
+ return 'General answer';
+ case 'handback':
+ return 'Handed over';
+ case 'learned':
+ return 'Learned from you';
+ default:
+ return 'Picked by Laya';
+ }
+}
diff --git a/frontend/src/signature.ts b/frontend/src/signature.ts
new file mode 100644
index 00000000..b9f60936
--- /dev/null
+++ b/frontend/src/signature.ts
@@ -0,0 +1,145 @@
+// Small signature elements that each state something the client already knows: the Verified stamp's
+// counts, the lessons chip, the goal heartbeat, the engine hand-off and the once-only "first" moments.
+import type { ChecksSummary, TaskEvent } from './missions';
+import type { GoalEvent } from './goals';
+
+type Counts = Pick<ChecksSummary, 'passed' | 'total'>;
+
+/** A count the stamp may show: every check passed. A Verified task can still have an optional check waiting (1 of 2); that is not a count to put on a stamp. */
+const full = (cs: Counts | null | undefined): cs is Counts => !!cs && Number.isFinite(cs.total) && cs.total > 0 && cs.passed === cs.total;
+
+/** "Verified · 3/3" when every check passed, else just "Verified". */
+export function stampText(cs: Counts | null | undefined): string {
+ return full(cs) ? `Verified · ${cs.passed}/${cs.total}` : 'Verified';
+}
+
+/** What a screen reader hears for the stamp. */
+export function stampLabel(cs: Counts | null | undefined): string {
+ return full(cs) ? `Verified, ${cs.passed} of ${cs.total} checks passed. Open the evidence receipt` : 'Verified. Open the evidence receipt';
+}
+
+/** The "Learned from N" chip, from a task's `lessons_shown` events. Null when there is none.
+ * The hover lists lesson titles only when the event carries them; otherwise "From N earlier tasks". */
+export function lessonsChip(events: Pick<TaskEvent, 'kind' | 'detail'>[]): { count: number; text: string; title: string } | null {
+ const e = [...events].reverse().find((x) => x.kind === 'lessons_shown');
+ if (!e) return null;
+ const keys = Array.isArray(e.detail?.keys) ? e.detail.keys : [];
+ const count = keys.length;
+ if (count === 0) return null;
+ const titles = Array.isArray(e.detail?.titles) ? (e.detail.titles as unknown[]).filter((t): t is string => typeof t === 'string' && t.trim() !== '') : [];
+ const title = titles.length ? `From earlier tasks: ${titles.join('; ')}` : `From ${count === 1 ? '1 earlier task' : `${count} earlier tasks`}`;
+ return { count, text: `Learned from ${count}`, title };
+}
+
+export type HeartTone = 'ok' | 'failing' | 'fixing' | 'unknown';
+export interface HeartDot {
+ tone: HeartTone;
+ label: string;
+ /** When the check (or fix) happened, as the event gave it. */
+ at?: string;
+}
+
+const verdictTone = (v: unknown): HeartTone => (v === 'met' ? 'ok' : v === 'not_met' ? 'failing' : 'unknown');
+
+/** The goal's last checks, oldest first, one square each: ok, failing, a fix underway, or couldn't check. */
+export function heartbeatDots(events: Array<Pick<GoalEvent, 'kind' | 'detail'> & Partial<Pick<GoalEvent, 'created_at'>>>, max = 7): HeartDot[] {
+ const dots: HeartDot[] = [];
+ for (const e of events) {
+ const at = typeof e.created_at === 'string' ? e.created_at : undefined;
+ if (e.kind === 'checked') {
+ const tone = verdictTone(e.detail?.verdict);
+ dots.push({ tone, label: tone === 'ok' ? 'ok' : tone === 'failing' ? 'failing' : 'can’t check', at });
+ } else if (e.kind === 'fix_opened' || e.kind === 'replanned') {
+ dots.push({ tone: 'fixing', label: 'fixing', at });
+ }
+ }
+ return dots.slice(-max);
+}
+
+const TONE_WORD: Record<HeartTone, string> = { ok: 'ok', failing: 'failing', fixing: 'fixing', unknown: 'can’t check' };
+
+/** "Last 7 checks: 5 ok, 1 fixing, 1 failing" (spec §3), counted from the squares shown. */
+export function heartbeatText(dots: HeartDot[]): string {
+ if (!dots.length) return 'No checks yet';
+ const count = (t: HeartTone) => dots.filter((d) => d.tone === t).length;
+ const parts = (['ok', 'fixing', 'failing', 'unknown'] as const).map((t) => [count(t), TONE_WORD[t]] as const).filter(([n]) => n > 0).map(([n, l]) => `${n} ${l}`);
+ return `Last ${dots.length} ${dots.length === 1 ? 'check' : 'checks'}: ${parts.join(', ')}`;
+}
+
+/** "5/7 ok": how many of the squares shown are ok. */
+export function heartbeatCount(dots: HeartDot[]): string {
+ return `${dots.filter((d) => d.tone === 'ok').length}/${dots.length} ok`;
+}
+
+export type HeartWord = 'Steady' | 'Back to ok' | 'Fixing' | 'Failing' | 'Can’t check';
+
+/**
+ * The heartbeat's word comes from the goal's badge, so it never argues with it (review of #266, fix 4);
+ * the squares already show the history, so there is no "Flapping".
+ * OK: Steady when the last 3 checks are ok, else Back to ok. Failing: Fixing while a bot works on it, else
+ * Failing. Can't check: Can’t check. Any other badge (needs you, draft, checking, paused, waiting, fixing): none.
+ */
+export function heartbeatWord(status: string, dots: HeartDot[], fixing = false): HeartWord | null {
+ if (!dots.length) return null;
+ switch (status) {
+ case 'met':
+ return dots.slice(-3).every((d) => d.tone === 'ok') ? 'Steady' : 'Back to ok';
+ case 'not_met':
+ return fixing || dots[dots.length - 1].tone === 'fixing' ? 'Fixing' : 'Failing';
+ case 'unknown':
+ return 'Can’t check';
+ default:
+ return null;
+ }
+}
+
+// ---- Once per space ----
+
+export type FirstKind = 'verified' | 'goal_met';
+
+const FIRST_KEY = (kind: FirstKind, spaceId: string) => `kwant.first.${kind}.${spaceId || 'default'}`;
+
+interface Store {
+ getItem(k: string): string | null;
+ setItem(k: string, v: string): void;
+}
+
+const defaultStore = (): Store | null => {
+ try {
+ return typeof localStorage === 'undefined' ? null : localStorage;
+ } catch {
+ return null;
+ }
+};
+
+/** The id the first moment was given to (the sticker stays on it), '' when it was claimed silently, null when unclaimed. */
+export function firstHolder(kind: FirstKind, spaceId: string, store: Store | null = defaultStore()): string | null {
+ try {
+ return store?.getItem(FIRST_KEY(kind, spaceId)) ?? null;
+ } catch {
+ return null;
+ }
+}
+
+/** True exactly once per space and kind, and never again; false when storage is unavailable (so nothing repeats). */
+export function claimFirst(kind: FirstKind, spaceId: string, id: string, store: Store | null = defaultStore()): boolean {
+ if (!store) return false;
+ try {
+ if (store.getItem(FIRST_KEY(kind, spaceId)) !== null) return false;
+ store.setItem(FIRST_KEY(kind, spaceId), id);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+/** A space that already had one when this screen first loaded is not new: claim it without a celebration. */
+export const claimQuietly = (kind: FirstKind, spaceId: string, store: Store | null = defaultStore()): void => {
+ claimFirst(kind, spaceId, '', store);
+};
+
+export const FIRST_LINE: Record<FirstKind, string> = {
+ verified: 'Your first verified task. A check confirmed it, so you can rely on it.',
+ goal_met: 'Your first goal kept. Its checks pass, and you will be told if that changes.',
+};
+export const FIRST_STICKER: Record<FirstKind, string> = { verified: 'First verified', goal_met: 'First goal kept' };
diff --git a/frontend/src/styles/modern.css b/frontend/src/styles/modern.css
index eb9f464e..b705a2f2 100644
--- a/frontend/src/styles/modern.css
+++ b/frontend/src/styles/modern.css
@@ -237,36 +237,6 @@
}
}
-/* Smart results: the "Pick in this reply" label in a table row. It sits in whatever room is left on the
- first cell's first line and adds no width (inline-size containment), so the table keeps the streamed
- reply's exact geometry. Short of room it says "Pick"; with almost none, the row's tint and bar show
- the pick and the full label stays for screen readers. */
-.smart-pick {
- container-type: inline-size;
- overflow: clip;
- white-space: nowrap;
-}
-.smart-pick-short {
- display: none;
-}
-@container (max-width: 7rem) {
- .smart-pick-full {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- border-width: 0;
- }
-}
-@container (min-width: 2.5rem) and (max-width: 7rem) {
- .smart-pick-short {
- display: inline-block;
- }
-}
-
/* ------------------------------------------------------------------------------------------------
Semantic classes (UI refresh). Use these rather than repeating long utility strings.
.kw-card a raised surface: hairline, 12px corners, soft shadow
diff --git a/frontend/src/styles/stream.css b/frontend/src/styles/stream.css
new file mode 100644
index 00000000..468b6044
--- /dev/null
+++ b/frontend/src/styles/stream.css
@@ -0,0 +1,196 @@
+/* Conversation stream (reply header, working strip, decision cards, action row, results).
+ Everything here moves with transform and opacity only, lasts 120-200 ms, and is off under
+ prefers-reduced-motion. The --kws-* variables alias Pixel's --kw-* tokens (modern.css). */
+:root {
+ --kws-accent: theme('colors.sky.400');
+ --kws-accent-soft: rgb(122 98 240 / 0.16);
+ --kws-ok: var(--kw-ok);
+ --kws-warn: var(--kw-warn);
+ --kws-hairline: var(--kw-hairline-strong);
+ --kws-raised: var(--kw-surface-raised);
+ --kws-shadow: theme('boxShadow.raised');
+}
+
+/* New replies fade and slide in. */
+@keyframes kws-in {
+ from { opacity: 0; transform: translateY(6px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+.kws-in { animation: kws-in 180ms ease-out both; }
+
+/* The working strip rises into place above the composer. */
+@keyframes kws-strip-in {
+ from { opacity: 0; transform: translateY(4px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+.kws-strip { animation: kws-strip-in 160ms ease-out both; }
+
+/* Skeleton lines while a reply has no words yet (opacity only). */
+@keyframes kws-skel {
+ 0%, 100% { opacity: 0.35; }
+ 50% { opacity: 0.75; }
+}
+.kws-skel {
+ height: 0.7rem;
+ border-radius: 9999px;
+ background: theme('colors.zinc.700');
+ animation: kws-skel 1.3s ease-in-out infinite;
+}
+
+/* A small burst on "Mark verified": a ring and six dots, 200 ms. */
+.kws-burst {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+}
+.kws-burst-ring {
+ position: absolute;
+ left: -11px;
+ top: -11px;
+ width: 22px;
+ height: 22px;
+ border-radius: 9999px;
+ border: 2px solid theme('colors.emerald.300');
+ animation: kws-burst-ring 200ms ease-out both;
+}
+.kws-burst-dot {
+ position: absolute;
+ left: -2px;
+ top: -2px;
+ width: 4px;
+ height: 4px;
+ border-radius: 9999px;
+ background: theme('colors.emerald.300');
+ animation: kws-burst-dot 200ms ease-out both;
+}
+@keyframes kws-burst-ring {
+ from { opacity: 0.9; transform: scale(0.3); }
+ to { opacity: 0; transform: scale(1.7); }
+}
+@keyframes kws-burst-dot {
+ from { opacity: 1; transform: rotate(var(--kws-a)) translateY(-6px) scale(1); }
+ to { opacity: 0; transform: rotate(var(--kws-a)) translateY(-17px) scale(0.4); }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .kws-in,
+ .kws-strip,
+ .kws-skel,
+ .kws-burst-ring,
+ .kws-burst-dot {
+ animation: none;
+ }
+ .kws-skel { opacity: 0.55; }
+ .kws-burst { display: none; }
+}
+
+/* ---- Earned moments (the sticker itself is Pixel's .kw-sticker). ---- */
+/* Presses in once when it appears: transform and opacity, 160 ms. */
+.kws-stamp {
+ animation: kws-stamp 160ms ease-out both;
+}
+@keyframes kws-stamp {
+ from { transform: scale(1.08); }
+ to { transform: scale(1); }
+}
+
+/* Laya hand-off: the answering bot's avatar rises into the reply header. */
+.kws-handoff {
+ animation: kws-handoff 200ms ease-out both;
+}
+@keyframes kws-handoff {
+ from { opacity: 0; transform: translateY(28px) scale(0.85); }
+ to { opacity: 1; transform: translateY(0) scale(1); }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .kws-stamp,
+ .kws-handoff {
+ animation: none;
+ }
+}
+
+/* ---- Chips (spec §4): 20 px tall, 0 8 px, full radius, 500 12/16, 12 px icon, gap 4 px. Information, never holo. ---- */
+.kws-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ height: 20px;
+ padding: 0 8px;
+ border-radius: 9999px;
+ font-size: 12px;
+ line-height: 16px;
+ font-weight: 500;
+ white-space: nowrap;
+}
+.kws-chip:focus-visible { outline: 2px solid #b8adff; outline-offset: 2px; }
+.kws-chip-engine { background: #231d4b; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07); color: #d9d6f0; }
+.kws-chip-failover { background: #2b2360; box-shadow: inset 0 0 0 1px #46379a; color: #e8e4ff; }
+.kws-chip-learned { background: #231d4b; color: #d3ccff; }
+
+/* A styled tooltip from data-tip, on hover and keyboard focus (spec §4). The aria-label carries the same words. */
+.kws-tip { position: relative; }
+.kws-tip::after {
+ content: attr(data-tip);
+ position: absolute;
+ left: 0;
+ top: calc(100% + 6px);
+ z-index: 30;
+ width: max-content;
+ max-width: min(280px, 80vw);
+ padding: 4px 8px;
+ border: 1px solid rgb(255 255 255 / 0.14);
+ border-radius: 8px;
+ background: #2c2552;
+ color: #ecebfa;
+ font-size: 12px;
+ line-height: 16px;
+ font-weight: 400;
+ white-space: normal;
+ pointer-events: none;
+ /* Out of layout until shown, so a hidden tip never widens the page at 390 px. */
+ display: none;
+ transition: opacity 120ms var(--kw-ease), transform 120ms var(--kw-ease);
+}
+.kws-tip:hover::after,
+.kws-tip:focus-visible::after { display: block; opacity: 1; transform: translateY(0); }
+@starting-style {
+ .kws-tip:hover::after,
+ .kws-tip:focus-visible::after { opacity: 0; transform: translateY(-2px); }
+}
+
+/* ---- Goal heartbeat (spec §3) ---- */
+.kws-heartbeat { container-type: inline-size; display: block; min-width: 0; }
+.kws-heartbeat-full,
+.kws-heartbeat-tight { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
+.kws-heartbeat-tight { display: none; }
+.kws-beats { display: inline-flex; align-items: center; gap: 3px; }
+.kws-beat { width: 6px; height: 6px; border-radius: 1px; flex: none; }
+.kws-beat-ok { background: #5eead4; }
+.kws-beat-fixing { background: #fcd34d; }
+.kws-beat-failing { background: #fb7185; }
+.kws-beat-unknown { box-shadow: inset 0 0 0 1.5px #8f88bb; }
+.kws-beat-newest { outline: 1px solid rgb(255 255 255 / 0.55); outline-offset: 1px; }
+.kws-beat-count { font-size: 12px; line-height: 16px; color: #d9d6f0; font-variant-numeric: tabular-nums; }
+.kws-beat-word { font-size: 12px; line-height: 16px; font-weight: 600; }
+/* Phones: the last 5 squares and the word. */
+@media (max-width: 639px) {
+ .kws-beat-desk,
+ .kws-beat-count-desk { display: none; }
+}
+/* Under 64 px free, or under 360 px wide: only the newest square and "1/5 ok". */
+@container (max-width: 63px) {
+ .kws-heartbeat-full { display: none; }
+ .kws-heartbeat-tight { display: inline-flex; }
+}
+@media (max-width: 359px) {
+ .kws-heartbeat-full { display: none; }
+ .kws-heartbeat-tight { display: inline-flex; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .kws-tip::after { transition: none; transform: none; }
+}
diff --git a/frontend/src/workingStrip.ts b/frontend/src/workingStrip.ts
new file mode 100644
index 00000000..a4bd0dfd
--- /dev/null
+++ b/frontend/src/workingStrip.ts
@@ -0,0 +1,39 @@
+// 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';
+
+export interface WorkingState {
+ live?: LiveActivity | null;
+ queued?: boolean;
+ awaitingAnswer?: boolean;
+ awaitingBrowser?: boolean;
+ /** The reply's first words have started streaming. */
+ writing?: boolean;
+}
+
+const lower = (t: string) => (t ? t.charAt(0).toLowerCase() + t.slice(1) : t);
+
+/** What the bot is doing right now, in a few lowercase words that follow "<Bot> is". */
+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);
+ if (open) {
+ const t = plainTitle(open.title).trim();
+ if (t) return lower(t);
+ }
+ if (s.writing) return 'writing the reply';
+ return 'getting started';
+}
+
+/** The strip's clock; the saved card header uses the same one. */
+export const formatElapsed = formatClock;
+
+/** When the turn began: the earliest step start, else the moment the strip appeared. */
+export function turnStart(live: LiveActivity | null | undefined, mountedAt: number): number {
+ let start = mountedAt;
+ for (const s of live?.steps ?? []) {
+ const t = Date.parse(s.started_at);
+ if (Number.isFinite(t) && t < start) start = t;
+ }
+ return start;
+}
diff --git a/frontend/tests/activity.test.mjs b/frontend/tests/activity.test.mjs
index 9026eba0..3e44cb06 100644
--- a/frontend/tests/activity.test.mjs
+++ b/frontend/tests/activity.test.mjs
@@ -63,8 +63,8 @@ test('durations and the summary line', () => {
step({ id: 'b', status: 'failed', started_at: '2026-10-22T10:00:10Z', ended_at: '2026-10-22T10:00:41Z' }),
step({ id: 'n', kind: 'note', status: 'ok', title: 'This engine doesn’t share its thinking.' }),
];
- assert.equal(a.activitySummary({ steps, dropped: 10 }), '12 steps · 41s · 1 failed');
- assert.equal(a.activitySummary({ steps: [steps[0]], dropped: 0 }), '1 step · 10s');
+ assert.equal(a.activitySummary({ steps, dropped: 10 }), 'Worked 0:41 · 12 steps · 1 failed');
+ assert.equal(a.activitySummary({ steps: [steps[0]], dropped: 0 }), 'Worked 0:10 · 1 step');
assert.equal(a.plainTitle('Running `ls`'), 'Running ls');
assert.equal(a.statusLabel(step({ kind: 'approval', status: 'declined' })), 'Denied');
});
diff --git a/frontend/tests/newOnMentionStreaming.test.mjs b/frontend/tests/newOnMentionStreaming.test.mjs
new file mode 100644
index 00000000..240e2036
--- /dev/null
+++ b/frontend/tests/newOnMentionStreaming.test.mjs
@@ -0,0 +1,132 @@
+// Mira's #266 fix 3: the "New" tag on the composer's "@" is hidden while a reply streams (so it never sits on
+// the working strip's edge) and comes back after the turn, because hiding it does not mark it as seen.
+import assert from "node:assert/strict";
+import test from "node:test";
+import { JSDOM } from "jsdom";
+import { loadBundled } from "./bundle.mjs";
+
+const dom = new JSDOM("<!doctype html><html><body></body></html>", {
+ url: "http://localhost/",
+ pretendToBeVisual: true,
+});
+for (const k of [
+ "window",
+ "document",
+ "navigator",
+ "HTMLElement",
+ "HTMLButtonElement",
+ "Element",
+ "Node",
+ "Event",
+ "KeyboardEvent",
+ "MutationObserver",
+ "requestAnimationFrame",
+ "cancelAnimationFrame",
+ "getComputedStyle",
+ "CSS",
+]) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(globalThis, k, {
+ value: dom.window[k],
+ configurable: true,
+ writable: true,
+ });
+}
+const store = new Map();
+const ls = {
+ getItem: (k) => (store.has(k) ? store.get(k) : null),
+ setItem: (k, v) => void store.set(k, String(v)),
+ removeItem: (k) => void store.delete(k),
+};
+Object.defineProperty(globalThis, "localStorage", {
+ value: ls,
+ configurable: true,
+ writable: true,
+});
+Object.defineProperty(dom.window, "localStorage", {
+ value: ls,
+ configurable: true,
+});
+dom.window.matchMedia ??= () => ({
+ matches: false,
+ addEventListener() {},
+ removeEventListener() {},
+ addListener() {},
+ removeListener() {},
+});
+globalThis.matchMedia = dom.window.matchMedia;
+globalThis.ResizeObserver ??= class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+};
+dom.window.ResizeObserver ??= globalThis.ResizeObserver;
+globalThis.IntersectionObserver ??= class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+};
+dom.window.HTMLElement.prototype.scrollIntoView ??= function () {};
+dom.window.HTMLElement.prototype.scrollTo ??= function () {};
+
+const ui = await loadBundled(`
+ import React from 'react';
+ import { flushSync } from 'react-dom';
+ import { createRoot } from 'react-dom/client';
+ import { ChatView } from './src/components/ChatView';
+ export * from './src/whatsNew';
+ export const mount = (p) => {
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = createRoot(host);
+ const render = (q) => flushSync(() => root.render(React.createElement(ChatView, q)));
+ render(p);
+ return { host, render, unmount: () => root.unmount() };
+ };
+`);
+
+const props = (isStreaming) => ({
+ title: "Dev",
+ subtitle: "Backend",
+ messages: [],
+ streamingText: "",
+ streamingThinking: "",
+ isStreaming,
+ pendingApprovals: [],
+ onSendMessage: () => {},
+ onResolveApproval: () => {},
+ onCancelDiscussion: () => {},
+ kwants: [],
+ teams: [],
+});
+const tag = (host) => host.querySelector('[data-new-tag="mention"]');
+
+test('"New" on @ is not rendered while a reply streams, and is back after the turn when not yet seen', () => {
+ assert.equal(ui.isNewThing("mention"), true, "not seen yet");
+ const v = ui.mount(props(true));
+ try {
+ assert.equal(tag(v.host), null, "hidden while streaming");
+ assert.equal(
+ ui.isNewThing("mention"),
+ true,
+ "streaming does not mark it as seen",
+ );
+ v.render(props(false));
+ assert.ok(tag(v.host), "back after the turn");
+ assert.equal(tag(v.host).hasAttribute("data-leaving"), false);
+ v.render(props(true));
+ assert.equal(tag(v.host), null, "hidden again on the next turn");
+ } finally {
+ v.unmount();
+ }
+});
+
+test('once seen, "New" on @ stays gone after the turn too', () => {
+ ui.markNewSeen("mention");
+ const v = ui.mount(props(false));
+ try {
+ assert.equal(tag(v.host), null);
+ } finally {
+ v.unmount();
+ }
+});
diff --git a/frontend/tests/proactive.test.mjs b/frontend/tests/proactive.test.mjs
index 8362f9d1..6df18fae 100644
--- a/frontend/tests/proactive.test.mjs
+++ b/frontend/tests/proactive.test.mjs
@@ -145,7 +145,7 @@ test('chips: question, pick, why, who was asked, and a Change button', () => {
assert.match(html, /Decided: B: Wax seal/);
assert.match(html, /Why: Matches the wax-seal hero/);
assert.match(html, /Asked Designer first\./);
- assert.match(html, /aria-expanded="false"[^>]*>Change</);
+ assert.match(html, /aria-expanded="false"[^>]*>(<svg[^>]*>.*?<\/svg>)?Change</);
// Without a handler, or once changed, there's nothing to press
assert.doesNotMatch(ui.chips({ messageId: 'm1', decisions: [DESIGN] }), />Change</);
const changed = ui.chips({ messageId: 'm1', decisions: [{ ...DESIGN, status: 'changed', changed_to: 'A: Classic' }], onChange: async () => {} });
diff --git a/frontend/tests/quickWins.test.mjs b/frontend/tests/quickWins.test.mjs
index b881c83e..ce3e1f81 100644
--- a/frontend/tests/quickWins.test.mjs
+++ b/frontend/tests/quickWins.test.mjs
@@ -44,7 +44,7 @@ test('quotaLine: "Out of quota until …" while the limit lasts, the server word
assert.equal(m.quotaLine(null, undefined, NOW), null);
});
-test('reply meta is one line, name · time, with engine, account and tokens behind Details', () => {
+test('reply meta is one line, name · engine chip (engine + account, spec §4) · time, with tokens behind Details', () => {
const html = m.meta({
name: 'Architect',
at: '2026-11-02T11:42:00Z',
@@ -57,8 +57,9 @@ test('reply meta is one line, name · time, with engine, account and tokens behi
assert.match(html, /data-reply-time/);
assert.match(html, /aria-expanded="false"/);
assert.match(html, />Details</);
- // Folded: none of the facts show.
- assert.doesNotMatch(html, /Opus 5\.5|Personal|1\.2k tokens/);
+ // The engine chip reads "engine · account" (Mira's spec §4); folded, the tokens stay hidden. No cost, no duration.
+ assert.match(html, /data-engine-chip[^>]*>.*Claude · Opus 5\.5 · Personal/);
+ assert.doesNotMatch(html, /1\.2k tokens/);
});
test('reply meta: a failed step shows on the folded toggle; no toggle without details', () => {
diff --git a/frontend/tests/signature.test.mjs b/frontend/tests/signature.test.mjs
new file mode 100644
index 00000000..8e4c4994
--- /dev/null
+++ b/frontend/tests/signature.test.mjs
@@ -0,0 +1,142 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const s = await loadBundled(`export * from './src/signature';`);
+const w = await loadBundled(`export * from './src/workingStrip';`);
+
+const ev = (kind, detail = {}) => ({ kind, detail });
+const fakeStore = () => {
+ const m = new Map();
+ return { getItem: (k) => (m.has(k) ? m.get(k) : null), setItem: (k, v) => void m.set(k, v), m };
+};
+
+test('heartbeat dots: met is green, not_met red, a fix amber, anything else grey; the last 7 stay', () => {
+ const dots = s.heartbeatDots([
+ ev('checked', { verdict: 'met' }),
+ ev('checked', { verdict: 'not_met' }),
+ ev('fix_opened'),
+ ev('replanned'),
+ ev('checked', { verdict: 'unknown' }),
+ ev('checked', {}),
+ ev('note'),
+ ev('checked', { verdict: 'met' }),
+ ]);
+ assert.deepEqual(dots.map((d) => d.tone), ['ok', 'failing', 'fixing', 'fixing', 'unknown', 'unknown', 'ok']);
+ const many = Array.from({ length: 12 }, (_, i) => ev('checked', { verdict: i % 2 ? 'met' : 'not_met' }));
+ assert.equal(s.heartbeatDots(many).length, 7);
+ assert.equal(s.heartbeatDots(many, 5).length, 5);
+ assert.deepEqual(s.heartbeatDots([]), []);
+});
+
+test('heartbeat text counts each tone and never claims more than the squares show (spec §3)', () => {
+ assert.equal(s.heartbeatText([]), 'No checks yet');
+ const dots = s.heartbeatDots([ev('checked', { verdict: 'met' }), ev('checked', { verdict: 'met' }), ev('checked', { verdict: 'not_met' }), ev('fix_opened')]);
+ assert.equal(s.heartbeatText(dots), 'Last 4 checks: 2 ok, 1 fixing, 1 failing');
+ assert.equal(s.heartbeatCount(dots), '2/4 ok');
+ assert.match(s.heartbeatText(s.heartbeatDots([ev('checked', { verdict: 'met' })])), /^Last 1 check:/);
+ assert.equal(s.heartbeatText(s.heartbeatDots([ev('checked', {})])), 'Last 1 check: 1 can’t check');
+});
+
+test('heartbeat squares keep the check time for their hover', () => {
+ const [d] = s.heartbeatDots([{ kind: 'checked', detail: { verdict: 'met' }, created_at: '2026-11-03T10:00:00Z' }]);
+ assert.equal(d.at, '2026-11-03T10:00:00Z');
+});
+
+test('heartbeat word follows the badge: never Flapping, never at odds with OK or Failing', () => {
+ const run = (...v) => s.heartbeatDots(v.map((x) => (x === 'fix' ? ev('fix_opened') : ev('checked', x ? { verdict: x } : {}))));
+ assert.equal(s.heartbeatWord('met', []), null);
+ assert.equal(s.heartbeatWord('met', run('not_met', 'met', 'met', 'met')), 'Steady');
+ assert.equal(s.heartbeatWord('met', run('met', 'not_met', 'met', 'not_met', 'met')), 'Back to ok');
+ assert.equal(s.heartbeatWord('met', run('met', 'met', 'not_met', 'met')), 'Back to ok');
+ assert.equal(s.heartbeatWord('not_met', run('met', 'not_met', 'met', 'not_met')), 'Failing');
+ assert.equal(s.heartbeatWord('not_met', run('met', 'met', 'not_met'), true), 'Fixing');
+ assert.equal(s.heartbeatWord('not_met', run('met', 'not_met', 'fix')), 'Fixing');
+ assert.equal(s.heartbeatWord('unknown', run('met', 'met', null)), 'Can’t check');
+ for (const st of ['needs_you', 'draft', 'paused', 'checking']) assert.equal(s.heartbeatWord(st, run('met', 'met')), null, st);
+});
+
+test('lessons chip: the count comes from the lessons_shown keys; none, no chip', () => {
+ const none = s.lessonsChip([ev('created')]);
+ assert.equal(none, null);
+ assert.equal(s.lessonsChip([ev('lessons_shown', { keys: [] })]), null);
+ assert.equal(s.lessonsChip([ev('lessons_shown', {})]), null);
+ const one = s.lessonsChip([ev('lessons_shown', { keys: ['a'] })]);
+ assert.equal(one.text, 'Learned from 1');
+ assert.equal(one.title, 'From 1 earlier task', 'no titles on the event: the count only');
+ const titled = s.lessonsChip([ev('lessons_shown', { keys: ['a', 'b'], titles: ['Check the flyer date', ' ', 7] })]);
+ assert.equal(titled.title, 'From earlier tasks: Check the flyer date', 'titles only when the event has them');
+ const three = s.lessonsChip([ev('lessons_shown', { keys: ['a', 'b'] }), ev('lessons_shown', { keys: ['a', 'b', 'c'] })]);
+ assert.equal(three.count, 3, 'the latest event wins');
+ assert.equal(three.text, 'Learned from 3');
+ assert.equal(three.title, 'From 3 earlier tasks');
+});
+
+test('verified stamp: a count only when every check passed, else just "Verified"', () => {
+ assert.equal(s.stampText({ passed: 3, total: 3 }), 'Verified · 3/3');
+ assert.equal(s.stampText({ passed: 1, total: 2 }), 'Verified', 'an optional check waiting is not a count');
+ assert.equal(s.stampText({ passed: 0, total: 0 }), 'Verified');
+ assert.equal(s.stampText(null), 'Verified');
+ assert.equal(s.stampLabel({ passed: 3, total: 3 }), 'Verified, 3 of 3 checks passed. Open the evidence receipt');
+ assert.equal(s.stampLabel(undefined), 'Verified. Open the evidence receipt');
+});
+
+test('first moments happen once per space and kind, and never again', () => {
+ const st = fakeStore();
+ assert.equal(s.firstHolder('verified', 'sp1', st), null);
+ assert.equal(s.claimFirst('verified', 'sp1', 't1', st), true);
+ assert.equal(s.claimFirst('verified', 'sp1', 't2', st), false, 'not twice');
+ assert.equal(s.firstHolder('verified', 'sp1', st), 't1', 'the sticker stays on the first task');
+ assert.equal(s.claimFirst('verified', 'sp2', 't9', st), true, 'another space has its own');
+ assert.equal(s.claimFirst('goal_met', 'sp1', 'g1', st), true, 'another kind has its own');
+ assert.equal(s.claimFirst('verified', '', 'x', st), true);
+ assert.equal(s.claimFirst('verified', '', 'y', st), false, 'no space shares one default key');
+});
+
+test('a space that already had one is claimed quietly: no celebration, no sticker', () => {
+ const st = fakeStore();
+ s.claimQuietly('goal_met', 'sp1', st);
+ assert.equal(s.claimFirst('goal_met', 'sp1', 'g1', st), false);
+ assert.equal(s.firstHolder('goal_met', 'sp1', st), '', 'held by no one');
+});
+
+test('without storage nothing celebrates, so nothing can repeat', () => {
+ assert.equal(s.claimFirst('verified', 'sp1', 't1', null), false);
+ const broken = { getItem: () => { throw new Error('blocked'); }, setItem: () => { throw new Error('blocked'); } };
+ assert.equal(s.claimFirst('verified', 'sp1', 't1', broken), false);
+ assert.equal(s.firstHolder('verified', 'sp1', broken), null);
+});
+
+test('first-moment copy: one line and one sticker label each, no emoji', () => {
+ for (const k of ['verified', 'goal_met']) {
+ assert.ok(s.FIRST_LINE[k].length > 10 && s.FIRST_STICKER[k].length > 3);
+ assert.doesNotMatch(s.FIRST_LINE[k] + s.FIRST_STICKER[k], /\p{Extended_Pictographic}/u);
+ }
+ assert.equal(s.FIRST_STICKER.verified, 'First verified');
+ assert.equal(s.FIRST_STICKER.goal_met, 'First goal kept');
+});
+
+test('working strip: the label follows the open step, then falls back', () => {
+ assert.equal(w.workingLabel({}), 'getting started');
+ assert.equal(w.workingLabel({ writing: true }), 'writing the reply');
+ assert.equal(w.workingLabel({ queued: true, writing: true }), 'waiting in line');
+ assert.equal(w.workingLabel({ awaitingAnswer: true }), 'waiting for your answer');
+ assert.equal(w.workingLabel({ awaitingAnswer: true, awaitingBrowser: true }), 'waiting for you in the browser');
+});
+
+test('elapsed time reads m:ss and h:mm:ss, never negative', () => {
+ assert.equal(w.formatElapsed(0), '0:00');
+ assert.equal(w.formatElapsed(42_900), '0:42');
+ assert.equal(w.formatElapsed(725_000), '12:05');
+ assert.equal(w.formatElapsed(3_729_000), '1:02:09');
+ assert.equal(w.formatElapsed(-5), '0:00');
+ assert.equal(w.formatElapsed(NaN), '0:00');
+});
+
+test('turn start is the earliest step, else when the strip appeared', () => {
+ assert.equal(w.turnStart(null, 5000), 5000);
+ const live = { steps: [{ started_at: new Date(2000).toISOString() }, { started_at: 'bad' }, { started_at: new Date(9000).toISOString() }] };
+ assert.equal(w.turnStart(live, 5000), 2000);
+});
diff --git a/frontend/tests/smartResults.test.mjs b/frontend/tests/smartResults.test.mjs
index 446ce2a2..573665d9 100644
--- a/frontend/tests/smartResults.test.mjs
+++ b/frontend/tests/smartResults.test.mjs
@@ -124,7 +124,7 @@ const steps = (over = {}) => ({
...over,
});
-const bodyRows = (host) => [...host.querySelectorAll('[data-smart-result="comparison"] tbody tr')].map((tr) => tr.querySelector('td').textContent.replace(/Pick in this reply(Pick)?$/, ''));
+const bodyRows = (host) => [...host.querySelectorAll('[data-smart-result="comparison"] tbody tr')].map((tr) => tr.querySelector('td').textContent.replace(/Pick in this reply(: .*)?$/, ''));
const header = (host, label) => [...host.querySelectorAll('th')].find((th) => th.textContent.includes(label));
// ---------------------------------------------------------------------------
@@ -156,7 +156,7 @@ test('a valid comparison replaces table #0 and shows the reply’s own cells', a
assert.match(v.host.textContent, /Here are the three plans\..*I recommend B for a team of five\./s);
// Wide view keeps the markdown table's classes, so the swap from the streamed table moves nothing.
const wrap = block.querySelector('.overflow-x-auto');
- assert.equal(wrap.className, 'overflow-x-auto rounded-xl border border-zinc-800 bg-zinc-950/70 shadow-sm');
+ assert.equal(wrap.className, 'overflow-x-auto rounded-xl border border-zinc-700/60 bg-zinc-900/60 shadow-[var(--kws-shadow)]');
assert.equal(wrap.querySelector('table').className, 'w-full text-left border-collapse text-xs font-sans');
});
@@ -165,8 +165,10 @@ test('the highlighted row carries one “Pick in this reply” label per view',
const picked = [...v.host.querySelectorAll('tr[data-pick]')];
assert.equal(picked.length, 1);
assert.match(picked[0].textContent, /^B\s*Pick in this reply/);
- assert.equal(picked[0].querySelectorAll('.smart-pick-full').length, 1, 'one label a screen reader reads, however narrow');
- assert.equal(picked[0].querySelector('.smart-pick-short')?.getAttribute('aria-hidden'), 'true');
+ // S2 on desktop too: the small holo sticker, never clipped, with the reason as its hover text.
+ const sticker = picked[0].querySelectorAll('.kw-sticker.kw-sticker-sm');
+ assert.equal(sticker.length, 1, 'one sticker in the picked row');
+ assert.equal(picked[0].querySelectorAll('.kw-sticker-hit').length, 0, 'not interactive');
const cards = [...v.host.querySelectorAll('li[data-pick]')];
assert.equal(cards.length, 1, 'the narrow view marks the same row');
assert.equal(v.host.querySelectorAll('tr:not([data-pick])').length, 3, 'header + two plain rows');
diff --git a/frontend/tests/streamSpec.test.mjs b/frontend/tests/streamSpec.test.mjs
new file mode 100644
index 00000000..29b2a69e
--- /dev/null
+++ b/frontend/tests/streamSpec.test.mjs
@@ -0,0 +1,78 @@
+// Mira's spec (ui-refresh/design/spec.md) as applied to the conversation stream: S1 in the action row,
+// the heartbeat squares, the three chips, the 44 px sticker hit area and no confetti.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { readFileSync } from 'node:fs';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { VerifiedStamp, GoalHeartbeat, EngineChip, LessonsChip } from './src/components/Signature';
+ export { verifiedCounts } from './src/components/results/SmartResult';
+ export { heartbeatDots } from './src/signature';
+ const r = (C) => (props) => renderToStaticMarkup(React.createElement(C, props));
+ export const stamp = r(VerifiedStamp);
+ export const beat = r(GoalHeartbeat);
+ export const engine = r(EngineChip);
+ export const lessons = r(LessonsChip);
+`);
+
+const check = (status) => ({ id: status + Math.random(), label: 'x', kind: 'k', status, checked_at: null });
+const vb = (...st) => ({ type: 'verification', checks: st.map(check) });
+
+test('S1: a Checks block earns the stamp only when every check passed', () => {
+ assert.deepEqual(m.verifiedCounts(vb('passed', 'passed', 'passed')), { passed: 3, total: 3 });
+ assert.equal(m.verifiedCounts(vb('passed', 'pending')), null);
+ assert.equal(m.verifiedCounts(vb('passed', 'failed')), null);
+ assert.equal(m.verifiedCounts({ type: 'comparison' }), null);
+});
+
+test('S1/S3 stickers: holo, −2° (stamp) and −3° (first), clickable ones inside a 44 px .kw-sticker-hit button', () => {
+ const plain = m.stamp({ text: 'Verified · 3/3', label: 'All 3 checks passed' });
+ assert.match(plain, /kw-sticker-holo/);
+ assert.match(plain, /--kw-tilt:-2deg/);
+ assert.doesNotMatch(plain, /<button/);
+ const first = m.stamp({ text: 'Verified', label: 'L', first: true, onOpen: () => {} });
+ assert.match(first, /--kw-tilt:-3deg/);
+ assert.match(first, /<button[^>]*class="kw-sticker-hit"[^>]*>.*<span[^>]*kw-sticker/);
+ assert.doesNotMatch(first, /confetti/);
+});
+
+test('heartbeat: nothing without data; one picture with the spec label, count and word', () => {
+ assert.equal(m.beat({ dots: [] }), '');
+ const dots = m.heartbeatDots(['met', 'met', 'not_met', 'met', 'met', 'met', 'met'].map((v) => ({ kind: 'checked', detail: { verdict: v } })));
+ const html = m.beat({ dots });
+ assert.match(html, /role="img" aria-label="Last 7 checks: 6 ok, 1 failing"/);
+ assert.match(html, />6\/7 ok</);
+ assert.equal((html.match(/kws-beat-newest/g) || []).length, 2, 'the newest is outlined in the full and tight views');
+ assert.equal((html.match(/kws-beat-desk/g) || []).length, 2, 'phones drop the two oldest of 7');
+ assert.match(html, /aria-label="Last 5 checks: 4 ok, 1 failing"[^]*>4\/5 ok</, 'the tight view counts the last 5');
+});
+
+test('chips: engine (Cpu) never shows cost; failover is info with a pixel baton and the reason as tooltip and label; learned is never holo', () => {
+ const e = m.engine({ label: 'Claude · Team' });
+ assert.match(e, /kws-chip-engine/);
+ assert.match(e, /Claude · Team/);
+ assert.doesNotMatch(e, /\$|cost|tokens/i);
+ const f = m.engine({ label: 'x', handoff: { from: 'Claude', to: 'Codex', why: 'Claude hit its usage limit · Codex took over' } });
+ assert.match(f, /kws-chip-failover/);
+ assert.doesNotMatch(f, /amber|warn/);
+ assert.match(f, /data-tip="Claude hit its usage limit · Codex took over"/);
+ assert.match(f, /aria-label="Claude to Codex\. Claude hit its usage limit · Codex took over"/);
+ assert.match(f, /<svg[^>]*width="12"/);
+ const l = m.lessons({ text: 'Learned from 3', title: 'From 3 earlier tasks' });
+ assert.match(l, /kws-chip-learned/);
+ assert.doesNotMatch(l, /holo|kw-sticker/);
+});
+
+test('no confetti left in the stream, and the reply header avatar carries the mood', () => {
+ const css = readFileSync(new URL('../src/styles/stream.css', import.meta.url), 'utf8');
+ assert.doesNotMatch(css, /confetti/);
+ const sig = readFileSync(new URL('../src/components/FirstMoment.tsx', import.meta.url), 'utf8');
+ assert.doesNotMatch(sig, /Confetti/);
+ const chat = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');
+ assert.equal((chat.match(/kwantId=\{replyKwantId\}/g) || []).length, 2, 'desktop and phone reply header avatars');
+});
diff --git a/frontend/tests/uiRefreshSignature.test.mjs b/frontend/tests/uiRefreshSignature.test.mjs
index 0b647f3b..0c39a0aa 100644
--- a/frontend/tests/uiRefreshSignature.test.mjs
+++ b/frontend/tests/uiRefreshSignature.test.mjs
@@ -280,4 +280,6 @@ test('composer: 44 px buttons on phones; "New" on @ clears when the picker opens
assert.equal((c.match(/w-11 h-11 sm:w-9 sm:h-9/g) || []).length, 4);
assert.match(c, /if \(isMentionOpen\) markNewSeen\('mention'\)/);
assert.match(c, /\$\{isMentionOpen \? 'hidden' : ''\}/);
+ // #266 Mira fix 3: hidden (not marked seen) while a reply streams; mounted behaviour is in newOnMentionStreaming.
+ assert.match(c, /\{!isStreaming && \(\s*<NewTag\s+id="mention"/);
});