~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

A tile's menu arranges it on the web, as on iOS

Open chadtmiller.com wants to merge into main from chadtmiller.com/hud:web/arrange-menu
docs/workspace.md+2−0
@@ -77,6 +77,8 @@ HUD puts a new tile in the first place that applies:
A move gives the moved tile a number between its new neighbours' numbers, so it's the only tile rewritten. Where two neighbours leave no room (some fifty halvings in one place), HUD numbers that line 1, 2, 3… again. When a column's head is taken off, the next tile in its stack heads it.
A tile's menu arranges it, on the web and in the iOS app. It moves its column a place left or right, sets the column's width, stacks the tile under the column on its left, and takes it out of its stack. On a phone, where a column fills the screen, it sets no width. On the web, Shift with ← or → moves the focused column too.
## Canonical calls
HUD keeps each call canonical:
web/workspace/lib/organisms/Strip.svelte+8−2
@@ -222,6 +222,7 @@
{#if one.kind === 'tile'}
{@const tile = one.tile}
{@const column = columnOf(one.key)}
{@const at = where.get(one.key) ?? { c: 0, r: 0 }}
{@const account = accountOf(tile.tool, tile.arguments)}
<Tile
{tile}
@@ -235,7 +236,9 @@
source={source(one.key, tile.from)}
author={tile.author !== me.did ? tile.author : null}
{readonly}
width={column?.slots[0].key === one.key ? widthOf(ui.zoomed === column.key ? 'full' : column.width).label : null}
width={column?.width ?? 'third'}
head={at.r === 0}
moves={{ left: at.c > 0, right: at.c < strip.length - 1, stack: strip[at.c - 1]?.slots[0].kind === 'tile', unstack: at.r > 0 }}
zoomed={ui.zoomed === column?.key}
live={shown && !(column && far.has(column.key))}
onfocus={() => ws.focus(canvas, one.key)}
@@ -243,7 +246,10 @@
if (!tile.from) return;
ws.show(canvas, tile.from);
}}
onwidth={() => ws.cycleWidth(canvas, one.key)}
onmove={(by) => void ws.move(canvas, one.key, by)}
onwidth={(width) => void ws.setWidth(canvas, one.key, width)}
onstack={() => void ws.stack(canvas, one.key)}
onunstack={() => void ws.unstack(canvas, one.key)}
onzoom={() => {
ws.focus(canvas, one.key);
ws.zoom(canvas);
web/workspace/lib/organisms/Tile.svelte+122−23
@@ -8,11 +8,12 @@
import Dot from '../atoms/Dot.svelte';
import Handle from '../atoms/Handle.svelte';
import Icon from '../atoms/Icon.svelte';
import Kbd from '../atoms/Kbd.svelte';
import Time from '../atoms/Time.svelte';
import { getTileContext } from '../context';
import { launcher } from '../launcher.svelte';
import { NowPlaying } from '../nowplaying.svelte';
import type { Actor, Tile } from '../model';
import { WIDTHS, widthOf, type Actor, type Tile, type Width } from '../model';
import TileMark from '../molecules/TileMark.svelte';
import { preview, type Preview } from '../preview';
import { profile } from '../profiles.svelte';
@@ -27,11 +28,13 @@
* A tile: its header (its icon, which opens its app's page, its title
* as people read it and the handle of the account it shows; the tile it
* was opened from; who added it, when someone else or an agent did; its
* column's width, zoom, refresh and close, on hover; and its details,
* the call and what it names, behind an info button), and its body, the
* call's result drawn as the MCP App view draws it, scrolling inside the
* column. What opens from it opens in a column of its own, right of it.
* To a viewer, nothing changes the canvas: no width, no close.
* column's menu to arrange it (a place left or right, its width, under
* the column on its left or out of its stack), zoom, refresh and close,
* on hover; and its details, the call and what it names, behind an info
* button), and its body, the call's result drawn as the MCP App view
* draws it, scrolling inside the column. What opens from it opens in a
* column of its own, right of it.
* To a viewer, nothing changes the canvas: no arranging, no close.
* A list newest first (a tree with `latest`) is asked now and then,
* while drawn, whether something newer came: then its refresh shows with
* a dot, and scrolled down, a button over its body goes to its top and
@@ -50,11 +53,16 @@
author,
readonly,
width,
head,
moves,
zoomed,
live,
onfocus,
onsource,
onmove,
onwidth,
onstack,
onunstack,
onzoom,
onclose,
onpreview,
@@ -77,14 +85,21 @@
/** Who added it, when not this person. */
author: string | null;
readonly: boolean;
/** Its column's width, as said (1/3), or null when a stack's lower tile, which takes its head's. */
width: string | null;
/** Its column's width. */
width: Width;
/** Whether it heads its column: its menu's button says the width, which a lower tile takes from its head. */
head: boolean;
/** Where it can go: its column a place left or right, under the column on its left, out of its stack. */
moves: { left: boolean; right: boolean; stack: boolean; unstack: boolean };
zoomed: boolean;
/** Whether to draw its body: near enough to the view, on the tab on screen. Not drawn, it keeps what it read and where its body was scrolled; a player's music goes on, in the workspace's player, but a video or an audio field in it stops. */
live: boolean;
onfocus: () => void;
onsource: () => void;
onwidth: () => void;
onmove: (step: -1 | 1) => void;
onwidth: (width: Width) => void;
onstack: () => void;
onunstack: () => void;
onzoom: () => void;
onclose: () => void;
/** What it drew, in short, each time it draws: its card in the overview. */
@@ -135,6 +150,19 @@
const callText = $derived(JSON.stringify({ tool: tile.tool, arguments: tile.arguments }, null, 2));
/** Which copy button just copied, for a moment. */
let copied = $state<'uri' | 'call' | null>(null);
/** Whether its menu to arrange it is open. */
let arranging = $state(false);
/** Its column's width as said, full while zoomed. */
const widthLabel = $derived(widthOf(zoomed ? 'full' : width).label);
/** Whether its menu has anything a phone shows, where a column is the screen's width and no width is chosen. */
const movable = $derived(moves.left || moves.right || moves.stack || moves.unstack);
/** A choice from its menu to arrange it: the menu closed, then the change made. */
function arrange(run: () => void) {
arranging = false;
run();
}
/** A profile tile of the very account that added it: its face is its mark already, so it is not drawn twice. */
const showsAuthor = $derived.by(() => {
const actor = actorOf(tile.tool, tile.arguments);
@@ -408,8 +436,40 @@
</div>
</details>
<div class="controls" class:fresh>
{#if width && !readonly}
<button type="button" class="icon-button width" title="Width (R)" aria-label="Width {width}, change" onclick={onwidth}>{width}</button>
{#if !readonly}
<details class="popover sheet end arrange" class:movable bind:open={arranging}>
<summary class="icon-button" title="Arrange" aria-label={head ? `Arrange, width ${widthLabel}` : 'Arrange'}>
{#if head}<span class="width">{widthLabel}</span>{/if}
<span class="glyph" class:alone={!head}><Icon name="arrange" /></span>
</summary>
<div class="menu" role="menu">
{#if movable}<p class="menu-head">Arrange</p>{/if}
{#if moves.left}
<button type="button" class="menu-item" role="menuitem" onclick={() => arrange(() => onmove(-1))}><Icon name="moveLeft" /><span class="grow">Move left</span><Kbd keys="⇧←" /></button>
{/if}
{#if moves.right}
<button type="button" class="menu-item" role="menuitem" onclick={() => arrange(() => onmove(1))}><Icon name="moveRight" /><span class="grow">Move right</span><Kbd keys="⇧→" /></button>
{/if}
{#if moves.stack}
<button type="button" class="menu-item" role="menuitem" onclick={() => arrange(onstack)}><Icon name="stack" /><span class="grow">Stack under the column on its left</span></button>
{/if}
{#if moves.unstack}
<button type="button" class="menu-item" role="menuitem" onclick={() => arrange(onunstack)}><Icon name="unstack" /><span class="grow">Take out of stack</span></button>
{/if}
<!-- On a phone a column is the screen's width already: no width to choose. -->
<div class="widths">
{#if movable}<hr />{/if}
<p class="menu-head">Width</p>
{#each WIDTHS as one (one.width)}
<button type="button" class="menu-item" role="menuitemradio" aria-checked={one.width === width} onclick={() => arrange(() => onwidth(one.width))}>
<span class="chosen">{#if one.width === width}<Icon name="check" />{/if}</span>
<span class="grow">{one.name}</span>
{#if one.label !== one.name}<span class="mute">{one.label}</span>{/if}
</button>
{/each}
</div>
</div>
</details>
{/if}
<button type="button" class="icon-button zoom" aria-pressed={zoomed} title="Zoom (Z)" aria-label="Zoom" onclick={onzoom}><Icon name="zoom" /></button>
{#if fresh}
@@ -649,7 +709,7 @@
margin-inline: calc(-1 * var(--space-1)) calc(-1 * var(--space-1-5));
}
/* Width, zoom, refresh and close: where a pointer hovers, on hover or focus; always on touch. Close is outermost, as everywhere. */
/* Arrange, zoom, refresh and close: where a pointer hovers, on hover or focus, or while its menu is open; always on touch. Close is outermost, as everywhere. */
.controls {
display: none;
flex: none;
@@ -658,7 +718,8 @@
}
.tile:hover .controls,
.head:focus-within .controls {
.head:focus-within .controls,
.controls:has(.arrange[open]) {
display: flex;
}
@@ -672,7 +733,8 @@
}
.tile:hover .controls.fresh > *,
.head:focus-within .controls.fresh > * {
.head:focus-within .controls.fresh > *,
.controls.fresh:has(.arrange[open]) > * {
visibility: visible;
}
@@ -686,10 +748,54 @@
}
}
/* On a phone a column is the screen's width already: no width to choose, nothing to zoom; and its header one line, the title giving way before the handle. */
/* Its menu's button says its column's width, as 1/3; a stack's lower tile, and a phone, its icon instead. */
.arrange > summary {
width: auto;
min-width: var(--control-sm);
padding: 0 var(--space-1);
}
.arrange[open] > summary {
background: var(--hover);
color: var(--fg);
}
.width {
font: var(--text-xs) var(--font-mono);
}
.glyph:not(.alone) {
display: none;
}
.grow {
flex: 1;
min-width: 0;
}
/* The check's column, kept on every width so the words beside it line up. */
.chosen {
display: inline-grid;
flex: none;
place-items: center;
width: var(--icon);
}
/* On a phone a column is the screen's width already: no width to choose, nothing to zoom, and a menu to arrange it only where it can move; and its header one line, the title giving way before the handle. */
@media (max-width: 640px) {
.width,
.zoom {
.widths,
.zoom,
.arrange:not(.movable) {
display: none;
}
.arrange .glyph {
display: inline-flex;
}
/* Nothing on a phone takes keys. */
.menu-item > :global(kbd) {
display: none;
}
@@ -783,13 +889,6 @@
line-height: var(--leading-tight);
}
.width {
width: auto;
min-width: var(--control-sm);
padding: 0 var(--space-1);
font: var(--text-xs) var(--font-mono);
}
/* Refresh, with something newer come: its dot on its corner, ringed apart from its arrow. */
.fresh > .refresh {
position: relative;
web/workspace/lib/icons.ts+8−0
@@ -9,6 +9,7 @@ import add from 'lucide-static/icons/plus.svg?raw';
import addAccount from 'lucide-static/icons/user-plus.svg?raw';
import agent from 'lucide-static/icons/sparkles.svg?raw';
import app from 'lucide-static/icons/app-window.svg?raw';
import arrange from 'lucide-static/icons/move-horizontal.svg?raw';
import back from 'lucide-static/icons/arrow-left.svg?raw';
import bell from 'lucide-static/icons/bell.svg?raw';
import canvas from 'lucide-static/icons/layout-dashboard.svg?raw';
@@ -28,6 +29,8 @@ import info from 'lucide-static/icons/info.svg?raw';
import issue from 'lucide-static/icons/circle-dot.svg?raw';
import light from 'lucide-static/icons/sun.svg?raw';
import more from 'lucide-static/icons/ellipsis.svg?raw';
import moveLeft from 'lucide-static/icons/move-left.svg?raw';
import moveRight from 'lucide-static/icons/move-right.svg?raw';
import music from 'lucide-static/icons/music.svg?raw';
import newCanvas from 'lucide-static/icons/square-plus.svg?raw';
import newer from 'lucide-static/icons/arrow-up.svg?raw';
@@ -49,6 +52,7 @@ import star from 'lucide-static/icons/star.svg?raw';
import switchAccount from 'lucide-static/icons/arrow-left-right.svg?raw';
import thread from 'lucide-static/icons/messages-square.svg?raw';
import system from 'lucide-static/icons/monitor.svg?raw';
import unstack from 'lucide-static/icons/square-split-vertical.svg?raw';
import theme from 'lucide-static/icons/palette.svg?raw';
import view from 'lucide-static/icons/eye.svg?raw';
import width from 'lucide-static/icons/columns-3.svg?raw';
@@ -59,6 +63,7 @@ const svgs = {
addAccount,
agent,
app,
arrange,
back,
bell,
canvas,
@@ -78,6 +83,8 @@ const svgs = {
issue,
light,
more,
moveLeft,
moveRight,
music,
newCanvas,
newer,
@@ -100,6 +107,7 @@ const svgs = {
system,
theme,
thread,
unstack,
view,
width,
zoom
web/workspace/lib/model.ts+6−6
@@ -25,12 +25,12 @@ export type Role = 'owner' | 'editor' | 'viewer';
export type Width = 'third' | 'half' | 'two-thirds' | 'full';
/** Each width, its share of the strip's visible width, and how it is said. */
export const WIDTHS: { width: Width; share: number; label: string }[] = [
{ width: 'third', share: 1 / 3, label: '1/3' },
{ width: 'half', share: 1 / 2, label: '1/2' },
{ width: 'two-thirds', share: 2 / 3, label: '2/3' },
{ width: 'full', share: 1, label: 'Full' }
/** Each width, its share of the strip's visible width, and how it is said, short and in words. */
export const WIDTHS: { width: Width; share: number; label: string; name: string }[] = [
{ width: 'third', share: 1 / 3, label: '1/3', name: 'A third' },
{ width: 'half', share: 1 / 2, label: '1/2', name: 'Half' },
{ width: 'two-thirds', share: 2 / 3, label: '2/3', name: 'Two thirds' },
{ width: 'full', share: 1, label: 'Full', name: 'Full' }
];
/** The most tiles a column stacks. */
web/workspace/lib/workspace.svelte.ts+3−3
@@ -678,11 +678,11 @@ export class Workspace {
}
}
/** Move the focused column one place left or right. */
async move(canvas: string, step: -1 | 1): Promise<boolean> {
/** Move a column, by any slot in it, one place left or right. */
async move(canvas: string, key: string, step: -1 | 1): Promise<boolean> {
const ui = this.ui(canvas);
const strip = this.strip(canvas);
const at = strip.findIndex((column) => column.slots.some((slot) => slot.key === ui.focus));
const at = strip.findIndex((column) => column.slots.some((slot) => slot.key === key));
const column = strip[at];
const other = strip[at + step];
if (!column || !other) return false;
web/workspace/Workspace.svelte+4−4
@@ -217,15 +217,15 @@
case 'h':
case 'H':
event.preventDefault();
if (shift) void ws.move(current, -1);
else step(-1);
if (!shift) step(-1);
else if (focus) void ws.move(current, focus, -1);
break;
case 'ArrowRight':
case 'l':
case 'L':
event.preventDefault();
if (shift) void ws.move(current, 1);
else step(1);
if (!shift) step(1);
else if (focus) void ws.move(current, focus, 1);
break;
case 'ArrowUp':
case 'ArrowDown':