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: only a file step's detail breaks at "/" (29l) (#835)

Oleksandr Ivanchenkob8bcda5cf229
diff --git a/frontend/src/activity.ts b/frontend/src/activity.ts
index 1986247d..5d8f338c 100644
--- a/frontend/src/activity.ts
+++ b/frontend/src/activity.ts
@@ -338,6 +338,14 @@ 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);
+/**
+ * 29l: whether a step is one of the built-in file tools (Read, Write, Edit, MultiEdit, NotebookEdit, any case), whose
+ * detail is a file path. Only these get 29i's path breaks: a shell step's detail is the whole command, which may start
+ * with a path ("/usr/bin/git status", "./gradlew test") and must wrap as it always did.
+ */
+const FILE_TOOLS = new Set(['read', 'write', 'edit', 'multiedit', 'notebookedit']);
+export const isFileStep = (step: Pick<ActivityStep, 'tool'>) => !!step.tool && FILE_TOOLS.has(step.tool.toLowerCase());
+
/**
* 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
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index 60fda991..8e1b1c6a 100644
--- a/frontend/src/components/ActivityList.tsx
+++ b/frontend/src/components/ActivityList.tsx
@@ -10,6 +10,7 @@ import {
shownStepCount,
foldAnswers,
formatDuration,
+ isFileStep,
isOpenStep,
pathBreakParts,
plainTitle,
@@ -230,7 +231,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'}`}
>
- <StepDetail text={step.detail} />
+ <StepDetail text={step.detail} path={isFileStep(step)} />
</pre>
</details>
) : (
@@ -240,9 +241,12 @@ 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);
+/**
+ * 29i: a path detail may break after each "/" (<wbr>), so the file name stays whole; any other detail is plain text.
+ * 29l: only a file step's detail (`path`) is read as a path; a command that starts with one renders as before 29i.
+ */
+const StepDetail: React.FC<{ text: string; path: boolean }> = ({ text, path }) => {
+ const parts = path ? pathBreakParts(text) : null;
if (!parts) return <>{text}</>;
return <>{parts.map((p, i) => <React.Fragment key={i}>{i > 0 && <wbr />}{p}</React.Fragment>)}</>;
};
diff --git a/frontend/tests/pathBreaksFileStepsOnly.test.mjs b/frontend/tests/pathBreaksFileStepsOnly.test.mjs
new file mode 100644
index 00000000..949e4f8d
--- /dev/null
+++ b/frontend/tests/pathBreaksFileStepsOnly.test.mjs
@@ -0,0 +1,69 @@
+// 29l (autonomy/path-breaks-file-steps-only/brief.md): 29i's path breaks (<wbr> after each "/") are for a file
+// step's detail only. A shell step's detail is the whole command, which may start like a path ("/usr/bin/git status",
+// "./gradlew test", "~/bin/x --flag"); it renders as plain text, as before 29i, so its wrap point doesn't move and
+// no lone "/" is left at a line end. The first test fails on 9cc2ec8f (#832).
+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, isFileStep } from './src/activity';
+ export const saved = (props) => renderToStaticMarkup(React.createElement(SavedActivityList, props));
+`);
+
+const at = (min) => new Date(Date.parse('2026-11-18T09:00:00Z') + min * 60000).toISOString();
+const step = (id, tool, t, detail) => ({
+ id, kind: 'tool', status: 'ok', title: `Step ${id}`, ...(tool ? { tool } : {}), detail,
+ started_at: at(t), ended_at: at(t + 0.5), duration_ms: 30000,
+});
+const pres = (steps) =>
+ [...m.saved({ activity: m.parseActivityMeta({ activity: { steps, dropped: 0 } }), idBase: 'r1', defaultOpen: true })
+ .matchAll(/<pre\b[^>]*>([\s\S]*?)<\/pre>/g)].map((x) => x[1]);
+const escaped = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;');
+const wbrs = (inner) => (inner.match(/<wbr\/?>/g) ?? []).length;
+
+const LONG = '/home/me/projects/spring-sale/drafts/spring-sale-plan.md';
+const COMMANDS = [
+ '/usr/bin/git status --short --untracked-files=all /home/me/projects/spring-sale',
+ './gradlew test',
+ '~/bin/x --flag',
+ '../scripts/run.sh /home/me/a.md',
+ 'C:\\Tools\\build.exe --out C:\\out',
+];
+
+test('a shell step whose command starts with a path renders as plain text, no <wbr> (fails on 9cc2ec8f)', () => {
+ for (const tool of ['Bash', 'bash', 'shell', 'exec_command', 'mcp__kwnt__run']) {
+ const r = pres(COMMANDS.map((c, i) => step(`${tool}${i}`, tool, i, c)));
+ COMMANDS.forEach((c, i) => assert.equal(r[i], escaped(c), `${tool}: ${c}`));
+ }
+});
+
+test('a step with no tool gets no <wbr> either', () => {
+ const r = pres([step('n', undefined, 0, LONG), step('c', undefined, 1, COMMANDS[0])]);
+ assert.equal(r[0], escaped(LONG));
+ assert.equal(r[1], escaped(COMMANDS[0]));
+});
+
+test('a Read, Write, Edit, MultiEdit or NotebookEdit step with a path still breaks after each "/", any case', () => {
+ const tools = ['Read', 'Write', 'Edit', 'MultiEdit', 'NotebookEdit', 'read', 'EDIT', 'multiedit'];
+ const r = pres(tools.map((t, i) => step(`f${i}`, t, i, LONG)));
+ tools.forEach((t, i) => {
+ assert.equal(wbrs(r[i]), 6, `${t}: ${r[i]}`);
+ assert.ok(r[i].endsWith('spring-sale-plan.md'), 'the file name stays one piece');
+ });
+ // In the same list, a command row next to a file row stays plain.
+ const mixed = pres([step('r', 'Read', 0, LONG), step('b', 'Bash', 1, COMMANDS[0])]);
+ assert.equal(wbrs(mixed[0]), 6);
+ assert.equal(mixed[1], escaped(COMMANDS[0]));
+});
+
+test('isFileStep knows the five file tools and nothing else', () => {
+ for (const t of ['Read', 'write', 'EDIT', 'MultiEdit', 'notebookedit']) assert.equal(m.isFileStep({ tool: t }), true, t);
+ for (const t of [undefined, '', 'Bash', 'Grep', 'Glob', 'WebFetch', 'Reader', 'mcp__x__read', 'read_file'])
+ assert.equal(m.isFileStep({ tool: t }), false, String(t));
+});