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
30j approval-flash-no-jump: the approval card no longer hops when kwant points at it (#878)
Oleksandr Ivanchenko1d3945222fd4
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex 13995a61..99f6e6cb 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -102,7 +102,6 @@ import { awayApi } from '../away';import { parseBudgetNotice } from '../botBudget';import { BudgetNotice, BudgetPausedBanner, useBudgets } from './BotBudget';import { isSystemNotice, parseExpiredApproval, parseInterruption, retryTargets } from '../interruptions';-import { ringElement } from '../ring';import { parseIsolationFailed, parseRequestLimit } from '../isolationNotice';import { IsolationNotice, RequestLimitNotice } from './IsolationNotice';import { IDEA_MAX, isIdeaCommand } from '../ideas';@@ -1135,7 +1134,6 @@ export const ChatView: React.FC<ChatViewProps> = ({// card's first choice does), never on Allow / Deny. A tap, an Inbox row or a notification leaves focus alone.const from = document.activeElement;if (from instanceof HTMLElement && stripSlotRef.current?.contains(from) && from.matches('[data-strip-action="decide"]:focus-visible')) card.focus({ preventScroll: true });- if (highlightRing) ringElement(card);setFlashKind(highlightRing ? 'ask' : 'search');setFlashId(highlightMessageId);onHighlightDone?.();@@ -2738,8 +2736,15 @@ export const ChatView: React.FC<ChatViewProps> = ({// (display: contents when not flashing), so the flash never remounts the card: focus that "Go to the// approval" put on it stays, and so does a half-typed Deny reason. 30h: while flashing, the wrapper is as wide// as the card (the card's own max-w-2xl), so the amber box hugs the card instead of running to the column's- // edge. Top and bottom already match: the card's my-3 collapses through the wrapper.- <div key={approval.id} className={flashId === approval.id ? 'max-w-2xl rounded-xl kw-flash' : 'contents'}>+ // edge. Top and bottom already match: the card's my-3 collapses through the wrapper. 30j: the wrapper has+ // the same box idle and flashing (only kw-flash toggles), and !mt-0 cancels the list's space-y gap, so the+ // card stays where it sat idle instead of hopping 8 / 12 px as the flash starts and ends. It is the one+ // amber ring (the card root no longer gets its own), tagged with the flash kind as message rows are.+ <div+ key={approval.id}+ className={`max-w-2xl rounded-xl !mt-0${flashId === approval.id ? ' kw-flash' : ''}`}+ data-flash-kind={flashId === approval.id ? flashKind : undefined}+ ><ModernApprovalCard approval={approval} onResolve={onResolveApproval} /></div>))}diff --git a/frontend/tests/approvalFlashNoJump.test.mjs b/frontend/tests/approvalFlashNoJump.test.mjsnew file mode 100644index 00000000..64e25ad7--- /dev/null+++ b/frontend/tests/approvalFlashNoJump.test.mjs@@ -0,0 +1,85 @@+// 30j (brief: autonomy/approval-flash-no-jump/brief.md; Rigel's 30h QA observations 1 and 2): when kwant points+// at a waiting approval, the card must not move as the amber flash starts and ends. Before, the wrapper was+// display: contents idle and a block while flashing, so the chat list's space-y gap (20 px, 24 px from sm) applied+// to it only while flashing and the card hopped 8 / 12 px down and back. And the card root got its own kw-flash from+// ring.ts on top of the wrapper's, so two amber rings were stacked.+// JSDOM has no layout, so this pins what decides the box: the wrapper's classes idle and flashing.+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 });+const g = globalThis;+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Node', 'DOMParser', 'localStorage', 'sessionStorage', 'getComputedStyle', 'requestAnimationFrame', 'cancelAnimationFrame']) {+ if (k in dom.window) Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });+}+g.IS_REACT_ACT_ENVIRONMENT = false;+dom.window.HTMLElement.prototype.scrollIntoView = function () {};+dom.window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} });+if (!('ResizeObserver' in dom.window)) dom.window.ResizeObserver = class { observe() {} unobserve() {} disconnect() {} };+g.ResizeObserver = dom.window.ResizeObserver;+if (!g.CSS) g.CSS = { escape: (s) => String(s).replace(/["\\]/g, '\\$&') };++const m = await loadBundled(`+ export { default as React } from 'react';+ export { createRoot } from 'react-dom/client';+ export { flushSync } from 'react-dom';+ export { ChatView } from './src/components/ChatView';+`);++const approval = { id: 'ap1', tool_name: 'execute_shell', details: { source: 'local_shell', tool: 'execute_shell', arguments: { command: 'curl -sI https://example.com', cwd: '/tmp' }, kwant_name: 'Mia' } };+const messages = [+ { id: 'u1', sender_role: 'user', sender_id: 'me', text: 'Check example.com', created_at: '2026-11-19T14:00:00Z', tokens_used: 0 },+ { id: 'a1', sender_role: 'kwant', sender_id: 'Mia', text: 'Checking it now.', created_at: '2026-11-19T14:00:05Z', tokens_used: 0 },+];+const base = {+ title: 'Mia', subtitle: '', messages, streamingText: '', streamingThinking: '', isStreaming: false,+ pendingApprovals: [approval], onSendMessage() {}, onResolveApproval() {}, kwants: [], teams: [], onHighlightDone() {},+};+const tick = (ms = 10) => new Promise((r) => setTimeout(r, ms));+const classes = (el) => new Set(el.className.split(/\s+/).filter(Boolean));++test('30j: the approval card keeps its box as the flash starts and ends; only kw-flash toggles, and on one element', async () => {+ const host = document.createElement('div');+ document.body.appendChild(host);+ const root = m.createRoot(host);+ m.flushSync(() => root.render(m.React.createElement(m.ChatView, base)));+ const card = host.querySelector('[data-approval-card="ap1"]');+ assert.ok(card, 'the approval card is rendered');+ const wrap = card.parentElement;+ const list = wrap.parentElement;+ assert.match(list.className, /\bspace-y-/, 'the wrapper sits in the chat list, whose space-y gap is what moved the card');+ const idle = classes(wrap);+ const cardIdle = classes(card);+ assert.ok(!idle.has('kw-flash'));++ m.flushSync(() => root.render(m.React.createElement(m.ChatView, { ...base, highlightMessageId: 'ap1', highlightRing: true })));+ for (let i = 0; i < 20 && !wrap.classList.contains('kw-flash'); i++) await tick();+ assert.ok(wrap.classList.contains('kw-flash'), 'the wrapper flashes');+ assert.equal(host.querySelector('[data-approval-card="ap1"]'), card, 'same card element: the flash never remounts it (30a)');+ assert.equal(card.parentElement, wrap, 'same wrapper element');+ const on = classes(wrap);++ // Same box idle and flashing: the classes differ by kw-flash and nothing else (no contents <-> block switch).+ const diff = [...new Set([...idle, ...on])].filter((c) => idle.has(c) !== on.has(c));+ assert.deepEqual(diff, ['kw-flash'], `idle "${[...idle].join(' ')}" vs flashing "${[...on].join(' ')}"`);+ // A wrapper with a box in a space-y list would take the 20 / 24 px gap and move the idle card down, so it cancels+ // it: the card's own my-3 stays the gap above it, exactly where it sat idle before.+ assert.ok(!idle.has('contents') && on.has('!mt-0'), 'the wrapper keeps a box and cancels the list gap');+ // One amber ring while flashing (Rigel's observation 2): the wrapper, sized to the card in 30h, not the card too.+ const rings = host.querySelectorAll('.kw-flash');+ assert.equal(rings.length, 1, `${rings.length} .kw-flash elements while flashing`);+ assert.equal(rings[0], wrap);+ assert.deepEqual(classes(card), cardIdle, 'the card root itself is untouched by the flash');+ // Still tagged as an ask, the way message rows are, so tests can tell it from a search landing.+ assert.equal(wrap.getAttribute('data-flash-kind'), 'ask');++ // The flash ends after 2.4 s and the wrapper is back to its idle classes.+ await tick(2500);+ assert.deepEqual(classes(wrap), idle);+ assert.equal(host.querySelectorAll('.kw-flash').length, 0);+ assert.equal(wrap.hasAttribute('data-flash-kind'), false);+ root.unmount();+ host.remove();+});diff --git a/frontend/tests/askHere.test.mjs b/frontend/tests/askHere.test.mjsindex abffc7a9..458c199e 100644--- a/frontend/tests/askHere.test.mjs+++ b/frontend/tests/askHere.test.mjs@@ -733,7 +733,8 @@ test('30a: keyboard "Go to the approval" (strip, pill, Answer ↑) focuses the c// The 29w hand-off to the composer still only runs when focus was lost (body) or is still in the hidden strip.assert.match(chat, /if \(!a \|\| a === document\.body \|\| stripSlotRef\.current\?\.contains\(a\)\) textareaRef\.current\?\.focus\(\{ preventScroll: true \}\);/);// The flash wrapper is always there, so flashing the card on landing doesn't remount it (and drop its focus).- assert.match(chat, /<div key=\{approval\.id\} className=\{flashId === approval\.id \? '[^']*\bkw-flash\b[^']*' : 'contents'\}>\n\s*<ModernApprovalCard approval=\{approval\} onResolve=\{onResolveApproval\} \/>\n\s*<\/div>/);+ // 30j: the flash only toggles kw-flash on the same wrapper (see the 30h test for the exact classes).+ assert.match(chat, /<div\s+key=\{approval\.id\}\s+className=\{`[^`]*\$\{flashId === approval\.id \? ' kw-flash' : ''\}`\}[^>]*>\n\s*<ModernApprovalCard approval=\{approval\} onResolve=\{onResolveApproval\} \/>\n\s*<\/div>/);assert.doesNotMatch(chat, /<ModernApprovalCard key=\{approval\.id\}/);// The dev production-floor card is a landing place too.assert.match(floor, /data-approval-card=\{id\}[\s\S]{0,400}tabIndex=\{-1\}/);@@ -744,13 +745,15 @@ test('30a: keyboard "Go to the approval" (strip, pill, Answer ↑) focuses the ctest('30h: the approval flash box is as wide as the card, and adds nothing to its height', () => {const chat = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');const card = readFileSync(new URL('../src/components/ModernApprovalCard.tsx', import.meta.url), 'utf8');- const flash = chat.match(/<div key=\{approval\.id\} className=\{flashId === approval\.id \? '([^']*)' : '([^']*)'\}>\s*<ModernApprovalCard /);+ const flash = chat.match(/<div\s+key=\{approval\.id\}\s+className=\{`([^`$]*)\$\{flashId === approval\.id \? '([^']*)' : ''\}`\}[^>]*>\s*<ModernApprovalCard /);assert.ok(flash, 'the approval card sits in the flash wrapper');- const [, on, idle] = flash;- const onCls = on.split(/\s+/);+ const [, idle, toggled] = flash;+ // 30j: one box idle and flashing; only kw-flash toggles (the brief's "no jump" rule; behaviour in approvalFlashNoJump).+ assert.equal(toggled, ' kw-flash');+ const on = `${idle}${toggled}`;+ const onCls = on.split(/\s+/).filter(Boolean);assert.ok(onCls.includes('kw-flash') && onCls.includes('rounded-xl'), on);- // The idle wrapper stays display: contents (30a: no remount, no layout of its own).- assert.equal(idle, 'contents');+ assert.ok(onCls.includes('!mt-0'), 'the wrapper cancels the list gap, so the card keeps its idle spot');// The card root's own max width, read from the card, is on the flashing wrapper too.const root = card.match(/data-approval-card=\{approval\.id\}[\s\S]{0,300}?className=\{`([^`$]*)/);assert.ok(root, 'card root class');@@ -758,6 +761,6 @@ test('30h: the approval flash box is as wide as the card, and adds nothing to itassert.equal(maxW.length, 1, root[1]);assert.ok(onCls.includes(maxW[0]), `flash wrapper "${on}" lacks the card's ${maxW[0]}`);// Top and bottom: the card's my-3 collapses through the wrapper only while the wrapper has no margin, padding,- // border or its own formatting context, so none of those may join the flashing class.- for (const c of onCls) assert.doesNotMatch(c, /^(-?m[trblxy]?|p[trblxy]?|border|ring|flex|grid|inline|overflow|flow-root|w)-|^(flex|grid|inline-block|flow-root|border)$/, c);+ // border or its own formatting context, so none of those may join the wrapper (its one margin class is !mt-0).+ for (const c of onCls.filter((c) => c !== '!mt-0')) assert.doesNotMatch(c, /^!?(-?m[trblxy]?|p[trblxy]?|border|ring|flex|grid|inline|overflow|flow-root|w)-|^!?(flex|grid|inline-block|flow-root|border|contents)$/, c);});