MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / EngineRow

Function EngineRow

dashboard/code-diagnostics/src/CodeDiagnostics.tsx:178–281  ·  view source on GitHub ↗
({
  engine,
  busy,
  onToggle,
  onConfigure,
  onRefresh,
}: {
  engine: EngineStatus;
  busy: boolean;
  onToggle: (enabled: boolean) => void;
  onConfigure: (commandOverride: string | null) => void;
  onRefresh: () => void;
})

Source from the content-addressed store, hash-verified

176}
177
178function EngineRow({
179 engine,
180 busy,
181 onToggle,
182 onConfigure,
183 onRefresh,
184}: {
185 engine: EngineStatus;
186 busy: boolean;
187 onToggle: (enabled: boolean) => void;
188 onConfigure: (commandOverride: string | null) => void;
189 onRefresh: () => void;
190}) {
191 const [expanded, setExpanded] = useState(false);
192 const [commandDraft, setCommandDraft] = useState(engine.command);
193 const hasOverride = engine.command !== engine.default_command;
194
195 useEffect(() => {
196 setCommandDraft(engine.command);
197 }, [engine.command]);
198
199 return (
200 <div className="tdcd-engine-row">
201 <label className="tdcd-toggle">
202 <input
203 type="checkbox"
204 checked={engine.enabled}
205 disabled={busy}
206 onChange={(event) => onToggle(event.currentTarget.checked)}
207 />
208 <span>{engine.language}</span>
209 </label>
210 <code>{engine.command}</code>
211 <Badge className={cn("tdcd-state", `tdcd-state-${engine.state}`)}>
212 {STATE_LABELS[engine.state]}
213 </Badge>
214 <span className="tdcd-engine-time">
215 {engine.last_diagnostic_update ? timeAgo(engine.last_diagnostic_update) : "Never"}
216 </span>
217 <Button size="sm" onClick={() => setExpanded((value) => !value)} disabled={busy}>
218 {engine.state === "unavailable" ? "Setup" : "Configure"}
219 </Button>
220 <Button size="sm" onClick={onRefresh} disabled={busy || !engine.enabled}>
221 Refresh
222 </Button>
223 {engine.last_error && <p className="tdcd-engine-error">{engine.last_error}</p>}
224 {expanded && (
225 <div className="tdcd-engine-setup">
226 <div className="tdcd-engine-setup-copy">
227 <span>Default</span>
228 <code>{engine.default_command}</code>
229 {engine.args.length > 0 && <code>{engine.args.join(" ")}</code>}
230 </div>
231 {engine.install_options.length > 0 && (
232 <div className="tdcd-install-options">
233 {engine.install_options.map((option) => (
234 <div key={`${engine.language}-${option.label}`} className="tdcd-install-option">
235 <span>{option.label}</span>

Callers

nothing calls this directly

Calls 5

cnFunction · 0.90
timeAgoFunction · 0.90
useStateFunction · 0.85
useEffectFunction · 0.85
copyCommandFunction · 0.85

Tested by

no test coverage detected