Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
0.8.0 B3 follow-ups: #458 review, design and QA Later items (#475)
Oleksandr Ivanchenko50d69a488962
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex eb6c0b6a..8f63db9c 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -140,14 +140,14 @@ import { requestSpendStopFocus } from './spendStop';import { SpendStopNeedsYou } from './components/SpendStop';import { EMPTY_PILL, NUDGES_SETTING_EVENT, browserIconDoc, createArrivals, createNudgeIcon, nudgesEnabled, pillAdd, pillPrune, setAppBadgeCount, shouldPill, type Nudge, type PillState } from './attention';import { NeedsYouPill } from './components/NeedsYouPill';-import { devApi, devStore, devTeamRefs } from './devMode';+import { DevModeError, devApi, devStore, devTeamRefs } from './devMode';import { GitHubConnectHost, connectedToast, openGitHubConnect } from './components/GitHubConnect';import { JiraSetupHost } from './components/JiraSetup';import { useDevModeOn } from './components/DevModeSwitch';import { DEV_CARD_EVENT, DevDeskView, type DevCardEvent } from './components/DevDesk';import { DEV_TICKET_EVENT, DEV_TICKET_PROGRESS_EVENT } from './components/dev/TicketsTab';import { PrepushNeedsYou, PrepushThread, threadCards, usePrepushCards, type PrepushEventDetail } from './components/dev/PrepushThread';-import { PREPUSH_EVENT, needsYou as prepushNeedsYou, overrideMessage, prepushApi, retryMessage, type PrepushCard as PrepushCardData } from './dev/prepush';+import { PREPUSH_EVENT, messageNotSent as prepushMessageNotSent, needsYou as prepushNeedsYou, overrideMessage, prepushApi, retryMessage, type PrepushCard as PrepushCardData } from './dev/prepush';import { StepReview } from './components/ShowOnce';import { inDesktopApp, leaveForSignIn, mcpSignIn, pollUntil, signInChanged } from './externalLinks';@@ -2028,14 +2028,25 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({setPage('chat');window.setTimeout(() => document.getElementById(`prepush-${c.id}`)?.scrollIntoView?.({ block: 'center' }), 250);};- const prepushRetry = async (c: PrepushCardData) => {- prepush.put(await prepushApi.retry(c.id));- await handleSendMessage(retryMessage(c));- };- const prepushOverride = async (c: PrepushCardData, reason: string) => {- prepush.put(await prepushApi.override(c.id, reason));- await handleSendMessage(overrideMessage(c));+ // The card call first; a 409 means the card moved on, so fetch it again (Rigel QA 1). Then the+ // chat message: if only that fails, say the change applied (Ada Later 7).+ const prepushAct = async (c: PrepushCardData, act: () => Promise<PrepushCardData>, message: string) => {+ try {+ prepush.put(await act());+ } catch (e) {+ if (e instanceof DevModeError && e.status === 409) void prepush.refresh(c.id);+ throw e;+ }+ let sent: boolean | string = false;+ try {+ sent = await handleSendMessage(message);+ } catch {+ sent = false;+ }+ if (sent !== true) throw new DevModeError(prepushMessageNotSent(kwantNames[c.kwant_id] || 'the bot'), 0, 'message_not_sent');};+ const prepushRetry = (c: PrepushCardData) => prepushAct(c, () => prepushApi.retry(c.id), retryMessage(c));+ const prepushOverride = (c: PrepushCardData, reason: string) => prepushAct(c, () => prepushApi.override(c.id, reason), overrideMessage(c));const openDirectChat = () => {if (!openThreadId) return;diff --git a/frontend/src/components/dev/FreshEyesChip.tsx b/frontend/src/components/dev/FreshEyesChip.tsxindex ab9384f4..2736aef7 100644--- a/frontend/src/components/dev/FreshEyesChip.tsx+++ b/frontend/src/components/dev/FreshEyesChip.tsx@@ -5,7 +5,7 @@// The popover is a flex item of the chip row: it wraps onto its own line, in flow, on phone, and// floats under the row from 640 px up. Give the row `relative` so it has something to float under.-import React, { useEffect, useId, useRef, useState } from 'react';+import React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';import { Check, Eye, X } from 'lucide-react';import { chipState, popoverTitle, sawLines, type FreshEyes } from '../../dev/freshEyes';@@ -20,11 +20,23 @@ export interface FreshEyesChipProps {export const FreshEyesChip: React.FC<FreshEyesChipProps> = ({ label, reviewer, author, diff = null, specRef = null }) => {const [open, setOpen] = useState(false);+ // From 640 px the popover floats under the row: put it under this chip, not the row's start, and+ // keep it inside the row (Mira ui-check-458 Later 1). On phone it's in flow, so `left` does nothing.+ const [left, setLeft] = useState(0);const btn = useRef<HTMLButtonElement>(null);const pop = useRef<HTMLDivElement>(null);const id = useId();const state = chipState(label);+ useLayoutEffect(() => {+ if (!open) return;+ const b = btn.current;+ const row = b?.offsetParent as HTMLElement | null;+ if (!b || !row) return;+ const max = Math.max(0, row.clientWidth - 300);+ setLeft(Math.min(Math.max(0, b.offsetLeft), max));+ }, [open]);+useEffect(() => {if (!open) return;const onDown = (e: MouseEvent | TouchEvent) => {@@ -88,7 +100,8 @@ export const FreshEyesChip: React.FC<FreshEyesChipProps> = ({ label, reviewer, atabIndex={-1}onBlur={onBlur}data-fresh-eyes-pop- className="fe-pop kw-card w-full basis-full p-3 text-xs leading-[18px] text-zinc-300 sm:absolute sm:left-0 sm:top-full sm:z-20 sm:mt-2 sm:w-auto sm:max-w-[300px] sm:basis-auto sm:bg-[#231d4b] sm:shadow-lg"+ style={{ left }}+ className="fe-pop kw-card w-full basis-full p-3 text-xs leading-[18px] text-zinc-300 sm:absolute sm:top-full sm:z-20 sm:mt-2 sm:w-auto sm:max-w-[300px] sm:basis-auto sm:bg-[#231d4b] sm:shadow-lg"><p className="text-zinc-200 [overflow-wrap:anywhere]">{popoverTitle(reviewer)}</p><ul role="list" className="mt-2 space-y-1">diff --git a/frontend/src/components/dev/PrepushCard.tsx b/frontend/src/components/dev/PrepushCard.tsxindex 7942e480..da0a53c8 100644--- a/frontend/src/components/dev/PrepushCard.tsx+++ b/frontend/src/components/dev/PrepushCard.tsx@@ -6,20 +6,23 @@import React, { useEffect, useId, useRef, useState } from 'react';import { ArrowUpFromLine, ChevronDown, ChevronRight, GitBranch } from 'lucide-react';import { DiffStat, Led } from './parts';+import { DevModeError } from '../../devMode';import {CHECK_NAME,STATE_LED,STATE_WORD,canOverride,- clearedLine,+ clearedParts,foldLine,foldable,footer,needsYouLead,+ openCount,overriddenLine,passedRows,phaseOf,reasonOk,+ rowBlocks,rowFindings,statusChip,toolLine,@@ -71,7 +74,10 @@ const Row: React.FC<{ k: PrepushCheck; card: Card; hidePhone: boolean }> = ({ k,const id = useId();const found = k.state === 'hit' ? rowFindings(card, k.key) : [];const dim = k.state === 'not_installed';- const tone = k.state === 'hit' ? 'text-rose-300' : dim ? 'text-zinc-500' : 'text-zinc-300';+ // A hit the server doesn't count as a blocker (risk, a low tamper or review finding): the LED stays+ // "found a problem", the words say it doesn't hold the push (Mira Later 4, contract §4.3).+ const soft = k.state === 'hit' && card.status !== 'checking' && !rowBlocks(card, k.key);+ const tone = k.state === 'hit' ? (soft ? 'text-zinc-300' : 'text-rose-300') : dim ? 'text-zinc-500' : 'text-zinc-300';const ledClass = k.state === 'running' ? 'dv-led-still mt-[5px]' : k.state === 'not_installed' ? 'dv-led-dashed mt-[5px]' : 'mt-[5px]';return (<li data-check={k.key} data-state={k.state} className={`border-t border-hairline py-2 first:border-t-0 ${hidePhone ? 'max-sm:hidden' : ''}`}>@@ -83,7 +89,10 @@ const Row: React.FC<{ k: PrepushCheck; card: Card; hidePhone: boolean }> = ({ k,<p className={`text-[13px] leading-[18px] ${dim ? 'text-zinc-500' : 'text-zinc-100'}`}>{CHECK_NAME[k.key]}</p><p className="text-[11px] leading-[15px] text-zinc-500 [overflow-wrap:anywhere]">{toolLine(k.key, card)}</p></div>- <p className={`min-w-0 flex-1 text-meta [overflow-wrap:anywhere] ${tone}`}>{k.text}</p>+ <p className={`min-w-0 flex-1 text-meta [overflow-wrap:anywhere] ${tone}`}>+ {k.text}+ {soft && <span data-soft className="text-zinc-400"> · doesn't block</span>}+ </p></div>{found.length > 0 && (<button type="button" className={LINK} aria-expanded={show} aria-controls={id} onClick={() => setShow((s) => !s)}>@@ -104,7 +113,14 @@ const Row: React.FC<{ k: PrepushCheck; card: Card; hidePhone: boolean }> = ({ k,};/** A one-line card (P0, retried, cleared and folded). */-const Line: React.FC<{ children: React.ReactNode; led?: 'ok' | 'off'; status?: boolean; extra?: React.ReactNode; phase: string }> = ({ children, led = 'off', status, extra, phase }) => (+const Line: React.FC<{ children: React.ReactNode; led?: 'ok' | 'off'; status?: boolean; extra?: React.ReactNode; phase: string; error?: string }> = ({+ children,+ led = 'off',+ status,+ extra,+ phase,+ error,+}) => (<divdata-prepush-phase={phase}role={status ? 'status' : undefined}@@ -113,6 +129,12 @@ const Line: React.FC<{ children: React.ReactNode; led?: 'ok' | 'off'; status?: b<Led s={led} className="shrink-0" /><span className="min-w-0 flex-1 [overflow-wrap:anywhere]">{children}</span>{extra}+ {error && (+ // A retry that applied but whose chat message failed lands here, on the retried line (#475 review 2).+ <p role="alert" className="w-full text-meta text-bad [overflow-wrap:anywhere]">+ {error}+ </p>+ )}</div>);@@ -121,11 +143,27 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, onconst [form, setForm] = useState(startOverride && canOverride(card));const [reason, setReason] = useState('');const [busy, setBusy] = useState<null | 'retry' | 'override'>(null);- const [error, setError] = useState<string | null>(null);+ // `keep`: how many status changes the error survives. Only a 409 keeps one, for the refetch it+ // starts; the change after that clears it like any other error (#475 review 1).+ const [error, setErrorState] = useState<{ text: string; keep: number } | null>(null);+ const setError = (text: string | null, keep = 0) => setErrorState(text ? { text, keep } : null);+ const statusNow = useRef(card.status);+ statusNow.current = card.status;const [collapsed, setCollapsed] = useState(phase === 'P2' && !live);const [unfold, setUnfold] = useState(startUnfolded);const cardRef = useRef<HTMLElement>(null);const area = useRef<HTMLTextAreaElement>(null);+ // "Push anyway…" that opened the form gets focus back on Cancel or Esc (Ada Later 3).+ const opener = useRef<HTMLButtonElement>(null);+ const refocus = useRef(false);+ // role=alert only on the move into P4 while watched, not on mount or after Cancel (Mira Later 5).+ const [seenPhase, setSeenPhase] = useState(phase);+ const [announceP4, setAnnounceP4] = useState(false);+ if (seenPhase !== phase) {+ // Set during render so the move into P4 renders with role=alert from its first frame.+ setSeenPhase(phase);+ setAnnounceP4(phase === 'P4');+ }const hintId = useId();const titleId = useId();@@ -144,26 +182,49 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on// The server moved the card on: drop a form that no longer applies.useEffect(() => {if (!canOverride(card)) setForm(false);- setError(null);+ setErrorState((e) => (e && e.keep > 0 ? { ...e, keep: e.keep - 1 } : null));}, [card.status, card.id]);useEffect(() => {- if (!form) return;- area.current?.focus({ preventScroll: true });- cardRef.current?.scrollIntoView?.({ block: 'nearest' });+ if (form) {+ setAnnounceP4(false);+ area.current?.focus({ preventScroll: true });+ cardRef.current?.scrollIntoView?.({ block: 'nearest' });+ return;+ }+ if (refocus.current) {+ refocus.current = false;+ opener.current?.focus({ preventScroll: true });+ }}, [form]);+ const openForm = () => {+ setError(null);+ setForm(true);+ };+ const cancelForm = () => {+ refocus.current = true;+ setForm(false);+ };+if (phase === 'P0') {return (<Line phase="P0" status>- Nothing to check: <code className="dv-sha">{card.branch}</code> has no new commits. Nothing was pushed.+ Nothing to check: <code className="dv-sha dv-sha-wrap">{card.branch}</code> has no new commits. Nothing was pushed.+ </Line>+ );+ }+ if (phase === 'UN') {+ return (+ <Line phase="UN">+ Pre-push check of <code className="dv-sha dv-sha-wrap">{card.branch}</code>. This version of the app can't show where it is yet. Update the app to see it.</Line>);}if (phase === 'RT') {return (- <Line phase="RT">- You asked for a new check of <code className="dv-sha">{card.branch}</code>. {bot}'s next push of this commit is checked again from try 1.+ <Line phase="RT" error={error?.text}>+ You asked for a new check of <code className="dv-sha dv-sha-wrap">{card.branch}</code>. {bot}'s next push of this commit is checked again from try 1.</Line>);}@@ -178,7 +239,16 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on</button>}>- {clearedLine(card)}+ {(() => {+ const p = clearedParts(card);+ return (+ <>+ {p.before}+ <code className="dv-sha dv-sha-wrap">{p.branch}</code>+ {p.after}+ </>+ );+ })()}</Line>);}@@ -189,6 +259,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, onif (busy) return;setBusy(kind);setError(null);+ const from = card.status;try {if (kind === 'retry') await onRetry?.(card);else {@@ -197,7 +268,10 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, onsetReason('');}} catch (e) {- setError(e instanceof Error && e.message ? e.message : 'Something went wrong. Try again.');+ // message_not_sent: the card already moved before the chat send, so the next change may clear it.+ // 409: keep it through the refetch, unless the card already moved on its own while we waited.+ const keep = e instanceof DevModeError && e.status === 409 && statusNow.current === from ? 1 : 0;+ setError(e instanceof Error && e.message ? e.message : 'Something went wrong. Try again.', keep);} finally {setBusy(null);}@@ -222,9 +296,9 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, onBefore {bot} pushes</h3><p className="mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-meta text-zinc-400">- <code className="dv-branch max-w-full">+ <code className="dv-branch dv-branch-wrap max-w-full"><GitBranch size={11} className="i" aria-hidden="true" />- <span className="h [overflow-wrap:anywhere]">{card.branch}</span>+ <span className="h">{card.branch}</span></code>{card.diffstat && (<span className="inline-flex items-center gap-1.5 whitespace-nowrap">@@ -239,7 +313,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on</div>{chip && (<span data-prepush-chip aria-live="polite" className={`${CHIP[chip.tone]} shrink-0 max-[420px]:order-last max-[420px]:ml-10`}>- {chip.led && <Led s={chip.led} className="dv-led-still" />}+ {chip.led && <Led s={chip.led} className="dv-led-still mx-0.5" />}{chip.text}</span>)}@@ -285,11 +359,11 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on<p className="flex min-w-0 flex-1 items-start gap-2 text-meta text-zinc-300"><Led s="run" className="dv-led-still mt-[5px] shrink-0" /><span className="min-w-0">- <strong className="font-semibold text-zinc-100">{bot} is fixing them.</strong> {footer(card, bot)}+ <strong className="font-semibold text-zinc-100">{bot} is fixing {openCount(card) === 1 ? 'it' : 'them'}.</strong> {footer(card, bot)}</span></p>{onOverride && (- <button type="button" className={PLAIN} onClick={() => setForm(true)}>+ <button type="button" className={PLAIN} ref={opener} onClick={openForm}>Push anyway…</button>)}@@ -306,7 +380,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on</button>)}{onOverride && (- <button type="button" className={PLAIN} onClick={() => setForm(true)}>+ <button type="button" className={PLAIN} ref={opener} onClick={openForm}>Push anyway…</button>)}@@ -315,7 +389,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on)}{!form && phase === 'P4' && (- <div data-needs-you role="alert" className="mt-3 rounded-xl border border-amber-400/40 bg-amber-400/[.06] p-3">+ <div data-needs-you role={announceP4 ? 'alert' : undefined} className="mt-3 rounded-xl border border-amber-400/40 bg-amber-400/[.06] p-3"><p className="text-meta text-zinc-200"><strong className="font-semibold text-amber-200">{needsYouLead(card, bot)}</strong> {footer(card, bot)}</p>@@ -327,7 +401,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on</button>)}{onOverride && (- <button type="button" className={AMBER_OUTLINE} disabled={busy !== null} onClick={() => setForm(true)}>+ <button type="button" className={AMBER_OUTLINE} disabled={busy !== null} ref={opener} onClick={openForm}>Push anyway…</button>)}@@ -363,7 +437,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, ononKeyDown={(e) => {if (e.key === 'Escape') {e.stopPropagation();- setForm(false);+ cancelForm();}}}className="mt-1 block w-full resize-y rounded-lg border border-hairline-strong bg-zinc-950/60 px-2.5 py-2 text-base text-zinc-100 placeholder:text-zinc-500 outline-none focus-visible:ring-2 focus-visible:ring-sky-400 sm:text-sm"@@ -375,7 +449,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on<button type="submit" className={AMBER} disabled={!ok || busy !== null}>{busy === 'override' ? 'Letting it go…' : 'Push anyway'}</button>- <button type="button" className={PLAIN} disabled={busy !== null} onClick={() => setForm(false)}>+ <button type="button" className={PLAIN} disabled={busy !== null} onClick={cancelForm}>Cancel</button></div>@@ -396,7 +470,7 @@ export const PrepushCard: React.FC<PrepushCardProps> = ({ card, bot, onRetry, on{error && (<p role="alert" className="mt-2 text-meta text-bad [overflow-wrap:anywhere]">- {error}+ {error.text}</p>)}</article>diff --git a/frontend/src/components/dev/PrepushThread.tsx b/frontend/src/components/dev/PrepushThread.tsxindex c6aa992c..4aed0529 100644--- a/frontend/src/components/dev/PrepushThread.tsx+++ b/frontend/src/components/dev/PrepushThread.tsx@@ -6,7 +6,7 @@import React, { useCallback, useEffect, useRef, useState } from 'react';import { ArrowUpFromLine } from 'lucide-react';import { PrepushCard } from './PrepushCard';-import { PREPUSH_EVENT, inboxLine, needsYou, prepushApi, upsert, type PrepushCard as Card } from '../../dev/prepush';+import { PREPUSH_EVENT, inboxLine, mergeList, needsYou, prepushApi, upsert, type PrepushCard as Card } from '../../dev/prepush';export interface PrepushEventDetail {space_id: string;@@ -20,6 +20,8 @@ export interface PrepushState {/** Ids that turned clear while this page was open (P2 shows, then folds). */live: ReadonlySet<string>;put: (c: Card) => void;+ /** Fetch one card again (after a 409, so the card shows where it really is). */+ refresh: (id: string) => Promise<void>;}type Api = Pick<typeof prepushApi, 'list' | 'get'>;@@ -28,6 +30,10 @@ export function usePrepushCards(spaceId: string, on: boolean, api: Api = prepushconst [cards, setCards] = useState<Card[]>([]);const [live, setLive] = useState<ReadonlySet<string>>(new Set());const seen = useRef(new Map<string, string>());+ // A list or card load that failed: load the list again on the next event or window focus, so a+ // card waiting for the person doesn't stay hidden until its own next event (Ada Later 1).+ const stale = useRef(false);+ const alive = useRef<() => boolean>(() => false);const put = useCallback((c: Card) => {const before = seen.current.get(c.id);@@ -36,33 +42,75 @@ export function usePrepushCards(spaceId: string, on: boolean, api: Api = prepushsetCards((list) => upsert(list, c));}, []);+ const refresh = useCallback(+ async (id: string) => {+ const ok = alive.current;+ try {+ const c = await api.get(id);+ if (ok()) put(c);+ } catch {+ stale.current = true;+ }+ },+ [api, put],+ );+useEffect(() => {setCards([]);setLive(new Set());seen.current = new Map();- if (!on || !spaceId) return;- let alive = true;- api.list(spaceId).then(- (list) => {- if (!alive) return;- for (const c of list) seen.current.set(c.id, c.status);- setCards(list);- },- () => undefined,- );+ stale.current = false;+ if (!on || !spaceId) {+ alive.current = () => false;+ return;+ }+ let on_ = true;+ const isAlive = () => on_;+ alive.current = isAlive;+ let loading = false;+ const load = () => {+ if (loading) return;+ loading = true;+ stale.current = false;+ api.list(spaceId).then(+ (list) => {+ loading = false;+ if (!on_) return;+ for (const c of list) if (!seen.current.has(c.id)) seen.current.set(c.id, c.status);+ setCards((cur) => mergeList(cur, list));+ },+ () => {+ loading = false;+ stale.current = true;+ },+ );+ };+ load();const onEvent = (e: Event) => {const d = (e as CustomEvent<PrepushEventDetail>).detail;if (!d || d.space_id !== spaceId || typeof d.id !== 'string') return;- api.get(d.id).then((c) => alive && put(c), () => undefined);+ if (stale.current) load();+ api.get(d.id).then(+ (c) => on_ && put(c),+ () => {+ stale.current = true;+ },+ );+ };+ const onFocus = () => {+ if (stale.current) load();};window.addEventListener(PREPUSH_EVENT, onEvent);+ window.addEventListener('focus', onFocus);return () => {- alive = false;+ on_ = false;+ if (alive.current === isAlive) alive.current = () => false;window.removeEventListener(PREPUSH_EVENT, onEvent);+ window.removeEventListener('focus', onFocus);};}, [spaceId, on, api, put]);- return { cards, live, put };+ return { cards, live, put, refresh };}/** How many of a bot's cards the thread shows: the newest few, oldest first like the chat. */diff --git a/frontend/src/components/dev/ReviewCard.tsx b/frontend/src/components/dev/ReviewCard.tsxindex 5b51f03b..b9a33612 100644--- a/frontend/src/components/dev/ReviewCard.tsx+++ b/frontend/src/components/dev/ReviewCard.tsx@@ -686,7 +686,7 @@ export const ReviewCard: React.FC<ReviewCardProps> = ({ card: given, onFinding,<ul role="list" className="grid grid-cols-1 gap-2 min-[420px]:grid-cols-2 lg:grid-cols-4"><SecTile name="Secrets" tool="Gitleaks" mono="gitleaks" state={sec.secrets.state} text={scanText(sec.secrets, 'secret', 'secrets', 'None found')} /><SecTile name="New packages" tool="Registry check" mono="registry" state={sec.packages.state} text={scanText(sec.packages, 'package', 'packages', 'All real')} />- <SecTile name="Dependencies" tool="OSV" mono="osv" state="later" text="in 0.7.x" />+ <SecTile name="Dependencies" tool="OSV" mono="osv" state="later" text="Not checked in this version" /><SecTile name="Code patterns" tool="Semgrep" mono="semgrep" {...semgrepTile(sec.semgrep)} /></ul></section>diff --git a/frontend/src/dev/prepush.ts b/frontend/src/dev/prepush.tsindex 103e5a07..ac6f48e5 100644--- a/frontend/src/dev/prepush.ts+++ b/frontend/src/dev/prepush.ts@@ -20,7 +20,9 @@ export const MAX_REASON = 2000;export const NEEDS_YOU_TRIES = 2;export const PREPUSH_STATUSES = ['checking', 'clear', 'blocked', 'failed', 'overridden', 'retried'] as const;-export type PrepushStatus = (typeof PREPUSH_STATUSES)[number];+/** `unknown`: a status this build can't read yet (e.g. §4.4b `pushed`). Shown as a read-only grey line,+ * never dropped, so a card doesn't vanish from the thread when the server learns a new state. */+export type PrepushStatus = (typeof PREPUSH_STATUSES)[number] | 'unknown';export const CHECK_KEYS = ['secrets', 'pkgs', 'tests', 'risk', 'review', 'semgrep'] as const;export type CheckKey = (typeof CHECK_KEYS)[number];export const CHECK_STATES = ['running', 'pass', 'hit', 'error', 'not_installed'] as const;@@ -110,7 +112,9 @@ export function parsePrepush(raw: unknown): PrepushCard | null {const id = str(raw.id, 120);const kwant = str(raw.kwant_id, 120);const branch = str(raw.branch, 200);- const status = PREPUSH_STATUSES.find((s) => s === raw.status);+ const known = PREPUSH_STATUSES.find((s) => s === raw.status);+ // A status string we don't know yet still names a real card: keep it, read-only (Ada Later 2).+ const status: PrepushStatus | null = known ?? (str(raw.status, 40) ? 'unknown' : null);if (!id || !kwant || !branch || !status) return null;const rawChecks = arr(raw.checks);const checks = rawChecks.map(check).filter((c): c is PrepushCheck => !!c);@@ -159,7 +163,8 @@ export type Phase =| 'P4' // needs you| 'P6' // pushed anyway (overridden)| 'P7' // a check couldn't run (failed, before needs_you)- | 'RT'; // the person asked for a re-check (retried)+ | 'RT' // the person asked for a re-check (retried)+ | 'UN'; // a status this build can't read yet: a read-only lineexport function phaseOf(c: PrepushCard): Phase {switch (c.status) {@@ -175,6 +180,8 @@ export function phaseOf(c: PrepushCard): Phase {return 'P6';case 'retried':return 'RT';+ case 'unknown':+ return 'UN';}}@@ -217,6 +224,8 @@ export function statusChip(c: PrepushCard): StatusChip | null {return { tone: 'plain', text: "Couldn't check", led: null };case 'RT':return { tone: 'plain', text: 'Checking again', led: null };+ case 'UN':+ return null;}}@@ -286,6 +295,17 @@ const ROW_SOURCES: Record<CheckKey, FindingSource[]> = {semgrep: ['semgrep'],};+/**+ * Whether a row that found something holds the push. The server's `blockers` list decides (contract+ * §4.3 "blocks?"): risk never blocks on its own, semgrep never blocks, and a tamper or review hit+ * blocks only when a high or critical finding behind it is in `blockers`.+ */+export function rowBlocks(c: PrepushCard, key: CheckKey): boolean {+ const src = ROW_SOURCES[key];+ if (src.length === 0 || key === 'semgrep') return false;+ return c.blockers.some((b) => src.includes(b.source));+}+/** What "Show" opens on a row that found something: the open findings behind it, from the card. */export function rowFindings(c: PrepushCard, key: CheckKey): PrepushFinding[] {const src = ROW_SOURCES[key];@@ -341,6 +361,8 @@ export function footer(c: PrepushCard, bot: string): string {return "A check couldn't run, so this push can't count as checked. Run the checks again, or push anyway with a reason.";case 'RT':return `You asked for a new check. ${bot}'s next push of this commit is checked again from try 1.`;+ case 'UN':+ return `This version of the app can't show where the check of ${c.branch} is yet. Update the app to see it.`;}}@@ -351,9 +373,15 @@ export function needsYouLead(c: PrepushCard, bot: string): string {return `${bot} couldn't clear ${plural(Math.max(n, 1), 'finding')} after ${plural(c.tries, 'try', 'tries')}.`;}-export function clearedLine(c: PrepushCard): string {+/** P2b's line around the branch, which the card renders as code (Mira Later 6). */+export function clearedParts(c: PrepushCard): { before: string; branch: string; after: string } {const at = hhmm(c.updated_at);- return `Cleared to push ${c.branch} after ${plural(requiredPassed(c), 'check')} passed${at ? ` · ${at}` : ''}`;+ return { before: 'Cleared to push ', branch: c.branch, after: ` after ${plural(requiredPassed(c), 'check')} passed${at ? ` · ${at}` : ''}` };+}++export function clearedLine(c: PrepushCard): string {+ const p = clearedParts(c);+ return `${p.before}${p.branch}${p.after}`;}export function overriddenLine(c: PrepushCard): string {@@ -375,7 +403,12 @@ export const retryMessage = (c: PrepushCard): string =>export const overrideMessage = (c: PrepushCard): string =>`I let your push of ${c.branch} go anyway, for this commit only. Run the same push again.`;-export const reasonOk = (s: string): boolean => s.trim().length >= MIN_REASON && s.trim().length <= MAX_REASON;+/** Characters as the server counts them (code points, not UTF-16 units: Ada Later 6). */+export const reasonLength = (s: string): number => [...s.trim()].length;+export const reasonOk = (s: string): boolean => reasonLength(s) >= MIN_REASON && reasonLength(s) <= MAX_REASON;++/** The card changed but the chat message to the bot didn't go (Ada Later 7). */+export const messageNotSent = (bot: string): string => `Done, but the message to ${bot} didn't send. Tell ${bot} in the chat.`;// ---------------------------------------------------------------------------------------------// Needs you (Inbox)@@ -385,6 +418,22 @@ export function needsYou(cards: PrepushCard[]): PrepushCard[] {return cards.filter((c) => c.needs_you).sort((a, b) => (b.updated_at ?? 0) - (a.updated_at ?? 0));}+/**+ * Merge a list response into what the page already holds (Ada Later 5): a card an event refreshed+ * after the list was read keeps its newer copy, by the server's `updated_at`.+ */+export function mergeList(current: PrepushCard[], list: PrepushCard[]): PrepushCard[] {+ const have = new Map(current.map((c) => [c.id, c]));+ const merged = list.map((c) => {+ const h = have.get(c.id);+ return h && (h.updated_at ?? 0) > (c.updated_at ?? 0) ? h : c;+ });+ const ids = new Set(merged.map((c) => c.id));+ // A card an event brought in that the (older) list didn't have yet stays too.+ for (const c of current) if (!ids.has(c.id)) merged.push(c);+ return merged.sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0));+}+/** Merge a fetched card into a list (newest first), replacing the same id. */export function upsert(list: PrepushCard[], c: PrepushCard): PrepushCard[] {const rest = list.filter((x) => x.id !== c.id);diff --git a/frontend/src/styles/modern.css b/frontend/src/styles/modern.cssindex 1c11844b..248bd070 100644--- a/frontend/src/styles/modern.css+++ b/frontend/src/styles/modern.css@@ -872,6 +872,8 @@ a.kw-sticker:hover { transform: rotate(var(--kw-tilt)) scale(1.04); box-shadow:/* The fresh-eyes chip keeps its size; its hit area grows on touch (b3 §3). */.fe-chip { position: relative; }.fe-chip::after { content: ''; position: absolute; inset: -6px; }+/* 24 px chip + 2 x 10 px = 44 px tall on phone (Mira ui-check-458 Later 3). */+@media (max-width: 639px) { .fe-chip::after { inset: -10px -6px; } }.fe-pop { animation: fe-in 150ms var(--kw-ease) both; }@keyframes fe-in { from { opacity: 0; } to { opacity: 1; } }@media (prefers-reduced-motion: reduce) { .fe-pop { animation: none; } }@@ -887,9 +889,16 @@ a.kw-sticker:hover { transform: rotate(var(--kw-tilt)) scale(1.04); box-shadow:.dv-sha { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--kw-hairline); background: var(--dv-code-bg);font: 500 11px/1 'JetBrains Mono', monospace; color: var(--t3); white-space: nowrap; }button.dv-sha { cursor: copy; } button.dv-sha:hover { color: var(--accent); border-color: var(--kw-hairline-strong); }+/* A branch inside a sentence wraps with the text (pre-push one-line cards, Mira ui-check-475 must-fix 1). */+.dv-sha.dv-sha-wrap { display: inline; height: auto; white-space: normal; overflow-wrap: anywhere;+ padding: 1px 5px; line-height: 20px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }.dv-branch { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 22px; padding: 0 7px; border-radius: 6px; border: 1px solid var(--kw-hairline); background: var(--dv-code-bg);font: 500 11px/1 'JetBrains Mono', monospace; color: var(--t3); min-width: 0; }.dv-branch .h { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t2); }+/* A long branch wraps instead of being cut off (pre-push card at 390 px, Ada review-458 Later 9). */+.dv-branch.dv-branch-wrap { height: auto; min-height: 22px; padding-top: 4px; padding-bottom: 4px; align-items: flex-start; line-height: 14px; }+.dv-branch.dv-branch-wrap svg.i { flex-shrink: 0; margin-top: 1.5px; }+.dv-branch.dv-branch-wrap .h { white-space: normal; overflow-wrap: anywhere; overflow: visible; min-width: 0; }.dv-branch .arr { color: var(--t5); }.dv-branch svg.i { width: 11px; height: 11px; color: var(--accent); }.dv-code { font: 500 0.92em/1 'JetBrains Mono', monospace; color: var(--accent); }diff --git a/frontend/tests/devCards.test.mjs b/frontend/tests/devCards.test.mjsindex 64f37ce5..daa7fa85 100644--- a/frontend/tests/devCards.test.mjs+++ b/frontend/tests/devCards.test.mjs@@ -547,14 +547,15 @@ test('Fix it sends the finding and offers Undo for 10 s', async () => {assert.deepEqual(actions, [['f1', 'fix'], ['f1', 'undo_fix']]);});-test('the review card: sample chip, tamper, security tiles in 0.7.x, no Post button on the sample', () => {+test('the review card: sample chip, tamper, security tiles not in this version, no Post button on the sample', () => {const out = html(m.ReviewCard, { card: review(fx.REVIEW_294), onFinding: async () => review(fx.REVIEW_294), sample: true, forge: 'github', now: NOW });assert.match(out, /Sample PR/);assert.match(out, /A test was made easier to pass/);assert.match(out, /Different engine from the author/);assert.match(out, /data-sec="OSV" data-state="later"/);assert.match(out, /data-sec="Semgrep" data-state="later"/);- assert.equal((out.match(/in 0\.7\.x/g) ?? []).length >= 1, true);+ assert.doesNotMatch(out, /in 0\.7\.x/, 'Rigel qa-458 2: no "in 0.7.x" on a 0.8.0 build');+ assert.match(out, /Not checked in this version/);assert.match(out, /Runs before a push, not on pull requests/, '0.8.0 B3: semgrep runs before a push, not on PR reviews');assert.doesNotMatch(out, /Post to GitHub/, 'S2: no button that can never be pressed');assert.match(out, /Nothing is posted until you press it\./);diff --git a/frontend/tests/prepush.test.mjs b/frontend/tests/prepush.test.mjsindex 0ea8ecad..3d5afe5e 100644--- a/frontend/tests/prepush.test.mjs+++ b/frontend/tests/prepush.test.mjs@@ -26,6 +26,7 @@ const m = await loadBundled(`export { PrepushCard } from './src/components/dev/PrepushCard';export { PrepushNeedsYou, PrepushThread, threadCards, usePrepushCards } from './src/components/dev/PrepushThread';export { FreshEyesChip } from './src/components/dev/FreshEyesChip';+ export { DevModeError } from './src/devMode';export { ReviewCard, semgrepTile } from './src/components/dev/ReviewCard';export { renderToStaticMarkup } from 'react-dom/server.browser';export { createRoot } from 'react-dom/client';@@ -88,7 +89,8 @@ test('every fixture parses and maps to Mira\'s phase', () => {test('the parser refuses cards it cannot show honestly', () => {assert.equal(m.parsePrepush(null), null);- assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, status: 'pushed' }), null, 'no pushed status on the server');+ assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, status: 'pushed' }).status, 'unknown', 'a newer status is kept, read-only (Ada Later 2)');+ assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, status: 7 }), null, 'a status that is not a word is refused');assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, branch: '' }), null);assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, checks: [...fx.PP_CLEAR.checks, { key: 'osv', state: 'pass', text: 'x' }] }), null, 'an unknown row is never dropped silently');assert.equal(m.parsePrepush({ ...fx.PP_CLEAR, checks: [{ key: 'secrets', state: 'queued', text: 'Waiting' }] }), null, 'no queued state in the contract');@@ -187,7 +189,7 @@ test('P2 clear: a card seen live shows Clear, then folds to P2b after about 2 s;test('P3 blocked: rose chip, the bot is fixing, a plain Push anyway, no amber', () => {const out = html(m.PrepushCard, { card: card(fx.PP_BLOCKED), bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });assert.match(out, /kw-chip kw-chip-bad[^"]*"[^>]*>1 to fix/);- assert.match(out, /Pixel is fixing them\./);+ assert.match(out, /Pixel is fixing it\./, 'one blocker reads it (#475 Mira Later 1)');assert.match(out, /Try 1 of 2\./);assert.match(out, />Push anyway…</);assert.doesNotMatch(out, /amber/);@@ -199,7 +201,7 @@ test('P4 needs you: amber box with role=alert, retry first, amber-outline Push aconst calls = [];const { host } = await mount(m.PrepushCard, { card: card(fx.PP_NEEDS_YOU), bot: 'Pixel', onRetry: async (c) => calls.push(['retry', c.id]), onOverride: async () => {} });const box = host.querySelector('[data-needs-you]');- assert.equal(box.getAttribute('role'), 'alert');+ assert.equal(box.getAttribute('role'), null, 'a card that mounts in P4 does not re-announce (Mira Later 5)');assert.match(text(box), /Pixel couldn't clear 1 finding after 2 tries\. The push is waiting for you\. It's also in your Inbox\./);const btns = [...box.querySelectorAll('button')].map(text);assert.deepEqual(btns, ['Ask Pixel to try again', 'Push anyway…']);@@ -524,3 +526,235 @@ test('semgrep tile: the real run, not installed is optional, and no more "in 0.7const r = m.parseReview({ ...m.dfx.REVIEW_294, security: { ...m.dfx.REVIEW_294.security, semgrep: { state: 'hit', count: 1 } } });assert.deepEqual(r.security.semgrep, { state: 'hit', count: 1, reason: null });});++// ---------------------------------------------------------------------------------------------+// #458 follow-ups (Ada review-458 Later 1–9, Mira ui-check-458 Later 1–6, Rigel qa-458 1–2)++test('Mira 5: role=alert only on the move into P4, not on mount or after Cancel', async () => {+ const { host, rerender } = await mount(m.PrepushCard, { card: card(fx.PP_BLOCKED), bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ await rerender({ card: card(fx.PP_NEEDS_YOU), bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ assert.equal(host.querySelector('[data-needs-you]').getAttribute('role'), 'alert');+ await click(button(host, 'Push anyway'));+ await click(button(host, 'Cancel'));+ assert.equal(host.querySelector('[data-needs-you]').getAttribute('role'), null);+});++test('Ada 3: Cancel and Esc put focus back on the Push anyway button that opened the form', async () => {+ const { host } = await mount(m.PrepushCard, { card: card(fx.PP_NEEDS_YOU), bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ await click(button(host, 'Push anyway'));+ await click(button(host, 'Cancel'));+ assert.equal(document.activeElement, button(host, 'Push anyway'));+ await click(button(host, 'Push anyway'));+ host.querySelector('textarea').dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));+ await settle();+ assert.equal(host.querySelector('[data-override-form]'), null);+ assert.equal(document.activeElement, button(host, 'Push anyway'));+});++test('Ada 6: the reason counts characters as the server does, not UTF-16 units', () => {+ assert.equal(m.reasonLength('🙂🙂🙂🙂🙂'), 5);+ assert.equal(m.reasonOk('🙂🙂🙂🙂🙂'), false, '5 emoji are 10 UTF-16 units but 5 characters');+ assert.equal(m.reasonOk(' revoked test key '), true);+});++test('Ada 2: an unknown status shows as a read-only grey line, never dropped or actionable', async () => {+ const c = card({ ...fx.PP_OVERRIDDEN, status: 'pushed' });+ assert.equal(m.phaseOf(c), 'UN');+ assert.equal(m.statusChip(c), null);+ assert.equal(m.canOverride(c), false);+ assert.equal(c.needs_you, false);+ assert.equal(m.parsePrepushList({ cards: [{ ...fx.PP_CLEAR, status: 'pushed' }] }).length, 1);+ const out = html(m.PrepushCard, { card: c, bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ assert.match(out, /data-prepush-phase="UN"/);+ assert.match(out, /can't show where it is yet/);+ assert.doesNotMatch(out, /<button/);+});++test('Mira 6: P2b renders the branch as code', () => {+ const out = html(m.PrepushCard, { card: card(fx.PP_CLEAR), bot: 'Pixel' });+ assert.match(out, /Cleared to push <code class="dv-sha dv-sha-wrap">/);+ assert.equal(m.clearedLine(card(fx.PP_CLEAR)).startsWith('Cleared to push '), true);+});++test('Mira 4: a hit the server does not count as a blocker says "doesn\'t block"; a blocker row does not', () => {+ const raw = {+ ...fx.PP_BLOCKED,+ checks: fx.PP_BLOCKED.checks.map((k) => (k.key === 'risk' ? { ...k, state: 'hit', text: 'Touches auth code' } : k)),+ };+ const c = card(raw);+ assert.equal(m.rowBlocks(c, 'risk'), false, 'risk never blocks on its own (contract §4.3)');+ assert.equal(m.rowBlocks(c, 'semgrep'), false);+ const out = html(m.PrepushCard, { card: c, bot: 'Pixel' });+ const risk = out.match(/<li data-check="risk"[\s\S]*?<\/li>/)[0];+ assert.match(risk, /doesn't block/);+ for (const b of c.blockers) {+ const key = { gitleaks: 'secrets', packages: 'pkgs', tamper: 'tests', review: 'review' }[b.source];+ if (!key) continue;+ assert.equal(m.rowBlocks(c, key), true, `${key} holds the push`);+ const row = out.match(new RegExp(`<li data-check="${key}"[\\s\\S]*?</li>`))[0];+ assert.doesNotMatch(row, /doesn't block/);+ }+});++test('Ada 5: a slow list never replaces a card an event already refreshed', () => {+ const old = card({ ...fx.PP_BLOCKED, updated_at: 1000 });+ const fresh = card({ ...fx.PP_BLOCKED, status: 'overridden', updated_at: 2000 });+ const other = card({ ...fx.PP_CLEAR, id: 'pp-other', updated_at: 5 });+ const merged = m.mergeList([fresh], [old, other]);+ assert.equal(merged.find((c) => c.id === fresh.id).status, 'overridden');+ assert.equal(merged.length, 2);+ assert.equal(m.mergeList([old], [fresh])[0].status, 'overridden', 'a newer list copy wins');+});++test('Ada 1: a failed list load is tried again on the next event and on window focus', async () => {+ let lists = 0;+ const api = {+ list: async () => {+ lists += 1;+ if (lists === 1) throw new Error('offline');+ return [card(fx.PP_NEEDS_YOU)];+ },+ get: async () => card(fx.PP_NEEDS_YOU),+ };+ let state;+ const Probe = () => {+ state = m.usePrepushCards('space-1', true, api);+ return null;+ };+ await mount(Probe, {});+ assert.equal(lists, 1);+ assert.equal(state.cards.length, 0);+ window.dispatchEvent(new window.Event('focus'));+ await settle();+ assert.equal(lists, 2, 'focus loads the list again after a failure');+ assert.equal(state.cards.length, 1);+ window.dispatchEvent(new window.Event('focus'));+ await settle();+ assert.equal(lists, 2, 'no reload once the list loaded');+});++test('Ada 7: when only the chat message failed, the card says the change applied', async () => {+ const { host } = await mount(m.PrepushCard, {+ card: card(fx.PP_NEEDS_YOU),+ bot: 'Pixel',+ onRetry: async () => {},+ onOverride: async () => {+ throw Object.assign(new Error(m.messageNotSent('Pixel')), { status: 0, code: 'message_not_sent' });+ },+ });+ await click(button(host, 'Push anyway'));+ await type(host.querySelector('textarea'), 'the key is a revoked test key');+ host.querySelector('form').dispatchEvent(new window.Event('submit', { bubbles: true, cancelable: true }));+ await settle();+ assert.match(text(host.querySelector('[role="alert"]')), /Done, but the message to Pixel didn't send\./);+ assert.equal(m.messageNotSent('Pixel'), "Done, but the message to Pixel didn't send. Tell Pixel in the chat.");+});++test('Mira 1: on desktop the popover sits under its own chip; Mira 2 and 3: chip LED gap, 44 px hit area', async () => {+ const out = html(m.FreshEyesChip, { label: card(fx.PP_CLEAR).fresh_eyes, reviewer: 'Iris', author: 'Pixel' });+ assert.match(out, /data-fresh-eyes="R1"/);+ const src = await import('node:fs').then((fs) => fs.readFileSync(new URL('../src/components/dev/FreshEyesChip.tsx', import.meta.url), 'utf8'));+ assert.doesNotMatch(src, /sm:left-0/);+ assert.match(src, /style=\{\{ left \}\}/);+ const css = await import('node:fs').then((fs) => fs.readFileSync(new URL('../src/styles/modern.css', import.meta.url), 'utf8'));+ assert.match(css, /@media \(max-width: 639px\) \{ \.fe-chip::after \{ inset: -10px -6px; \} \}/);+ assert.match(css, /\.dv-branch\.dv-branch-wrap \.h \{ white-space: normal;/, 'Ada 9: a long branch wraps instead of being cut off');+ const p1 = html(m.PrepushCard, { card: card(fx.PP_CHECKING), bot: 'Pixel' });+ assert.match(p1, /data-prepush-chip[^>]*>.*?class="[^"]*dv-led-still mx-0\.5/);+});++test('Rigel 1: refresh() fetches one card again, so a 409 leaves the card where it really is', async () => {+ let gets = 0;+ const api = { list: async () => [card(fx.PP_NEEDS_YOU)], get: async () => (gets++, card({ ...fx.PP_NEEDS_YOU, status: 'overridden', updated_at: 9e12 })) };+ let state;+ const Probe = () => {+ state = m.usePrepushCards('space-1', true, api);+ return null;+ };+ await mount(Probe, {});+ assert.equal(state.cards[0].status, 'blocked');+ await state.refresh(state.cards[0].id);+ await settle();+ assert.equal(gets, 1);+ assert.equal(state.cards[0].status, 'overridden');+});++test('#475 review 1: a 409 line survives the refetch and goes on the next change', async () => {+ const moved = 'This card moved on in the meantime. It shows where it is now.';+ const props = (c) => ({+ card: card(c),+ bot: 'Pixel',+ onRetry: async () => {+ throw new m.DevModeError(moved, 409, 'conflict');+ },+ onOverride: async () => {},+ });+ const { host, rerender } = await mount(m.PrepushCard, props(fx.PP_NEEDS_YOU));+ await click(button(host, 'Ask Pixel to try again'));+ assert.equal(text(host.querySelector('[role="alert"]')), moved);+ await rerender(props({ ...fx.PP_NEEDS_YOU, status: 'overridden', override: fx.PP_OVERRIDDEN.override }));+ assert.equal(text(host.querySelector('[role="alert"]')), moved, 'still there after the refetch');+ await rerender(props({ ...fx.PP_CHECKING, id: fx.PP_NEEDS_YOU.id }));+ assert.equal(host.querySelector('[role="alert"]'), null, 'gone on the next change (checking)');+ await rerender(props({ ...fx.PP_CLEAR, id: fx.PP_NEEDS_YOU.id }));+ assert.doesNotMatch(text(host), /moved on in the meantime/);+});++test('#475 review 1: a 409 after the card already moved, and message_not_sent, keep nothing', async () => {+ let r;+ const { host, rerender } = await mount(m.PrepushCard, {+ card: card(fx.PP_NEEDS_YOU),+ bot: 'Pixel',+ onRetry: async () => {+ await r(card({ ...fx.PP_NEEDS_YOU, status: 'overridden', override: fx.PP_OVERRIDDEN.override }));+ throw new m.DevModeError('This card moved on in the meantime. It shows where it is now.', 409, 'conflict');+ },+ onOverride: async () => {},+ });+ r = (c) => rerender({ card: c, bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ await click(button(host, 'Ask Pixel to try again'));+ await settle(); // onRetry's own rerender settles in parallel with click's; wait for the throw too+ assert.match(text(host.querySelector('[role="alert"]')), /moved on/);+ await r(card({ ...fx.PP_CHECKING, id: fx.PP_NEEDS_YOU.id }));+ assert.equal(host.querySelector('[role="alert"]'), null);+ const src = await import('node:fs').then((fs) => fs.readFileSync(new URL('../src/components/dev/PrepushCard.tsx', import.meta.url), 'utf8'));+ assert.doesNotMatch(src, /code === 'message_not_sent'/, 'message_not_sent is not kept');+});++test('#475 review 2: a retry that applied but whose message failed shows the alert on the retried line', async () => {+ let r;+ const { host, rerender } = await mount(m.PrepushCard, {+ card: card(fx.PP_NEEDS_YOU),+ bot: 'Pixel',+ onRetry: async () => {+ await r(card(fx.PP_RETRIED));+ throw new m.DevModeError(m.messageNotSent('Pixel'), 0, 'message_not_sent');+ },+ onOverride: async () => {},+ });+ r = (c) => rerender({ card: c, bot: 'Pixel', onRetry: async () => {}, onOverride: async () => {} });+ await click(button(host, 'Ask Pixel to try again'));+ await settle(); // onRetry's own rerender settles in parallel with click's; wait for the throw too+ assert.ok(host.querySelector('[data-prepush-phase="RT"]'), 'the card is the retried line');+ const alert = host.querySelector('[data-prepush-phase="RT"] [role="alert"]');+ assert.ok(alert, 'alert under the RT line');+ assert.equal(text(alert), "Done, but the message to Pixel didn't send. Tell Pixel in the chat.");+ assert.match(alert.className, /text-bad/);+ await r(card({ ...fx.PP_CHECKING, id: fx.PP_RETRIED.id }));+ assert.equal(host.querySelector('[role="alert"]'), null, 'cleared by the next change');+});++test('#475 Mira must-fix 1: the branch on one-line cards wraps; "fixing it" with one blocker', async () => {+ const long = 'pixel/inbox-empty-state-for-new-spaces-with-no-bots';+ for (const c of [fx.PP_NO_CHANGE, fx.PP_RETRIED, { ...fx.PP_CLEAR, status: 'pushed' }, fx.PP_CLEAR]) {+ const out = html(m.PrepushCard, { card: card({ ...c, branch: long }), bot: 'Pixel' });+ assert.match(out, new RegExp(`<code class="dv-sha dv-sha-wrap">${long}</code>`), c.id);+ }+ const css = await import('node:fs').then((fs) => fs.readFileSync(new URL('../src/styles/modern.css', import.meta.url), 'utf8'));+ assert.match(css, /\.dv-sha\.dv-sha-wrap \{ display: inline; height: auto; white-space: normal; overflow-wrap: anywhere;/);+ const one = card({ ...fx.PP_BLOCKED, blockers: fx.PP_BLOCKED.blockers.slice(0, 1) });+ assert.equal(m.openCount(one), 1);+ assert.match(html(m.PrepushCard, { card: one, bot: 'Pixel' }), /Pixel is fixing it\./);+ const many = card(fx.PP_MANY);+ if (m.openCount(many) > 1) assert.match(html(m.PrepushCard, { card: many, bot: 'Pixel' }), /Pixel is fixing them\./);+});