swarm ui: agents page opens an agent's details beside the list
Selecting an agent card opens its details in a column on the right of the agents list, at /agents/<name>, instead of unfolding the card in place. The list is full width until an agent is selected, then narrows and the details slide in. A narrow screen shows the details alone, with a back button. A card's message is cut to one line. The shell treats /agents/<name> as the agents page, so the nav tab stays lit and the page is not rebuilt on each selection.
This commit is contained in:
parent
2d3da56907
commit
7bdaea7954
2 changed files with 494 additions and 154 deletions
|
|
@ -16,7 +16,7 @@ import { HideDebugSetting } from "@hive/shared/hide-debug-setting.js";
|
|||
import { ShowThinkingSetting } from "@hive/shared/show-thinking-setting.js";
|
||||
import { GripIcon } from "@hive/shared/icons.js";
|
||||
import { ExpandDetailsSetting } from "@hive/shared/expand-details-setting.js";
|
||||
import { isFullBleedRoute, visibleNavItems } from "./routes.js";
|
||||
import { isFullBleedRoute, pageOf, visibleNavItems } from "./routes.js";
|
||||
import { useDynamicTabs } from "./useDynamicTabs.js";
|
||||
import {
|
||||
groupIdOf,
|
||||
|
|
@ -175,7 +175,9 @@ function DynamicTabLink({
|
|||
|
||||
export function Shell({ children }: { children: ComponentChildren }) {
|
||||
const swarmName = useSwarmName();
|
||||
const [location] = useLocation();
|
||||
const [path] = useLocation();
|
||||
// An agent selected on the agents page is still that page.
|
||||
const location = pageOf(path);
|
||||
// Open agent-terminal tabs, drawn in the nav row after the fixed routes.
|
||||
const { tabs, close: closeTab, move: moveTabTo } = useDynamicTabs();
|
||||
const termGroups = useTermGroups();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,36 @@ export function isFullBleedRoute(location: string): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
// The agents page shows one agent's details beside the list at
|
||||
// `/agents/:name`. A single segment after `/agents` is that, except `group`,
|
||||
// which starts a terminal group's path (`/agents/group/:id`).
|
||||
const SELECTED_AGENT_PATTERN = /^\/agents\/([^/]+)$/;
|
||||
|
||||
/** The agent a path selects on the agents page, or `null` for any other path. */
|
||||
export function selectedAgent(location: string): string | null {
|
||||
const match = SELECTED_AGENT_PATTERN.exec(location);
|
||||
if (match === null || match[1] === "group") return null;
|
||||
try {
|
||||
return decodeURIComponent(match[1]);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The path of the agents page with this agent selected. */
|
||||
export function agentPath(name: string): string {
|
||||
return `/agents/${encodeURIComponent(name)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The page a path belongs to, for the shell: selecting an agent on the agents
|
||||
* page stays on that page, so its nav tab stays lit and the page's body is not
|
||||
* rebuilt (which would replay its entrance and drop the list's scroll).
|
||||
*/
|
||||
export function pageOf(location: string): string {
|
||||
return selectedAgent(location) === null ? location : "/agents";
|
||||
}
|
||||
|
||||
// Routes that only a developer needs. "hide developer details" takes their
|
||||
// tabs out of the nav; the pages themselves still answer at their paths.
|
||||
const DEVELOPER_ROUTES = ["/components"];
|
||||
|
|
|
|||
Loading…
Reference in a new issue