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.

Human check card: icons keep their size when a line wraps on a phone (#304)

Oleksandr Ivanchenko8685d46d7b36
diff --git a/frontend/src/components/HumanStepCard.tsx b/frontend/src/components/HumanStepCard.tsx
index ce7915c5..fd4d5050 100644
--- a/frontend/src/components/HumanStepCard.tsx
+++ b/frontend/src/components/HumanStepCard.tsx
@@ -51,37 +51,37 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
const line =
status === 'resolved_auto' ? (
<span className="inline-flex items-center gap-1.5 text-emerald-300">
- <CheckCircle2 size={13} aria-hidden="true" /> Solved. {kwantName} continues.
+ <CheckCircle2 size={13} className="shrink-0" aria-hidden="true" /> Solved. {kwantName} continues.
</span>
) : status === 'timed_out' ? (
<span className="inline-flex items-center gap-1.5 text-zinc-400">
- <Clock size={13} aria-hidden="true" /> Nobody solved it in time. {kwantName} moved on without it.
+ <Clock size={13} className="shrink-0" aria-hidden="true" /> Nobody solved it in time. {kwantName} moved on without it.
</span>
) : status === 'done' ? (
<span className="inline-flex items-center gap-1.5 text-emerald-300">
- <CheckCircle2 size={13} aria-hidden="true" /> Done. {kwantName} is carrying on{view.status === 'open' ? '…' : '.'}
+ <CheckCircle2 size={13} className="shrink-0" aria-hidden="true" /> Done. {kwantName} is carrying on{view.status === 'open' ? '…' : '.'}
</span>
) : status === 'declined' ? (
<span className="inline-flex items-center gap-1.5 text-zinc-400">
- <MinusCircle size={13} aria-hidden="true" /> Skipped. {kwantName} continues without it.
+ <MinusCircle size={13} className="shrink-0" aria-hidden="true" /> Skipped. {kwantName} continues without it.
</span>
) : status === 'cancelled' ? (
<span className="inline-flex items-center gap-1.5 text-zinc-400">
- <MinusCircle size={13} aria-hidden="true" /> Closed: the reply was stopped.
+ <MinusCircle size={13} className="shrink-0" aria-hidden="true" /> Closed: the reply was stopped.
</span>
) : waiting ? (
<span className="inline-flex items-center gap-1.5 text-amber-300">
- <Clock size={13} aria-hidden="true" /> {kwantName} is paused and waiting for you.
+ <Clock size={13} className="shrink-0" aria-hidden="true" /> {kwantName} is paused and waiting for you.
</span>
) : captcha ? (
// The turn ended, but the step's watcher still resumes the bot once the puzzle clears.
// This one line also carries the privacy note, so there is no footer under it.
<span className="inline-flex items-center gap-1.5 text-zinc-400">
- <Clock size={13} aria-hidden="true" /> {kwantName} carries on by itself once it’s solved. Nothing you do there is passed to {kwantName}.
+ <Clock size={13} className="shrink-0" aria-hidden="true" /> {kwantName} carries on by itself once it’s solved. Nothing you do there is passed to {kwantName}.
</span>
) : (
<span className="inline-flex items-center gap-1.5 text-zinc-400">
- <Clock size={13} aria-hidden="true" /> {kwantName} stopped waiting. Press Done any time and it picks up in a new reply.
+ <Clock size={13} className="shrink-0" aria-hidden="true" /> {kwantName} stopped waiting. Press Done any time and it picks up in a new reply.
</span>
);
@@ -98,7 +98,7 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
<div className="px-4 pt-3 pb-2 space-y-1">
{/* One run of text, so on a phone it wraps like a sentence instead of into columns. */}
<p data-hs-meta="" className="text-[11px] font-medium text-zinc-400 leading-snug break-words">
- <Hand size={12} className="inline-block align-[-2px] mr-1.5 text-amber-300" aria-hidden="true" />
+ <Hand size={12} className="shrink-0 inline-block align-[-2px] mr-1.5 text-amber-300" aria-hidden="true" />
<span className="text-zinc-200">{kwantName}</span> needs you in the browser
{view.source === 'auto' && ' · spotted automatically'}
</p>
@@ -108,7 +108,7 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
{view.reason && <p className="text-sm text-zinc-300 whitespace-pre-wrap break-words leading-snug">{view.reason}</p>}
{domain && (
<p className="inline-flex items-center gap-1.5 text-xs text-zinc-400">
- <Globe size={12} aria-hidden="true" />
+ <Globe size={12} className="shrink-0" aria-hidden="true" />
<span className="font-mono text-zinc-200">{domain}</span>
</p>
)}
@@ -122,7 +122,7 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
onClick={() => onOpenBrowser(view.sandbox_target, true)}
className={`inline-flex items-center justify-center gap-2 min-h-[48px] sm:min-h-[38px] px-4 py-2 rounded-xl text-base sm:text-sm font-semibold bg-amber-400 text-zinc-950 hover:bg-amber-300 ${focusRing}`}
>
- <Puzzle size={16} aria-hidden="true" /> Solve it
+ <Puzzle size={16} className="shrink-0" aria-hidden="true" /> Solve it
</button>
)}
{onOpenBrowser && !captcha && (
@@ -131,7 +131,7 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
onClick={() => onOpenBrowser(view.sandbox_target, true)}
className={`inline-flex items-center justify-center gap-2 min-h-[48px] sm:min-h-[38px] px-4 py-2 rounded-xl text-base sm:text-sm font-semibold bg-amber-400 text-zinc-950 hover:bg-amber-300 ${focusRing}`}
>
- <MonitorPlay size={16} aria-hidden="true" /> Open browser
+ <MonitorPlay size={16} className="shrink-0" aria-hidden="true" /> Open browser
</button>
)}
<button
@@ -144,7 +144,7 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k
: 'font-semibold bg-amber-400 text-zinc-950 hover:bg-amber-300'
}`}
>
- {busy === 'done' ? <Loader2 size={14} className="animate-spin motion-reduce:animate-none" aria-hidden="true" /> : <CheckCircle2 size={14} aria-hidden="true" />}
+ {busy === 'done' ? <Loader2 size={14} className="shrink-0 animate-spin motion-reduce:animate-none" aria-hidden="true" /> : <CheckCircle2 size={14} className="shrink-0" aria-hidden="true" />}
{text.done}
</button>
<button
diff --git a/frontend/tests/humanSteps.test.mjs b/frontend/tests/humanSteps.test.mjs
index dbafb94b..868609d7 100644
--- a/frontend/tests/humanSteps.test.mjs
+++ b/frontend/tests/humanSteps.test.mjs
@@ -101,6 +101,36 @@ test('captcha card after the turn ended: one line, carries on by itself, not "st
assert.match(ui.render(props({ waiting: false, meta: h.parseHumanStepMeta(meta({ step_kind: 'sign_in' })) })), /stopped waiting\. Press Done any time/);
});
+test('card icons never shrink when a line wraps on a phone (shrink-0 on every icon)', () => {
+ const cap = (over = {}) => h.parseHumanStepMeta(meta({ step_kind: 'captcha', source: 'auto', ...over }));
+ const cards = {
+ 'captcha, turn ended': props({ waiting: false, meta: cap() }),
+ 'captcha, paused': props({ meta: cap() }),
+ 'captcha, solved': props({ meta: cap({ status: 'resolved_auto' }) }),
+ 'captcha, timed out': props({ meta: cap({ status: 'timed_out' }) }),
+ 'sign-in, stopped waiting': props({ waiting: false }),
+ 'sign-in, paused': props(),
+ 'done': props({ live: rec({ status: 'done' }) }),
+ 'skipped': props({ live: rec({ status: 'declined' }) }),
+ 'cancelled': props({ live: rec({ status: 'cancelled' }) }),
+ };
+ const seen = new Set();
+ for (const [name, p] of Object.entries(cards)) {
+ const html = ui.render(p);
+ const icons = [...html.matchAll(/<svg[^>]*class="([^"]*\blucide\b[^"]*)"/g)].map((m) => m[1]);
+ assert.ok(icons.length > 0, `${name}: has icons`);
+ for (const cls of icons) {
+ assert.match(cls, /(^|\s)shrink-0(\s|$)/, `${name}: ${cls}`);
+ seen.add(cls.match(/lucide-[a-z0-9-]+/g).pop());
+ }
+ // The status line icon is a flex child of a wrapping line: the one Rigel saw shrink to a dot
+ assert.match(html, /role="status"[^>]*><span class="inline-flex[^"]*"><svg[^>]*class="[^"]*\bshrink-0\b/, `${name}: status icon`);
+ }
+ for (const icon of ['lucide-clock', 'lucide-hand', 'lucide-globe', 'lucide-puzzle', 'lucide-monitor-play', 'lucide-circle-check', 'lucide-circle-minus']) {
+ assert.ok(seen.has(icon), `covered ${icon} (saw ${[...seen].join(', ')})`);
+ }
+});
+
test('captcha target: finite box only, kind defaults to puzzle', () => {
assert.deepEqual(h.parseCaptchaTarget({ x: 460, y: 180, width: 360, height: 380 }), { kind: 'puzzle', x: 460, y: 180, width: 360, height: 380 });
assert.equal(h.parseCaptchaTarget({ x: 1, y: 1, width: 0, height: 5 }), null);