fix: biome format issues (12 errors)

This commit is contained in:
2026-05-15 09:10:39 +08:00
parent fac215bd21
commit 153178c545
12 changed files with 190 additions and 90 deletions
+7 -2
View File
@@ -12,7 +12,8 @@ import { useHashRoute } from "./use-hash-route.ts";
export function App() {
const [authed, setAuthed] = useState(hasApiKey());
const { view, client, threadId, workflowName, setView, setClient, setThreadId, setWorkflowName } = useHashRoute();
const { view, client, threadId, workflowName, setView, setClient, setThreadId, setWorkflowName } =
useHashRoute();
const [showRun, setShowRun] = useState(false);
if (!authed) {
@@ -51,7 +52,11 @@ export function App() {
<WorkflowList client={client} onSelect={setWorkflowName} />
)}
{client && view === "workflows" && workflowName !== null && (
<WorkflowDetail client={client} workflowName={workflowName} onBack={() => setWorkflowName(null)} />
<WorkflowDetail
client={client}
workflowName={workflowName}
onBack={() => setWorkflowName(null)}
/>
)}
</div>
</main>
@@ -96,42 +96,45 @@ export function ThreadDetail({ client, threadId, onBack }: Props) {
// Track which occurrence to jump to next per role (cycling)
const clickCycleRef = useRef<Map<string, number>>(new Map());
const handleGraphNodeClick = useCallback((nodeId: string) => {
// Only allow clicks on lit (non-default) nodes
if (nodeStates.get(nodeId) === undefined || nodeStates.get(nodeId) === "default") return;
const handleGraphNodeClick = useCallback(
(nodeId: string) => {
// Only allow clicks on lit (non-default) nodes
if (nodeStates.get(nodeId) === undefined || nodeStates.get(nodeId) === "default") return;
// __start__: scroll to the first record (thread-start prompt)
if (nodeId === "__start__") {
const firstCard = document.querySelector('[data-record-index="0"]');
if (firstCard !== null) firstCard.scrollIntoView({ behavior: "smooth", block: "center" });
return;
}
// __start__: scroll to the first record (thread-start prompt)
if (nodeId === "__start__") {
const firstCard = document.querySelector('[data-record-index="0"]');
if (firstCard !== null) firstCard.scrollIntoView({ behavior: "smooth", block: "center" });
return;
}
// __end__: scroll to bottom
if (nodeId === "__end__") {
recordsEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
return;
}
// __end__: scroll to bottom
if (nodeId === "__end__") {
recordsEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
return;
}
// Role nodes: cycle through occurrences
const indices = indicesByRole.get(nodeId);
if (indices === undefined || indices.length === 0) return;
// Role nodes: cycle through occurrences
const indices = indicesByRole.get(nodeId);
if (indices === undefined || indices.length === 0) return;
const cycle = clickCycleRef.current.get(nodeId) ?? 0;
const idx = indices[cycle % indices.length];
clickCycleRef.current.set(nodeId, cycle + 1);
const cycle = clickCycleRef.current.get(nodeId) ?? 0;
const idx = indices[cycle % indices.length];
clickCycleRef.current.set(nodeId, cycle + 1);
const el = document.querySelector(`[data-record-index="${idx}"]`);
if (el !== null) {
el.scrollIntoView({ behavior: "smooth", block: "center" });
if (highlightTimerRef.current !== null) clearTimeout(highlightTimerRef.current);
setHighlightedRole(nodeId);
highlightTimerRef.current = setTimeout(() => {
setHighlightedRole(null);
highlightTimerRef.current = null;
}, 1500);
}
}, [nodeStates, indicesByRole]);
const el = document.querySelector(`[data-record-index="${idx}"]`);
if (el !== null) {
el.scrollIntoView({ behavior: "smooth", block: "center" });
if (highlightTimerRef.current !== null) clearTimeout(highlightTimerRef.current);
setHighlightedRole(nodeId);
highlightTimerRef.current = setTimeout(() => {
setHighlightedRole(null);
highlightTimerRef.current = null;
}, 1500);
}
},
[nodeStates, indicesByRole],
);
useEffect(() => {
return () => {
@@ -285,7 +288,11 @@ export function ThreadDetail({ client, threadId, onBack }: Props) {
</div>
);
}
return <div key={key} data-record-index={i}><RecordCard record={r} highlighted={false} /></div>;
return (
<div key={key} data-record-index={i}>
<RecordCard record={r} highlighted={false} />
</div>
);
})}
<div ref={recordsEndRef} aria-hidden />
</div>
@@ -76,7 +76,14 @@ function flattenSchema(
);
for (const [pName, pDef] of Object.entries(variantProps)) {
if (pDef.const !== undefined) continue;
const subRows = flattenProperty(pName, pDef, depth + 1, childPrefix, `${keyPrefix}v${vi}-`, variantRequired);
const subRows = flattenProperty(
pName,
pDef,
depth + 1,
childPrefix,
`${keyPrefix}v${vi}-`,
variantRequired,
);
rows.push(...subRows);
}
}
@@ -121,7 +128,14 @@ function flattenProperty(
if (prop.type === "object" && prop.properties !== undefined) {
const childPrefix = depth > 0 ? `${parentPrefix} ` : " ";
rows.push(...flattenSchema(prop as Record<string, unknown>, depth + 1, childPrefix, `${keyPrefix}${name}-`));
rows.push(
...flattenSchema(
prop as Record<string, unknown>,
depth + 1,
childPrefix,
`${keyPrefix}${name}-`,
),
);
}
if (prop.type === "array") {
@@ -134,7 +148,14 @@ function flattenProperty(
if (hasOneOf) {
const childPrefix = depth > 0 ? `${parentPrefix} ` : " ";
rows.push(...flattenSchema(prop as Record<string, unknown>, depth + 1, childPrefix, `${keyPrefix}${name}-`));
rows.push(
...flattenSchema(
prop as Record<string, unknown>,
depth + 1,
childPrefix,
`${keyPrefix}${name}-`,
),
);
}
return rows;
@@ -142,13 +163,7 @@ function flattenProperty(
// ── Components ──────────────────────────────────────────────────────
function RoleCard({
roleName,
role,
}: {
roleName: string;
role: WorkflowRoleDescriptor;
}) {
function RoleCard({ roleName, role }: { roleName: string; role: WorkflowRoleDescriptor }) {
const rows = flattenSchema(role.schema, 0, "", `${roleName}-`);
return (
<div
@@ -156,10 +171,7 @@ function RoleCard({
className="rounded-lg border p-4"
style={{ borderColor: "var(--color-border)", background: "var(--color-surface)" }}
>
<h4
className="text-sm font-semibold font-mono mb-1"
style={{ color: "var(--color-text)" }}
>
<h4 className="text-sm font-semibold font-mono mb-1" style={{ color: "var(--color-text)" }}>
{roleName}
</h4>
{role.description !== "" && (
@@ -178,9 +190,24 @@ function RoleCard({
<table className="w-full text-xs" style={{ borderCollapse: "collapse" }}>
<thead>
<tr style={{ borderBottom: "1px solid var(--color-border)" }}>
<th className="text-left py-1 pr-3 font-medium" style={{ color: "var(--color-text-muted)" }}>Field</th>
<th className="text-left py-1 pr-3 font-medium" style={{ color: "var(--color-text-muted)" }}>Type</th>
<th className="text-left py-1 font-medium" style={{ color: "var(--color-text-muted)" }}>Description</th>
<th
className="text-left py-1 pr-3 font-medium"
style={{ color: "var(--color-text-muted)" }}
>
Field
</th>
<th
className="text-left py-1 pr-3 font-medium"
style={{ color: "var(--color-text-muted)" }}
>
Type
</th>
<th
className="text-left py-1 font-medium"
style={{ color: "var(--color-text-muted)" }}
>
Description
</th>
</tr>
</thead>
<tbody>
@@ -200,8 +227,12 @@ function RoleCard({
>
{r.name}
</td>
<td className="py-1 pr-3 font-mono" style={{ color: "var(--color-text-muted)" }}>{r.type}</td>
<td className="py-1" style={{ color: "var(--color-text)" }}>{r.description || (r.isVariantHeader ? "" : "—")}</td>
<td className="py-1 pr-3 font-mono" style={{ color: "var(--color-text-muted)" }}>
{r.type}
</td>
<td className="py-1" style={{ color: "var(--color-text)" }}>
{r.description || (r.isVariantHeader ? "" : "—")}
</td>
</tr>
))}
</tbody>
@@ -274,12 +305,8 @@ export function WorkflowDetail({ client, workflowName, onBack }: Props) {
<h2 className="text-xl font-semibold mb-4 font-mono">{workflowName}</h2>
{status === "loading" && (
<p style={{ color: "var(--color-text-muted)" }}>Loading...</p>
)}
{status === "error" && (
<p style={{ color: "var(--color-error)" }}>Error: {error}</p>
)}
{status === "loading" && <p style={{ color: "var(--color-text-muted)" }}>Loading...</p>}
{status === "error" && <p style={{ color: "var(--color-error)" }}>Error: {error}</p>}
{detail !== null && (
<div className="flex gap-4" style={{ minHeight: "calc(100vh - 160px)" }}>
@@ -327,7 +354,10 @@ export function WorkflowDetail({ client, workflowName, onBack }: Props) {
className="rounded-lg border p-4"
style={{ borderColor: "var(--color-border)", background: "var(--color-surface)" }}
>
<p className="text-sm whitespace-pre-wrap mb-3" style={{ color: "var(--color-text)" }}>
<p
className="text-sm whitespace-pre-wrap mb-3"
style={{ color: "var(--color-text)" }}
>
{descriptor !== null && descriptor.description !== ""
? descriptor.description
: "—"}
@@ -10,7 +10,13 @@ const FEEDBACK_RADIUS = 16;
* Build an SVG path for a feedback (back) edge that routes to the given side of the nodes.
* The path goes: source → arc → vertical up → arc → target
*/
function feedbackPath(sourceX: number, sourceY: number, targetX: number, targetY: number, side: "right" | "left"): string {
function feedbackPath(
sourceX: number,
sourceY: number,
targetX: number,
targetY: number,
side: "right" | "left",
): string {
const d = side === "right" ? 1 : -1;
const offsetX =
side === "right"
@@ -88,12 +94,7 @@ export function ConditionEdge(props: EdgeProps) {
return (
<>
<BaseEdge
id={id}
path={path}
markerEnd={markerEnd}
style={{ stroke, strokeWidth: 1.5 }}
/>
<BaseEdge id={id} path={path} markerEnd={markerEnd} style={{ stroke, strokeWidth: 1.5 }} />
{label !== "" && (
<EdgeLabelRenderer>
<div
@@ -45,11 +45,41 @@ export function RoleNode(props: NodeProps) {
}}
title={data.description}
>
<Handle type="target" position={Position.Top} id="top-in" style={handleStyle} isConnectable={false} />
<Handle type="target" position={Position.Left} id="left-in" style={handleStyle} isConnectable={false} />
<Handle type="target" position={Position.Right} id="right-in" style={handleStyle} isConnectable={false} />
<Handle type="source" position={Position.Left} id="left-out" style={handleStyle} isConnectable={false} />
<Handle type="source" position={Position.Right} id="right-out" style={handleStyle} isConnectable={false} />
<Handle
type="target"
position={Position.Top}
id="top-in"
style={handleStyle}
isConnectable={false}
/>
<Handle
type="target"
position={Position.Left}
id="left-in"
style={handleStyle}
isConnectable={false}
/>
<Handle
type="target"
position={Position.Right}
id="right-in"
style={handleStyle}
isConnectable={false}
/>
<Handle
type="source"
position={Position.Left}
id="left-out"
style={handleStyle}
isConnectable={false}
/>
<Handle
type="source"
position={Position.Right}
id="right-out"
style={handleStyle}
isConnectable={false}
/>
<div className="flex items-center gap-1.5 font-mono">
{icon !== null && (
<span
@@ -67,7 +97,13 @@ export function RoleNode(props: NodeProps) {
{data.description}
</div>
)}
<Handle type="source" position={Position.Bottom} id="bottom-out" style={handleStyle} isConnectable={false} />
<Handle
type="source"
position={Position.Bottom}
id="bottom-out"
style={handleStyle}
isConnectable={false}
/>
</div>
);
}
@@ -50,7 +50,13 @@ export function TerminalNode(props: NodeProps) {
isConnectable={false}
/>
) : (
<Handle type="target" position={Position.Top} id="top-in" style={handleStyle} isConnectable={false} />
<Handle
type="target"
position={Position.Top}
id="top-in"
style={handleStyle}
isConnectable={false}
/>
)}
{isStart ? "▶" : "■"}
</div>
@@ -216,7 +216,11 @@ function computeLayout(input: LayoutInput): LayoutResult {
id: edgeKey(e),
source: e.from,
target: e.to,
sourceHandle: isFeedback ? (feedbackSide === "left" ? "left-out" : "right-out") : "bottom-out",
sourceHandle: isFeedback
? feedbackSide === "left"
? "left-out"
: "right-out"
: "bottom-out",
targetHandle: isFeedback ? (feedbackSide === "left" ? "left-in" : "right-in") : "top-in",
type: "condition",
data: {
@@ -28,7 +28,11 @@ export function WorkflowList({ client, onSelect }: Props) {
type="button"
onClick={() => onSelect(w.name)}
className="w-full text-left p-4 rounded-lg border hover:opacity-90"
style={{ background: "var(--color-surface)", borderColor: "var(--color-border)", color: "var(--color-text)" }}
style={{
background: "var(--color-surface)",
borderColor: "var(--color-border)",
color: "var(--color-text)",
}}
>
<div className="flex items-center gap-2">
<span className="font-medium">{w.name}</span>
@@ -40,10 +44,7 @@ export function WorkflowList({ client, onSelect }: Props) {
{w.hash !== null ? w.hash : "—"}
</code>
{w.timestamp !== null ? (
<span
className="text-xs mt-1 block"
style={{ color: "var(--color-text-muted)" }}
>
<span className="text-xs mt-1 block" style={{ color: "var(--color-text-muted)" }}>
Updated {new Date(w.timestamp).toLocaleString()}
</span>
) : null}
@@ -80,17 +80,20 @@ export function useHashRoute(): {
);
const setClient = useCallback(
(a: string | null) => navigate({ view: route.view, client: a, threadId: null, workflowName: null }),
(a: string | null) =>
navigate({ view: route.view, client: a, threadId: null, workflowName: null }),
[navigate, route.view],
);
const setThreadId = useCallback(
(id: string | null) => navigate({ view: "threads", client: route.client, threadId: id, workflowName: null }),
(id: string | null) =>
navigate({ view: "threads", client: route.client, threadId: id, workflowName: null }),
[navigate, route.client],
);
const setWorkflowName = useCallback(
(name: string | null) => navigate({ view: "workflows", client: route.client, threadId: null, workflowName: name }),
(name: string | null) =>
navigate({ view: "workflows", client: route.client, threadId: null, workflowName: name }),
[navigate, route.client],
);