swarm-ui: fix treefmt formatting drift on the agent term files
This commit is contained in:
parent
b3c242ea5c
commit
e18619329d
2 changed files with 11 additions and 8 deletions
|
|
@ -9,7 +9,10 @@
|
|||
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
||||
import { Row } from "@hive/shared/term-row.js";
|
||||
import { useSwarmTermStream, type ConnectionState } from "./useSwarmTermStream.js";
|
||||
import {
|
||||
useSwarmTermStream,
|
||||
type ConnectionState,
|
||||
} from "./useSwarmTermStream.js";
|
||||
import "./AgentTermPreview.css";
|
||||
|
||||
const NEAR_BOTTOM_PX = 48;
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@
|
|||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import type { TermMsg, TermRow } from "@hive/shared/term-msg.js";
|
||||
|
||||
export type ConnectionState =
|
||||
| "connecting"
|
||||
| "open"
|
||||
| "reconnecting"
|
||||
| "closed";
|
||||
export type ConnectionState = "connecting" | "open" | "reconnecting" | "closed";
|
||||
|
||||
function appendRow(rows: TermRow[], row: TermRow): TermRow[] {
|
||||
const last = rows[rows.length - 1];
|
||||
|
|
@ -30,7 +26,9 @@ export interface UseSwarmTermStreamResult {
|
|||
connection: ConnectionState;
|
||||
}
|
||||
|
||||
export function useSwarmTermStream(streamUrl: string): UseSwarmTermStreamResult {
|
||||
export function useSwarmTermStream(
|
||||
streamUrl: string,
|
||||
): UseSwarmTermStreamResult {
|
||||
const [rows, setRows] = useState<TermRow[]>([]);
|
||||
const [connection, setConnection] = useState<ConnectionState>("connecting");
|
||||
const keySeqRef = useRef(0);
|
||||
|
|
@ -61,7 +59,9 @@ export function useSwarmTermStream(streamUrl: string): UseSwarmTermStreamResult
|
|||
setRows((prev) => appendRow(prev, { ...msg, key, fromHistory: false }));
|
||||
};
|
||||
es.onerror = () => {
|
||||
setConnection(es.readyState === 0 /* CONNECTING */ ? "reconnecting" : "closed");
|
||||
setConnection(
|
||||
es.readyState === 0 /* CONNECTING */ ? "reconnecting" : "closed",
|
||||
);
|
||||
};
|
||||
return () => es.close();
|
||||
}, [streamUrl]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue