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.1 F3: pre-push pointer lines in team chats (#483)
Oleksandr Ivanchenko1e49dbd5ec78
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 2875d3c4..ba5e7dea 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -152,6 +152,8 @@ 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 { PrepushPointers } from './components/dev/PrepushPointers';+import { ModernAvatar } from './components/ModernAvatar';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';@@ -1887,7 +1889,12 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({playSfx('click');};+ // 0.8.1 F3: where phone Back returns after a team chat's pointer line opened a 1:1. Any other+ // chat open clears it (openPrepushFromTeam sets it after its own open), so it never goes stale.+ const prepushReturnRef = useRef<{ channel: string; kwant: string } | null>(null);+const handleSelectChannel = (channel: Channel) => {+ prepushReturnRef.current = null;setOpenThreadId(null);setPage('chat');setPhoneView('chat');@@ -1902,6 +1909,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({};const handleSelectKwant = (kwant: Kwant) => {+ prepushReturnRef.current = null;setOpenThreadId(null);setPage('chat');setPhoneView('chat');@@ -2048,7 +2056,29 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const openPrepush = (c: PrepushCardData) => {if (!openTarget({ channel_id: null, kwant_id: c.kwant_id })) return pushToast('That bot no longer exists.');setPage('chat');- window.setTimeout(() => document.getElementById(`prepush-${c.id}`)?.scrollIntoView?.({ block: 'center' }), 250);+ window.setTimeout(() => {+ const el = document.getElementById(`prepush-${c.id}`);+ el?.scrollIntoView?.({ block: 'center' });+ // 0.8.1 F3: a short ring so the eye finds the card it landed on (none under reduced motion, in CSS).+ if (el) {+ el.classList.remove('kw-prepush-flash');+ void el.offsetWidth;+ el.classList.add('kw-prepush-flash');+ window.setTimeout(() => el.classList.remove('kw-prepush-flash'), 1300);+ }+ }, 250);+ };+ // 0.8.1 F3: a team chat's pointer line opens the bot's 1:1; on a phone, back returns to that team chat.+ const openPrepushFromTeam = (c: PrepushCardData) => {+ const from = isChannelRef.current ? selectedIdRef.current : null;+ openPrepush(c);+ prepushReturnRef.current = from ? { channel: from, kwant: c.kwant_id } : null;+ };+ const phoneBackFromChat = () => {+ const r = prepushReturnRef.current;+ prepushReturnRef.current = null;+ if (r && !isChannelRef.current && selectedIdRef.current === r.kwant && !openThreadId && openTarget({ channel_id: r.channel, kwant_id: null })) return;+ setPhoneView('list');};// 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).@@ -2953,6 +2983,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const currentTeamMembers = currentTeam? kwants.filter((k) => currentTeamMemberIds.includes(k.id)): [];+ // 0.8.1 F3: whose pre-push lines a team chat or channel shows (membership, like approvalsForChat).+ const pointerMemberIds: string[] = currentTeam ? currentTeamMemberIds : openChat?.kind === 'channel' ? openChat.memberIds.filter((id): id is string => !!id) : [];const chatTitle = !isChannel? currentKwant?.name || 'Bot'@@ -3740,7 +3772,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({title={chatTitle}subtitle={chatSubtitle}spaceName={space.name}- onBack={isPhone ? () => setPhoneView('list') : undefined}+ onBack={isPhone ? phoneBackFromChat : undefined}messages={viewingHistory ? historyWindow.messages : messages}viewingHistory={viewingHistory}onJumpToLatest={() => setHistoryWindow(null)}@@ -3750,6 +3782,16 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({prepush={devOn && currentKwant && !viewingHistory ? (<PrepushThread cards={threadCards(prepush.cards, currentKwant.id)} bot={currentKwant.name} live={prepush.live} onRetry={prepushRetry} onOverride={prepushOverride} />+ ) : devOn && isChannel && !viewingHistory && pointerMemberIds.length > 0 ? (+ // 0.8.1 F3: team chats and channels get one pointer line per member bot; the card stays in the 1:1.+ <PrepushPointers+ cards={prepush.cards}+ memberIds={pointerMemberIds}+ names={kwantNames}+ onOpen={openPrepushFromTeam}+ onOpenInbox={() => showPage('inbox')}+ avatar={(id, name) => <ModernAvatar role={name} name={name} size={20} kwantId={id} />}+ />) : undefined}settledApprovals={approvalsForChat(settledApprovals, openChat)}diff --git a/frontend/src/components/dev/PrepushPointers.tsx b/frontend/src/components/dev/PrepushPointers.tsxnew file mode 100644index 00000000..197487b1--- /dev/null+++ b/frontend/src/components/dev/PrepushPointers.tsx@@ -0,0 +1,221 @@+// 0.8.1 F3 (Mira, designs/f3-prepush-in-team.md): in a team chat or channel, one line per member+// bot that points at its newest pre-push card. The card and its buttons stay in the bot's 1:1+// (prepushAct posts to whichever chat is open), so a line only opens that chat at the card.+// Cards have no channel_id yet, so lines match by membership, like approvalsForChat.++import React, { useEffect, useRef, useState } from 'react';+import { ChevronRight } from 'lucide-react';+import { Led } from './parts';+import { NEEDS_YOU_TRIES, hhmm, openCount, phaseOf, requiredPassed, type Phase, type PrepushCard as Card } from '../../dev/prepush';++/** How many lines a chat shows before "+{n} more in the Inbox". */+export const POINTER_LINES = 3;+/** A card is a candidate for 24 h after it was created. */+export const POINTER_WINDOW_MS = 24 * 60 * 60 * 1000;+/** P2, P6 and P0 lines leave 10 min after the card's last update. */+export const POINTER_SETTLED_MS = 10 * 60 * 1000;+const SETTLED: ReadonlySet<Phase> = new Set(['P2', 'P6', 'P0']);++export interface PointerPick {+ lines: Card[];+ /** Bots with a line that didn't fit. */+ more: number;+ /** When the next settled line leaves (ms), so the chat can drop it without a new event. */+ nextExpiry: number | null;+}++/**+ * Each member bot's newest card (by updated_at) created in the last 24 h; a settled one leaves 10 min+ * after its update. Needs-you lines first, then newest first; at most 3.+ */+export function pointerLines(cards: Card[], memberIds: readonly string[], now: number): PointerPick {+ const members = new Set(memberIds);+ const newest = new Map<string, Card>();+ for (const c of cards) {+ if (!members.has(c.kwant_id)) continue;+ if (c.created_at === null || now - c.created_at > POINTER_WINDOW_MS) continue;+ const cur = newest.get(c.kwant_id);+ if (!cur || (c.updated_at ?? 0) > (cur.updated_at ?? 0)) newest.set(c.kwant_id, c);+ }+ let nextExpiry: number | null = null;+ const live: Card[] = [];+ for (const c of newest.values()) {+ if (SETTLED.has(phaseOf(c))) {+ const leaves = (c.updated_at ?? 0) + POINTER_SETTLED_MS;+ if (leaves <= now) continue;+ nextExpiry = nextExpiry === null ? leaves : Math.min(nextExpiry, leaves);+ }+ // Lines also leave when the 24 h window closes.+ const closes = (c.created_at ?? 0) + POINTER_WINDOW_MS;+ nextExpiry = nextExpiry === null ? closes : Math.min(nextExpiry, closes);+ live.push(c);+ }+ live.sort((a, b) => {+ const pa = phaseOf(a) === 'P4' ? 0 : 1;+ const pb = phaseOf(b) === 'P4' ? 0 : 1;+ return pa - pb || (b.updated_at ?? 0) - (a.updated_at ?? 0);+ });+ return { lines: live.slice(0, POINTER_LINES), more: Math.max(0, live.length - POINTER_LINES), nextExpiry };+}++const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;++/** One piece of a line: plain text, the bot's name (bold) or the branch (code). */+export type Part = { t: 'text' | 'bot' | 'branch'; v: string };++/** Mira's copy for each phase, in parts so the name is bold and the branch is code. */+export function pointerParts(c: Card, bot: string): Part[] {+ const T = (v: string): Part => ({ t: 'text', v });+ const B: Part = { t: 'bot', v: bot };+ const Bs: Part = { t: 'bot', v: `${bot}'s` };+ const R: Part = { t: 'branch', v: c.branch };+ const n = openCount(c);+ switch (phaseOf(c)) {+ case 'P1':+ return [B, T(' is checking before pushing '), R];+ case 'RT':+ return [Bs, T(' push of '), R, T(' is being checked again')];+ case 'P3':+ return n > 0+ ? [B, T(` is fixing ${plural(n, 'finding')} before pushing `), R, T(` · Try ${c.tries} of ${NEEDS_YOU_TRIES}`)]+ : [B, T(' is fixing what blocked pushing '), R, T(` · Try ${c.tries} of ${NEEDS_YOU_TRIES}`)];+ case 'P7':+ return [T("A check couldn't run on "), Bs, T(' push of '), R];+ case 'P4':+ return n > 0+ ? [Bs, T(' push of '), R, T(` is waiting for you: ${plural(n, 'finding')} open`)]+ : [Bs, T(' push of '), R, T(" is waiting for you: the checks couldn't run")];+ case 'P2':+ return [T('Cleared: '), B, T(' can push '), R, T(` · ${plural(requiredPassed(c), 'check')} passed`)];+ case 'P6':+ return [T('You let '), Bs, T(' push of '), R, T(' go anyway')];+ case 'P0':+ return [T('Nothing to push: '), R, T(' has no new commits')];+ case 'UN':+ return [B, T(" has a push check this version can't show · update the app to see where it is")];+ }+}++export const pointerText = (c: Card, bot: string): string => pointerParts(c, bot).map((p) => p.v).join('');++/** The button's name: the line, then where it goes. */+export const pointerLabel = (c: Card, bot: string): string => `${pointerText(c, bot)}. Open ${bot}'s chat`;++const LED: Record<Phase, 'run' | 'bad' | 'warn' | 'ok' | 'off'> = {+ P1: 'run',+ RT: 'run',+ P3: 'bad',+ P7: 'warn',+ P4: 'warn',+ P2: 'ok',+ P6: 'off',+ P0: 'off',+ UN: 'off',+};++const ROW =+ 'flex w-full max-w-[860px] min-h-11 sm:min-h-10 items-center gap-2.5 rounded-xl border px-3 py-2 text-left text-meta max-sm:text-[13px] max-sm:leading-[18px] outline-none transition-colors duration-[120ms] motion-reduce:transition-none focus-visible:ring-2 focus-visible:ring-sky-400 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-main';+const PLAIN = 'border-hairline bg-surface-main text-zinc-300 hover:border-hairline-strong hover:bg-surface-raised';+const AMBER = 'border-amber-500/30 bg-amber-950/20 text-zinc-200 hover:bg-amber-950/30';++export interface PrepushPointersProps {+ cards: Card[];+ memberIds: readonly string[];+ names: Record<string, string>;+ onOpen: (c: Card) => void;+ onOpenInbox: () => void;+ /** The bot's avatar (the app passes its pixel avatar, 20 px). */+ avatar?: (kwantId: string, name: string) => React.ReactNode;+ /** For tests. */+ now?: () => number;+}++export const PrepushPointers: React.FC<PrepushPointersProps> = ({ cards, memberIds, names, onOpen, onOpenInbox, avatar, now = Date.now }) => {+ // Re-render when the next settled line is due to leave, without waiting for a new event.+ const [, setTick] = useState(0);+ const pick = pointerLines(cards, memberIds, now());+ useEffect(() => {+ if (pick.nextExpiry === null) return;+ const wait = Math.max(0, pick.nextExpiry - now()) + 50;+ const t = window.setTimeout(() => setTick((n) => n + 1), Math.min(wait, 2 ** 31 - 1));+ return () => window.clearTimeout(t);+ }, [pick.nextExpiry, now]);++ // Announce phase changes only: one short sentence, the line's text.+ const phases = useRef(new Map<string, Phase>());+ const [said, setSaid] = useState('');+ const sig = pick.lines.map((c) => `${c.id}:${phaseOf(c)}`).join('|');+ useEffect(() => {+ let say = '';+ for (const c of pick.lines) {+ const p = phaseOf(c);+ const before = phases.current.get(c.id);+ if (before !== undefined && before !== p) say = pointerText(c, names[c.kwant_id] || 'A bot');+ phases.current.set(c.id, p);+ }+ if (say) setSaid(say);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [sig]);++ if (pick.lines.length === 0) return null;+ return (+ <section aria-label="Checks before pushing" data-prepush-pointers className="flex flex-col gap-1.5">+ <p aria-live="polite" className="sr-only" data-prepush-pointers-live>+ {said}+ </p>+ {pick.lines.map((c) => {+ const bot = names[c.kwant_id] || 'A bot';+ const phase = phaseOf(c);+ const p4 = phase === 'P4';+ const at = hhmm(c.updated_at);+ return (+ <button+ key={c.id}+ type="button"+ data-prepush-pointer={c.id}+ data-prepush-phase={phase}+ aria-label={pointerLabel(c, bot)}+ onClick={() => onOpen(c)}+ className={`${ROW} ${p4 ? AMBER : PLAIN}`}+ >+ <Led s={LED[phase]} className={`dv-led-still shrink-0 max-sm:hidden${phase === 'UN' ? ' opacity-60' : ''}`} />+ {avatar && <span className="inline-flex shrink-0">{avatar(c.kwant_id, bot)}</span>}+ <span+ className={`min-w-0 flex-1 [overflow-wrap:anywhere] max-sm:line-clamp-2${phase === 'P0' || phase === 'UN' ? ' text-zinc-500' : ''}`}+ >+ {p4 && <span className="kw-chip kw-chip-warn mr-1.5 !py-0 !px-2 align-[1px] !text-[11px] !leading-4">Needs you</span>}+ {pointerParts(c, bot).map((part, i) =>+ part.t === 'bot' ? (+ <span key={i} className="font-semibold text-zinc-100">+ {part.v}+ </span>+ ) : part.t === 'branch' ? (+ <code key={i} className="dv-sha">+ {part.v}+ </code>+ ) : (+ <React.Fragment key={i}>{part.v}</React.Fragment>+ ),+ )}+ </span>+ {at && <span className="shrink-0 tabular-nums text-zinc-500 max-sm:hidden">{at}</span>}+ <span aria-hidden="true" className="inline-flex shrink-0 items-center gap-0.5 font-medium text-violet-300">+ Open+ <ChevronRight size={14} />+ </span>+ </button>+ );+ })}+ {pick.more > 0 && (+ <button+ type="button"+ data-prepush-pointers-more+ onClick={onOpenInbox}+ className="inline-flex min-h-11 max-w-[860px] items-center self-start rounded-lg px-3 text-meta font-medium text-violet-300 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-sky-400 sm:min-h-10"+ >+ +{pick.more} more in the Inbox+ </button>+ )}+ </section>+ );+};diff --git a/frontend/src/components/dev/PrepushThread.tsx b/frontend/src/components/dev/PrepushThread.tsxindex 4aed0529..bd21ddc4 100644--- a/frontend/src/components/dev/PrepushThread.tsx+++ b/frontend/src/components/dev/PrepushThread.tsx@@ -136,7 +136,7 @@ export const PrepushThread: React.FC<{return (<section aria-label={`Checks before ${bot} pushes`} data-prepush-thread className="space-y-2">{cards.map((c) => (- <div key={c.id} id={`prepush-${c.id}`} className="scroll-mt-4">+ <div key={c.id} id={`prepush-${c.id}`} className="relative max-w-[640px] scroll-mt-4 rounded-xl"><PrepushCard card={c} bot={bot} live={live.has(c.id)} onRetry={onRetry} onOverride={onOverride} /></div>))}diff --git a/frontend/src/styles/modern.css b/frontend/src/styles/modern.cssindex 248bd070..a04e7ba9 100644--- a/frontend/src/styles/modern.css+++ b/frontend/src/styles/modern.css@@ -987,3 +987,11 @@ button.dv-sha { cursor: copy; } button.dv-sha:hover { color: var(--accent); bord[data-whats-new-all] ul > li:not([hidden]) + li:not([hidden]) { margin-top: 8px; }[data-whats-new-all] li::marker { color: #5a5383; }[data-whats-new-all] strong { color: #ecebfa; }++/* 0.8.1 F3: the card a team chat's pointer line lands on gets a 1.2 s ring (opacity only), so the eye finds it. */+.kw-prepush-flash::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; display: none; }+@keyframes kw-prepush-flash { 0% { opacity: 0; } 13.3% { opacity: 1; } 86.7% { opacity: 1; } 100% { opacity: 0; } }+/* Off by default; on only when motion is allowed, so reduced motion never sees it. */+@media (prefers-reduced-motion: no-preference) {+ .kw-prepush-flash::after { display: block; box-shadow: 0 0 0 2px rgb(167 139 250 / 0.6); opacity: 0; animation: kw-prepush-flash 1.2s linear 1 both; }+}diff --git a/frontend/tests/prepushPointers.test.mjs b/frontend/tests/prepushPointers.test.mjsnew file mode 100644index 00000000..ecd5a4b2--- /dev/null+++ b/frontend/tests/prepushPointers.test.mjs@@ -0,0 +1,192 @@+// 0.8.1 F3 (Iris): the pre-push pointer lines in team chats and channels (Mira,+// release-090/designs/f3-prepush-in-team.md): which lines show, their order and cap, each phase's+// copy, the screen-reader name, the 10 min leave, and that a line only opens the bot's 1:1.+process.env.TZ = 'UTC';++import assert from 'node:assert/strict';+import test, { afterEach } 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 });+const g = globalThis;+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'Event', 'MouseEvent', 'KeyboardEvent', 'CustomEvent', 'FocusEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle']) {+ if (!(k in dom.window)) continue;+ Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });+}+g.window.matchMedia ??= () => ({ matches: false, addEventListener() {}, removeEventListener() {} });+g.IS_REACT_ACT_ENVIRONMENT = false;++const m = await loadBundled(`+ export * from './src/dev/prepush';+ export * as fx from './src/dev/prepushFixtures';+ export * from './src/components/dev/PrepushPointers';+ export { renderToStaticMarkup } from 'react-dom/server.browser';+ export { createRoot } from 'react-dom/client';+ export { createElement } from 'react';+`);+const { fx } = m;+const h = m.createElement;+const MIN = 60_000;+const card = (raw) => {+ const c = m.parsePrepush(raw);+ assert.ok(c, 'fixture parses');+ return c;+};+/** A card for bot `k`, created `ago` min before T0+60 and updated `upd` min before it. */+const NOW = fx.PP_T0 + 60 * MIN;+const at = (raw, k, id, createdAgo, updatedAgo) => card({ ...raw, id, kwant_id: k, created_at: NOW - createdAgo * MIN, updated_at: NOW - updatedAgo * MIN });++const mounted = new Set();+afterEach(() => {+ for (const u of mounted) u();+ document.body.replaceChildren();+});+const settle = async () => {+ for (let i = 0; i < 20; i++) await new Promise((r) => setTimeout(r, 0));+};+const mount = async (props) => {+ const host = document.createElement('div');+ document.body.appendChild(host);+ const root = m.createRoot(host);+ root.render(h(m.PrepushPointers, props));+ await settle();+ const u = () => {+ if (!mounted.delete(u)) return;+ root.unmount();+ host.remove();+ };+ mounted.add(u);+ return { host, rerender: async (p) => { root.render(h(m.PrepushPointers, p)); await settle(); } };+};+const text = (el) => el.textContent.replace(/\s+/g, ' ').trim();+const names = { k_ann: 'Ann', k_bo: 'Bo', k_cy: 'Cy', k_di: 'Di', k_out: 'Out' };++test('one line per member bot: its newest card by updated_at, created in the last 24 h', () => {+ const cards = [+ at(fx.PP_CHECKING, 'k_ann', 'a_old', 50, 40),+ at(fx.PP_BLOCKED, 'k_ann', 'a_new', 30, 5),+ at(fx.PP_CHECKING, 'k_bo', 'b_stale', 25 * 60, 1), // created 25 h ago+ at(fx.PP_CHECKING, 'k_out', 'o_1', 5, 1), // not a member+ ];+ const pick = m.pointerLines(cards, ['k_ann', 'k_bo'], NOW);+ assert.deepEqual(pick.lines.map((c) => c.id), ['a_new']);+ assert.equal(pick.more, 0);+});++test('Needs-you lines first, then newest first; at most 3 with the rest counted', () => {+ const cards = [+ at(fx.PP_CHECKING, 'k_ann', 'a', 10, 1),+ at(fx.PP_BLOCKED, 'k_bo', 'b', 10, 2),+ at(fx.PP_NEEDS_YOU, 'k_cy', 'c', 30, 20),+ at(fx.PP_RETRIED, 'k_di', 'd', 10, 3),+ at(fx.PP_FAILED_NEEDS_YOU, 'k_out', 'e', 30, 25),+ ];+ const all = m.pointerLines(cards, ['k_ann', 'k_bo', 'k_cy', 'k_di', 'k_out'], NOW);+ assert.deepEqual(all.lines.map((c) => c.id), ['c', 'e', 'a']);+ assert.equal(all.more, 2);+ const two = m.pointerLines(cards, ['k_ann', 'k_cy'], NOW);+ assert.deepEqual(two.lines.map((c) => c.id), ['c', 'a'], 'two bots in one team: two lines, P4 first');+});++test('P2, P6 and P0 leave 10 min after their update; other phases stay', () => {+ const settled = [at(fx.PP_CLEAR, 'k_ann', 'clear', 30, 11), at(fx.PP_OVERRIDDEN, 'k_bo', 'over', 30, 10), at(fx.PP_NO_CHANGE, 'k_cy', 'none', 30, 12)];+ assert.deepEqual(m.pointerLines(settled, ['k_ann', 'k_bo', 'k_cy'], NOW).lines, []);+ const fresh = [at(fx.PP_CLEAR, 'k_ann', 'clear', 30, 9), at(fx.PP_BLOCKED, 'k_bo', 'blk', 300, 200)];+ const pick = m.pointerLines(fresh, ['k_ann', 'k_bo'], NOW);+ assert.deepEqual(pick.lines.map((c) => c.id).sort(), ['blk', 'clear']);+ assert.equal(pick.nextExpiry, NOW + MIN, 'the clear line leaves in 1 min');+ // A settled newest card doesn't bring back the bot's older card.+ const older = [at(fx.PP_BLOCKED, 'k_ann', 'older', 60, 50), at(fx.PP_CLEAR, 'k_ann', 'newer', 30, 20)];+ assert.deepEqual(m.pointerLines(older, ['k_ann'], NOW).lines, []);+});++test("each phase's copy matches Mira's table", () => {+ const T = (raw, extra = {}) => m.pointerText(card({ ...raw, ...extra, branch: 'qa-skip' }), 'Ann');+ assert.equal(T(fx.PP_CHECKING), 'Ann is checking before pushing qa-skip');+ assert.equal(T(fx.PP_RETRIED), "Ann's push of qa-skip is being checked again");+ assert.equal(T(fx.PP_BLOCKED), 'Ann is fixing 1 finding before pushing qa-skip · Try 1 of 2');+ assert.equal(T(fx.PP_BLOCKED, { blockers: [] }), 'Ann is fixing what blocked pushing qa-skip · Try 1 of 2');+ assert.equal(T(fx.PP_FAILED), "A check couldn't run on Ann's push of qa-skip");+ assert.equal(T(fx.PP_NEEDS_YOU), "Ann's push of qa-skip is waiting for you: 1 finding open");+ assert.equal(T(fx.PP_FAILED_NEEDS_YOU), "Ann's push of qa-skip is waiting for you: the checks couldn't run");+ assert.equal(T(fx.PP_CLEAR), 'Cleared: Ann can push qa-skip · 5 checks passed');+ assert.equal(T(fx.PP_OVERRIDDEN), "You let Ann's push of qa-skip go anyway");+ assert.equal(T(fx.PP_NO_CHANGE), 'Nothing to push: qa-skip has no new commits');+ assert.equal(T(fx.PP_CHECKING, { status: 'pushed' }), "Ann has a push check this version can't show · update the app to see where it is");+ const two = card({ ...fx.PP_BLOCKED, branch: 'qa-skip', blockers: [fx.PP_BLOCKED.blockers[0], { ...fx.PP_BLOCKED.blockers[0], id: 'f2' }] });+ assert.equal(m.openCount(two), 2);+ assert.equal(m.pointerText(two, 'Ann'), 'Ann is fixing 2 findings before pushing qa-skip · Try 1 of 2');+});++test('screen-reader name: the line, then where it goes', () => {+ const c = card({ ...fx.PP_NEEDS_YOU, branch: 'qa-skip' });+ assert.equal(m.pointerLabel(c, 'Ann'), "Ann's push of qa-skip is waiting for you: 1 finding open. Open Ann's chat");+});++test('the stack: labelled, P4 amber with the chip, branch as code, no card buttons, never HTML from data', async () => {+ const evil = { ...fx.PP_NEEDS_YOU, kwant_id: 'k_ann', branch: '<img src=x onerror=alert(1)>', created_at: NOW - 5 * MIN, updated_at: NOW - MIN };+ const { host } = await mount({ cards: [card(evil), at(fx.PP_CHECKING, 'k_bo', 'b', 5, 1)], memberIds: ['k_ann', 'k_bo'], names, onOpen() {}, onOpenInbox() {}, now: () => NOW });+ const stack = host.querySelector('[data-prepush-pointers]');+ assert.equal(stack.getAttribute('aria-label'), 'Checks before pushing');+ const rows = [...host.querySelectorAll('[data-prepush-pointer]')];+ assert.equal(rows.length, 2);+ assert.equal(rows[0].dataset.prepushPhase, 'P4');+ assert.match(rows[0].className, /amber/);+ assert.equal(rows[0].querySelector('.kw-chip-warn').textContent, 'Needs you');+ assert.equal(rows[0].querySelector('code.dv-sha').textContent, evil.branch);+ assert.equal(host.querySelector('img'), null);+ assert.doesNotMatch(rows[1].className, /amber/);+ assert.equal(rows[1].querySelector('.dv-led').dataset.s, 'run');+ for (const r of rows) {+ assert.equal(r.tagName, 'BUTTON');+ assert.equal(r.getAttribute('type'), 'button');+ assert.match(r.className, /min-h-11/, '44 px on a phone');+ assert.match(text(r), /Open$/);+ }+ assert.equal([...host.querySelectorAll('button')].filter((b) => /try again|anyway/i.test(text(b))).length, 0, 'the card buttons stay in the 1:1');+ assert.equal(host.querySelector('[data-prepush-pointers-more]'), null);+});++test('Open: a click on the line opens the bot chat at that card; "+n more" opens the Inbox', async () => {+ const opened = [];+ let inbox = 0;+ const cards = ['k_ann', 'k_bo', 'k_cy', 'k_di'].map((k, i) => at(fx.PP_CHECKING, k, `c_${k}`, 10, i + 1));+ const { host } = await mount({ cards, memberIds: Object.keys(names), names, onOpen: (c) => opened.push(c.id), onOpenInbox: () => inbox++, now: () => NOW });+ const rows = [...host.querySelectorAll('[data-prepush-pointer]')];+ assert.equal(rows.length, 3);+ rows[1].dispatchEvent(new window.MouseEvent('click', { bubbles: true }));+ assert.deepEqual(opened, ['c_k_bo']);+ const more = host.querySelector('[data-prepush-pointers-more]');+ assert.equal(text(more), '+1 more in the Inbox');+ more.dispatchEvent(new window.MouseEvent('click', { bubbles: true }));+ assert.equal(inbox, 1);+});++test('nothing renders when no member bot has a line', async () => {+ const { host } = await mount({ cards: [at(fx.PP_CHECKING, 'k_out', 'o', 5, 1)], memberIds: ['k_ann'], names, onOpen() {}, onOpenInbox() {}, now: () => NOW });+ assert.equal(host.innerHTML, '');+});++test('the live region speaks phase changes only, with the line text', async () => {+ const props = (raw) => ({ cards: [card({ ...raw, id: 'x', kwant_id: 'k_ann', branch: 'qa-skip', created_at: NOW - 5 * MIN, updated_at: NOW - MIN })], memberIds: ['k_ann'], names, onOpen() {}, onOpenInbox() {}, now: () => NOW });+ const { host, rerender } = await mount(props(fx.PP_CHECKING));+ const live = host.querySelector('[data-prepush-pointers-live]');+ assert.equal(live.getAttribute('aria-live'), 'polite');+ assert.equal(live.textContent, '', 'the first render says nothing');+ await rerender(props(fx.PP_CHECKING));+ assert.equal(live.textContent, '');+ await rerender(props(fx.PP_NEEDS_YOU));+ assert.equal(live.textContent, "Ann's push of qa-skip is waiting for you: 1 finding open");+});++test('a settled line leaves on its own when its 10 min are up', async () => {+ let now = NOW;+ const c = at(fx.PP_CLEAR, 'k_ann', 'cl', 30, 10 - 0.001); // leaves 60 ms after NOW+ const { host } = await mount({ cards: [c], memberIds: ['k_ann'], names, onOpen() {}, onOpenInbox() {}, now: () => now });+ assert.ok(host.querySelector('[data-prepush-pointer]'));+ now = NOW + MIN;+ await new Promise((r) => setTimeout(r, 200));+ await settle();+ assert.equal(host.querySelector('[data-prepush-pointer]'), null);+});