swarm ui: the messages page's feed is a folded card named message log
The messages page had a card called messages under a nav tab called messages, and its feed was the only part of the page open on arrival. The feed is now the folded message log card, like the broadcast and schedules cards above it. Its header carries the connection badge (live, reconnecting, disconnected) so the state shows while it is folded; the reconnect button moves into the bar inside it. The stream keeps running while the card is folded, and opening it scrolls the list to the newest message.
This commit is contained in:
parent
c3e24fe2c6
commit
f29435fcf1
2 changed files with 27 additions and 23 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/* <MessagesPage>: the filter bar over the terminal-style message list. */
|
||||
@import "@hive/shared/terminal.css";
|
||||
|
||||
/* The broadcast card, folded by default, over the messages card. */
|
||||
/* The broadcast and schedules cards, folded by default, over the message log. */
|
||||
.ui-messages-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// streams them (`GET /api/messages/stream`), across all hives. Above the
|
||||
// list, a folded **broadcast** card holds the composer that sends one message
|
||||
// to several agents, and a folded **schedules** card holds the scheduled prompts.
|
||||
// The list itself is the folded **message log** card.
|
||||
//
|
||||
// The stream sends the chosen window of history first, then the live tail. A
|
||||
// message an agent drained with an in-turn `recv` is missing, because it starts
|
||||
|
|
@ -17,7 +18,6 @@ import { BroadcastComposer } from "../broadcast/BroadcastComposer.js";
|
|||
import { SchedulesCard } from "../schedules/SchedulesPage.js";
|
||||
import { Disclosure } from "../../ui/disclosure/Disclosure.js";
|
||||
import { Hint } from "../../ui/hint/Hint.js";
|
||||
import { Panel } from "../../ui/panel/Panel.js";
|
||||
import { SelectField } from "../../ui/select-field/SelectField.js";
|
||||
import { TextField } from "../../ui/text-field/TextField.js";
|
||||
import {
|
||||
|
|
@ -57,6 +57,8 @@ export function MessagesPage() {
|
|||
const [sinceMinutes, setSinceMinutes] = useState(DEFAULT_WINDOW_MINUTES);
|
||||
const [query, setQuery] = useState("");
|
||||
const [composing, setComposing] = useState(false);
|
||||
// The log starts folded, as the cards above it do.
|
||||
const [logOpen, setLogOpen] = useState(false);
|
||||
// The composer is built on the first open and kept after, so what was typed
|
||||
// and ticked stays through a fold, and a page where it is never opened does
|
||||
// not poll the agent list.
|
||||
|
|
@ -82,7 +84,7 @@ export function MessagesPage() {
|
|||
useLayoutEffect(() => {
|
||||
const el = logRef.current;
|
||||
if (el && stickToBottom) el.scrollTop = el.scrollHeight - el.clientHeight;
|
||||
}, [newestId, shown.length, stickToBottom]);
|
||||
}, [newestId, shown.length, stickToBottom, logOpen]);
|
||||
|
||||
return (
|
||||
<div class="ui-messages-page">
|
||||
|
|
@ -99,27 +101,27 @@ export function MessagesPage() {
|
|||
{composerBuilt ? <BroadcastComposer /> : null}
|
||||
</Disclosure>
|
||||
<SchedulesCard />
|
||||
<Panel
|
||||
title="messages"
|
||||
<Disclosure
|
||||
title="message log"
|
||||
icon="💬"
|
||||
actions={
|
||||
<>
|
||||
<Badge
|
||||
tone={CONNECTION_TONE[connection]}
|
||||
value={CONNECTION_LABEL[connection]}
|
||||
/>
|
||||
{connection === "closed" ? (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
title="open the message stream again"
|
||||
onClick={reconnect}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
hint={
|
||||
<Badge
|
||||
tone={CONNECTION_TONE[connection]}
|
||||
value={CONNECTION_LABEL[connection]}
|
||||
/>
|
||||
}
|
||||
open={logOpen}
|
||||
onToggle={setLogOpen}
|
||||
>
|
||||
<div class="ui-messages-bar">
|
||||
{connection === "closed" ? (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
title="open the message stream again"
|
||||
onClick={reconnect}
|
||||
/>
|
||||
) : null}
|
||||
<SelectField
|
||||
id="messages-window"
|
||||
label="history"
|
||||
|
|
@ -165,7 +167,7 @@ export function MessagesPage() {
|
|||
an in-turn <code>recv</code> is missing. The history is at most 100
|
||||
recent messages per agent.
|
||||
</Hint>
|
||||
</Panel>
|
||||
</Disclosure>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue