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
30q quote-jump-restarts: a second click on a quote always rings the original again (#894)
Oleksandr Ivanchenko64e2cd3bf466
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex eb5074b6..c223992f 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -1122,12 +1122,12 @@ export const ChatView: React.FC<ChatViewProps> = ({// A search hit glows amber for 2.4 s; the original of a reply quote gets a violet ring for 1.6 s.// 22i: a Needs-attention landing ('ask') is the same amber flash as search, tagged so tests tell them apart.const [flashKind, setFlashKind] = useState<'search' | 'quote' | 'ask'>('search');- // 30n: a second "Go to the approval" (or search hit) on what is already flashing restarts the ring and its 2.4 s,- // like the quote jump: clear the flash, then set it again. Setting the same id again would change nothing. The- // second step waits for the cleared flash to commit, then two frames, so the browser draws a frame without+ // 30n: a second "Go to the approval" (or search hit) on what is already flashing restarts the ring and its 2.4 s;+ // 30q: so does a second quote jump (1.6 s). Clear the flash, then set it again. Setting the same id again would+ // change nothing. The second step waits for the cleared flash to commit, then two frames, so the browser draws a frame without// kw-flash and the CSS animation starts over (rAFs queued at once can both run before React commits the null).const [flashNext, setFlashNext] = useState<string | null>(null);- const restartFlash = (id: string, kind: 'search' | 'ask') => {+ const restartFlash = (id: string, kind: 'search' | 'quote' | 'ask') => {setFlashId(null);setFlashKind(kind);setFlashNext(id);@@ -1280,9 +1280,8 @@ export const ChatView: React.FC<ChatViewProps> = ({const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;el.scrollIntoView({ block: 'center', behavior: reduce ? 'auto' : 'smooth' });if (el.tabIndex < 0 || el.hasAttribute('tabindex')) el.focus({ preventScroll: true });- setFlashId(null);- setFlashKind('quote');- requestAnimationFrame(() => setFlashId(quoteJump.id));+ // 30q: same race-free restart as search and approvals, so a second click on a quote always rings again.+ restartFlash(quoteJump.id, 'quote');}, [quoteJump, messages, openThoughts]);// Thumbs on the bot's newest question are a yes or no; once one has answered it, they're feedback again.diff --git a/frontend/tests/quoteJumpRestarts.test.mjs b/frontend/tests/quoteJumpRestarts.test.mjsnew file mode 100644index 00000000..6ff88d50--- /dev/null+++ b/frontend/tests/quoteJumpRestarts.test.mjs@@ -0,0 +1,84 @@+// 30q (brief: autonomy/quote-jump-restarts/brief.md; Mira's 30n design check, "Small things" 3): a second click on+// a reply's quote while the original is still ringing must ring it again. The quote jump used a single-frame restart+// (clear, then set the id in one requestAnimationFrame), which in Chromium sometimes ran before React committed the+// clear, so nothing restarted. It now uses restartFlash (wait for the clear to commit, then two frames), like 30n.+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', 'MutationObserver']) {+ 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 messages = [+ { id: 'a1', sender_role: 'kwant', sender_id: 'Mia', text: 'The report is in the Files tab.', created_at: '2026-11-19T14:00:00Z', tokens_used: 0 },+ { id: 'u1', sender_role: 'user', sender_id: 'me', text: 'Thanks, opening it.', created_at: '2026-11-19T14:00:05Z', tokens_used: 0,+ reply_to: { id: 'a1', sender_role: 'kwant', sender_id: 'Mia', excerpt: 'The report is in the Files tab.' } },+];+const tick = (ms = 10) => new Promise((r) => setTimeout(r, ms));+const until = async (f) => { for (let i = 0; i < 40 && !f(); i++) await tick(); return f(); };++function mount() {+ const host = document.createElement('div');+ document.body.appendChild(host);+ const root = m.createRoot(host);+ m.flushSync(() => root.render(m.React.createElement(m.ChatView, {+ title: 'Mia', subtitle: '', messages, streamingText: '', streamingThinking: '', isStreaming: false,+ pendingApprovals: [], onSendMessage() {}, onResolveApproval() {}, kwants: [], teams: [],+ })));+ return { host, done: () => { root.unmount(); host.remove(); } };+}++// 'jsdom': JSDOM's own frames (~16 ms timers), which happen to land after React commits. 'early': the frame runs+// before React commits the cleared flash (a microtask), which is the Chromium race 30n measured (3 of 6 misses).+const realRaf = g.requestAnimationFrame;+for (const frames of ['jsdom', 'early']) test(`30q (${frames} frames): a second click on the same quote during its 1.6 s ring rings the original again and starts a fresh 1.6 s`, async () => {+ g.requestAnimationFrame = frames === 'early' ? (cb) => { queueMicrotask(() => cb(performance.now())); return 0; } : realRaf;+ const { host, done } = mount();+ const quote = host.querySelector('[data-reply-quote="a1"]');+ assert.ok(quote, 'the reply shows its quote');+ const orig = () => host.querySelector('[data-message-id="a1"]');+ const el = orig();+ const ringed = () => orig().classList.contains('kw-flash-quote');++ quote.click();+ assert.ok(await until(ringed), 'the first click rings the original');+ assert.equal(orig().getAttribute('data-flash-kind'), 'quote');+ await tick(1000);+ assert.ok(ringed(), 'still ringing 1.0 s in');++ const seen = [];+ const mo = new MutationObserver(() => seen.push(ringed()));+ mo.observe(el, { attributes: true, attributeFilter: ['class'] });+ host.querySelector('[data-reply-quote="a1"]').click();+ await until(() => seen.length >= 2 && ringed());+ mo.disconnect();+ assert.deepEqual(seen, [false, true], `second click: kw-flash-quote went ${JSON.stringify(seen)} (want off, then on again)`);+ assert.equal(orig(), el, 'same message element');+ assert.equal(host.querySelectorAll('.kw-flash-quote, .kw-flash').length, 1, 'one ring');+ assert.equal(orig().getAttribute('data-flash-kind'), 'quote', 'still the violet quote ring, not amber');++ // A fresh 1.6 s from the second click: still on at 2.0 s after the first click, off by 1.6 s after the second.+ await tick(1000);+ assert.ok(ringed(), 'still ringing 2.0 s after the first click');+ await tick(800);+ assert.ok(!ringed(), 'off 1.6 s after the second click');+ done();+ g.requestAnimationFrame = realRaf;+});diff --git a/frontend/tests/reactReply.test.mjs b/frontend/tests/reactReply.test.mjsindex fa658966..2ec61940 100644--- a/frontend/tests/reactReply.test.mjs+++ b/frontend/tests/reactReply.test.mjs@@ -217,6 +217,8 @@ test('ChatView: the quote in the bubble opens the original; a deleted one says sawait new Promise((r) => setTimeout(r, 30));assert.equal(g.__scrolled, 'b1');const row = v.host.querySelector('[data-message-id="b1"]');+ // 30q: the ring comes on after the cleared flash commits plus two frames (restartFlash), so wait for it.+ for (let i = 0; i < 50 && !row.className.includes('kw-flash-quote'); i++) await new Promise((r) => setTimeout(r, 10));assert.ok(row.className.includes('kw-flash-quote'), 'violet ring, not the amber search flash');assert.equal(document.activeElement, row, 'focus lands on the original');const gone = v.host.querySelector('[data-reply-quote="gone"]');