# Authoring a view (view/1) A view is a record of kind `view` whose `spec` is a `view/1` object: named sources (queries the hub runs for each viewer) and sections (built-in layouts over those sources). No remote references, and no HTML or script except in an app section, which runs sandboxed. This page is everything an agent needs to write one with only MCP or REST access. - JSON Schema of view/1: https://ah.meyu.us/schemas/view/1.json, and of theme/1: https://ah.meyu.us/schemas/theme/1.json (structure, types and limits; the cross-field rules below are checked by the hub, so for a view preview_view is the final word; a theme is checked when it's published). The same schemas are the ViewSpec and ThemeSpec components of https://ah.meyu.us/openapi.json (REST) and https://ah.meyu.us/openrpc.json (MCP), and the api-catalog links them as `describedby`. - create_record and preview_view carry a complete, valid example spec in their input schemas (the `examples` of `spec`). ## The authoring loop 1. Draft the spec and check it without saving: preview_view {"spec": {...}, "title": "..."}. It returns {valid, errors, rendered}. When valid is false, each error has a `path` (for example `spec.sources.news`, or `spec.sections.0.source`) and a `message`; a check across several fields reports at the source and its message starts with "Value error, ". A field a spec object doesn't take lists the ones it does ("allowed here: ..."). Fix exactly those paths and preview again. 2. Publish it: create_record {"key": "front-page", "kind": "view", "title": "...", "text": "What this view is for, in Markdown.", "spec": {...}, "idempotency_key": "..."}. An invalid spec is refused with code `invalid_spec` and the same per-path list, with `guide` and `schema` naming this page and the spec's JSON Schema. Revise later with update_record and the whole new `spec`. 3. Preview the saved record: preview_view {"view": "records/front-page"}, or render_view with the same view. 4. Hand it to the person. Agents can't assign a person's view: set_my_view always sets the caller's own default, so an agent calling it sets its own. Point the person to the view's page on the dashboard, /view/ (for example /view/front-page): there they preview it as themselves and choose "Use as my view", with or without replacing the Daily. Workspace administrators can also use it for the whole workspace there. Every view is also listed under Library → Views. As a fallback, give them the input to run as themselves: set_my_view {"view": "records/front-page", "replaces_daily": true, "idempotency_key": "front-page-home-1"} `replaces_daily: true` shows the view on Today instead of the Daily (still a tab away); false shows it above the Daily. `records/` follows the latest revision; `records/@` pins one. A workspace's home view (set_workspace_view) is people-only: delegated agents are refused. Previews and renders run as the caller. An authoring agent sees only its own reach (its workspaces, labels and sight), never a reader's, so an empty section in your preview may be full for the person, and the reverse. Each viewer gets only what they may see; publishing a view grants nothing. ## Shape {"spec": "view/1", "sources": {: }, "sections": [
], "actions": {: }, "theme": "records/[@]", "guidance": "..."} Required: `spec`, `sources` (1 to 8), `sections` (1 to 20). Names of sources, sections and actions are lowercase: a letter, then up to 31 of a-z, 0-9, `_` or `-`. Unknown keys are refused everywhere. ## Sources A source is `{from, where, workspaces, order, fields, limit, window, bind}`; only `from` is required. `from` is one of: | `from` | items | `where` takes | `order` by | `fields` | |---|---|---|---|---| | `records` | records (not one held by a future not_before, where the workspace's Daily ranks records) | kinds, tags_all, tags_any, tags_none, since, until (last update, or there not_before when later), status, text | updated_at, created_at, title, endorsements, due | title, text_excerpt, text, tags, author, updated_at, created_at, endorsements, events, status, due, assignee, references | | `tasks` | tasks | tags_all, tags_any, tags_none, since, until, text, state | updated_at, created_at, title, endorsements, due | the records fields plus state, not_before, done_by | | `calendar` | happenings (records' events), as occurrences | kinds, tags_all, tags_any, tags_none, text, state; dated by `window` | start, sort_start, state | title, start, end, place, url, tags, state, sort_start | | `notes` | conversations or the viewer's inbox | since, until (last activity), text, box | updated_at, created_at | title, text_excerpt, author, created_at, updated_at, status, about | Anything a source can't honor is refused at its path. - `where.kinds`: up to 8 of goal, decision, finding, proposal, artifact, message, view, theme, contract, story, charter. - `where.tags_all` / `tags_any` / `tags_none`: up to 10 key:value tags each. - `where.since` / `until`: an ISO 8601 duration counting back from now (`P7D`, `PT12H`) or an instant (`2026-10-15`, `2026-10-15T09:00Z`). - `where.status`: active, superseded, archived (default `["active"]`). - `where.text`: text search, up to 200 characters. - `where.state` (tasks): open, pending, claimed, lease_expired, opens_later, standing, complete, cancelled. `open` means pending, claimed or lease_expired. - `where.state` (calendar): ongoing, upcoming, finished (see `window`). - `where.box` (notes only): `conversations` (default; each conversation's first note, by latest activity) or `inbox` (notes to the viewer they haven't seen, answered or closed). Notes leave the hub as 280-character excerpts. - `window` (calendar only): `{"past_days": 0-31, "days": 1-92}`, defaults 0 and 14, in the hub's paper time zone: from past_days before today up to, not including, days after today. A window holds every occurrence that intersects it, so a multi-day happening that began earlier and is still running is listed too. Each calendar item says where it stands: `state`, carried whatever its `fields`, is `ongoing` (began before today and hasn't ended), `upcoming` (begins today or later) or `finished` (ended before today; only a window with past_days reaches one), and `sort_start` is the later of its `start` and the window's first day, carried in full only when `fields` holds `start` or `sort_start` and otherwise as the date alone (a view that hides times keeps them hidden; ordering still uses the full value). Order by `sort_start` to list what is already running at the window's start instead of at its old start date, by `state` to group them (ascending: finished, ongoing, upcoming), or filter with `where.state` (see the example below). - `workspaces`: `{"scope": "this"}` (default; the view's workspace), `{"scope": "viewer"}` (every workspace the viewer can read) or `{"scope": "list", "ids": [...]}` (up to 50 workspace IDs or addresses, as the workspace menu and brief.you.workspaces show them). Narrow by workspace tags with `tags_any` / `tags_all` (for example `["kind:news"]`). Each item names its workspace. A calendar source groups one event's reports across all the workspaces it reads, each read with the viewer's own sight there. An occurrence that more than one record reports adds `sources` (each record's `id`, `workspace` slug, `title` and `url`) and `workspaces` (`id`, `slug`, `name`); its item is the best-cited, then newest, report. - `order`: up to 3 of `{"by": ..., "dir": "asc"|"desc", "count": "people"|"all"}` (`count` for endorsements). Default updated_at descending; calendar defaults to start ascending (by each happening's own start, ongoing ones included). - `fields`: up to 16; only these leave the hub. Default `["title", "updated_at"]` (calendar: title, start, end, place; notes: title, text_excerpt, author, updated_at). A tasks source's `done_by` names who finished a complete task (whoever finished its claim, or closed a standing request): `person:` for a person's own dashboard sign-in, with `done_by_role: "owner"` for the workspace's owner, and otherwise the agent's subject; nothing on unfinished tasks. - `limit`: 1 to 200, default 50. - `bind` (optional): what each viewer may choose for this source in their own private bindings: `{"workspaces": true}` (needs scope viewer or list), `{"tags_any": true}` (not for notes), or both. Bindings only narrow; a source without `bind` is fixed. A person sets theirs with set_view_bindings {"view": "records/front-page", "bindings": {"news": {"workspaces": ["family"], "tags_any": ["topic:garden"]}}, "idempotency_key": "..."} and lists their choices with view_bindings. ## Sections `{id, source, layout, title, take, skip, group_by, actions, app, height}`; `id` and `layout` are required, `source` is required for every layout but `app`, and `source` must name a declared source. - `layout`: lead, cards, compact, columns, table, calendar, checklist, app (an app section, below; off unless the operator sets HUB_VIEW_APPS=1). - `title`: up to 120 characters. - `take` (1 to 200) and `skip` (0 to 200) slice the source's items, so two sections can share one source (a lead of 1, then cards after it). - `group_by`: `tag:`, `kind`, `author` or `day`. - `actions`: up to 8 names declared in the view's `actions`. ## App sections (HUB_VIEW_APPS) A view can carry its own app: HTML, SVG and script you write, stored in the hub, drawing the section's items however you like (a countdown, a ticker, an animated scene). Nothing outside the hub is needed. On a hub without HUB_VIEW_APPS=1, a spec with an app section is refused with code `feature_unavailable` (preview_view lists it under `errors`), and a stored one isn't shown: render_view lists it in `unresolved` as `apps_off`. 1. Upload the page with attach {"name": "Holiday countdown", "content_type": "text/html", "data": ""}: one self-contained UTF-8 HTML file of at most 256 KiB, with inline script, style, SVG and `data:` images. It returns the attachment's `id`. 2. Name it in a section: `{"id": "board", "layout": "app", "app": "attachment:", "source": "chores", "height": 420}`. `height` is 160 to 800 pixels (default 360): the frame's height until the app says how tall it is (see "Size" below). `title`, `source`, `take` and `skip` work as for any section; `group_by` and `actions` don't apply. 3. Publish the view with create_record. The HTML must be this view record's own: an attachment you uploaded that no other record uses. Another record's HTML is refused at `spec.sections.N.app`. The app runs on the person's dashboard in the hub's app sandbox: its own origin, scripts only, no network, storage, cookies or credentials, the same isolation as app blocks in records. It never fetches. It receives the section's items: what a built-in layout gets for that viewer (their own access, bindings and hidden records, after order, limit, `take` and `skip`, only the source's `fields`), capped by what you, the HTML's uploader, could read now. An app sees the intersection of its viewer and its author: an item in a workspace you've left, or with a label you hold no grant for, stays in the viewer's built-in sections but never reaches the app, and the hub's chrome says how many weren't shared with it. So an app can't reveal anything its author couldn't already read. Each viewer's app gets only their own items, and nothing about other viewers. Sources across workspaces work as in any section: each item is read as the viewer in its own workspace, with their bindings, and capped by your access there. Items carry no private signals of the viewer's: endorsement counts without their own stance, and no view actions or current-workspace flag. An app stays on its page. If its frame loads another document (it navigates itself), the dashboard stops it and sends nothing more until the person starts it again; `location.reload()` and `document.open()` after load count too. The app starts on its own wherever the view shows: on Today for people who chose the view (set_my_view) or whose workspace uses it (set_workspace_view), on the view's page, and in "Preview as me" for the previewer alone. Choosing or assigning the view is the consent; there is no separate approval or Play step. The HTML is part of the view record's version: a pinned view (`records/@`) keeps that version's app, and a following one gets each new version's, like the rest of the view. The app talks to the dashboard in the standard MCP Apps protocol (JSON-RPC 2.0 over `postMessage`, protocol version 2026-01-26), with the dashboard as a read-only host. An app written with the MCP Apps `App` class works unchanged; without a library it is a few lines: 1. Send the request `ui/initialize` (`{appInfo, appCapabilities, protocolVersion}`) to `window.parent`. The result carries `hostContext` (theme, locale, time zone, container size). 2. Send the notification `ui/notifications/initialized`. 3. Receive `ui/notifications/tool-input` once (`arguments`: `{view, section}`) and `ui/notifications/tool-result` with the data, then tool-result again with fresh items whenever the dashboard refreshes the view. Until it sends `ui/initialize` the app gets nothing at all: an app that only waits for data shows its loading state forever. preview_view can't catch that; it resolves the section's items but never runs the HTML, so its result says `app_runtime: "not_verified"` (and warns `app_handshake_missing` when the HTML never mentions `ui/initialize`). ### The app handshake Copy this into your HTML and write `draw`; it is the whole protocol an app needs to show its items, and it redraws on every later delivery: ```html
    ``` What arrives, each time (the items are the section's, with the source's fields): ```json {"jsonrpc": "2.0", "method": "ui/notifications/tool-result", "params": { "content": [{"type": "text", "text": "2 items for section board."}], "structuredContent": { "section": "board", "rendered_at": 1761390000, "workspace": {"id": "", "name": "Home"}, "items": [ {"id": "records/fair", "workspace": {"id": "", "slug": "home", "name": "Home"}, "title": "Harvest fair", "start": "2026-10-24", "end": "2026-10-26", "state": "ongoing", "sort_start": "2026-10-25"} ]}}} ``` The tool result's `structuredContent` is `{section, items, rendered_at, workspace}`: `section` is the section's id, `items` the rendered items (each with `id`, its own `workspace` and the source's fields), `rendered_at` the render time in Unix seconds and `workspace` the view's workspace `{id, name}`. A delivery over 512 KiB isn't sent, and an app's own messages are bounded too. Apps can't call tools or operations yet: `tools/call` and every other request gets a JSON-RPC error. Buttons that act through the hub's own chrome are later work. The hub's frame around the app carries a one-line "App by · never enter passwords here" and a small "App" badge in its corner, outside the app's pixels. It opens a panel with the app's author, the view, its version and workspace, why it's shown (the reader's own view, the workspace's home view, a view they opened, or a preview), how fresh the data is, how many items were withheld and why, and actions: Report (a note to the workspace owner) and Stop. Next to the badge are two icon buttons: Expand (shows the app in all the room below the hub's header; Collapse or Escape gives it back) and Stop (Start once stopped). ### Size The frame is the page's, not the app's: tell the dashboard how tall your content is and the frame grows or shrinks to fit, so the person never scrolls inside a scrolling page. Send the MCP Apps notification `ui/notifications/size-changed` with `{"height": }` after `ui/initialize` and whenever your content's height changes (the MCP Apps `App` class does this for you). The height must be a finite positive number; anything else is ignored. It is kept between 60 pixels and three times the window's height (at least 800). `width` is ignored: the frame is as wide as the section. ```js host.postMessage({jsonrpc: "2.0", method: "ui/notifications/size-changed", params: {height: document.documentElement.scrollHeight}}, "*"); ``` A home view whose first section is an app (on Today, as the person's view or the workspace's) gives that app the screen: its frame fills the room below the hub's header, or grows past it to your reported height, and it has no Expand button. Elsewhere the frame starts at the section's `height`. `hostContext.containerDimensions.height` is the frame's height when the app starts. Sizes only change the frame's height in the page's flow; an app can't place itself over the hub's header, badge or controls, and its sandbox is the same at any size. When the app is mostly scrolled out of view, or the tab is hidden, it gets `ui/notifications/host-context-changed` with `{"visibility": "hidden"}` (and `"visible"` when it's back; `hostContext.visibility` gives the state at start). Pause your own animation and sound then, and carry on where you left off, like a video. An app hidden for over a minute, or whose slot another visible app needs (at most four run at once), is unloaded and loads again when it's back, with a new `ui/initialize` and its data: draw everything from the data you're sent, not from state kept only inside the page. A theme still styles the page around the app; the art inside is the app's. ## Actions, theme and guidance - `actions` (up to 12): `{"operation": "endorse", "target": "item"|"view", "args": {"stance": "yea"}, "private": false, "label": "More like this"}`. Running one calls that operation as the viewer, with the fixed `args` plus the item's key; it grants nothing a direct call wouldn't. The operation must exist and can't be a people-only administrative one. All args together are at most 8 KiB. - `theme`: a theme record, `records/` or `records/@`, whose spec is theme/1 (palette `light` / `dark` with background, text, muted, accent, line, panel as #rrggbb; `font` and `headline_font` of system, serif, sans, mono, newspaper; `scale` 0.8 to 1.4; `density` compact, comfortable, spacious; `radius` 0 to 24). - `guidance` (up to 4000 characters): what the view's items mean, for agents. ## Pinned and excluded records Every view has two collections, kept beside the record, not in its spec, so curating one makes no new revision and needn't be its author: - `pinned`: these records come first in the view's records sources, in the view's own order. - `excluded`: these records never appear in the view until taken out again. They stay readable everywhere else. Only this workspace's administrators, or an agent acting for one, change them: set_view_collection {"view": "records/front-page", "collection": "excluded", "record": "rumour-roundup", "member": true, "idempotency_key": "..."} (`member: false` takes it out) and list them with view_collections. They apply to records in the view's own workspace, and only to what each viewer can already read: a pin never shows a record to someone who can't read it. The Daily (`"view": "daily"`, where it ranks records) takes them too: a pin there holds for one edition (`window`: the edition being written, the default, or the next); an exclusion holds in every edition until lifted. ## Limits The whole spec is at most 65536 bytes of JSON and nested at most 8 levels. A source has at most 8 kinds, 10 tags per tag list, 3 order rules and 16 fields; a view at most 8 sources, 20 sections and 12 actions. ## Example: a cross-workspace front page The week's findings and decisions from every workspace the viewer can read, the next two weeks' happenings, their inbox and their open tasks. The news source is bindable, so each person can narrow it to some workspaces or tags. ```json { "spec": "view/1", "sources": { "news": { "from": "records", "where": {"kinds": ["finding", "decision"], "since": "P7D"}, "workspaces": {"scope": "viewer"}, "order": [{"by": "updated_at", "dir": "desc"}], "fields": ["title", "text_excerpt", "tags", "author", "updated_at"], "limit": 20, "bind": {"workspaces": true, "tags_any": true} }, "coming_up": { "from": "calendar", "workspaces": {"scope": "viewer"}, "window": {"days": 14}, "fields": ["title", "start", "end", "place", "url"], "limit": 30 }, "inbox": { "from": "notes", "where": {"box": "inbox"}, "workspaces": {"scope": "viewer"}, "limit": 10 }, "work": { "from": "tasks", "where": {"state": ["open"]}, "workspaces": {"scope": "viewer"}, "order": [{"by": "updated_at", "dir": "desc"}], "fields": ["title", "state", "assignee", "updated_at"], "limit": 20 } }, "sections": [ {"id": "lead", "source": "news", "layout": "lead", "take": 1}, {"id": "news", "source": "news", "layout": "cards", "skip": 1, "take": 6, "actions": ["more"]}, {"id": "coming-up", "source": "coming_up", "layout": "calendar", "title": "Coming up"}, {"id": "inbox", "source": "inbox", "layout": "compact", "title": "For you"}, {"id": "work", "source": "work", "layout": "checklist", "title": "Open work"} ], "actions": { "more": {"operation": "endorse", "target": "item", "args": {"stance": "yea"}, "label": "More like this"} }, "guidance": "A front page across the viewer's workspaces: recent findings and decisions, happenings in the next two weeks, the viewer's inbox and open tasks." } ``` ## Example: the next three days, what's on now apart A multi-day happening that began last week is still in the next three days; ordered by `start` it would lead the list with its old date. Two sources over the same window keep it apart: what's on now, and what starts in the window, each ordered by `sort_start`. (One source ordered by `[{"by": "state", "dir": "asc"}, {"by": "sort_start", "dir": "asc"}]` lists the ongoing ones first in a single list instead.) ```json { "spec": "view/1", "sources": { "on_now": { "from": "calendar", "where": {"state": ["ongoing"]}, "window": {"days": 3}, "order": [{"by": "sort_start", "dir": "asc"}], "fields": ["title", "start", "end", "place"] }, "starting": { "from": "calendar", "where": {"state": ["upcoming"]}, "window": {"days": 3}, "order": [{"by": "sort_start", "dir": "asc"}], "fields": ["title", "start", "end", "place"] } }, "sections": [ {"id": "on-now", "source": "on_now", "layout": "compact", "title": "On now"}, {"id": "next", "source": "starting", "layout": "calendar", "title": "Next three days"} ] } ``` ## Example: a holiday countdown with a chores ticker (app section) A festive board: a countdown to a date and a ticker of the chores people finished this month, over a tasks source of completed tasks tagged `topic:chores`. The countdown isn't a hub feature; it's the app's own script. Replace the attachment id with the one attach returned for your HTML. ```json { "spec": "view/1", "sources": { "chores": { "from": "tasks", "where": {"state": ["complete"], "tags_any": ["topic:chores"], "since": "P30D"}, "workspaces": {"scope": "viewer"}, "order": [{"by": "updated_at", "dir": "desc"}], "fields": ["title", "done_by", "updated_at"], "limit": 40 } }, "sections": [ {"id": "board", "layout": "app", "app": "attachment:0123456789abcdef0123456789abcdef", "source": "chores", "title": "Holiday board", "height": 420}, {"id": "done", "source": "chores", "layout": "compact", "title": "Done lately", "take": 5} ], "guidance": "Completed chores (tasks tagged topic:chores) from the last 30 days, shown by a countdown-and-ticker app and as a list." } ``` The HTML, uploaded with attach (trimmed; style and art are yours): ```html

    …

    Waiting for the list…
    ``` Write item text with `textContent`, as here: item titles are other people's words. Common refusals and their fixes: - `spec.sections.N.source: names no declared source`: use a key of `sources`. - `spec.sources.X: ... can't project ...`: pick fields from that source's row in the table above. - `spec.sources.X: a calendar source is dated by window, over active records`: drop since, until and status from a calendar source; use `window`. - `spec.sources.X: bind.workspaces needs workspaces scope "viewer" or "list"`. - `spec.actions.X.operation: administrative operations can't be view actions`. - `spec.sections.N.app: no HTML attachment ... with this id here`: upload the page with attach first and use the `id` it returns. - `spec.sections.N.app: another record's HTML`: attach this view's own HTML. The same bytes always get the same id, so change them (a comment will do). - code `feature_unavailable` on `spec.sections.N.layout`: app sections are off on this hub; use a built-in layout. The design behind the format: docs/design/view-records.md in the hub's source.