Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344<script lang="ts"> import type { NodeProps } from '@xyflow/svelte'; import type { Session } from '../api'; import { SIZE, type AgentsWindow } from '../board.svelte'; import { refit } from '../agentTree'; import { boards } from '../boards.svelte'; import { sessions } from '../sessions.svelte'; import AgentsView from '../views/AgentsView.svelte'; import WindowFrame from './WindowFrame.svelte';
// The agents of one session as a tree, beside the chat it was asked from; // an agent picked in it opens as a chat window beside the tree. The window // is as big as its tree needs until the person resizes it; the size it was // last fitted to is kept on the window, so a reload still tells the two apart. let { id, data, selected }: NodeProps<AgentsWindow> = $props(); const session = $derived(sessions.byId.get(data.sessionId)); const node = $derived(boards.board?.nodes.find((candidate) => candidate.id === id));
/** The title bar's height (WindowFrame's), and the most a window grows to however big the tree. */ const HEADER = 42; const MOST = { width: 1500, height: 960 }; let content = $state<{ width: number; height: number } | null>(null);
$effect(() => { if (!content || node?.type !== 'agents') return; const want = { width: Math.round(Math.min(MOST.width, Math.max(SIZE.minWidth, content.width))), height: Math.round(Math.min(MOST.height, Math.max(SIZE.minHeight, content.height + HEADER))), }; const size = { width: node.width ?? 0, height: node.height ?? 0 }; const fitted = refit(size, node.data.fit, want); if (fitted) boards.board?.fitAgents(id, fitted.width, fitted.height); });
function open(agent: Session) { sessions.adopt(agent); boards.board?.openSession(agent.id, id); }</script>
<WindowFrame {id} selected={!!selected} title="agents · {session?.name || 'untitled session'}"> <AgentsView sessionId={data.sessionId} onopen={open} onfit={(size) => (content = size)} /></WindowFrame>