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.

30g ran-on-this-machine: Details' Ran on says "on this machine" for the built-in account (#873)

Oleksandr Ivanchenko34b843174528
diff --git a/frontend/src/modelUsage.ts b/frontend/src/modelUsage.ts
index dc4eee21..33cc63b2 100644
--- a/frontend/src/modelUsage.ts
+++ b/frontend/src/modelUsage.ts
@@ -1,6 +1,7 @@
// Per-bot model calls and tokens from `GET /api/kwants/:id/model-usage` (API-key, custom API and
// Claude CLI bots), per-day totals from `GET /api/usage/daily`, and the split on each reply.
import { request } from './threads';
+import { KIND_LABELS } from './profiles';
export type UsagePurpose = 'reply' | 'tool_round' | 'summary' | string;
@@ -156,10 +157,12 @@ export function replyCostWords(meta: string | null | undefined): { text: string;
return { text: parts.join(' · '), note };
}
-/** reply-chrome part 4: "Claude Sonnet 5.5, on your Work account" from ranOnLabel's "Claude · Sonnet 5.5" and the account. */
+/** reply-chrome part 4: "Claude Sonnet 5.5, on your Work account" from ranOnLabel's "Claude · Sonnet 5.5" and the account.
+ * The built-in account ("This machine", a CLI's own login) isn't one the person named: "Claude Opus 5.5, on this machine". */
export function ranOnWords(ranOn: string | null | undefined, account: string | null | undefined): string | null {
const model = ranOn ? ranOn.split(' · ').join(' ') : null;
const acct = account?.trim();
+ if (acct && acct.toLowerCase() === KIND_LABELS.system.toLowerCase()) return model ? `${model}, on this machine` : KIND_LABELS.system;
if (!model) return acct ? (/account$/i.test(acct) ? `Your ${acct}` : `The ${acct} account`) : null;
if (!acct) return model;
return /account$/i.test(acct) ? `${model}, on your ${acct}` : `${model}, on the ${acct} account`;
diff --git a/frontend/tests/replyChrome.test.mjs b/frontend/tests/replyChrome.test.mjs
index 5cb97aa1..6f752b8b 100644
--- a/frontend/tests/replyChrome.test.mjs
+++ b/frontend/tests/replyChrome.test.mjs
@@ -236,6 +236,27 @@ test('ranOnWords: "Claude Sonnet 5.5, on your Work account"', () => {
assert.equal(m.ranOnWords(null, null), null);
});
+test('ranOnWords: the built-in account reads "on this machine", named accounts keep their wording', () => {
+ assert.equal(m.ranOnWords('Claude · Opus 5.5', 'This machine'), 'Claude Opus 5.5, on this machine');
+ assert.equal(m.ranOnWords('Claude · Opus 5.5', ' this machine '), 'Claude Opus 5.5, on this machine');
+ assert.equal(m.ranOnWords('Codex', 'THIS MACHINE'), 'Codex, on this machine');
+ assert.equal(m.ranOnWords(null, 'This machine'), 'This machine');
+ assert.doesNotMatch(m.ranOnWords('Claude · Opus 5.5', 'This machine'), /This machine account/);
+ assert.equal(m.ranOnWords('Claude · Opus 5.5', 'Work'), 'Claude Opus 5.5, on the Work account');
+ assert.equal(m.ranOnWords('Claude · Opus 5.5', 'Work account'), 'Claude Opus 5.5, on your Work account');
+ assert.equal(m.ranOnWords('Claude · Opus 5.5', 'This machine 2'), 'Claude Opus 5.5, on the This machine 2 account');
+ assert.equal(m.ranOnWords(null, 'Work'), 'The Work account');
+});
+
+test('ReplyMeta: Details Ran on for a CLI reply on the built-in account reads "on this machine"', async () => {
+ const { host, unmount } = mount(ui.ReplyMeta, { name: 'Mia', ranOn: 'Claude · Opus 5.5', account: 'This machine' });
+ await click([...host.querySelectorAll('button')].find((b) => /Details/.test(b.textContent)));
+ const rows = [...host.querySelectorAll('[data-reply-details] dt')].map((dt) => [dt.textContent, dt.nextElementSibling.textContent]);
+ assert.deepEqual(rows.find(([k]) => k === 'Ran on'), ['Ran on', 'Claude Opus 5.5, on this machine']);
+ assert.doesNotMatch(host.textContent, /This machine account/);
+ unmount();
+});
+
test('replyCostWords: cost and new work, cache reads as a note; never "fresh" or "cache"', () => {
const meta = (u) => JSON.stringify({ usage: u });
const full = m.replyCostWords(meta({ fresh_input: 9120, cache_write: 1880, output: 812, cache_read: 38400, cost_usd: 0.0412 }));