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.

Engines UI: match final ran_on contract and disabled status

Pixel (kwant bot)9685cd83cba8
diff --git a/frontend/src/engines.ts b/frontend/src/engines.ts
index 93f5e931..d5714b1a 100644
--- a/frontend/src/engines.ts
+++ b/frontend/src/engines.ts
@@ -3,7 +3,7 @@
export type EngineId = 'claude' | 'codex' | 'grok' | 'anthropic_api' | 'openai_api' | 'xai_api' | 'ollama';
export type EngineKind = 'cli' | 'api' | 'local';
-export type EngineStatus = 'ready' | 'signed_out' | 'not_installed' | 'error' | 'checking';
+export type EngineStatus = 'ready' | 'signed_out' | 'not_installed' | 'error' | 'checking' | 'disabled';
export type Tier = 'fast' | 'balanced' | 'deep';
export interface EngineModel {
@@ -52,7 +52,7 @@ export const familyLabel = (f: Family) => FAMILIES.find((x) => x.id === f)?.labe
export type Tone = 'ok' | 'warn' | 'error' | 'muted' | 'busy';
export function statusView(e: Pick<EngineInfo, 'status' | 'enabled'> & { kind?: EngineKind }): { label: string; tone: Tone } {
- if (e.enabled === false) return { label: 'Off', tone: 'muted' };
+ if (e.enabled === false || e.status === 'disabled') return { label: 'Off', tone: 'muted' };
switch (e.status) {
case 'ready':
return { label: 'Ready', tone: 'ok' };
@@ -70,7 +70,7 @@ export function statusView(e: Pick<EngineInfo, 'status' | 'enabled'> & { kind?:
export const isUsable = (e: EngineInfo) => e.status === 'ready' && e.enabled !== false;
-const RANK: Record<EngineStatus, number> = { ready: 0, checking: 1, error: 2, signed_out: 3, not_installed: 5 };
+const RANK: Record<EngineStatus, number> = { ready: 0, checking: 1, error: 2, signed_out: 3, disabled: 4, not_installed: 5 };
/** Ready first, then ones that need attention, switched-off ones, and not installed last. Stable. */
export function sortEngines(list: EngineInfo[]): EngineInfo[] {
@@ -228,6 +228,12 @@ export function pickLabel(value: string, engines: EngineInfo[] | null = null): s
return `${family} · ${known?.label ?? pick.model}`;
}
+/** "Claude Haiku (latest)" → "Haiku" when shown after the family name. */
+function shortModelLabel(label: string, family: string): string {
+ const out = label.replace(/\s*\(latest\)$/i, '');
+ return out.toLowerCase().startsWith(family.toLowerCase() + ' ') ? out.slice(family.length + 1) : out;
+}
+
/** "Claude · Sonnet" for a reply, from the `ran_on` the server adds to a message's meta. */
export function ranOnLabel(meta: string | null | undefined, engines: EngineInfo[] | null = null): string | null {
if (!meta) return null;
@@ -235,7 +241,7 @@ export function ranOnLabel(meta: string | null | undefined, engines: EngineInfo[
const ran = JSON.parse(meta)?.ran_on;
if (!ran || typeof ran.engine !== 'string') return null;
const engine = ran.engine as EngineId;
- const family = FAMILY_OF[engine];
+ const family: Family | undefined = FAMILIES.some((f) => f.id === ran.family) ? ran.family : FAMILY_OF[engine];
const name = family ? familyLabel(family).replace(/ \(.*\)$/, '') : engine;
if (typeof ran.model !== 'string' || !ran.model) return name;
const label = typeof ran.model_label === 'string' && ran.model_label
@@ -243,7 +249,7 @@ export function ranOnLabel(meta: string | null | undefined, engines: EngineInfo[
: [...(engines?.filter((e) => e.id === engine) ?? []), ...(engines?.filter((e) => e.id !== engine && FAMILY_OF[e.id] === family) ?? [])]
.flatMap((e) => e.models)
.find((m) => m.id === ran.model)?.label ?? ran.model;
- return `${name} · ${label}`;
+ return `${name} · ${shortModelLabel(label, name)}`;
} catch {
return null;
}
diff --git a/frontend/tests/engines.test.mjs b/frontend/tests/engines.test.mjs
index 8971ed30..41840c3f 100644
--- a/frontend/tests/engines.test.mjs
+++ b/frontend/tests/engines.test.mjs
@@ -203,6 +203,10 @@ test('a reply says which engine and model answered it', () => {
assert.equal(m.ranOnLabel(JSON.stringify({ ran_on: { engine: 'claude', model: 'sonnet', model_label: 'Sonnet' } })), 'Claude · Sonnet');
assert.equal(m.ranOnLabel(JSON.stringify({ ran_on: { engine: 'anthropic_api', model: 'opus' } }), live), 'Claude · Opus');
assert.equal(m.ranOnLabel(JSON.stringify({ ran_on: { engine: 'codex' } })), 'Codex');
+ // Lin's final shape: EngineId + family + full model_label.
+ assert.equal(m.ranOnLabel(JSON.stringify({ ran_on: { engine: 'claude', family: 'claude', model: 'haiku', model_label: 'Claude Haiku (latest)', tier: 'fast', picked_by: 'laya' } })), 'Claude · Haiku');
+ assert.equal(m.ranOnLabel(JSON.stringify({ ran_on: { engine: 'anthropic_api', family: 'claude', model: 'claude-opus-5-5', model_label: null } })), 'Claude · claude-opus-5-5');
+ assert.equal(m.statusView({ status: 'disabled' }).label, 'Off');
assert.equal(m.ranOnLabel(JSON.stringify({ delegation: {} })), null);
assert.equal(m.ranOnLabel('not json'), null);
assert.equal(m.ranOnLabel(null), null);