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.
12345678910111213141516171819202122232425262728293031323334353637383940414243<script lang="ts"> import type { Session } from '../api'; import { SIZE, type AgentsWindow, type WindowProps } 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 }: WindowProps<AgentsWindow> = $props(); const session = $derived(sessions.byId.get(data.sessionId)); const placed = $derived(boards.board?.placedOf(id) ?? null);
/** 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 || !placed) 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: placed.width, height: placed.height ?? 0 }; const fitted = refit(size, 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>