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: every engine's file step wraps its path at a folder; phone ring clears the ✓ (29m) (#837)

Oleksandr Ivanchenko4ae49b8f99b5
diff --git a/frontend/src/activity.ts b/frontend/src/activity.ts
index 5d8f338c..00bcb43a 100644
--- a/frontend/src/activity.ts
+++ b/frontend/src/activity.ts
@@ -339,12 +339,27 @@ export const plainTitle = (t: string) => t.replace(/`([^`]*)`/g, '$1');
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.
+ * 29l/29m: whether a step is a file tool, 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. The list is the server's one list, `FileTool::of` (src/drivers/activity.rs), so Codex, grok and MCP
+ * file steps count too; keep the two in step. Like the server's `tool_part`, an `mcp__<server>__` prefix is dropped
+ * (strip "mcp__", then split once at the first "__") and the name is lowercased, so `mcp__kwnt__read_file` is a file step.
*/
-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());
+const FILE_TOOLS = new Set([
+ // FileTool::Read
+ 'read', 'read_file', 'view', 'cat',
+ // FileTool::Edit
+ 'edit', 'multiedit', 'edit_file', 'str_replace', 'str_replace_based_edit_tool', 'apply_patch', 'file_change', 'notebookedit',
+ // FileTool::Write
+ 'write', 'write_file', 'create_file',
+]);
+const toolPart = (name: string) => {
+ const rest = name.startsWith('mcp__') ? name.slice(5) : null;
+ const at = rest?.indexOf('__') ?? -1;
+ return rest !== null && at >= 0 ? rest.slice(at + 2) : name;
+};
+export const isFileStep = (step: Pick<ActivityStep, 'tool'>) =>
+ !!step.tool && FILE_TOOLS.has(toolPart(step.tool).toLowerCase());
/**
* 29i: a single-line detail that is a file path, split after each "/" or "\" (["/", "home/", "me/", "plan.md"]), so
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index 8e1b1c6a..aa44c4ea 100644
--- a/frontend/src/components/ActivityList.tsx
+++ b/frontend/src/components/ActivityList.tsx
@@ -220,8 +220,10 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
// 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. 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.
+ // 29m: -mx-0.5 px-0.5 widens the summary by 2 px each side without moving its content, so that inset ring
+ // clears the ✓ again (Mira's 29i design check).
<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 [@media(max-width:767px)_and_(pointer:coarse)]:focus-visible:-outline-offset-2">
+ <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 [@media(max-width:767px)_and_(pointer:coarse)]:-mx-0.5 [@media(max-width:767px)_and_(pointer:coarse)]:px-0.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>
diff --git a/frontend/tests/fileStepsEveryEngine.test.mjs b/frontend/tests/fileStepsEveryEngine.test.mjs
new file mode 100644
index 00000000..df6ee3b6
--- /dev/null
+++ b/frontend/tests/fileStepsEveryEngine.test.mjs
@@ -0,0 +1,79 @@
+// 29m (autonomy/file-steps-every-engine/brief.md): every engine's file step wraps its path at a folder, not only
+// Claude's. isFileStep uses the server's one list (FileTool::of, src/drivers/activity.rs) and drops an
+// `mcp__<server>__` prefix the way the server's tool_part does. And on a touch phone the step summary is 2 px wider
+// each side (-mx-0.5 px-0.5), so its inset focus ring clears the ✓. Both tests fail on b7d44d03 (#835).
+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-18T10: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 html = (steps) =>
+ m.saved({ activity: m.parseActivityMeta({ activity: { steps, dropped: 0 } }), idBase: 'r1', defaultOpen: true });
+const pres = (steps) => [...html(steps).matchAll(/<pre\b[^>]*>([\s\S]*?)<\/pre>/g)].map((x) => x[1]);
+const escaped = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+const wbrs = (inner) => (inner.match(/<wbr\/?>/g) ?? []).length;
+
+const LONG = '/home/me/projects/spring-sale/drafts/spring-sale-plan.md';
+const ENGINE_FILE_TOOLS = [
+ 'apply_patch', 'read_file', 'edit_file', 'create_file', 'str_replace_based_edit_tool',
+ 'mcp__kwnt__read_file', 'mcp__fs__write_file',
+ 'view', 'cat', 'str_replace', 'file_change', 'write_file', 'Read_File', 'mcp__kwnt__Edit',
+];
+
+test("Codex, grok and MCP file steps break their path after each '/' (fails on b7d44d03)", () => {
+ const r = pres(ENGINE_FILE_TOOLS.map((t, i) => step(`f${i}`, t, i, LONG)));
+ ENGINE_FILE_TOOLS.forEach((t, i) => {
+ assert.equal(wbrs(r[i]), 6, `${t}: ${r[i]}`);
+ assert.equal(r[i].replace(/<wbr\/?>/g, ''), LONG, `${t}: the copied text is the path`);
+ assert.ok(r[i].endsWith('spring-sale-plan.md'), `${t}: the file name stays one piece`);
+ });
+});
+
+test('a non-file MCP tool, Bash or Glob step with a path-like detail stays plain', () => {
+ const tools = ['mcp__x__run', 'mcp__kwnt__run', 'Bash', 'Glob', 'exec_command', 'mcp__read_file', 'mcp__fs__'];
+ const r = pres(tools.map((t, i) => step(`p${i}`, t, i, LONG)));
+ tools.forEach((t, i) => assert.equal(r[i], escaped(LONG), t));
+});
+
+test('isFileStep matches the server FileTool list after dropping mcp__<server>__', () => {
+ const server = ['read', 'read_file', 'view', 'cat', 'edit', 'multiedit', 'edit_file', 'str_replace',
+ 'str_replace_based_edit_tool', 'apply_patch', 'file_change', 'notebookedit', 'write', 'write_file', 'create_file'];
+ for (const t of server) {
+ for (const name of [t, t.toUpperCase(), `mcp__kwnt__${t}`, `mcp__some_server__${t}`])
+ assert.equal(m.isFileStep({ tool: name }), true, name);
+ }
+ // tool_part: only a leading "mcp__" is dropped, then everything up to the first "__"; with no second "__" the
+ // whole name is used, as on the server.
+ for (const t of [undefined, '', 'Bash', 'Grep', 'Glob', 'WebFetch', 'Reader', 'shell', 'exec_command',
+ 'mcp__kwnt__run', 'mcp__read_file', 'x__read_file', 'MCP__kwnt__read', 'readfile', 'read_files'])
+ assert.equal(m.isFileStep({ tool: t }), false, String(t));
+});
+
+test('on a touch phone the step summary is 2 px wider each side so its ring clears the ✓ (fails on b7d44d03)', () => {
+ const summary = html([step('s', 'Read', 0, LONG)]).match(/<summary\b[^>]*class="([^"]*)"/)?.[1] ?? '';
+ const cls = summary.split(/\s+/);
+ for (const c of [
+ '[@media(max-width:767px)_and_(pointer:coarse)]:-mx-0.5',
+ '[@media(max-width:767px)_and_(pointer:coarse)]:px-0.5',
+ // 29e/29i stay as they were.
+ '[@media(max-width:767px)_and_(pointer:coarse)]:-my-1.5',
+ '[@media(max-width:767px)_and_(pointer:coarse)]:py-1.5',
+ '[@media(max-width:767px)_and_(pointer:coarse)]:focus-visible:-outline-offset-2',
+ ]) assert.ok(cls.includes(c), `${c} in ${summary}`);
+ // No horizontal padding at desktop/pointer widths: the summary's own content doesn't move there.
+ assert.ok(!cls.some((c) => /^-?(mx|px)-/.test(c)), summary);
+});
diff --git a/frontend/tests/pathBreaksFileStepsOnly.test.mjs b/frontend/tests/pathBreaksFileStepsOnly.test.mjs
index 949e4f8d..3ae2da6b 100644
--- a/frontend/tests/pathBreaksFileStepsOnly.test.mjs
+++ b/frontend/tests/pathBreaksFileStepsOnly.test.mjs
@@ -62,8 +62,11 @@ test('a Read, Write, Edit, MultiEdit or NotebookEdit step with a path still brea
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'])
+// 29m: isFileStep now uses the server's FileTool list, so read_file and mcp__x__read are file steps
+// (fileStepsEveryEngine.test.mjs); shell, search and web tools stay out.
+test('isFileStep knows the file tools and not shell, search or web tools', () => {
+ for (const t of ['Read', 'write', 'EDIT', 'MultiEdit', 'notebookedit', 'read_file', 'mcp__x__read'])
+ assert.equal(m.isFileStep({ tool: t }), true, t);
+ for (const t of [undefined, '', 'Bash', 'Grep', 'Glob', 'WebFetch', 'Reader', 'mcp__kwnt__run', 'exec_command', 'shell'])
assert.equal(m.isFileStep({ tool: t }), false, String(t));
});