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.

30e: Details stops repeating the CLI run line as reasoning; effort moves next to Ran on (#872)

Oleksandr Ivanchenkoc0a0e0baa09c
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index 71a95a9a..13995a61 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -45,6 +45,7 @@ import { BrowsedChip } from './BrowsedChip';
import { pagesOfReply, type ReplyPage } from '../browserPages';
import { ReplyCheckLine } from './ReplyCheckLine';
import { replyOutcome } from '../replyOutcome';
+import { effortWords, isCliRunLine } from '../reasoningEcho';
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';
@@ -1903,6 +1904,7 @@ export const ChatView: React.FC<ChatViewProps> = ({
avatar={<span className={routed && freshTrack.current.fresh.has(msg.id) ? 'kws-handoff inline-flex' : 'inline-flex'}><ModernAvatar role={title} name={displayName} size={REPLY_AVATAR_PHONE} kwantId={replyKwantId} modelBadge={false} /></span>}
ranOn={ranOn}
account={account}
+ effort={effortWords(msg.reasoning_content)}
tokens={tokens}
cost={cost}
done={done}
@@ -1946,7 +1948,8 @@ export const ChatView: React.FC<ChatViewProps> = ({
)}
{/* Collapsible Reasoning Disclosure (the steps above already hold the thinking when they have it) */}
- {msg.reasoning_content && !hasThinkingText(savedActivity) && (
+ {/* 30e: a CLI reply's only "reasoning" is its run line, which Ran on already says; its effort moves there */}
+ {msg.reasoning_content && !isCliRunLine(msg.reasoning_content) && !hasThinkingText(savedActivity) && (
<div className="mb-2 max-w-full">
<button
type="button"
diff --git a/frontend/src/components/ReplyMeta.tsx b/frontend/src/components/ReplyMeta.tsx
index c6ae5d35..017d4676 100644
--- a/frontend/src/components/ReplyMeta.tsx
+++ b/frontend/src/components/ReplyMeta.tsx
@@ -13,6 +13,8 @@ export interface ReplyFacts {
/** "Claude · Opus 5.5": the engine and model the reply ran on. */
ranOn?: string | null;
account?: string | null;
+ /** 30e: a CLI reply's effort in words ("medium effort"), shown after Ran on; never invented when absent. */
+ effort?: string | null;
tokens?: { label: string; detail: string } | null;
/** Details' Cost row in words (replyCostWords); `tokens.detail` is its tooltip. */
cost?: { text: string; note: string | null } | null;
@@ -68,7 +70,7 @@ export const FailoverNote: React.FC<{ text: string }> = ({ text }) => (
const hasContent = (n: React.ReactNode) => React.Children.toArray(n).length > 0;
/** A bot reply's header: one line, "Name · [Done] · 3:42 PM · Details", and a Details toggle holding the rest in words. */
-export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, account, tokens, cost, failed = false, outcome, openRequest, note, route, done, handoff, now, sentToTelegram = false, children }) => {
+export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, account, effort, tokens, cost, failed = false, outcome, openRequest, note, route, done, handoff, now, sentToTelegram = false, children }) => {
const [open, setOpen] = useState(false);
useEffect(() => {
if (openRequest) setOpen(true);
@@ -89,7 +91,8 @@ export const ReplyMeta: React.FC<ReplyMetaProps> = ({ name, at, avatar, ranOn, a
</>,
]);
const ran = ranOnWords(ranOn, account);
- if (ran) facts.push(['Ran on', ran]);
+ if (ran) facts.push(['Ran on', effort ? `${ran} · ${effort}` : ran]);
+ else if (effort) facts.push(['Effort', effort]);
if (cost)
facts.push([
'Cost',
diff --git a/frontend/src/reasoningEcho.ts b/frontend/src/reasoningEcho.ts
new file mode 100644
index 00000000..17e0c196
--- /dev/null
+++ b/frontend/src/reasoningEcho.ts
@@ -0,0 +1,23 @@
+// 30e (autonomy/details-no-echo-reasoning/brief.md): a CLI reply saves "Executed via claude CLI · This machine
+// [Effort: medium]" as its reasoning (src/drivers/cli.rs executed_via). It repeats Details' "Ran on" row and reads like
+// thinking to open when there is none, so Details hides it and keeps only the effort, in words, next to Ran on.
+
+/** The whole of a CLI run line: one line, nothing before or after. */
+const CLI_RUN_LINE = /^Executed via .+ CLI · .+ \[Effort: ([^\]]+)\]$/;
+
+/** The run line's effort when the reasoning is only that line, else null (real reasoning, or more than one line). */
+export function cliRunLineEffort(reasoning: string | null | undefined): string | null {
+ const text = reasoning?.trim();
+ if (!text || text.includes('\n')) return null;
+ const m = CLI_RUN_LINE.exec(text);
+ return m ? m[1].trim() : null;
+}
+
+/** Whether the reasoning is only the CLI run line, so there is nothing to open. */
+export const isCliRunLine = (reasoning: string | null | undefined): boolean => cliRunLineEffort(reasoning) !== null;
+
+/** The effort in plain words for "Ran on": "medium effort". Null when the line didn't carry one. */
+export function effortWords(reasoning: string | null | undefined): string | null {
+ const effort = cliRunLineEffort(reasoning);
+ return effort ? `${effort.toLowerCase()} effort` : null;
+}
diff --git a/frontend/tests/detailsNoEchoReasoning.test.mjs b/frontend/tests/detailsNoEchoReasoning.test.mjs
new file mode 100644
index 00000000..7b585fb5
--- /dev/null
+++ b/frontend/tests/detailsNoEchoReasoning.test.mjs
@@ -0,0 +1,97 @@
+// 30e (autonomy/details-no-echo-reasoning/brief.md): a CLI reply's only "reasoning" is its run line,
+// "Executed via claude CLI · This machine [Effort: medium]" (src/drivers/cli.rs executed_via). Details stops showing it
+// as a reasoning disclosure and keeps the effort in words next to Ran on. Real reasoning shows as before.
+// Every test here fails on main 7f76f171 / bd8740d1 (no src/reasoningEcho.ts, no effort on ReplyMeta).
+process.env.TZ = 'UTC';
+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/', pretendToBeVisual: true });
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Node', 'Event', 'MouseEvent', 'KeyboardEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'localStorage', 'sessionStorage']) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(globalThis, k, { value: dom.window[k], configurable: true, writable: true });
+}
+globalThis.IS_REACT_ACT_ENVIRONMENT = false;
+
+let m = {};
+let loadError = null;
+try {
+ m = await loadBundled(`
+ import React from 'react';
+ import { flushSync } from 'react-dom';
+ export { createRoot } from 'react-dom/client';
+ export { ReplyMeta } from './src/components/ReplyMeta';
+ export { cliRunLineEffort, isCliRunLine, effortWords } from './src/reasoningEcho';
+ export { React, flushSync };
+ `);
+} catch (e) {
+ loadError = e;
+}
+const need = () => assert.equal(loadError, null, `src/reasoningEcho.ts loads (${loadError?.message?.split('\n')[0]})`);
+
+const CLI = 'Executed via claude CLI · This machine [Effort: medium]';
+
+test('the CLI run line alone is hidden; its effort is kept', () => {
+ need();
+ assert.equal(m.isCliRunLine(CLI), true);
+ assert.equal(m.isCliRunLine(` ${CLI}\n`), true, 'surrounding whitespace is still just the line');
+ assert.equal(m.isCliRunLine('Executed via codex CLI · Work account [Effort: high]'), true);
+ assert.equal(m.cliRunLineEffort(CLI), 'medium');
+ assert.equal(m.effortWords(CLI), 'medium effort');
+ assert.equal(m.effortWords('Executed via grok CLI · The Team account [Effort: High]'), 'high effort');
+});
+
+test('real reasoning, a multi-line text and an API reply’s reasoning still show', () => {
+ need();
+ const shows = [
+ 'I compared both prices and picked the cheaper shop.',
+ `${CLI}\nThen I read the file and found the bug.`,
+ `Thinking first.\n${CLI}`,
+ '🔮 The user wants a short answer, so I keep it to two lines.',
+ 'Executed via claude CLI · This machine',
+ 'Executed via claude CLI · This machine [Effort: medium] and then more',
+ '',
+ null,
+ undefined,
+ ];
+ for (const r of shows) {
+ assert.equal(m.isCliRunLine(r), false, JSON.stringify(r));
+ assert.equal(m.effortWords(r), null, `no effort is invented for ${JSON.stringify(r)}`);
+ }
+});
+
+const mount = (props) => {
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = m.createRoot(host);
+ m.flushSync(() => root.render(m.React.createElement(m.ReplyMeta, props)));
+ return { host, unmount: () => (root.unmount(), host.remove()) };
+};
+const tick = () => new Promise((r) => setTimeout(r, 0));
+const openDetails = async (host) => {
+ const toggle = [...host.querySelectorAll('button')].find((b) => /Details/.test(b.textContent));
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ await tick();
+ await tick();
+ const panel = host.querySelector('[data-reply-details]');
+ return Object.fromEntries([...panel.querySelectorAll('dt')].map((dt) => [dt.textContent, dt.nextElementSibling.textContent]));
+};
+
+test('Details: Ran on carries the effort in words; without one it reads as before', async () => {
+ need();
+ const withEffort = mount({ name: 'Mia', ranOn: 'Claude · Opus 5.5', account: null, effort: m.effortWords(CLI) });
+ assert.equal((await openDetails(withEffort.host))['Ran on'], 'Claude Opus 5.5 · medium effort');
+ withEffort.unmount();
+ const api = mount({ name: 'Mia', ranOn: 'Claude · Opus 5.5', account: 'Work account', effort: m.effortWords('I thought about it.') });
+ assert.equal((await openDetails(api.host))['Ran on'], 'Claude Opus 5.5, on your Work account');
+ api.unmount();
+});
+
+test('ChatView hides the disclosure only for the run line and passes the effort to ReplyMeta', () => {
+ const src = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');
+ assert.match(src, /\{msg\.reasoning_content && !isCliRunLine\(msg\.reasoning_content\) && !hasThinkingText\(savedActivity\) && \(/);
+ assert.match(src, /effort=\{effortWords\(msg\.reasoning_content\)\}/);
+});