Add GUI visual smoke and bounded actions
This commit is contained in:
parent
a2c44a52a3
commit
21a05368d3
14 changed files with 620 additions and 32 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { AlertTriangle, BriefcaseBusiness, ClipboardCheck, Database, FileText, GitBranch, RefreshCw } from "lucide-react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import type { ArtifactBundle, OperatorSnapshot, StatusRequest } from "./types";
|
||||
import { loadOperatorSnapshot, runOperatorAction } from "./operatorApi";
|
||||
import type { ArtifactBundle, OperatorAction, OperatorActionResult, OperatorSnapshot, StatusRequest } from "./types";
|
||||
|
||||
const roleOrder = ["implementation", "modeling", "verification", "reorientation"];
|
||||
|
||||
|
|
@ -34,13 +34,15 @@ function useSnapshot() {
|
|||
const [snapshot, setSnapshot] = useState<OperatorSnapshot | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [actionResult, setActionResult] = useState<OperatorActionResult | null>(null);
|
||||
const [runningAction, setRunningAction] = useState<OperatorAction | null>(null);
|
||||
const [request, setRequest] = useState<StatusRequest>({});
|
||||
|
||||
async function refresh(nextRequest = request) {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = await invoke<OperatorSnapshot>("load_operator_snapshot", { request: nextRequest });
|
||||
const result = await loadOperatorSnapshot(nextRequest);
|
||||
setSnapshot(result);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
|
|
@ -49,16 +51,31 @@ function useSnapshot() {
|
|||
}
|
||||
}
|
||||
|
||||
async function runAction(action: OperatorAction) {
|
||||
setRunningAction(action);
|
||||
setError(null);
|
||||
setActionResult(null);
|
||||
try {
|
||||
const result = await runOperatorAction(action, request);
|
||||
setActionResult(result);
|
||||
await refresh(request);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
setRunningAction(null);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void refresh({});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return { snapshot, loading, error, request, setRequest, refresh };
|
||||
return { snapshot, loading, error, request, setRequest, refresh, actionResult, runningAction, runAction };
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const { snapshot, loading, error, request, setRequest, refresh } = useSnapshot();
|
||||
const { snapshot, loading, error, request, setRequest, refresh, actionResult, runningAction, runAction } = useSnapshot();
|
||||
const status = snapshot?.status;
|
||||
const scene = status?.scene?.scene ?? {};
|
||||
const pressure = status?.pressure?.pressure ?? {};
|
||||
|
|
@ -106,6 +123,32 @@ export function App() {
|
|||
</label>
|
||||
</section>
|
||||
|
||||
<section className="actionStrip" aria-label="Bounded operator actions">
|
||||
<button
|
||||
className="secondaryButton"
|
||||
onClick={() => void runAction("statusSnapshot")}
|
||||
disabled={runningAction !== null}
|
||||
title="Write an auditable status snapshot"
|
||||
>
|
||||
<FileText size={16} aria-hidden="true" />
|
||||
{runningAction === "statusSnapshot" ? "Writing" : "Status Snapshot"}
|
||||
</button>
|
||||
<button
|
||||
className="secondaryButton"
|
||||
onClick={() => void runAction("coordinatorPlan")}
|
||||
disabled={runningAction !== null}
|
||||
title="Run a review-gated coordinator plan"
|
||||
>
|
||||
<ClipboardCheck size={16} aria-hidden="true" />
|
||||
{runningAction === "coordinatorPlan" ? "Running" : "Coordinator Plan"}
|
||||
</button>
|
||||
{actionResult && (
|
||||
<p className="actionResult">
|
||||
{actionResult.summary} <code>{actionResult.artifactPath}</code>
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{error && (
|
||||
<section className="notice dangerNotice" role="alert">
|
||||
<AlertTriangle size={18} aria-hidden="true" />
|
||||
|
|
@ -171,7 +214,7 @@ export function App() {
|
|||
<article className="jobRow" key={text(job.id)}>
|
||||
<div>
|
||||
<strong>{text(job.id)}</strong>
|
||||
<span>{text(job.kind)} · {text(job.ownerRole)}</span>
|
||||
<span>{text(job.kind)} - {text(job.ownerRole)}</span>
|
||||
</div>
|
||||
<Pill tone={statusClass(job.status)}>{text(job.status)}</Pill>
|
||||
</article>
|
||||
|
|
|
|||
31
apps/epiphany-gui/src/operatorApi.ts
Normal file
31
apps/epiphany-gui/src/operatorApi.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { OperatorAction, OperatorActionResult, OperatorSnapshot, StatusRequest } from "./types";
|
||||
|
||||
export async function loadOperatorSnapshot(request: StatusRequest): Promise<OperatorSnapshot> {
|
||||
if (hasTauriRuntime()) {
|
||||
return invoke<OperatorSnapshot>("load_operator_snapshot", { request });
|
||||
}
|
||||
|
||||
const response = await fetch("/operator-snapshot.sample.json", { cache: "no-store" });
|
||||
if (!response.ok) {
|
||||
throw new Error(`sample operator snapshot failed: ${response.status}`);
|
||||
}
|
||||
return (await response.json()) as OperatorSnapshot;
|
||||
}
|
||||
|
||||
export async function runOperatorAction(action: OperatorAction, request: StatusRequest): Promise<OperatorActionResult> {
|
||||
if (hasTauriRuntime()) {
|
||||
return invoke<OperatorActionResult>("run_operator_action", { action, request });
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
return {
|
||||
action,
|
||||
artifactPath: "E:\\Projects\\EpiphanyAgent\\.epiphany-gui\\sample-action",
|
||||
summary: `${action} sample completed.`,
|
||||
};
|
||||
}
|
||||
|
||||
function hasTauriRuntime(): boolean {
|
||||
return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
}
|
||||
|
|
@ -75,7 +75,8 @@ h3 {
|
|||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.primaryButton {
|
||||
.primaryButton,
|
||||
.secondaryButton {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
|
@ -89,16 +90,44 @@ h3 {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.primaryButton:disabled {
|
||||
.secondaryButton {
|
||||
border-color: #b8c4bc;
|
||||
color: #244d3a;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.primaryButton:disabled,
|
||||
.secondaryButton:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.68;
|
||||
}
|
||||
|
||||
.controls {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.actionStrip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.actionResult {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 34px;
|
||||
color: #3e493f;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.actionResult code {
|
||||
max-width: min(580px, 70vw);
|
||||
}
|
||||
|
||||
label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
|
|
@ -378,6 +407,11 @@ code {
|
|||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.actionStrip,
|
||||
.secondaryButton {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cardGrid,
|
||||
.facts,
|
||||
.facts.compact,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,14 @@ export interface StatusRequest {
|
|||
appServer?: string;
|
||||
}
|
||||
|
||||
export type OperatorAction = "statusSnapshot" | "coordinatorPlan";
|
||||
|
||||
export interface OperatorActionResult {
|
||||
action: OperatorAction;
|
||||
artifactPath: string;
|
||||
summary: string;
|
||||
}
|
||||
|
||||
export interface ArtifactBundle {
|
||||
name: string;
|
||||
path: string;
|
||||
|
|
|
|||
Reference in a new issue