Third phase of the DESIGN.md migration. Removes every raw Tailwind
color palette utility (bg-red-*, text-amber-*, border-blue-*, etc.)
from component source and replaces them with the semantic tokens
introduced in phases 1 and 2.
Scope:
- 84 files touched under ui/src/
- ~420 raw palette utility instances replaced
- 23 hardcoded hex fallbacks replaced with var(--token) refs
- Zero raw palette utilities remain in component source
(verified with rg '(bg|text|border|ring)-(red|blue|green|amber|
yellow|cyan|violet|purple|pink|slate|zinc|neutral|sky|teal|
emerald|indigo|rose|orange|fuchsia)-[0-9]+' ui/src)
Mapping rules applied:
- red-* -> destructive
- amber-/yellow-/orange-* -> warning
- green-/emerald-* -> success
- blue-/cyan-/sky-* -> primary (info/in-progress) or muted-foreground
- slate-/gray-/zinc-/neutral-* -> muted / muted-foreground / border
- violet-/purple-/pink-/indigo-/rose-/teal-* -> collapsed to
primary or muted (most were one-off decorative choices, not
role-bearing). Role-bearing uses go through lib/agent-role-colors
which was rewritten in phase 2.
- Opacity modifiers preserved (/10, /15, /20, etc.)
- dark: variant duplicates removed (theme tokens auto-switch)
Hardcoded hex fallbacks fixed:
- #6366f1 (indigo) -> var(--primary) / var(--volt)
- #64748b (slate) -> var(--muted-foreground) / var(--silver)
- #4f46e5 (indigo) -> var(--primary)
- #89b4fa (old Catppuccin blue) -> var(--primary) / #faff69
- OrgChart status dots (#22d3ee/#4ade80/#facc15/#f87171/#a3a3a3)
-> var(--primary) / var(--success) / var(--warning) /
var(--destructive) / var(--muted-foreground) per status
- VoiceWaveform fallback #89b4fa -> #faff69 (volt)
Legitimate hex values left untouched (12 total):
- lib/color-contrast.ts WCAG reference constants
- lib/worktree-branding.ts contrast fallback references
- lib/mention-chips.ts runtime-generated SVG fills
- context/ThemeContext.tsx theme metadata brand hexes
- components/ThemeSeedInput.tsx user-facing hex picker
Ambiguous decisions (flagged for visual QA):
- AgentDetail.tsx invocation-source badges (timer/assignment/
on_demand) collapsed to primary/muted — visual distinction
is reduced, labels still differ. Consider chart-role slots
if differentiation matters.
- AgentDetail.tsx mixed-opacity amber banners: bg-warning/60
against new warning base reads heavier than original amber-50
base.
- Live-state dots in KanbanBoard/AgentDetail: bg-blue-* ->
bg-primary — will glow volt in dark mode, probably desirable.
Verification:
- npx tsc --noEmit in ui/ — zero errors introduced. Pre-existing
errors in AgentConfigForm, command.tsx, useKeyboardShortcuts,
usePiperTts, useVadRecorder, PersonalAssistant remain, all
unrelated to color work.
- Dev server on :6100 returns 200.
Not changed in this commit:
- ui/src/lib/company-routes.ts — separate routing fix for broken
Assistant/ContentStudio/Convert links, committed next.
- Test files — a few will need assertion updates but are out of
phase 3 scope.
Phase 4 follow-ups (rounded-xl/2xl collapse, soft shadow removal,
gradient removal) noted in .planning/AUDIT-RADIUS-SHADOWS.md.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
166 lines
6 KiB
TypeScript
166 lines
6 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { Mic, Volume2, CheckCircle2, Info } from "lucide-react";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import type { VoiceCapability } from "../../hooks/useHardwareInfo";
|
|
|
|
interface VoiceStepProps {
|
|
onEnable: () => void;
|
|
onSkip: () => void;
|
|
voiceCapability?: VoiceCapability;
|
|
}
|
|
|
|
export function VoiceStep({ onEnable, onSkip, voiceCapability }: VoiceStepProps) {
|
|
const [micAvailable, setMicAvailable] = useState<boolean | null>(null);
|
|
|
|
useEffect(() => {
|
|
navigator.mediaDevices?.enumerateDevices()
|
|
.then(devices => setMicAvailable(devices.some(d => d.kind === "audioinput")))
|
|
.catch(() => setMicAvailable(false));
|
|
}, []);
|
|
|
|
// Determine STT status label
|
|
function whisperStatusLabel(): string {
|
|
if (!voiceCapability) {
|
|
if (micAvailable === false) return "No microphone detected -- unavailable";
|
|
if (micAvailable === true) return "Microphone detected -- speak to your assistant";
|
|
return "Checking microphone...";
|
|
}
|
|
if (voiceCapability.whisperAvailable) return "Whisper detected -- speech recognition ready";
|
|
return "Whisper not found -- install whisper-cpp for voice input";
|
|
}
|
|
|
|
function whisperBadge() {
|
|
if (!voiceCapability) return null;
|
|
if (voiceCapability.whisperAvailable) {
|
|
return (
|
|
<Badge variant="outline" className="text-[color:var(--chart-2)] border-[color:var(--chart-2)]/30 bg-[color:var(--chart-2)]/10 text-xs">
|
|
Available
|
|
</Badge>
|
|
);
|
|
}
|
|
return (
|
|
<Badge variant="outline" className="text-[color:var(--chart-4)] border-[color:var(--chart-4)]/30 bg-[color:var(--chart-4)]/10 text-xs">
|
|
Install needed
|
|
</Badge>
|
|
);
|
|
}
|
|
|
|
// Determine TTS status label
|
|
function piperStatusLabel(): string {
|
|
if (!voiceCapability) {
|
|
return "Hear responses read aloud. Runs entirely on your device -- no server needed.";
|
|
}
|
|
if (voiceCapability.piperAvailable) return "Piper detected -- text-to-speech ready";
|
|
return "Piper not found -- install piper for voice output";
|
|
}
|
|
|
|
function piperBadge() {
|
|
if (!voiceCapability) return null;
|
|
if (voiceCapability.piperAvailable) {
|
|
return (
|
|
<Badge variant="outline" className="text-[color:var(--chart-2)] border-[color:var(--chart-2)]/30 bg-[color:var(--chart-2)]/10 text-xs">
|
|
Available
|
|
</Badge>
|
|
);
|
|
}
|
|
return (
|
|
<Badge variant="outline" className="text-[color:var(--chart-4)] border-[color:var(--chart-4)]/30 bg-[color:var(--chart-4)]/10 text-xs">
|
|
Install needed
|
|
</Badge>
|
|
);
|
|
}
|
|
|
|
// Insufficient hardware: show note but still allow enabling
|
|
if (voiceCapability && !voiceCapability.voiceTierSufficient) {
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
<div className="flex items-start gap-3 rounded-lg border border-[color:var(--chart-4)]/30 bg-[color:var(--chart-4)]/5 p-4">
|
|
<Info className="h-5 w-5 text-[color:var(--chart-4)] shrink-0 mt-0.5" />
|
|
<div>
|
|
<p className="text-sm font-medium">Limited hardware for voice</p>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
Voice features require at least 4GB free RAM. Transcription may be slower on your system.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-2">
|
|
<Button onClick={onEnable} variant="outline" className="w-full">
|
|
Enable voice anyway
|
|
</Button>
|
|
<Button variant="ghost" onClick={onSkip} className="w-full">
|
|
Skip voice setup
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// Sufficient hardware or unknown -- show full UI
|
|
const neitherBinaryFound =
|
|
voiceCapability &&
|
|
!voiceCapability.whisperAvailable &&
|
|
!voiceCapability.piperAvailable;
|
|
|
|
// CPU-only note
|
|
const isCpuOnly = voiceCapability && !voiceCapability.whisperAvailable && !voiceCapability.piperAvailable;
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
{/* Install note when tier is sufficient but binaries are missing */}
|
|
{neitherBinaryFound && (
|
|
<div className="flex items-start gap-3 rounded-lg border border-primary/20 bg-primary/5 p-4">
|
|
<Info className="h-5 w-5 text-primary shrink-0 mt-0.5" />
|
|
<p className="text-sm text-muted-foreground">
|
|
Install whisper-cpp and piper for local voice features. You can enable voice now and configure binaries later.
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{/* CPU-only note */}
|
|
{voiceCapability?.voiceTierSufficient && !voiceCapability.whisperAvailable && (
|
|
<p className="text-sm text-muted-foreground">
|
|
Works on CPU -- transcription may take a few extra seconds.
|
|
</p>
|
|
)}
|
|
|
|
<div className="flex flex-col gap-3">
|
|
<div className="flex items-center gap-3 rounded-lg border border-border p-4">
|
|
<Mic className="h-5 w-5 text-primary shrink-0" />
|
|
<div className="flex-1">
|
|
<p className="text-sm font-medium">Speech-to-Text (Whisper)</p>
|
|
<p className="text-xs text-muted-foreground mt-0.5">
|
|
{whisperStatusLabel()}
|
|
</p>
|
|
</div>
|
|
{whisperBadge()}
|
|
</div>
|
|
|
|
<div className="flex items-center gap-3 rounded-lg border border-border p-4">
|
|
<Volume2 className="h-5 w-5 text-primary shrink-0" />
|
|
<div className="flex-1">
|
|
<p className="text-sm font-medium">Text-to-Speech (Piper)</p>
|
|
<p className="text-xs text-muted-foreground mt-0.5">
|
|
{piperStatusLabel()}
|
|
</p>
|
|
</div>
|
|
{piperBadge()}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-2">
|
|
<Button
|
|
onClick={onEnable}
|
|
className="w-full"
|
|
variant={neitherBinaryFound ? "outline" : "default"}
|
|
>
|
|
Enable voice
|
|
</Button>
|
|
<Button variant="ghost" onClick={onSkip} className="w-full">
|
|
Skip
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|