Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

17c: the live reply's name line looks like the finished one (#664)

Oleksandr Ivanchenko93af2b4be7c9
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index 22175c1b..ea935c09 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -42,7 +42,7 @@ import { LiveActivity, hasThinkingText, parseActivityMeta } from '../activity';
import { LiveActivityList, SavedActivityList } from './ActivityList';
import { BrowsedChip } from './BrowsedChip';
import { pagesOfReply, type ReplyPage } from '../browserPages';
-import { FailoverNote, ReplyMeta } from './ReplyMeta';
+import { FailoverNote, REPLY_NAME, REPLY_NAME_LINE_LIVE_HEIGHT, ReplyMeta, replyNameLine } from './ReplyMeta';
import { assignSwitchNotes, liveSwitchNote, type SwitchNote } from '../failoverNotes';
import { savedFailoverHandoff, savedFailoverNotice } from '../failover';
import { SuggestionMeta, parseSuggestionMeta } from '../mcpSuggestions';
@@ -2481,11 +2481,12 @@ export const ChatView: React.FC<ChatViewProps> = ({
<ModernAvatar role={liveName} name={liveName} size={REPLY_AVATAR} />
</span>
<div className="flex flex-col items-start min-w-0 flex-1 max-w-4xl">
- <div className="flex items-center gap-2 mb-1.5 text-[11px] text-zinc-400 font-medium">
+ {/* The finished name line's type and height (17c), so it doesn't grow when the reply lands */}
+ <div className={replyNameLine(REPLY_NAME_LINE_LIVE_HEIGHT)} data-live-name-line="">
<span className="sm:hidden shrink-0 inline-flex">
<ModernAvatar role={liveName} name={liveName} size={REPLY_AVATAR_PHONE} />
</span>
- <span className="text-zinc-200">{liveName}</span>
+ <span className={REPLY_NAME}>{liveName}</span>
{queued ? (
<span className="inline-flex items-center gap-1 text-zinc-400 text-[10px]">
<span className="w-1.5 h-1.5 rounded-full bg-zinc-500" aria-hidden="true" />
diff --git a/frontend/src/components/ReplyMeta.tsx b/frontend/src/components/ReplyMeta.tsx
index e4ac0cc6..656d3ddc 100644
--- a/frontend/src/components/ReplyMeta.tsx
+++ b/frontend/src/components/ReplyMeta.tsx
@@ -42,6 +42,17 @@ export interface ReplyMetaProps extends ReplyFacts {
}
/** The quiet line for a reply that ran on another account. It wraps rather than clips, so it fits at 390 px. */
+// The reply's name line, shared with the live row in ChatView (17c) so the name line keeps its type and height
+// when the reply lands. replyNameLine(extra) puts extra between the box and the type classes: the finished line
+// passes 'sm:flex-wrap' (its class string is unchanged), the live line REPLY_NAME_LINE_LIVE_HEIGHT.
+export const REPLY_NAME = 'min-w-0 truncate text-[13px] font-semibold text-zinc-50';
+const REPLY_NAME_LINE_BOX = 'mb-1.5 flex min-w-0 max-w-full flex-nowrap';
+const REPLY_NAME_LINE_TYPE = 'items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium';
+// The Details button's height: min-h-6, and 44 px where modern.css makes every control a 44 px tap target
+// (touch screens below 768 px), so the live line is as tall as the finished one there too.
+export const REPLY_NAME_LINE_LIVE_HEIGHT = 'min-h-6 [@media(max-width:767px)_and_(pointer:coarse)]:min-h-11';
+export const replyNameLine = (extra: string): string => `${REPLY_NAME_LINE_BOX} ${extra} ${REPLY_NAME_LINE_TYPE}`;
+
export const FailoverNote: React.FC<{ text: string }> = ({ text }) => (
<p data-failover-note="" className="-mt-0.5 mb-1.5 max-w-full text-xs leading-snug text-zinc-500 break-words">
{text}
@@ -79,9 +90,9 @@ export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, a
const hasDetails = facts.length > 0 || hasContent(children) || !!why.panel;
return (
<div className="w-full max-w-full min-w-0">
- <div className="mb-1.5 flex min-w-0 max-w-full flex-nowrap sm:flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium">
+ <div className={replyNameLine('sm:flex-wrap')}>
{avatar && <span className="sm:hidden shrink-0 inline-flex">{avatar}</span>}
- <span className="min-w-0 truncate text-[13px] font-semibold text-zinc-50">{name}</span>
+ <span className={REPLY_NAME}>{name}</span>
{done && <DoneMarker done={done} />}
{handoff && <EngineChip label={[ranOn, account].filter(Boolean).join(' · ')} short={ranOn ? ranOn.split(' · ').pop() : null} handoff={handoff} />}
{time && (
diff --git a/frontend/tests/liveNameLine.test.mjs b/frontend/tests/liveNameLine.test.mjs
new file mode 100644
index 00000000..79748db6
--- /dev/null
+++ b/frontend/tests/liveNameLine.test.mjs
@@ -0,0 +1,56 @@
+// 17c live-name-line: the live reply's name line takes the finished ReplyMeta line's type and height through
+// shared class strings, and the finished line's markup is unchanged.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { readFileSync } from 'node:fs';
+import { JSDOM } from 'jsdom';
+import { loadBundled } from './bundle.mjs';
+
+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/' });
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'localStorage', 'sessionStorage']) {
+ Object.defineProperty(globalThis, k, { value: dom.window[k], configurable: true, writable: true });
+}
+
+const m = await loadBundled(`
+ export { default as React } from 'react';
+ export { renderToStaticMarkup } from 'react-dom/server.browser';
+ export { ReplyMeta, REPLY_NAME, REPLY_NAME_LINE_LIVE_HEIGHT, replyNameLine } from './src/components/ReplyMeta';
+`);
+const h = m.React.createElement;
+
+test("the shared strings are the finished line's classes", () => {
+ assert.equal(m.REPLY_NAME, 'min-w-0 truncate text-[13px] font-semibold text-zinc-50');
+ assert.equal(
+ m.replyNameLine('sm:flex-wrap'),
+ 'mb-1.5 flex min-w-0 max-w-full flex-nowrap sm:flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium',
+ );
+ // The live line is as tall as the Details button: 24 px, or 44 px as a phone tap target (modern.css).
+ assert.equal(m.REPLY_NAME_LINE_LIVE_HEIGHT, 'min-h-6 [@media(max-width:767px)_and_(pointer:coarse)]:min-h-11');
+ const css = readFileSync(new URL('../src/styles/modern.css', import.meta.url), 'utf8');
+ assert.match(css, /@media \(max-width: 767px\) and \(pointer: coarse\) \{\s+:is\(button,[^{]+\{\s+min-height: 44px;/);
+});
+
+test('the finished name line renders exactly as before (b5449933)', () => {
+ const out = m.renderToStaticMarkup(h(m.ReplyMeta, { name: 'Juno', avatar: h('i', null, 'a') }));
+ assert.ok(
+ out.startsWith(
+ '<div class="w-full max-w-full min-w-0"><div class="mb-1.5 flex min-w-0 max-w-full flex-nowrap sm:flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400 font-medium">' +
+ '<span class="sm:hidden shrink-0 inline-flex"><i>a</i></span><span class="min-w-0 truncate text-[13px] font-semibold text-zinc-50">Juno</span>',
+ ),
+ out,
+ );
+});
+
+test("the live name line uses the shared strings, with the Details button's height", () => {
+ const chat = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');
+ assert.match(chat, /import \{ FailoverNote, REPLY_NAME, REPLY_NAME_LINE_LIVE_HEIGHT, ReplyMeta, replyNameLine \} from '\.\/ReplyMeta';/);
+ const liveRow = chat.slice(chat.indexOf('data-live-row=""'), chat.indexOf('data-live-bubble-body=""'));
+ assert.match(liveRow, /<div className=\{replyNameLine\(REPLY_NAME_LINE_LIVE_HEIGHT\)\} data-live-name-line="">/);
+ assert.match(liveRow, /<span className=\{REPLY_NAME\}>\{liveName\}<\/span>/);
+ assert.doesNotMatch(liveRow, /text-\[11px\] text-zinc-400 font-medium|className="text-zinc-200">\{liveName\}/);
+ // The chips keep their wording and colours.
+ for (const chip of ['In line', 'Waiting for your OK', 'Speaking...', 'text-amber-300 text-[10px]', 'text-sky-400 text-[10px]']) assert.ok(liveRow.includes(chip), chip);
+ // ReplyMeta does not import ChatView.
+ const meta = readFileSync(new URL('../src/components/ReplyMeta.tsx', import.meta.url), 'utf8');
+ assert.doesNotMatch(meta, /from '\.\/ChatView'/);
+});