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.

0.7.1: production floor card, style v2 (PX-4) (#347)

Oleksandr Ivanchenkoe1f4e431b964
diff --git a/frontend/src/components/dev/ProdFloorCard.tsx b/frontend/src/components/dev/ProdFloorCard.tsx
index d7feec1d..441394b6 100644
--- a/frontend/src/components/dev/ProdFloorCard.tsx
+++ b/frontend/src/components/dev/ProdFloorCard.tsx
@@ -1,8 +1,8 @@
import React, { useEffect, useReducer, useRef, useState } from 'react';
-import { Database, Loader2, ShieldAlert, Target, X, Check } from 'lucide-react';
+import { Database, Folder, Target, X, Check } from 'lucide-react';
import type { BackupResult, ProdFloor } from '../../dev/types';
import { parseBackupResult } from '../../dev/types';
-import { allowReady, floorHeader, floorReducer, floorSentence, floorSubline, floorView, initialFloorUi, type RowTone } from '../../dev/logic';
+import { allowReady, floorLed, floorReducer, floorSentence, floorSubline, floorView, floorWho, initialFloorUi, type RowTone } from '../../dev/logic';
export type FloorDecision = 'allow_once' | 'deny';
@@ -123,26 +123,36 @@ export const ProdFloorCard: React.FC<ProdFloorCardProps> = ({ id, floor, bot, co
data-floor-case={view.case}
role="group"
aria-labelledby={headingId}
- className="my-3 max-w-2xl rounded-xl border border-amber-500/30 bg-amber-950/20 p-3 text-zinc-100 shadow-lg backdrop-blur-sm sm:p-4"
+ className="dv-floor my-3 max-w-2xl rounded-xl text-zinc-100 shadow-lg backdrop-blur-sm"
>
- <div className="mb-1 flex items-start gap-2 text-xs font-semibold tracking-wide text-amber-400">
- <ShieldAlert size={16} aria-hidden="true" className="mt-px shrink-0" />
- <h3 id={headingId} className="min-w-0 [overflow-wrap:anywhere]">
- {floorHeader(floor, bot ?? 'A bot')}
+ {/* The hazard tape is .dv-floor::before (4 px, only on the floor card). */}
+ <div className="p-3 sm:px-4 sm:pb-4 sm:pt-3.5">
+ <div className="flex min-w-0 items-center gap-2">
+ <span className="dv-led" data-s={view.tone === 'ok' ? 'ok' : 'warn'} data-floor-led aria-hidden="true" />
+ <h3 id={headingId} className="min-w-0 text-meta text-zinc-400 [overflow-wrap:anywhere]">
+ <span className="font-mono text-[11px] font-bold uppercase tracking-[0.1em] text-amber-300">Production floor</span>
+ <span className="sr-only">: </span>
+ <span className="before:content-['·_'] before:text-zinc-500" data-floor-who>
+ {' '}
+ {floorWho(floor, bot ?? 'A bot')}
+ </span>
</h3>
</div>
- <p className="mb-3 text-[11px] text-zinc-400 sm:pl-6">{floorSubline(floor)}</p>
+ {why && <p className="mt-2 text-[16px] font-semibold leading-snug text-zinc-50 [overflow-wrap:anywhere]" data-floor-why>{why}</p>}
+ <p className={`${why ? 'mt-0.5' : 'mt-2'} mb-2.5 text-[13px] text-zinc-300`}>{floorSubline(floor)}</p>
- <div className="mb-3 space-y-2 rounded-lg border border-zinc-800 bg-zinc-900/90 p-3 text-xs">
- {why && <p className="text-zinc-300 [overflow-wrap:anywhere]">{why}</p>}
- <pre className="max-h-64 overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-zinc-800 bg-zinc-950/70 p-2 font-mono text-[12px] text-zinc-100">
- {command || '(empty command)'}
- </pre>
+ <div className="dv-cmd mb-3" data-floor-cmd>
{cwd && (
- <p className="break-all text-[11px] text-zinc-400">
- <span className="text-zinc-500">In folder:</span> <span className="font-mono text-zinc-300">{cwd}</span>
- </p>
+ <div className="bar" data-floor-cwd>
+ <Folder size={12} aria-hidden="true" className="shrink-0" />
+ <span className="sr-only">In folder:</span>
+ <span className="min-w-0 break-all">{cwd}</span>
+ </div>
)}
+ <pre className="max-h-64 overflow-y-auto">
+ <span className="ps" aria-hidden="true">$ </span>
+ {command || '(empty command)'}
+ </pre>
</div>
{floor.blast.length > 0 && (
@@ -165,13 +175,7 @@ export const ProdFloorCard: React.FC<ProdFloorCardProps> = ({ id, floor, bot, co
)}
<div data-backup-row={view.case} aria-live="polite" className={`mb-3 flex items-start gap-2 rounded-lg border px-3 py-2 text-xs ${ROW[view.tone]}`}>
- {view.case === 'taking' ? (
- <Loader2 size={14} aria-hidden="true" className="mt-px shrink-0 animate-spin motion-reduce:animate-none" />
- ) : view.tone === 'bad' ? (
- <X size={14} aria-hidden="true" className={`mt-px shrink-0 ${LEAD.bad}`} />
- ) : (
- <Database size={14} aria-hidden="true" className={`mt-px shrink-0 ${LEAD[view.tone]}`} />
- )}
+ <span className="dv-led mt-[5px]" data-s={floorLed(view.tone, view.case)} data-backup-led aria-hidden="true" />
<p className="min-w-0 [overflow-wrap:anywhere]">
{view.lead && <span className={`font-semibold ${LEAD[view.tone]}`}>{view.lead}</span>}
{view.text}
@@ -222,6 +226,7 @@ export const ProdFloorCard: React.FC<ProdFloorCardProps> = ({ id, floor, bot, co
Deny
</button>
</div>
+ </div>
</div>
);
};
diff --git a/frontend/src/dev/logic.ts b/frontend/src/dev/logic.ts
index 73b04a66..de81be69 100644
--- a/frontend/src/dev/logic.ts
+++ b/frontend/src/dev/logic.ts
@@ -248,6 +248,11 @@ export function floorView(floor: ProdFloor, ui: FloorUi, now: number, mountedAt:
/** Header verb per floor kind (design §6). */
export function floorHeader(floor: ProdFloor, bot: string): string {
+ return `Production floor: ${floorWho(floor, bot)}`;
+}
+
+/** The eyebrow's second half (style v2 §8): "{bot} wants to deploy". */
+export function floorWho(floor: ProdFloor, bot: string): string {
const what: Record<ProdFloor['kind'], string> = {
deploy: 'deploy',
deploy_migration: 'deploy a database change',
@@ -257,7 +262,16 @@ export function floorHeader(floor: ProdFloor, bot: string): string {
destructive: 'delete data',
prod_key: 'use a production key',
};
- return `Production floor: ${bot} wants to ${what[floor.kind]}`;
+ return `${bot} wants to ${what[floor.kind]}`;
+}
+
+/** The LED on the backup line (style v2 §8): warn old/none, run taking, ok fresh, bad failed/blocked. */
+export function floorLed(tone: RowTone, kase: string): 'ok' | 'run' | 'warn' | 'bad' | 'off' {
+ if (kase === 'taking') return 'run';
+ if (tone === 'ok') return 'ok';
+ if (tone === 'bad') return 'bad';
+ if (tone === 'warn') return 'warn';
+ return 'off';
}
/** Leads of the clauses 0.7.0 sent ("runs deploy.sh, a deploy script", "a force-push to main"):
diff --git a/frontend/tests/devCards.test.mjs b/frontend/tests/devCards.test.mjs
index 1b319c1d..147b4c48 100644
--- a/frontend/tests/devCards.test.mjs
+++ b/frontend/tests/devCards.test.mjs
@@ -336,10 +336,10 @@ test('the floor card never offers "always allow", in any case', () => {
const out = html(m.ModernApprovalCard, { approval: ap, onResolve() {} });
assert.match(out, /data-prod-floor=/);
assert.doesNotMatch(out, /Always Allow|Always this session/);
- assert.match(out, /Production floor: /);
+ assert.match(heading(out), /^Production floor: /);
}
const fresh = html(m.ModernApprovalCard, { approval: fx.FLOOR_DEPLOY_FRESH, onResolve() {} });
- assert.match(fresh, /Production floor: Pixel wants to deploy/);
+ assert.equal(heading(fresh), 'Production floor: Pixel wants to deploy', 'the heading reads as one line to a screen reader');
assert.match(fresh, /Allow this deploy/);
assert.match(fresh, /<dt[^>]*>Downtime<\/dt>/);
assert.match(fresh, /aria-live="polite"/);
@@ -349,6 +349,29 @@ test('the floor card never offers "always allow", in any case', () => {
assert.match(mig, /Back up first/);
});
+/** The floor card's <h3> as text (tags stripped). */
+function heading(out) {
+ const h3 = out.match(/<h3[^>]*>([\s\S]*?)<\/h3>/);
+ return h3 ? h3[1].replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim() : '';
+}
+
+test('style v2 §8: hazard tape frame, PRODUCTION FLOOR eyebrow with an LED, $ command box with the cwd bar, backup LED', () => {
+ const out = html(m.ModernApprovalCard, { approval: fx.FLOOR_DEPLOY_FRESH, onResolve() {} });
+ assert.match(out, /class="dv-floor /, 'the floor frame carries the hazard tape');
+ assert.match(out, /class="dv-led" data-s="ok" data-floor-led/, 'backed up: the eyebrow LED is ok');
+ assert.match(html(m.ModernApprovalCard, { approval: fx.FLOOR_MIGRATION, onResolve() {} }), /class="dv-led" data-s="warn" data-floor-led/, 'waiting: warn');
+ assert.match(out, /<div class="dv-cmd[^"]*" data-floor-cmd/);
+ assert.match(out, /<span class="ps" aria-hidden="true">\$ <\/span>/);
+ assert.doesNotMatch(out, /This is /);
+ assert.match(out, /data-backup-led/);
+ const led = (ap) => html(m.ModernApprovalCard, { approval: ap, onResolve() {} }).match(/data-s="(\w+)" data-backup-led/)?.[1];
+ assert.equal(led(fx.FLOOR_DEPLOY_FRESH), 'ok');
+ assert.equal(led(fx.FLOOR_DEPLOY_OLD), 'warn');
+ assert.equal(led(fx.FLOOR_MIGRATION), 'bad');
+ assert.equal(m.floorLed('info', 'taking'), 'run');
+ assert.equal(m.floorLed('neutral', 'no_data'), 'off');
+});
+
// ---------------------------------------------------------------------------------------------------
// The 500 ms Allow guard