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.

Steps: the phone focus ring sits inside the row; a path detail breaks at "/" (29i) (#832)

Oleksandr Ivanchenko3efe44f9b3b9
diff --git a/frontend/src/activity.ts b/frontend/src/activity.ts
index 5d9cb48f..1986247d 100644
--- a/frontend/src/activity.ts
+++ b/frontend/src/activity.ts
@@ -337,3 +337,15 @@ export const plainTitle = (t: string) => t.replace(/`([^`]*)`/g, '$1');
/** Whether the saved activity has thinking text, so the old reasoning block would repeat it. */
export const hasThinkingText = (a: SavedActivity | null) => !!a?.steps.some((s) => s.kind === 'thinking' && s.text);
+
+/**
+ * 29i: a single-line detail that is a file path, split after each "/" or "\" (["/", "home/", "me/", "plan.md"]), so
+ * StepRow can put a <wbr> between the parts and a long path breaks at a folder, not inside the file name. Null for
+ * every other detail (commands, URLs, errors, more than one line), which renders exactly as before. Joining the parts
+ * gives back the detail, so the text a person copies is unchanged.
+ */
+export function pathBreakParts(detail: string): string[] | null {
+ if (!/^(\/|~\/|\.\.?\/|[A-Za-z]:[\\/])/.test(detail) || /[\r\n]/.test(detail)) return null;
+ const parts = detail.match(/[^/\\]*(?:[/\\]+|$)/g)?.filter(Boolean) ?? [];
+ return parts.length > 1 ? parts : null;
+}
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index 7c819fbc..60fda991 100644
--- a/frontend/src/components/ActivityList.tsx
+++ b/frontend/src/components/ActivityList.tsx
@@ -11,6 +11,7 @@ import {
foldAnswers,
formatDuration,
isOpenStep,
+ pathBreakParts,
plainTitle,
shownStatus,
statusLabel,
@@ -216,9 +217,10 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
>
{step.detail ? (
// 29e: on a touch phone the 44 px summary takes in the li's py-1.5 (-my-1.5 py-1.5), so a row with › is 44 px
- // like the rows without, not 56, and its tap area stays 44 px.
+ // like the rows without, not 56, and its tap area stays 44 px. 29i: there its ring sits inside (-outline-offset-2,
+ // like the li's), so the list's overflow-hidden doesn't clip it and it doesn't cross an open row's output.
<details className="group" open={opened || undefined}>
- <summary className="flex items-start [@media(max-width:767px)_and_(pointer:coarse)]:items-center [@media(max-width:767px)_and_(pointer:coarse)]:-my-1.5 [@media(max-width:767px)_and_(pointer:coarse)]:py-1.5 gap-2 cursor-pointer list-none rounded [&::-webkit-details-marker]:hidden focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400">
+ <summary className="flex items-start [@media(max-width:767px)_and_(pointer:coarse)]:items-center [@media(max-width:767px)_and_(pointer:coarse)]:-my-1.5 [@media(max-width:767px)_and_(pointer:coarse)]:py-1.5 gap-2 cursor-pointer list-none rounded [&::-webkit-details-marker]:hidden focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 [@media(max-width:767px)_and_(pointer:coarse)]:focus-visible:-outline-offset-2">
{head}
<ChevronRight size={13} className="mt-px flex-shrink-0 text-zinc-400 transition-transform motion-reduce:transition-none group-open:rotate-90" aria-hidden="true" />
</summary>
@@ -228,7 +230,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
step.status === 'declined' ? 'font-sans text-xs' : 'font-mono text-[11px]'
} ${step.status === 'failed' ? 'text-rose-200 bg-rose-950/30 border-rose-500/20' : 'text-zinc-300 bg-zinc-950/80 border-zinc-800'}`}
>
- {step.detail}
+ <StepDetail text={step.detail} />
</pre>
</details>
) : (
@@ -238,6 +240,13 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
);
};
+/** 29i: a path detail may break after each "/" (<wbr>), so the file name stays whole; any other detail is plain text. */
+const StepDetail: React.FC<{ text: string }> = ({ text }) => {
+ const parts = pathBreakParts(text);
+ if (!parts) return <>{text}</>;
+ return <>{parts.map((p, i) => <React.Fragment key={i}>{i > 0 && <wbr />}{p}</React.Fragment>)}</>;
+};
+
const Steps: React.FC<{ steps: ActivityStep[]; live?: LiveActivity; dropped?: number; id: string; openStep?: string | null }> = ({ steps, live, dropped = 0, id, openStep = null }) => {
const now = useNow(steps.some(isOpenStep));
// 28s: one row per answer. A settled card folds into its command row; draw time only.
diff --git a/frontend/tests/stepRowRingAndPath.test.mjs b/frontend/tests/stepRowRingAndPath.test.mjs
new file mode 100644
index 00000000..c0d84174
--- /dev/null
+++ b/frontend/tests/stepRowRingAndPath.test.mjs
@@ -0,0 +1,92 @@
+// 29i (autonomy/step-row-ring-and-path/brief.md), two of Mira's calls on the same StepRow:
+// (1) since 29e a touch-phone summary reaches its li's top and bottom edges, so its focus ring must sit inside
+// (-outline-offset-2, like the li's own ring), or the list's overflow-hidden clips it and it crosses an open
+// row's output.
+// (2) a single-line path detail may break after each "/" (<wbr>), so the file name stays whole; every other detail
+// renders exactly as before, and the text a person copies is the detail itself.
+// Every test here fails on fa47a67b (#827).
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { SavedActivityList } from './src/components/ActivityList';
+ export { parseActivityMeta } from './src/activity';
+ export const saved = (props) => renderToStaticMarkup(React.createElement(SavedActivityList, props));
+`);
+
+const PHONE = '[@media(max-width:767px)_and_(pointer:coarse)]:';
+const at = (min) => new Date(Date.parse('2026-11-18T09:00:00Z') + min * 60000).toISOString();
+const step = (id, title, t, detail, extra = {}) => ({
+ id, kind: 'tool', status: 'ok', title, tool: 'Read', started_at: at(t), ended_at: at(t + 0.5), duration_ms: 30000,
+ ...(detail ? { detail } : {}), ...extra,
+});
+const render = (steps) =>
+ m.saved({ activity: m.parseActivityMeta({ activity: { steps, dropped: 0 } }), idBase: 'r1', defaultOpen: true });
+
+/** Each step row's summary class and the inner HTML of its detail <pre>, in order. */
+function rows(html) {
+ return [...html.matchAll(/<li\b[^>]*\bdata-step-status="[^"]*"[^>]*>([\s\S]*?)<\/li>/g)].map((li) => ({
+ summary: /<summary\b[^>]*class="([^"]*)"/.exec(li[1])?.[1] ?? null,
+ pre: /<pre\b[^>]*>([\s\S]*?)<\/pre>/.exec(li[1])?.[1] ?? null,
+ }));
+}
+const ENT = { '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&#x27;': "'", '&#39;': "'" };
+/** The text a person copies from the pre: tags dropped (<wbr> adds no characters), entities decoded. */
+const copied = (inner) => inner.replace(/<[^>]*>/g, '').replace(/&(?:amp|lt|gt|quot|#x27|#39);/g, (e) => ENT[e]);
+const escaped = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;');
+
+const LONG = '/home/me/projects/spring-sale/drafts/spring-sale-plan.md';
+
+test('a touch-phone step summary keeps its focus ring inside the row (fails on fa47a67b)', () => {
+ const r = rows(render([step('a', 'Read plan', 0, LONG), step('b', 'Read b', 1)]));
+ const toks = r[0].summary.split(/\s+/);
+ assert.ok(toks.includes(`${PHONE}focus-visible:-outline-offset-2`), r[0].summary);
+ // Desktop keeps its ring as it was: no unprefixed offset, and the 29e pair is untouched.
+ assert.ok(!toks.some((t) => /^focus-visible:-?outline-offset/.test(t)), 'desktop ring unchanged');
+ for (const t of ['focus-visible:outline', 'focus-visible:outline-2', 'focus-visible:outline-sky-400', `${PHONE}-my-1.5`, `${PHONE}py-1.5`])
+ assert.ok(toks.includes(t), t);
+});
+
+test('a path detail can break after each separator, and copies as the same text (fails on fa47a67b)', () => {
+ const paths = [
+ [LONG, 6],
+ ['~/notes/today.md', 2],
+ ['./src/a b/c.ts', 3],
+ ['../up/x.txt', 2],
+ ['C:\\Users\\me\\Desk top\\plan.docx', 4],
+ ['D:/work/plan.md', 2],
+ ];
+ const r = rows(render(paths.map(([p], i) => step(`p${i}`, `Read ${i}`, i, p))));
+ paths.forEach(([p, seps], i) => {
+ const inner = r[i].pre;
+ assert.equal((inner.match(/<wbr\/?>/g) ?? []).length, seps, `${p}: ${inner}`);
+ assert.equal(copied(inner), p, 'copied text is the detail');
+ // Each break comes right after a separator, never inside a name.
+ for (const piece of inner.split(/<wbr\/?>/).slice(0, -1)) assert.match(copied(piece), /[/\\]$/, `${p}: ${piece}`);
+ });
+ // The file name is one piece.
+ assert.ok(r[0].pre.endsWith('spring-sale-plan.md'), r[0].pre);
+});
+
+test('every other detail renders exactly as before (fails on fa47a67b only through the path rows)', () => {
+ const others = [
+ 'built in 4.1s',
+ 'https://example.com/a/b/c.html',
+ 'npm run build && cp dist/a.js /tmp/a.js',
+ '/home/me/a.md\n/home/me/b.md',
+ 'Error: ENOENT: no such file, open /home/me/x.md',
+ '/',
+ 'You said no: not this folder <yet>',
+ ];
+ const html = render([...others.map((d, i) => step(`o${i}`, `Step ${i}`, i, d)), step('p', 'Read', 9, LONG)]);
+ const r = rows(html);
+ others.forEach((d, i) => assert.equal(r[i].pre, escaped(d), JSON.stringify(d)));
+ assert.match(r[others.length].pre, /<wbr\/?>/, 'and the path row in the same list does break');
+ // The pre keeps overflow-wrap:anywhere as the fallback for a segment longer than the line.
+ assert.match(html, /<pre\b[^>]*\[overflow-wrap:anywhere\]/);
+});