swarm-ui: let a closed stream reconnect and a failed caps read retry
When the server answers an event stream with an error status the browser gives up and the badge stayed on disconnected with nothing to press. The terminal, its state header and the messages page now offer a reconnect, and the one rule for the state after an error moved into a tested helper. The resource caps panel gets a retry beside its error, and its loading state announces itself.
This commit is contained in:
parent
9b1fe85706
commit
31b7452e56
9 changed files with 118 additions and 34 deletions
|
|
@ -203,8 +203,10 @@ export function AgentTermPreview({
|
|||
leading?: ComponentChildren;
|
||||
}) {
|
||||
const paths = termPaths(agentName, subagent);
|
||||
const { rows, connection } = useSwarmTermStream(paths.stream);
|
||||
const { header } = useSwarmAgentStateStream(paths.state);
|
||||
const { rows, connection, reconnect } = useSwarmTermStream(paths.stream);
|
||||
const { header, reconnect: reconnectState } = useSwarmAgentStateStream(
|
||||
paths.state,
|
||||
);
|
||||
const { open: openTab } = useDynamicTabs();
|
||||
const logRef = useRef<HTMLDivElement>(null);
|
||||
const [stickToBottom, setStickToBottom] = useState(true);
|
||||
|
|
@ -246,6 +248,17 @@ export function AgentTermPreview({
|
|||
tone={CONNECTION_TONE[connection]}
|
||||
value={CONNECTION_LABEL[connection]}
|
||||
/>
|
||||
{connection === "closed" && (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
title={`open ${paths.label}'s terminal stream again`}
|
||||
onClick={() => {
|
||||
reconnect();
|
||||
reconnectState();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{header && showHeaderBadges && (
|
||||
<StateBadges header={header} ctx={ctx} cost={cost} />
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue