# Pitwall extensions (Preview) > Pitwall's extension and Tile SDK docs in one file, for coding agents. Generated from docs/reference/extensions/ and the tile world's WIT; Preview until WIT 1.0, so names may still change. Source: https://pitwalls.github.io/pitwall/docs/extensions/ # Extensions An extension adds to Pitwall. Its main part is usually a tile: a view of its own in Pitwall's layout, next to your agents' terminals, files and web pages. An author writes it in Rust, Pitwall runs it in a sandbox and draws it with its own UI code, so it looks and behaves like the rest of the app. An extension can also give your agents tools of its own, and Pitwall registers them with every agent it starts through its MCP server, with no setup on your part. The first is opening the tile, in the preview now: any agent can open your tile next to itself with content in it ("draft that as a note on the right"), the way it already opens files and web pages in Pitwall with `show_files` and `show_web`, and your tile can declare show tools of its own. See [Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/). **Preview.** The Tile SDK is being built. These pages describe what the SDK preview has today, and mark what is still coming; names and details can change until version 1.0 of the tile world (WIT 1.0), when the Preview label comes off. ## Extensions and tiles There is one kind of extension: one package, one manifest, one install, one permission screen. A tile is one thing an extension can contribute; an extension with no tile is still an extension. | Term | Means | |---|---| | **Extension** | The package: its manifest (`extension.json`), id, version, source, permissions and everything it contributes | | **Tile** | A view the extension draws in the layout, built from the SDK's elements and components | | **Component** | The extension's own code: one WebAssembly component, run by Pitwall in a sandbox inside the app, with or without tiles | | **Service** | An optional long-running server that comes with the extension | ## How a tile works - **Written in Rust.** An author writes a tile against the `pitwall-extension` crate, whose UI code reads like GPUI (`div().flex().gap_2().child(…)`), and compiles it to a WebAssembly component (target `wasm32-wasip2`). The Rust target is all the toolchain it needs: `rustup target add wasm32-wasip2`. - **The tile describes, Pitwall draws.** After each change the tile returns a description of its UI: a tree of boxes, text and Pitwall's own components. Pitwall draws that tree itself. The tile's code never touches a window. - **It looks like Pitwall.** Styles name Pitwall's theme colours by meaning (text, surface, warning), not fixed colours, so a tile has Pitwall's fonts, focus ring, keyboard and text input, and follows Dark, Light, Flat, Glass and Reduce motion by itself. - **Its own thread.** Each tile runs on a worker thread of its own, so a slow tile doesn't hold up the window. ## How tiles are kept safe - **Nothing by default.** A tile starts with no files, no network and no programs: nothing but what you granted it. - **Permissions with reasons.** An extension names each permission it needs, with the author's reason. You see them on the permission screen before it runs, can take any of them back at any time, and the change applies to the tile's next call. - **Limits.** A tile has a memory limit (64 MiB unless its manifest asks for more, which the permission screen shows) and a time limit on each call; a tile that runs too long is stopped. ## The SDK preview The first preview is for authors who want to build tiles early: - The `pitwall-extension` crate to write a tile with, and Pitwall's tile runtime with its sandbox and limits, on macOS, Linux and Windows. - Tiles in Pitwall's layout, opened from the command palette, with their Log in Settings → Extensions. - `pitwall extension new` scaffolds a tile project from a template, `pitwall extension dev` builds and checks it on every save and reloads it in the running Pitwall keeping its state, `pitwall extension check` checks it, and `pitwall extension test` runs its tests in Pitwall's own tile runtime. - Tiles are shared as signed packages. `pitwall extension pack` makes a `.pwtile` file and `pitwall extension sign` signs it with your Pitwall signing key. Pitwall installs the file from Settings → Extensions → Install from file… or with `pitwall extension install `. It checks the signature first, shows the key, and requires updates to be signed by the same key. The version before an update is kept for Go back ([Packaging](https://pitwalls.github.io/pitwall/docs/extensions/packaging/), [Install](https://pitwalls.github.io/pitwall/docs/extensions/install/)). - An extensions index lists tiles for Browse. Its signed list is checked against keys built into Pitwall. Verified marks a version a maintainer reviewed. Withdrawn, blocked and unlisted versions are refused or turned off, with the reason. `pitwall extension publish` writes your tile's entry and opens the pull request ([Marketplace](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/), [Publishing](https://pitwalls.github.io/pitwall/docs/extensions/publishing/)). The Extensions tile has Installed and Browse at full size ([Extensions in Settings](https://pitwalls.github.io/pitwall/docs/extensions/settings/)). The index opens to everyone after the outside security review. - For a quick try, an unsigned folder installs too (Install from folder…), with an "Unsigned, preview" warning. Folder installs don't update. - An authoring skill for coding agents, and the docs as one `llms.txt` file ([For coding agents](https://pitwalls.github.io/pitwall/docs/extensions/for-agents/)). - Agents open tiles with content (`__open`) and use the show tools a tile declares, through Pitwall's MCP server, with a switch per tile ([Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/)). The other kinds of tools (reading back what a tile shows, acting outside it) come in phase 3 of the SDK. The marketplace's index is built; Browse opens to everyone after the outside security review. ## In this section - [Quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/): from `pitwall extension new` to a tile running in Pitwall, and sharing it. - [Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/): the elements a tile is built from, styles, events and keys. - Pitwall's components for tiles, by group: [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/), [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/), [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/) and [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/). - [Canvas and drag](https://pitwalls.github.io/pitwall/docs/extensions/canvas/): drawing diagrams with zoom, pan and clickable regions; drag and drop inside a tile. - [Native building blocks](https://pitwalls.github.io/pitwall/docs/extensions/blocks/): Pitwall's code view and diff view in a tile. - [Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/): tools a tile gives your agents: opening it with content and show tools (phase 3: reading and acting). - [C4 diagrams and Notes](https://pitwalls.github.io/pitwall/docs/extensions/seed-tiles/): two tiles built on the SDK alone: diagrams your agents draw, and notes you send them. - [Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/): what each grant means. - [Packaging](https://pitwalls.github.io/pitwall/docs/extensions/packaging/): packing and signing a `.pwtile`, keys and updates. - [Install](https://pitwalls.github.io/pitwall/docs/extensions/install/): installing from a file, who signed it, updates, Go back and Remove. - [Extensions in Settings](https://pitwalls.github.io/pitwall/docs/extensions/settings/): the Extensions tile, searching what is installed, an extension's page, Browse and installing from the index. - [Marketplace](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/): the extensions index, how Pitwall checks it, Verified, reports, withdrawn and blocked versions. - [Publishing](https://pitwalls.github.io/pitwall/docs/extensions/publishing/): listing a tile in the index with `pitwall extension publish`. - [Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/): what Pitwall gives every tile. - [Servers in extensions](https://pitwalls.github.io/pitwall/docs/extensions/servers/): a tile and a server the extension keeps running. - [WIT reference 0.1](https://pitwalls.github.io/pitwall/docs/extensions/wit/): the tile world's interfaces, generated from the WIT. - [For coding agents](https://pitwalls.github.io/pitwall/docs/extensions/for-agents/): the authoring skill and `llms.txt`. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/quick-start/ # Extensions quick start **Preview.** This page takes you from an empty folder to a tile running in Pitwall: scaffolded, reloaded on every save, checked, tested, and shared with someone else as a folder. ## Before you start You need Rust, installed with [rustup](https://rustup.rs), and its WebAssembly target. The target is the only addition the SDK needs: no `cargo-component`, no other tools. ```sh rustup target add wasm32-wasip2 ``` You also need Pitwall's CLI, `pitwall`, which comes with the app (see [the CLI reference](https://pitwalls.github.io/pitwall/docs/cli/)). The `pitwall extension new`, `check` and `test` commands work on a folder without the app running; `dev` and `install` work with the running app. ## Make a tile `pitwall extension new` writes a Cargo project into a new folder. The folder's name is the extension's id: lowercase letters, digits and hyphens. ```sh pitwall extension new my-tile --template blank cd my-tile ``` There are four templates: | Template | What it is | Shows | |---|---|---| | `blank` | A counter kept in storage | Elements, listeners, `storage` | | `list` | A checklist you add to, tick and filter; it can be opened with a list to show | Keys on rows, scrolling, text fields, content, `save_state` | | `form` | A form that saves notes, signed with a setting; it can be opened with a draft | Multi-line fields, `settings`, toasts | | `program` | A tile and Setup view that check Git's version after approval | `programs`, exact command patterns, completion events, fake native helpers in tests | `pitwall extension new my-helper --program` is shorthand for `--template program`. Opening its Setup view runs nothing. The user grants Programs and clicks **Check Git version**, then approves the exact `git --version` command. Its harness tests use fake output and never run Git. See [Programs and servers](https://pitwalls.github.io/pitwall/docs/extensions/servers/) for supervision and downloads. `--name "My tile"` sets the name Pitwall shows (by default it comes from the folder's name). Until the SDK is on crates.io, the project takes it from Pitwall's repository on GitHub; `--sdk ` takes it from a local checkout instead. The new project holds: | File | What | |---|---| | `extension.json` | The manifest: id, name, version, the tile (`contributes.tiles`), settings, permissions with your reasons | | `Cargo.toml` | A library with `crate-type = ["cdylib"]`, the `pitwall-extension` SDK, and `pitwall-extension-test` for tests | | `src/lib.rs` | The tile: its state, `render`, listeners | | `tests/tile.rs` | Tests that build the tile and run it in Pitwall's tile runtime | | `input.schema.json` | `list` and `form` only: what the tile can be opened with, as a JSON schema | | `README.md` | How to develop it | | `LICENSE` | Apache-2.0 license text, matching the generated manifest | | `AGENTS.md`, `.claude/skills/`, `.agents/skills/` | The authoring skill, for a coding agent working in the project ([For coding agents](https://pitwalls.github.io/pitwall/docs/extensions/for-agents/)) | ## The tile This is the `blank` template's tile. `NAME` is a constant above it that `new` fills in with the tile's name. ```rust #[derive(Default)] struct App { clicks: u32, } impl Tile for App { fn new(_cx: &mut Cx) -> Self { // What the user must not lose goes in storage: on disk at once, // kept across restarts and updates. let clicks = storage::get_json("clicks").ok().flatten().unwrap_or(0); App { clicks } } fn render(&mut self, _view: &str, cx: &mut Cx) -> impl IntoElement { v_flex() .size_full() .gap_2() .p_3() .child(text(NAME).text_lg().font_semibold()) .child(text(format!("Clicked {} times", self.clicks)).text_color(Token::Text2)) .child( h_flex() .gap_2() .child(button("Click me").primary().on_click(cx.listener(|this, _, cx| { this.set_clicks(this.clicks + 1); cx.notify(); }))) .child(button("Reset").on_click(cx.listener(|this, _, cx| { this.set_clicks(0); cx.notify(); }))), ) } } impl App { fn set_clicks(&mut self, n: u32) { self.clicks = n; if let Err(e) = storage::set_json("clicks", &n) { log::warn(format!("the count wasn't saved: {e}")); } } } pitwall_extension::export!(App); ``` - `new` makes the tile's state. Here it reads the count kept in `storage`. - `render` returns the tree of one view. Pitwall calls it after the view opens and after a listener calls `cx.notify()`. - `cx.listener` makes a click handler. It gets the tile, the event and the context. - `export!` makes `App` the component's tile, once per crate. [Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/) describes the elements, styles and events. ## The manifest `extension.json` describes the extension. The fields a tile project uses: | Field | Means | |---|---| | `v` | The manifest format: `2` for extensions with tiles | | `id` | The extension's id, the same as the folder's name | | `name`, `description`, `icon` | What Pitwall shows for it | | `version` | Its version, like `0.1.0` | | `pitwall` | The oldest Pitwall it runs on, like `>=0.9.0` | | `settings` | Settings Pitwall draws a form for ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#settings)) | | `permissions` | Each permission it asks for, with your reason ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/)) | | `contributes.tiles` | Its tiles. Each has an `id`, a `title`, an `icon`, the component (`"wasm": "tile.wasm"`), the world (`"world": "pitwall:tile@0.1.0"`) and, when it can be opened with content, its schema (`"input": "input.schema.json"`) | An extension has one component. Every tile entry names the same `tile.wasm`, and each tile id is a view that component renders. ## Develop with `pitwall extension dev` ```sh pitwall extension dev ``` Each round, `dev` builds the tile (`cargo build --release --target wasm32-wasip2`), copies the component to `tile.wasm` beside `extension.json`, checks it as `pitwall extension check` does, and loads it into the running Pitwall. It does this once at the start and again after every save in the folder (changes in `target/` and to `tile.wasm` are ignored), and prints one JSON line per round. `--once` does one round and exits, with status 1 when the build or the check failed. A round whose build or check fails loads nothing. **Loading into Pitwall.** The first time, Pitwall asks you to confirm. It then lists the folder in Settings → Extensions as a development extension, loaded where it is (never copied or updated), and turns it on. Open the tile from the command palette: "Open ()". It opens as a tile in the layout, beside your terminals. **Reloading.** Later rounds ask nothing. The running tile saves its state, a new one starts from the new build with that state, and the tiles that were open stay open. If Pitwall isn't running, `dev` says so, and a later round loads the tile once it is. `dev` is only for extensions that add tiles and run no programs; one with an adapter, a service or setup actions is loaded from Settings → Extensions instead. **The Log.** What the tile logs and prints is in its Log, on its card in Settings → Extensions, and `pitwall extension log ` prints it. When a tile stops (over a deadline, a crash, a frame too large), it says why in its place, with Restart. Keep what the user is typing or looking at across a reload with `save_state`. The `list` template keeps its filter and the item being typed: ```rust fn save_state(&self) -> Option { // Keep what's being typed across a reload. SavedState::json(&(&self.filter, &self.draft)) } ``` and reads them back in `new`: ```rust // After a reload (`pitwall extension dev`): what was being typed. if let Some((filter, draft)) = cx.restore::<(String, String)>() { (list.filter, list.draft) = (filter, draft); } ``` ## Check it with `pitwall extension check` ```sh pitwall extension check . ``` `check` reads the folder without running anything: the manifest, the component's world and imports, its size (at most 20 MiB), each tile's input schema, and each permission with its reason. It exits with status 1 when something fails. You can also give it `extension.json` or a `.wasm` file alone. ## Test it The project's tests run the built tile in the same runtime Pitwall uses, with a test host: a temporary data folder, the settings and grants you give it, and the toasts and Log lines it produces. Each action waits until the tile has handled it and rendered. ```rust #[test] fn counts_clicks_and_keeps_them() { let mut tile = Harness::build(env!("CARGO_MANIFEST_DIR")).open("main"); assert!(tile.find_text("Clicked 0 times").is_some(), "{}", tile.text_snapshot()); tile.click_text("Click me").click_text("Click me"); assert!(tile.find_text("Clicked 2 times").is_some()); assert_eq!(tile.stored_json::("clicks"), Some(2)); // Started again with the same data: the count is still there. tile.reload(); assert!(tile.find_text("Clicked 2 times").is_some()); tile.click_text("Reset"); assert_eq!(tile.stored_json::("clicks"), Some(0)); } ``` Run them with `cargo test`, or with: ```sh pitwall extension test . ``` which builds the tile, checks it, and then runs `cargo test`. A test can open a view with content, as an agent would, and give it new content later: ```rust #[test] fn shows_a_list_it_is_opened_with() { let content = json!({ "title": "Release", "items": [ { "id": "a", "text": "Write the changelog" }, { "id": "b", "text": "Tag the release", "done": true } ] }); let mut tile = Harness::build(env!("CARGO_MANIFEST_DIR")).open_with("main", content); assert!(tile.find_text("Release").is_some(), "{}", tile.text_snapshot()); assert!(tile.find_text("1 of 2").is_some()); tile.click_key("items/a/0"); assert!(tile.find_text("2 of 2").is_some()); // The same view given new content (an agent showing an update). tile.set_content("main", json!({ "items": [{ "id": "c", "text": "Announce it" }] })); assert!(tile.find_text("Announce it").is_some()); assert!(tile.find_text("Write the changelog").is_none()); } ``` The harness, `pitwall-extension-test`, can also type into fields (`type_into`, `submit`), select in them (`select_text`, `select_in`), press keys (`press`), let time pass for timers (`wait`, `wait_for_text`), change a setting (`set_setting`), reload the tile (`reload`), and read what it stored (`stored`, `stored_json`), logged (`log_text`) and toasted (`toasts`). `text_snapshot()` prints the tree, which helps when an assertion fails. ## Share it To give a tile to others, pack it and sign it: `pitwall extension pack`, then `pitwall extension sign `. Send the `.pwtile` file and its `.pwsig` together. [Packaging](https://pitwalls.github.io/pitwall/docs/extensions/packaging/) covers making a key and shipping updates, and [Install](https://pitwalls.github.io/pitwall/docs/extensions/install/) covers what the other person sees. ### Share a preview tile For a quick try without a key, you can also pass a tile around as a folder: the one holding `extension.json`, `tile.wasm` and the files the manifest names (such as `input.schema.json`). The person you send it to installs it: - **In Pitwall:** Settings → Extensions → Install from folder… - **From a terminal:** `pitwall extension install `. The argument must be a path with a `/` in it (such as `./my-tile`); a bare name is the id of an extension Pitwall ships. The terminal prints what installing changes, and you approve it in Pitwall. Only extensions that add tiles and run no programs install this way. Pitwall checks the folder (its manifest, its files, and that `tile.wasm` is a component), copies it into its own extensions folder, and lists the tiles it adds and the permissions it asks for with their reasons, with the warning "Unsigned, preview: only install tiles from people you trust" ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/#unsigned-preview-tiles)). It is installed off: turn it on in Settings → Extensions, or with `pitwall extension on `, to use its tiles. It is never updated: installing a newer folder replaces it and keeps its settings and data. Unlike `pitwall extension dev`, the folder is copied, not loaded in place. **Coming in this preview:** installing from the address of such a folder served over HTTPS. For now `pitwall extension install` refuses an address: download and unpack it, then install the folder. A marketplace comes in a later release. ## Next - [Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/): elements, styles, events and keys. - [Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/): storage, settings, timers, toasts and the Log. - [WIT reference 0.1](https://pitwalls.github.io/pitwall/docs/extensions/wit/): the contract between a tile and Pitwall. - [The CLI reference](https://pitwalls.github.io/pitwall/docs/cli/extension/#extension-new) for each `pitwall extension` command's options. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/ui/ # Tiles and UI components **Preview.** A tile describes what to show as a tree of elements, and Pitwall lays it out and draws it in its own theme. This page covers the elements and components of WIT 0.1 (long lists, tables, trees, tabs, selects, menus, Markdown and images, all drawn by Pitwall), styles and theme colours, events and keys, the `Tile` trait, and opening a tile with content. A canvas with drag and drop is on [Canvas and drag](https://pitwalls.github.io/pitwall/docs/extensions/canvas/), and Pitwall's code and diff views on [Native building blocks](https://pitwalls.github.io/pitwall/docs/extensions/blocks/). The names follow GPUI, the UI framework Pitwall is built with, so `div().flex().gap_2().child(…)` reads as it does there. Everything below comes from `use pitwall_extension::prelude::*;`. ## A tile in Pitwall Each tile an extension that is on contributes is in the command palette as "Open ()". It opens as a tile in the layout, beside your terminals, files and web pages. The extension's component starts when one of its tiles is shown, and stops when its last tile closes or the extension is turned off. While none of its tiles is shown (another space, another tile maximised over it), it is suspended: no renders, no timers. While it starts, the tile says so (the first time, Pitwall prepares each version for this computer, which takes a moment). When it stops, over a deadline, after a crash, or with a frame over the limits, it says why in its place, with Restart. ## The `Tile` trait A tile is a type that implements `Tile`. One value of it runs per extension; each place in the layout that shows one of the extension's tiles is a view of it, rendered with its own id. | Method | Called | Default | |---|---|---| | `new(cx)` | Once, before any view opens. Make the state, read `storage`, start timers. Deadline 2 s | Required | | `render(view, cx)` | After a view opens, after a listener or timer calls `cx.notify()`, and when the tile is shown again. Returns the view's whole tree | Required | | `on_view_opened(view, cx)` | A view opened; its first render follows | Nothing | | `on_content(view, cx)` | A view was given content, when it opened or later ([below](https://pitwalls.github.io/pitwall/docs/extensions/ui/#opening-a-tile-with-content)) | Nothing | | `on_view_closed(view, cx)` | A view closed | Nothing | | `on_event(event, cx)` | Shown or hidden, focus, a view's size, the theme, settings or grants changed | Renders again on theme, settings and grants changes | | `save_state()` | Before the tile is reloaded or dropped to save memory. At most 1 MiB, 50 ms | Nothing kept | End the crate with `pitwall_extension::export!(MyTile);`. The [quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#the-tile) shows a whole tile. **Keep `render` quick.** Aim for under 8 ms; past 250 ms the tile is stopped and the user sees why. Compute in listeners and timers, and only read state in `render`. A listener or event has 1 s. `cx` (the context, `Cx`) is passed to every call. Besides `listener`, `notify` and the timers ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#tasks-timers)), it tells the tile about its views (`cx.views()`, `cx.view(id)`, `cx.content(id)`), the theme (`cx.theme()`), its grants (`cx.is_granted("memory")`), whether it is shown (`cx.is_visible()`), and its own id and version. ## Elements | Element | Made with | What it is | |---|---|---| | Box | `div()`, `v_flex()`, `h_flex()` | A flex container. `div()` and `v_flex()` are columns; `h_flex()` is a row with its children centred across it. The usual root | | Text | `text("…")` | A paragraph. Its children are inline runs, each with its own style: `text("Built in ").child(text("3 s").font_bold())`. Plain `&str` and `String` children become text | | Button | `button("Save")`, `icon_button(Icon::X, "Remove")` | Pitwall's own buttons. Looks: `.primary()` (one main action per area), the default hairline, `.danger()`, `.link()`. Size: regular, or `.small()`, with any look (`.small().danger()`). `.icon(Icon::Plus)` puts an icon before the label; `.disabled(true)` dims it and drops clicks. An icon button is square; its label is its accessible name and tooltip | | Icon | `icon(Icon::Check)` | One of Pitwall's icons ([the list](https://pitwalls.github.io/pitwall/docs/extensions/ui/#icons)), in the text colour and size | | Text field | `input("key")` | A one-line or multi-line field ([below](https://pitwalls.github.io/pitwall/docs/extensions/ui/#text-fields)). Its key is required | | Scroll | `.overflow_y_scroll()`, `.overflow_x_scroll()`, `.overflow_scroll()` on a box | Its children scroll inside it. Pitwall draws the scrollbar and keeps the position | | Components | `virtual_list`, `table`, `tree`, `tabs`, `select`, `menu_button`, `.context_menu(…)`, `markdown`, `image_asset`, `image_data` | Pitwall's own lists, menus, Markdown and images ([below](https://pitwalls.github.io/pitwall/docs/extensions/ui/#components)) | Every element can have: - `.id("key")`: its key among its siblings ([below](https://pitwalls.github.io/pitwall/docs/extensions/ui/#keys)). - `.tooltip("…")`: text shown when the pointer rests on it. - `.label("…")`: its accessible name, read by screen readers. - `.focusable()`: it can take keyboard focus. Buttons and fields always can. - `.when(condition, |el| …)` and `.when_some(option, |el, value| …)`: apply styles or children only sometimes. `Div` (what `div()`, `v_flex()` and `h_flex()` return), `Button`, `Input`, `Text` and `IconElement` are in the prelude, for helpers that build part of a tree. Children are added with `.child(…)` and `.children(iter)`. `.into_any()` turns any element into an `AnyElement`, so different builders fit one type (for a helper function, or the arms of a `match`). A row of the `list` template: a button that toggles the item, its text, and a button to remove it. ```rust /// One row: a check, the text, a remove button. Keyed by the item's id so /// Pitwall keeps each row's state when the list changes. fn row(item: Item, cx: &mut Cx) -> AnyElement { let (toggle, remove) = (item.id.clone(), item.id.clone()); h_flex() .id(item.id.clone()) .gap_2() .px_2() .py_1() .hover_bg(Token::Surface2) .child( button(if item.done { "Done" } else { "To do" }) .small() .when(item.done, |b| b.icon(Icon::Check)) .on_click(cx.listener(move |this: &mut List, _, cx| { if let Some(i) = this.items.iter_mut().find(|i| i.id == toggle) { i.done = !i.done; } this.save(); cx.notify(); })), ) .child(text(item.text).flex_1().when(item.done, |t| t.text_color(Token::Text3))) .child(icon_button(Icon::X, "Remove").on_click(cx.listener(move |this: &mut List, _, cx| { this.items.retain(|i| i.id != remove); this.save(); cx.notify(); }))) .into_any() } ``` ### Icons `Icon` has one variant per icon Pitwall draws, and `Icon::from_name` and `.name()` go between them and their names, which are also what `extension.json` names an icon by. An unknown `Icon::Named("…")` draws a dot (`pitwall-extension-test` warns of it), and `pitwall extension check` warns of an unknown icon in the manifest. The names: `sidebar`, `search`, `gear`, `plus`, `x`, `send`, `stop`, `restart`, `refresh`, `trash`, `branch`, `folder`, `chevron`, `grid`, `wall`, `maximize`, `restore`, `window`, `more`, `review`, `terminal`, `file`, `expand`, `copy`, `chevron-down`, `check`, `headset`, `user`, `laptop`, `server`, `eye`, `external`, `image`, `browser`, `back`, `phone`, `inspect`, `page-right`, `page-left`, `page-below`, `pin`, `grip`, `minus`, `chevron-up`, `lock`, `alert`, `extension`, `inbox`, `bell`, `chat`, `list`. ## Components Components are drawn by Pitwall as its own lists, menus and Preview are, so they look and behave like the rest of the app (theme, hover, keyboard, scrollbars), and work without a round trip to the tile while the user scrolls or hovers. Prefer them to lists, tabs or menus built from boxes. This page has the lists, tables, trees, tabs, selects, menus, Markdown and images; the other components have a page per group: [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/) (checkboxes, switches, radio groups, segmented controls, sliders, number and search fields, form rows), [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/) (progress, spinners, skeletons, empty states, banners, badges, chips, key hints, tooltips), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/) (split panes, disclosures, cards, dividers, breadcrumbs, toolbars, popovers, confirm sheets), [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/) (key-value lists, avatars, relative times, copyable text, links) and [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/) (sparklines, bar and line charts, status timelines). The examples below come from the gallery tile Pitwall's tests run (`crates/pitwall-tile-host/tests/fixtures/hello-tile/src/gallery.rs`), and the screenshots are that tile drawn headless, dark and light (`gallery_shots` in `crates/pitwall-app/src/tiles/gallery_tests.rs`); `pitwall-extension-test` drives each one ([quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#test-it)). What every component shares: - **Key.** Each takes a key first (menus excepted: their button's label is it). Events and the test harness name it by its key path, like any element's. - **Accessibility.** A component's text (row text, column titles, tab, option and item labels) is its accessible name; `.label("…")` names one that has no text, such as an icon-only menu button or an image. `.tooltip("…")` works on all of them. - **Limits.** Over a limit, the tile stops with the reason, as for any frame ([Limits](https://pitwalls.github.io/pitwall/docs/extensions/ui/#limits)). ### Virtual list ![Virtual list, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-virtual-list-dark.png) ![Virtual list, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-virtual-list-light.png) A long list: search results, log lines, a file's history, anything that may run past a few hundred rows. `virtual_list(key, count, rows)` is a list of `count` rows that scrolls smoothly at 100 000 rows. The frame holds only the count; `rows`, made with `cx.rows(|tile, i, cx| …)`, renders row `i` when it comes into sight. Pitwall asks for rows a page (64) at a time and keeps what it has drawn until the list's data changes. For a dozen rows that never grow, a column of boxes is simpler. ```rust let rows = cx.rows(|_: &mut crate::Hello, i, cx| { h_flex() .id(format!("r{i}")) .gap(px(8.0)) .items_center() .child(icon(Icon::File).text_color(Token::Text3)) .child(text(format!("Row {i}")).flex_1()) .child(text(format!("{} KB", (i * 37) % 1000)).text_sm().text_color(Token::Text3)) // Rows hold badges, avatars and relative times too. .when(i % 4 == 0, |r| r.child(badge("new").tone(Tone::Info))) .context_menu( vec![menu_item("open", "Open"), menu_item("copy", "Copy name"), separator(), menu_item("remove", "Remove").danger()], cx.listener(move |t: &mut crate::Hello, key: &str, cx| { t.gallery.said = format!("Row {i}: {key}"); cx.notify(); }), ) }); let list = virtual_list("rows", ROWS, rows) .revision(1) .selected(self.picked.clone()) .on_select(cx.listener(|t: &mut crate::Hello, e: &Picked, cx| { t.gallery.picked = Some(e.key.clone()); t.gallery.said = if e.activate { format!("Opened {}", e.key) } else { format!("Selected {}", e.key) }; cx.notify(); })); ``` | Option | What it does | |---|---| | `.row_height(px)` | Every row's height: 12 to 200, default 28 (Pitwall's own rows') | | `.selected(keys)` | The selected rows' keys, drawn selected; the tile keeps the selection | | `.revision(n)` | A number that changes only when the rows do. Without it every render counts as new data and Pitwall asks for the rows in sight again | | `.on_select(listener)` | Hears a row chosen | - **Rows.** A row is a small tree (at most 64 nodes) of boxes, text, icons, buttons, images, a context menu, [badges](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [avatars and relative times](https://pitwalls.github.io/pitwall/docs/extensions/components-data/); no text fields or nested lists. Give each row its item's id with `.id(…)`, so the selection follows the item; a key has no `/`. Listeners in a row (a button's `on_click`, a [context menu](https://pitwalls.github.io/pitwall/docs/extensions/ui/#menus)) work like any other. - **Events.** `on_select` gets the row's key (`&str`), or the whole `Picked`: `key`, `index`, `modifiers` (⌘ or Shift for adding to a selection), and `activate`, true for a double click or Enter. - **Keyboard.** With the list focused (a click on it), Up and Down move the selection, Home and End go to the ends, Page Up and Page Down by a screen, and Enter activates; each sends `select`. A row that isn't loaded yet is selected when it arrives. - **Size.** It fills its parent: give the parent a height, or let it grow (`flex_1` in a column that has one). - **Speed.** Keep the row callback quick: a page of 64 rows in a few milliseconds. In Pitwall's measurement a page of 64 gallery rows took about 0.5 ms, and a jump to row 50 000 was drawn in about 20 ms ([runtime.md §2.7](https://github.com/pitwalls/pitwall/blob/main/docs/spec/tile-sdk/runtime.md)). - **Limits.** 1 000 000 rows; a row 64 nodes; a `rows` call 256 rows and 250 ms. ### Table ![Table, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-table-dark.png) ![Table, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-table-light.png) Rows with the same fields side by side: files with their size and date, test results, issues. `table(key, columns, count, rows)` is a virtual list with a header. Each row's root holds its cells, one child per column in order. ```rust let rows = cx.rows(|t: &mut crate::Hello, i, _| { let (name, size, when) = t.gallery.files[i].clone(); h_flex().id(name.clone()).child(text(name)).child(text(format!("{:.1} KB", size as f64 / 1000.0)).text_color(Token::Text2)).child(text(when).text_color(Token::Text3)) }); let (col, dir) = self.sort.clone(); let table = table("files", vec![column("name", "Name").sortable(), column("size", "Size").width(90.0).align_end().sortable(), column("when", "Modified").width(110.0)], self.files.len(), rows) .sort(col, dir) .on_sort(cx.listener(|t: &mut crate::Hello, e: &SortChange, cx| { t.gallery.sort = (e.column.clone(), e.direction); t.gallery.sorted(); cx.notify(); })) .on_column_resize(cx.listener(|t: &mut crate::Hello, e: &ColumnWidth, cx| { t.gallery.said = format!("{} is {} wide", e.column, e.width.round()); cx.notify(); })); ``` | Option | What it does | |---|---| | `column(key, title)` | A column. `.width(px)` fixes its width (else it shares the room left); `.align_end()` (numbers) or `.align_center()`; `.sortable()` makes its title clickable | | `.sort(column, direction)` | Which column the rows are sorted by, drawn as an arrow in its title | | `.on_sort(listener)` | Hears a sortable title clicked: `SortChange` with the `column` and the next `direction` (ascending first). Sort the rows, pass `.sort(…)` | | `.on_column_resize(listener)` | Hears a column resized: `ColumnWidth` with the `column` and its `width`, once at the end of the drag, to keep it | | `.row_height`, `.selected`, `.revision`, `.on_select` | As in a [virtual list](https://pitwalls.github.io/pitwall/docs/extensions/ui/#virtual-list) | - **Resizing.** The user drags the right edge of a title; Pitwall keeps that width until the column's own `.width` changes. - **Keyboard.** As in a virtual list. - **Limits.** 64 columns; rows as in a virtual list. ### Tree ![Tree, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-tree-dark.png) ![Tree, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-tree-light.png) Nested items: folders and files, symbols, an outline. `tree(key, count, rows)` is a virtual list of the tree's visible rows, in order: the tile flattens its open branches and keeps which are open. A row is a `tree_row(element)`. ```rust let shown = self.shown(); let rows = cx.rows(|t: &mut crate::Hello, i, _| { let (path, name, folder, depth) = t.gallery.shown()[i]; let open = t.gallery.open.iter().any(|o| o == path); // A key has no `/` (it joins key paths). let row = h_flex().id(path.replace('/', ":")).gap(px(6.0)).items_center().child(icon(if folder { Icon::Folder } else { Icon::File }).text_color(Token::Text3)).child(text(name)); let row = tree_row(row).depth(depth); if folder { row.branch(open) } else { row } }); let tree = tree("tree", shown.len(), rows).on_toggle(cx.listener(|t: &mut crate::Hello, e: &Toggled, cx| { let path = e.key.replace(':', "/"); if e.on { t.gallery.open.push(path); } else { t.gallery.open.retain(|o| o != &path); } cx.notify(); })); ``` | Option | What it does | |---|---| | `tree_row(el).depth(n)` | The row's level, 0 at the top; Pitwall indents it | | `tree_row(el).branch(open)` | A branch, open or closed, drawn with a chevron. Leave it out for a leaf | | `.on_toggle(listener)` | Hears a branch opened or closed: `Toggled` with the row's `key`, its `index` and `on` (true: open it). Change your open set and render again | | `.row_height`, `.selected`, `.revision`, `.on_select` | As in a [virtual list](https://pitwalls.github.io/pitwall/docs/extensions/ui/#virtual-list) | - **Opening.** A click on the chevron, or a double click on a branch, sends `toggle`. - **Keyboard.** As in a virtual list, and → opens the selected branch, ← closes it; ← on a leaf or a closed branch moves to its parent. - **Limits.** As in a virtual list (counting only the visible rows). ### Tabs ![Tabs, a select and a menu button, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-toolbar-dark.png) ![Tabs, a select and a menu button, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-toolbar-light.png) A few views of the same thing, one at a time: Overview, Files, Log. `tabs(key, [tab(key, label), …])` is Pitwall's segmented control. It only marks the choice: draw the tab's content yourself, by the key you keep. For more than about five choices, or ones that aren't views, use a [select](https://pitwalls.github.io/pitwall/docs/extensions/ui/#select). ```rust let tabs = tabs("tabs", [tab("overview", "Overview").icon(Icon::Grid), tab("files", "Files").icon(Icon::File), tab("log", "Log")]) .selected(self.tab.clone()) .on_select(cx.listener(|t: &mut crate::Hello, key: &str, cx| { t.gallery.tab = key.to_string(); cx.notify(); })); ``` | Option | What it does | |---|---| | `tab(key, label).icon(icon)` | An icon before the tab's label | | `.selected(key)` | The current tab | | `.on_select(listener)` | Hears a tab clicked, with its key (`&str`) or `Picked` | - **Keyboard.** Tabs are chosen with the pointer for now; bind keys with `cx.bind_key` to switch them ([Keyboard and focus](https://pitwalls.github.io/pitwall/docs/extensions/ui/#keyboard-and-focus)). - **Limits.** 1 000 tabs. ### Select ![Select open, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-select-dark.png) ![Select open, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-select-light.png) One value out of a list: a size, a sort order, a branch. `select(key, [choice(key, label), …])` is a dropdown: a button with the chosen label that opens Pitwall's menu of the options, the chosen one ticked. ```rust let size = select("size", [choice("s", "Small"), choice("m", "Medium"), choice("l", "Large")]) .selected(self.size.clone()) .on_select(cx.listener(|t: &mut crate::Hello, key: &str, cx| { t.gallery.size = key.to_string(); t.gallery.said = format!("Size: {key}"); cx.notify(); })); ``` | Option | What it does | |---|---| | `.selected(key)` | The chosen option | | `.placeholder("…")` | Shown while no option is chosen | | `.disabled(true)` | Dimmed; it doesn't open | | `.on_select(listener)` | Hears an option chosen, with its key (`&str`) or `Picked` | - **Keyboard.** Esc closes the open list; options are chosen with the pointer for now. - **Limits.** 1 000 options. ### Menus ![A menu button's menu, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-menu-button-dark.png) ![A menu button's menu, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-menu-button-light.png) Actions on a thing that don't need a button each: Copy, Rename, Delete. A menu is a list of `menu_item(key, label)` and `separator()`. Pitwall draws it as its own menus, above the tile (a glass pop-up under Liquid Glass), closes it on a click outside or Esc, and calls the listener with the chosen item's key. - `menu_button(label, entries)` is a button that opens it; `menu_icon_button(icon, label, entries)` an icon-only one, `label` being its accessible name. - `.context_menu(entries, listener)` on any element opens it on a right-click there, rows of lists, tables and trees included (a right-click selects the row first). An element has at most one. ```rust let actions = menu_button("Actions", vec![menu_item("copy", "Copy").icon(Icon::Copy).hint("⌘C"), menu_item("refresh", "Refresh").icon(Icon::Refresh), separator(), menu_item("delete", "Delete").icon(Icon::Trash).danger()]) .on_select(cx.listener(|t: &mut crate::Hello, key: &str, cx| { t.gallery.said = format!("Menu: {key}"); cx.notify(); })); ``` | Option | What it does | |---|---| | `menu_item(…).icon(icon)` | An icon before the label | | `menu_item(…).hint("⌘C")` | A shortcut shown on the right (bind it yourself with `cx.bind_key`) | | `menu_item(…).disabled(true)` | Dimmed; it can't be chosen | | `menu_item(…).danger()` | Drawn in the danger colour, for destructive actions | | `menu_button(…).icon(icon)`, `.disabled(true)` | The button's icon; a disabled button doesn't open | | `.on_select(listener)` | Hears an item chosen, with its key (`&str`) or `Picked` | - **Keyboard.** Esc closes an open menu; items are chosen with the pointer for now. - **Limits.** 1 000 items in a menu. ### Markdown ![Markdown, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-markdown-dark.png) ![Markdown, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-markdown-light.png) Text the user or an agent wrote: notes, a README, a description. `markdown(text)` draws it with Pitwall's Preview: headings, lists, tasks, code, tables, quotes. It is inert: no HTML, no remote images, nothing runs. ```rust let md = markdown(text) .on_link(cx.listener(|t: &mut crate::Hello, e: &LinkClick, cx| { t.gallery.said = format!("Link: {}", e.url); cx.notify(); })) .on_toggle(cx.listener(|t: &mut crate::Hello, e: &Toggled, cx| { // The task's line: 4 is the first. if let Some(done) = t.gallery.tasks.get_mut((e.index as usize).saturating_sub(4)) { *done = e.on; } cx.notify(); })); ``` | Option | What it does | |---|---| | `.on_link(listener)` | Gets every link click instead of Pitwall opening it: `LinkClick` with the `url` as written (a relative link can open another of the tile's items) and the `modifiers` | | `.on_toggle(listener)` | Makes task boxes clickable: `Toggled` with the task's line in `index` (0-based) and `on`, whether it is ticked now. Change the text and render again | - **Links.** Without `on_link`, `http`, `https` and `mailto` links open in the browser and other links do nothing; without `on_toggle`, task boxes can't be clicked. - **Size.** Given a height (or room to grow), it fills it and scrolls; otherwise it is as tall as its text. - **Keyboard.** Text can be selected and copied as in Preview. - **Limits.** 1 MiB of text. ### Images ![Images, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-image-dark.png) ![Images, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-image-light.png) A logo, an avatar, a thumbnail or a picture the tile made. `image_asset("assets/logo.svg")` shows a file of the extension's folder (a path inside it, no `..`); `image_data(name)` shows bytes the tile handed over with `ui::put_image(name, &bytes)` ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#ui)) and can drop with `ui::drop_image(name)`. PNG, JPEG, GIF, WebP and SVG; never fetched from the network. ```rust let logo = image_asset("assets/logo.svg").contain().w(px(48.0)).h(px(48.0)); let dot = image_data("dot").contain().w(px(48.0)).h(px(48.0)); ``` | Option | What it does | |---|---| | `.contain()` | Fits inside its box, whole (the default) | | `.cover()` | Fills its box, cropped | | `.fill()` | Stretched to its box | | `.w(…)`, `.h(…)` | Its size: give it one | | `.label("…")` | What it shows, for screen readers | - **Missing.** A missing or unreadable image draws an image icon in its place. - **Limits.** An asset at most 16 MiB; a put image at most 8 MiB, and 64 MiB for all of a tile's. ## Styles Styles use GPUI's names: | Kind | Methods | |---|---| | Flex | `flex`, `flex_row`, `flex_col`, `flex_wrap`, `flex_1`, `flex_grow`, `flex_shrink_0`, `flex_none`, `gap_0` … `gap_8`, `gap(length)` | | Alignment | `items_start`, `items_center`, `items_end`, `items_baseline`, `justify_start`, `justify_center`, `justify_end`, `justify_between`, `justify_around`, `self_align` | | Size | `w`, `h`, `size`, `w_full`, `h_full`, `size_full`, `min_w`, `max_w`, `min_h`, `max_h` | | Spacing | `p_0` … `p_6`, `px_1` … `px_4`, `py_1` … `py_3`, `pt_*`, `pb_*`, `pl_2`, `pl_3`, `pr_1`, `pr_2`, `m_1`, `m_2`, `mx_2`, `my_2`, `mt_2`, `mb_2`, `p(length)`, `m(length)` | | Borders and corners | `border_1`, `border_t_1`, `border_b_1`, `border_l_1`, `border_r_1`, `border_color`, `rounded_none`, `rounded_sm`, `rounded_md`, `rounded_lg`, `rounded_full` | | Colour | `text_color`, `bg`, `hover_bg`, `opacity` | | Text | `text_xs`, `text_sm`, `text_base`, `text_lg`, `text_xl`, `font_mono`, `font_ui`, `font_normal`, `font_medium`, `font_semibold`, `font_bold`, `italic`, `underline`, `truncate`, `line_clamp(n)`, `selectable` | | Hover groups | `group("row")` names a hover group; `visible_on_group_hover("row")` on an element inside it keeps the element hidden (its space kept) until the pointer is over the group, drawn by Pitwall without a round trip: a row's Delete | | Other | `overflow_hidden`, `cursor_pointer`, `cursor_text` | Lengths are `px(n)` (logical pixels), `rems(n)` (multiples of Pitwall's text size, so they follow the user's font size), `relative(f)` (a fraction of the parent) or a bare number (pixels). The spacing scale (`gap_2`, `p_3`) is in rems. ### Theme colours A tile has no raw colours. `text_color`, `bg`, `hover_bg` and `border_color` take a theme token, named by meaning. Each has a light and a dark value, and the user's theme picks one, so a tile follows Pitwall's appearance by itself. | Token | For | |---|---| | `Bg` | The window's background, behind tiles | | `Surface`, `Surface2`, `Surface3` | A tile's background, then raised areas inside it (a header, a selected row, a field) | | `Raised` | Floating surfaces | | `Line`, `LineStrong` | Hairlines and borders; stronger ones that must be seen | | `Text`, `Text2`, `Text3`, `Text4` | Main text, secondary, muted, faint | | `Focus` | The focus ring | | `Good`, `Warn`, `Bad`, `Done` | Success, needs attention, failure, finished | | `GoodSoft`, `WarnSoft`, `BadSoft`, `DoneSoft` | Soft backgrounds for the same | | `DiffAddBg`, `DiffDelBg` | Added and removed lines in a diff | `cx.theme()` gives the rest of the user's appearance: light or dark, density (comfortable, compact, dense) and whether they asked for less motion. When it changes, the tile hears `Event::Theme` and renders again. ## Events A listener is made with `cx.listener` while rendering and handed to the element at once. Its closure gets the tile, the event and the context; it calls `cx.notify()` when what the tile shows changed. | Method | On | The closure gets | |---|---|---| | `on_click` | Any element; also Space or Enter while it has focus | `Click`: button, modifier keys, click count, position | | `on_hover` | Any element | `Hover`: entered or left, position | | `on_pointer` | Any element | `Pointer`: press, release or move, with position and modifiers. After a press, moves and the release go to the same node | | `on_change` | Text field | The new text (`&str`) or the whole `InputChange` with the selection | | `on_submit` | Text field | `Submit`: Enter (⌘Enter, Ctrl+Enter off macOS, in a multi-line field) | | `on_select` | Text field | `Selection`: the cursor or selection moved | | `on_wheel` | Any element | `Pointer` with `PointerKind::Wheel` or `PointerKind::Pinch`: for zooming and panning a [canvas](https://pitwalls.github.io/pitwall/docs/extensions/canvas/#zoom-and-pan) | | `on_drop` | Any element | `Dropped`: something dragged with `.draggable` was dropped on it ([Drag and drop](https://pitwalls.github.io/pitwall/docs/extensions/canvas/#drag-and-drop)) | | `on_scroll` | Scroll container | `ScrollPosition`: offset and content size, for loading more at the end | | `on_focus`, `on_blur` | Text field or focusable element | `Focused` / `Blur`: it took the keyboard, or lost it (to another element, or out of the tile). A field's blur is the moment to save it | | `on_select` | List, table, tree, tabs, select, menu button, `context_menu` | The chosen row's, tab's, option's or item's key (`&str`), or the whole `Picked` (key, index, modifiers, `activate`) | | `on_toggle` | Tree, Markdown | `Toggled`: a branch opened or closed, or a task's box clicked (its line) | | `on_link` | Markdown | `LinkClick`: a link's target | | `on_sort`, `on_column_resize` | Table | `SortChange` (column, direction), `ColumnWidth` (column, width) | Events that aren't for one element (shown or hidden, focus, a view's size, the theme, settings, grants) go to `Tile::on_event`. ## Keys Give each element that can move a key with `.id("key")`: list rows take their item's id. Pitwall keeps scroll positions, focus and typed text by key path (the keys from the root down, joined by `/`), so they survive when the list around them changes. Children without a key get their position as their key. Keys are unique among siblings (a duplicate gets a suffix and a Log line) and at most 128 bytes. The `list` template's scrolling list, keyed by `items`, with one keyed row per item: ```rust v_flex() .id("items") .flex_1() .overflow_y_scroll() .when(shown.is_empty(), |list| list.child(text("Nothing here yet").p_3().text_color(Token::Text3))) .children(shown.into_iter().map(|item| row(item, cx))), ``` ## Text fields Pitwall owns what the user types: typing, selection, undo and input methods never wait for the tile. The tile hears each change with `on_change`, keeps its own copy, and passes that copy back with `.value(…)`. The SDK sends the value only when it differs from what the field holds, so this never undoes what the user typed meanwhile, and setting your copy to `""` clears the field. ```rust input("new") .placeholder("Add an item and press Enter") .value(self.draft.clone()) .flex_1() .on_change(cx.listener(|this, v: &str, _| this.draft = v.to_string())) .on_submit(cx.listener(|this, _, cx| { this.add(); cx.notify(); })), ``` **The selection.** `on_change` with the whole `InputChange` has the cursor or selection after each edit, and `.on_select(listener)` hears it move without an edit (`Selection`, a range of UTF-8 byte offsets in the text); keep the latest with your copy of the text, and the selected text is that range of it. Notes sends the selection to an agent this way. In tests, `t.select_text(key, range)` or `t.select_in(key, "words")` selects as the user would. `.placeholder(…)` shows faint text while it is empty. `.multiline()` makes it several lines (Enter adds a line, ⌘Enter submits) and `.rows(n)` its height, or, given a height or room to grow (`.size_full()`, `.flex_1()`), it fills that, at least its rows; `.select(range)` places the cursor when `.value` changes the text; `.disabled(true)` makes it read-only. The `form` template's fields: ```rust .child(input("title").placeholder("Title").value(self.title.clone()).on_change(cx.listener(|this, v: &str, _| this.title = v.to_string())).on_submit(cx.listener(|this, _, cx| { this.save(); cx.notify(); }))) .child(input("body").placeholder("Note").multiline().rows(4).value(self.body.clone()).on_change(cx.listener(|this, v: &str, _| this.body = v.to_string()))) ``` ## Keyboard and focus - A tile gets keys only while it has focus. Pitwall's own shortcuts always win. - Tab and Shift-Tab move focus among focusable elements in tree order, with Pitwall's focus ring. - While rendering, `cx.bind_key("j", handler)` makes a key call a listener (`Handler`) while the view has focus. Keys are written like `j`, `enter`, `/`, `shift-tab` or `cmd-s`; `cmd` is ⌘ on macOS and Ctrl elsewhere. - A binding without ⌘, Ctrl or Alt (`j`, `/`, `shift-n`) doesn't fire while a text field has focus: the key types into the field. - Number keys answer a question as Pitwall's inbox does: bind `1` to `9` while the question is open, each picking its suggestion. They type into a reply field that has focus, and pick when it doesn't. - Pitwall's own keys are never a tile's: a binding of one is dropped, with a line in the tile's Log. They are Esc, Tab, Shift-Tab, Ctrl-Enter (and Ctrl-Shift-Enter), `cmd-` and `cmd-shift-` with any of `enter`, `0`–`9`, `=`, `+`, `-`, `,`, `a`, `b`, `c`, `e`, `h`, `i`, `j`, `k`, `l`, `m`, `n`, `p`, `q`, `r`, `t`, `v`, `w`, `x`, `z`, and `cmd-shift-f`, `cmd-alt-h`, `cmd-ctrl-f`, `cmd-shift-alt-e`, `-n`, `-r` and `-t`. (Off macOS Pitwall's keys are Ctrl+Shift ones; the list is the same everywhere, so a tile's keys work the same on every system.) - While rendering, `cx.focus("list/row-3")` asks for focus on the element at that key path: the keys from the root down, joined by `/`, without the root's (the same path `ui::scroll_to` takes). Pitwall honours it only while the tile already has focus, so a tile can't take the keyboard from an agent's terminal. `cx.focused(view)` is the element that has it. ## Opening a tile with content A tile can be opened with content: a JSON value that matches a schema the tile names in its manifest entry (`"input": "input.schema.json"`). Pitwall checks the content against the schema before the tile sees it. A later call with the same content id goes to the same view and updates it in place. The tile hears `on_view_opened` and then `on_content`, or only `on_content` when an open view gets new content. `Content::parse` reads the JSON into the tile's own `serde` type. The `list` template's input type and handler: ```rust /// What the tile is opened with (input.schema.json). #[derive(Deserialize)] struct Shown { title: Option, items: Vec, } #[derive(Clone, Serialize, Deserialize)] struct Item { id: String, text: String, #[serde(default)] done: bool, } ``` ```rust fn on_content(&mut self, view: &ViewInfo, _cx: &mut Cx) { let Some(content) = &view.content else { return }; match content.parse::() { Ok(shown) => { self.title = shown.title.unwrap_or_else(|| "Checklist".into()); self.items = shown.items; self.save(); } Err(e) => { log::warn(e.to_string()); ui::toast("That list couldn't be shown", Tone::Warn); } } } ``` `Content` also has `id()` (the caller's id for it), `json_text()` and `bytes()` (a binary payload, at most 8 MiB). Keep the schema small and describe each field: agents read it. In this preview, opening a tile from the palette gives it no content, so content reaches a tile in tests (`open_with`, `set_content`, see the [quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#test-it)). Agents opening a tile with content come in phase 2 ([Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/)). `ui::open_view("main")` opens one of the extension's own tiles, or focuses it when it is open ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#ui)). ## A shortcut to open a tile A tile may suggest keys that open it from anywhere in Pitwall, as ⌘I opens the inbox: `"shortcut": "cmd-shift-u"` in its manifest entry, with the `shortcut` permission and your reason. ```json "permissions": { "shortcut": "To open the desk from anywhere" }, "contributes": { "tiles": [{ "id": "main", "title": "Desk", "wasm": "tile.wasm", "shortcut": "cmd-shift-u" }] } ``` - The keys are `cmd-` or `cmd-shift-`, the key a letter, a digit or F1 to F12. As for Pitwall's own shortcuts, `cmd` is ⌘ on macOS and Ctrl+Shift elsewhere (`cmd-shift` is Ctrl+Shift+Alt there), so plain Ctrl stays the terminals'. - Pitwall's own keys are refused ([Keyboard and focus](https://pitwalls.github.io/pitwall/docs/extensions/ui/#keyboard-and-focus)): `pitwall extension check` says so. Two tiles of one extension can't share keys. - The shortcut is off until the user grants it: the permission screen offers "Use a keyboard shortcut" switched off, with the keys it suggests. Granted, the palette shows the keys beside "Open ". - The user can change the keys under the permission, in the extension's card, or leave the field empty for the ones the tile suggests. Pitwall's own keys are refused there too, and keys another extension has: of two extensions that want the same keys, the first by name gets them. ## Toolbar button An extension may add one button to Pitwall's top bar. Its buttons sit in a group of their own after the agent counts, behind a hairline, in the order of the extensions. Ask only when the button is worth a place there: a count that needs attention, or a quick look. ```json "contributes": { "toolbar": { "icon": "server", "tooltip": "Builds", "badge": true, "visibleByDefault": true, "action": { "kind": "popover", "tile": "main", "size": { "w": 320, "h": 400 } } } } ``` | Field | | |---|---| | `icon` | One of Pitwall's icon names ([Icons](https://pitwalls.github.io/pitwall/docs/extensions/ui/#icons)) | | `tooltip` | What it does, in a few words, at most 80 characters (needed); the tile can change it | | `badge` | `true`: the tile sets a badge, and Pitwall keeps the tile running for it | | `scope` | `window` (the default), or `project`: the badge of the project the window shows | | `visibleByDefault` | Shown when the extension is turned on (the default); `false`: the user turns it on from the card | | `action` | What a press does: `{ "kind": "tile", "tile": "main" }` opens the tile; `popover` opens the tile's popover, `size` from 200×100 to 420×560 (320×400 when not given); `{ "kind": "command", "command": "sync" }` runs a command; `{ "kind": "menu", "commands": […] }` shows a menu of up to 10 commands | The user hides the button with Hide from toolbar (its right-click menu), or with Show in toolbar on the extension's card. What they choose is kept: an update never shows a hidden button again. The popover is a view of the tile with the id `toolbar::POPOVER_VIEW`: draw it in `render` when `view` is that id. Esc, a press outside it, a press on the button or `toolbar::close_popover()` closes it. The badge shows only while the tile runs ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#toolbar-button)). ## Limits | | Limit | |---|---| | Nodes in a view | 20 000 | | A frame | About 2 MiB | | A key | 128 bytes | | A text field's text | 1 MiB | | A list's, table's or tree's rows | 1 000 000; a row 64 nodes, 12–200 px tall | | A table's columns; tabs, options or menu items | 64; 1 000 | | Markdown | 1 MiB | | An image | 16 MiB from the folder, 8 MiB put (64 MiB for all) | | `render` | 250 ms (aim for under 8 ms) | | A listener or event | 1 s | | `new` | 2 s | A tile over a frame limit or a deadline is stopped, and the user sees the reason. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/components-forms/ # Form controls Checkboxes, switches, radio groups, segmented controls, sliders, number fields, search fields and form rows, drawn by Pitwall with the controls of its own Settings and dialogs, in the user's theme. Anything Pitwall's own screens draw, a tile draws the same way ("kit parity", [ui.md §3.10](https://github.com/pitwalls/pitwall/blob/main/docs/spec/tile-sdk/ui.md)). The examples come from the gallery tile Pitwall's tests run (the Form controls page of `crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs`); the screenshots are that tile drawn headless, dark and light. Other component groups: [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/), [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/), [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/), and the lists, tables and menus in [Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/#components). What every control shares: - **Controlled.** A control shows the value the tile gives it. The user's change comes to its `on_change` listener as `value-changed`; set your state, call `cx.notify()`, and the next frame shows it. A control without a listener can't be changed. Text fields are the exception: Pitwall owns what is typed ([Text fields](https://pitwalls.github.io/pitwall/docs/extensions/ui/#text-fields)). - **Keyboard and focus.** Each enabled control is a Tab stop with Pitwall's focus ring. A disabled one is skipped and can't be changed by click or key. - **Accessibility.** The label is the accessible name; `.label("…")` names a control that has none (a radio group, a slider). `.tooltip("…")` works on all of them. - **Limits.** Over a limit, the tile stops with the reason, as for any frame ([Limits](https://pitwalls.github.io/pitwall/docs/extensions/ui/#limits)). - **Tests.** `pitwall-extension-test` drives each control as the user would, with the host's own rules for clicks and keys, so the harness and Pitwall agree. ## Checkbox ![Checkbox, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-checkbox-dark.png) ![Checkbox, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-checkbox-light.png) An option the user turns on or off, usually among others in a form or a filter. Use a [switch](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#switch) instead for a setting that takes effect at once. ```rust let boxes = v_flex() .gap_2() .child(checkbox("Only failures").id("failures").checked(self.only_failures).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| { t.widgets.only_failures = *on; cx.notify(); }))) // Some of a group on: a dash; a click turns them all on. .child(checkbox("All branches").id("branches").checked(some == Some(true)).mixed(some.is_none()).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| { t.widgets.all_branches = Some(*on); cx.notify(); }))); ``` | Option | What it does | |---|---| | `checkbox(label)` | A checkbox with its label; the label is clickable too | | `.checked(bool)` | On | | `.mixed(bool)` | Some of a group on: drawn with a dash. A click turns it on | | `.disabled(bool)` | Drawn dimmed; no clicks, no Tab stop | | `.on_change(listener)` | Hears the new state (`&bool`) | - **Events.** `value-changed` with `on(bool)`: the other state, or `on(true)` from mixed. - **Keyboard.** Space toggles it. - **Accessibility.** Its label is its name. - **Test.** `t.toggle("key")`; `t.key_on("key", "space")`. ## Switch ![Switch, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-switch-dark.png) ![Switch, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-switch-light.png) An on/off setting that applies right away, as Pitwall's Settings use them. The same options and events as a [checkbox](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#checkbox), without `mixed`. ```rust let notify = switch("Notify me when a run fails").id("notify").checked(self.notify).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| { t.widgets.notify = *on; cx.notify(); })); ``` | Option | What it does | |---|---| | `switch(label)` | A switch with its label | | `.checked(bool)`, `.disabled(bool)`, `.on_change(listener)` | As for a checkbox | - **Events.** `value-changed` with `on(bool)`. - **Keyboard.** Space toggles it. - **Test.** `t.toggle("key")`. ## Radio group ![Radio group, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-radio-group-dark.png) ![Radio group, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-radio-group-light.png) One of a few choices, all in sight, stacked: up to about six, when each needs words. For more, or less room, use a [select](https://pitwalls.github.io/pitwall/docs/extensions/ui/#select); for two to four short ones side by side, a [segmented control](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#segmented-control). ```rust let scope = radio_group() .id("scope") .label("Which runs") .option("all", "All runs") .option("mine", "My runs") .option("failed", "Failed runs") .selected(self.scope.clone()) .on_change(cx.listener(|t: &mut Hello, key: &str, cx| { t.widgets.scope = key.to_string(); cx.notify(); })); ``` | Option | What it does | |---|---| | `radio_group()` | An empty group | | `.option(key, label)` | A choice; `key` is what the tile hears | | `.option_disabled()` | The last option added can't be chosen | | `.selected(key)` | The chosen option | | `.horizontal()` | Side by side instead of stacked | | `.disabled(bool)` | The whole group | | `.on_change(listener)` | Hears the chosen key (`&str`) | - **Events.** `value-changed` with `choice(key)`. - **Keyboard.** One Tab stop for the group. The arrow keys move the choice (skipping disabled options, wrapping), Home and End go to the first and last, Space chooses the first when none is. - **Accessibility.** Name the group with `.label("…")`; each option's label is its name. - **Limits.** 64 options; keys unique. - **Test.** `t.choose("key", "option")`; `t.key_on("key", "down")`. ## Segmented control ![Segmented control, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-segmented-dark.png) ![Segmented control, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-segmented-light.png) Two to five short choices side by side: a range (Day, Week, Month), a view mode. It is drawn with the same segmented control as [tabs](https://pitwalls.github.io/pitwall/docs/extensions/ui/#tabs), Pitwall's own. Tabs switch what the tile shows and send `select`; a segmented control is a form value: it sends `value-changed`, and options and the whole control can be disabled. ```rust let range = segmented() .id("range") .label("Range") .option("day", "Day") .option("week", "Week") .option("month", "Month") .selected(self.range.clone()) .on_change(cx.listener(|t: &mut Hello, key: &str, cx| { t.widgets.range = key.to_string(); cx.notify(); })); ``` | Option | What it does | |---|---| | `segmented()` | An empty control | | `.option(key, label)`, `.option_disabled()`, `.selected(key)`, `.disabled(bool)`, `.on_change(listener)` | As for a [radio group](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#radio-group) | - **Events.** `value-changed` with `choice(key)`. - **Keyboard.** As a radio group: Left and Right move the choice, wrapping. - **Accessibility.** Name it with `.label("…")`. - **Limits.** 64 options; keys unique. - **Test.** `t.choose("key", "option")`; `t.key_on("key", "right")`. ## Slider ![Slider, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-slider-dark.png) ![Slider, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-slider-light.png) A number in a range where the exact value matters less than where it sits: a volume, an opacity, a threshold. For an exact number, use a [number field](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#number-field). ```rust let volume = slider(self.volume, 0.0..=100.0).id("volume").label("Volume").step(5.0).show_value().w(px(240.)).on_change(cx.listener(|t: &mut Hello, v: &f64, cx| { t.widgets.volume = *v; cx.notify(); })); ``` | Option | What it does | |---|---| | `slider(value, min..=max)` | A slider at `value` | | `.step(n)` | Values snap to `min + k·n`; 0 (the default) is any value | | `.show_value()` | The value drawn beside it | | `.disabled(bool)` | No dragging, no Tab stop | | `.on_change(listener)` | Hears the value (`&f64`) | - **Events.** `value-changed` with `number(f64)`, kept in the range and snapped to the step. While the user drags, Pitwall draws the thumb itself and sends at most one value every 50 ms, and always the last one when they let go. - **Keyboard.** Left and Down step down, Right and Up step up (a step, or a hundredth of the range), Page Up and Page Down by a tenth of the range, Home and End to the ends. - **Accessibility.** Name it with `.label("…")`. - **Limits.** `min` below `max`, both finite; the step 0 or more. - **Test.** `t.set_slider("key", 73.0)` (snapped as Pitwall snaps); `t.key_on("key", "end")`. ## Number field ![Number field, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-number-field-dark.png) ![Number field, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-number-field-light.png) An exact number: retries, a port, a timeout. A text field with − and + steps; Pitwall checks what is typed and keeps it within the bounds. ```rust let retries = number_field(self.retries).id("retries").label("Retries").min(0.).max(10.).placeholder("None").w(px(140.)).on_change(cx.listener(|t: &mut Hello, v: &Option, cx| { t.widgets.retries = *v; cx.notify(); })); ``` | Option | What it does | |---|---| | `number_field(Option)` | A field holding the number, or empty | | `.min(v)`, `.max(v)` | The bounds; a number typed past one is kept at it | | `.step(n)` | What − and + add (default 1) | | `.decimals(n)` | Decimal places shown and kept (0–6, default 0) | | `.placeholder(text)` | Shown while empty | | `.readonly(bool)` | Shown, selectable, not changed | | `.disabled(bool)` | Dimmed, no Tab stop | | `.on_change(listener)` | Hears `&Option`: the number, or `None` when emptied | - **Events.** `value-changed` with `number(f64)`, or `empty` when the user clears it. A typed number is sent on Enter or when the field loses focus; text that isn't a number puts the old value back and sends nothing. A comma works as the decimal point. - **Keyboard.** Up and Down step; an empty field steps to its min (or 0). Typing as in any text field. - **Accessibility.** Name it with `.label("…")` or a [form row](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#form-row). - **Limits.** The step above 0; `min` at most `max`; all finite. - **Test.** `t.type_number("key", "12")` (returns whether it sent anything); `t.step_number("key", true)`; `t.key_on("key", "up")`. ## Search field ![Search field, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-search-field-dark.png) ![Search field, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-search-field-light.png) Filter text above a list or a table: a text field with a magnifier and a clear button, as Pitwall's own lists have. ```rust let search = search_field("query").placeholder("Filter branches").on_change(cx.listener(|t: &mut Hello, q: &str, cx| { t.widgets.query = q.to_string(); cx.notify(); })); ``` | Option | What it does | |---|---| | `search_field(key)` | A search field; it takes the same options as `input(key)`: `.placeholder`, `.value`, `.disabled`, `.on_change`, `.on_submit` | - **Events.** As a text field's: `input-changed` while the user types (at most one every 50 ms), `submit` on Enter. The clear button empties it and sends `input-changed` with `""`. - **Keyboard.** As a text field. The clear button is shown only while it has text. - **Limits.** As a text field: 1 MiB of text. - **Test.** `t.type_into("key", "fix")`; `t.clear_search("key")`; `t.field_text("key")`. ## Form row ![Form row, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-form-row-dark.png) ![Form row, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-form-row-light.png) A control with its label, help text, validation message and required mark, laid out as Pitwall's Settings and dialogs lay theirs out. Use one for every field of a form, so forms in tiles read like Pitwall's. ```rust let branch = form_row("Branch") .id("branch-row") .required() .help("Runs start from this branch") .error(missing.then_some("Name a branch")) .child(input("branch").placeholder("main").on_change(cx.listener(|t: &mut Hello, v: &str, cx| { t.widgets.branch = v.to_string(); cx.notify(); }))); let retries = form_row("Retries").id("retries-row").inline().child(number_field(self.retries).id("retries").min(0.).max(10.).w(px(120.))); ``` | Option | What it does | |---|---| | `form_row(label)` | A row; its children are the control | | `.help(text)` | A line under the control | | `.error(Option)` | The validation message, in red; `None` hides it | | `.required()` | A required mark after the label | | `.inline()` | The label beside the control instead of above | - **Events.** None of its own; the control's. - **Accessibility.** The label names the control under it; the error is read with it. - **Test.** The snapshot shows `form-row "Branch" required help=… error=…`. ## Disabled and read-only ![Disabled and read-only controls, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-disabled-dark.png) ![Disabled and read-only controls, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-disabled-light.png) Every control has `.disabled(true)`: drawn dimmed, no clicks, no keys, no Tab stop. A number field and a text field also have read-only (`.readonly(true)` on a number field): the value is shown and can be selected and copied, but not changed. Say why something is disabled near it (a [form row](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#form-row)'s help, a tooltip) when it isn't plain. ```rust let off = v_flex() .gap_2() .child(checkbox("Can't change this").id("box").checked(true).disabled(true)) .child(switch("Turned off by your admin").id("switch").disabled(true)) .child(segmented().id("seg").option("a", "On").option("b", "Off").selected("a").disabled(true)) .child(slider(40., 0.0..=100.0).id("slider").disabled(true).w(px(200.))) .child(number_field(Some(3.)).id("number").readonly(true).w(px(120.))) .child(input("locked").value("Read only").disabled(true).w(px(200.))); ``` - **Test.** The snapshot shows `disabled` and `readonly`; the harness panics when a test changes a disabled control, as the user can't. ## Secure field A Setup view places `secret_field(key)` where the user sets a declared `secret` setting. Pitwall owns this field: it masks typing, saves on Enter or blur, and offers Paste, Replace and Remove. The saved value is never drawn or sent to the component. Its appearance is host-controlled. ```rust secret_field("apiKey").id("api-key").placeholder("API key") ``` Use `settings::secret_set("apiKey")` to learn whether it is set, and `Event::SecretChanged { key, set }` to react to a save or removal. There is no `value` or text-change listener on a secure field. Ordinary `input` fields are for non-secret text and send their changes to the component. A field naming a key that is not a declared secret shows an error instead of accepting input. ![Secure field before entry, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/secure-field-unset-dark.png) ![Secure field saved, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/secure-field-saved-light.png) Tests use `session.enter_secret("api-key", Some("test-key"))` (or `None` to remove it); snapshots include only the key and set/unset state. ## Host-owned setting field ![Host-owned setting fields, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/setting-field-dark.png) ![Host-owned setting fields, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/setting-field-light.png) Use `setting_field("server")` in the Setup view for a manifest setting, especially a URL used by a network grant. Pitwall supplies the saved value, owns the input, validates and saves it on Enter or blur. The component supplies only the schema key and an optional placeholder: ```rust,ignore setting_field("server").id("server-field").placeholder("https://example.com") ``` It has no component change listener and accepts no component-supplied value. Unknown or secret schema keys show an error instead of an input. A URL that supplies a network host follows the network permission's transport rules (HTTPS, or HTTP to loopback). A valid edit updates an already-granted dynamic host; an explicit network refusal remains refused. The component hears `Event::SettingsChanged(Some(key))` after a save. For ordinary settings drawn with your own controls, use `settings::set(key, settings::Value::Text(value))` instead; secrets and grant-bearing keys are denied. Test the host-owned path with `t.enter_setting("server-field", "https://example.com")`. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/ # Feedback Progress bars, spinners, skeletons, empty states, banners, badges, chips, key hints and tooltips: how a tile says what is going on, drawn as Pitwall's own screens say it. The examples come from the Feedback page of the gallery tile (`crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs`), the screenshots from that tile drawn headless. See also [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/), [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/) and [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/). Colours by meaning come from `Tone`: `Info`, `Good`, `Warn`, `Bad`, drawn with the theme's own colours for them, in dark and light. ## Progress bar ![Progress bars, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-progress-dark.png) ![Progress bars, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-progress-light.png) Work with a known end (indexing, an upload), or still going with none known. For a short wait in place, use a [spinner](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/#spinner). ```rust let bars = v_flex() .gap_3() .w(px(280.)) .child(progress(Some(0.62)).id("indexing").label("Indexing files")) .child(progress(Some(1.)).id("uploaded").tone(Tone::Good).label("Uploaded")) // Still going, with no share known. .child(progress(None).id("waiting").label("Waiting for the runner")); ``` | Option | What it does | |---|---| | `progress(Some(share))` | A bar `share` done, 0.0–1.0 (kept in it) | | `progress(None)` | Indeterminate: a moving band (still with Reduce motion on) | | `.tone(Tone)` | Its colour by meaning (default: the text colour) | | `.label(text)` | What it measures; drawn by screen readers, not on screen | - **Events.** None. - **Accessibility.** Name it with `.label("…")`; its value is read as a percentage. - **Test.** The snapshot shows `progress 62%` or `progress indeterminate`. ## Spinner ![Spinner, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-spinner-dark.png) ![Spinner, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-spinner-light.png) Something is loading and will be here soon: Pitwall's own spinning ring. Pair it with a line saying what. ```rust let loading = h_flex().gap_2().items_center().child(spinner().id("spin").label("Loading")).child(text("Loading runs…").text_color(Token::Text3)); ``` | Option | What it does | |---|---| | `spinner()` | The ring, as tall as the text | | `.label(text)` | Its accessible name ("Loading") | - **Motion.** It turns without the tile doing anything; with Reduce motion it is still. ## Skeleton ![Skeleton, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-skeleton-dark.png) ![Skeleton, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-skeleton-light.png) A grey placeholder in the shape of content that is loading, so the layout doesn't jump when it comes. ```rust let placeholder = h_flex().gap_3().items_start().w(px(300.)).child(skeleton(SkeletonShape::Circle).size(px(28.))).child(v_flex().flex_1().child(skeleton(SkeletonShape::Lines(3)))); ``` | Option | What it does | |---|---| | `skeleton(SkeletonShape::Lines(n))` | `n` lines of text (1–20), the last shorter | | `skeleton(SkeletonShape::Block)` | A box; give it a size | | `skeleton(SkeletonShape::Circle)` | A circle as tall as its width (an avatar's place) | - **Motion.** It shimmers, unless Reduce motion is on. - **Limits.** 20 lines. ## Empty state ![Empty state, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-empty-state-dark.png) ![Empty state, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-empty-state-light.png) Nothing to show yet, and what to do about it: as Pitwall's own lists say they are empty. Centred in its box. ```rust let empty = empty_state("No runs yet") .id("empty") .icon(Icon::Folder) .text("Runs show here when CI starts one.") .action("Refresh", cx.listener(|t: &mut Hello, _: &Click, cx| said(t, "Refreshed", cx))); ``` | Option | What it does | |---|---| | `empty_state(title)` | The title | | `.icon(Icon)` | An icon over it | | `.text(text)` | A line under it: why, or what to do | | `.action(label, listener)` | A button; its listener hears `Click` | - **Events.** `click` from the action. - **Keyboard.** The action is a Tab stop. ## Banner ![Banners, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-banner-dark.png) ![Banners, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-banner-light.png) A message in the tile's flow: information, success, a warning or an error, with an action and a close button. Use it for something that stays true until fixed (a refused token); for "Saved", a toast (`ui::toast`) is enough. ```rust if self.banner_shown { col = col.child( banner(Tone::Bad, "The CI token was refused. Sign in again to load runs.") .id("token") .title("Can't load runs") .action("Sign in", cx.listener(|t: &mut Hello, _: &Click, cx| said(t, "Signing in", cx))) .on_dismiss(cx.listener(|t: &mut Hello, _: &Dismissed, cx| { t.widgets.banner_shown = false; cx.notify(); })), ); } col = col .child(banner(Tone::Info, "Runs older than 90 days are archived.").id("info")) .child(banner(Tone::Good, "Deployed to staging.").id("good")) .child(banner(Tone::Warn, "Two runners are offline.").id("warn")); ``` | Option | What it does | |---|---| | `banner(Tone, text)` | A banner of that tone | | `.title(text)` | A bold first line | | `.action(label, listener)` | A button; its listener hears `Click` | | `.on_dismiss(listener)` | A close button; its listener hears `Dismissed`. Leave the banner out of the next render | - **Events.** `click` from the action; `dismissed` from the close button. - **Keyboard.** The action and the close button are Tab stops. - **Accessibility.** Don't rely on the colour alone: say what happened in the text or the title. - **Test.** `t.dismiss("key")`; the snapshot shows `banner bad "…" title=… action=… dismissible`. ## Badge ![Badges, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-badge-dark.png) ![Badges, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-badge-light.png) A small count or status beside something: "3 failing", "beta". Not clickable; for a tag the user picks or removes, use a [chip](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/#chip). ```rust let badges = h_flex() .gap_2() .child(badge("12")) .child(badge("3 failing").tone(Tone::Bad)) .child(badge("passing").tone(Tone::Good)) .child(badge("flaky").tone(Tone::Warn)) .child(badge("beta").tone(Tone::Info)); ``` | Option | What it does | |---|---| | `badge(text)` | A badge | | `.tone(Tone)` | Its colour by meaning (default: neutral) | - **Limits.** 32 bytes of text. ## Chip ![Chips, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-chip-dark.png) ![Chips, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-chip-light.png) A tag or a filter: picked on and off with a click, or removed with its ×. ```rust let mut chips = h_flex().gap_2().flex_wrap().w(px(360.)).child(chip("Flaky only").id("flaky").icon(Icon::Restart).selected(self.flaky_only).on_click(cx.listener(|t: &mut Hello, _: &Click, cx| { t.widgets.flaky_only = !t.widgets.flaky_only; cx.notify(); }))); for tag in self.tags.iter().copied() { chips = chips.child(chip(tag).id(tag).on_remove(cx.listener(move |t: &mut Hello, _: &Dismissed, cx| { t.widgets.tags.retain(|have| *have != tag); cx.notify(); }))); } let chips = chips.child(chip("main").id("main").tone(Tone::Good)); ``` | Option | What it does | |---|---| | `chip(label)` | A chip | | `.icon(Icon)` | An icon before the label | | `.tone(Tone)` | Its colour by meaning | | `.selected(bool)` | Drawn picked (a filter that is on) | | `.disabled(bool)` | Dimmed; no clicks | | `.on_click(listener)` | Clickable: hears `Click` | | `.on_remove(listener)` | A × that sends `Dismissed` | - **Events.** `click`; `dismissed` from the × (or the keys below). - **Keyboard.** A chip that can be clicked or removed is a Tab stop. Enter or Space clicks it; Backspace or Delete removes it. - **Test.** `t.click_key("key")`; `t.dismiss("key")`; `t.key_on("key", "backspace")`. ## Key hint ![Key hints, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-kbd-dark.png) ![Key hints, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-kbd-light.png) A key or shortcut, drawn as Pitwall draws its own: `"cmd-k"` is ⌘K on macOS and Ctrl+K elsewhere. Use the names the keymap uses ([Keys](https://pitwalls.github.io/pitwall/docs/extensions/ui/#keys)). ```rust let hint = h_flex().gap_2().items_center().child(text("Search").text_color(Token::Text3)).child(kbd("cmd-k")).child(text("or").text_color(Token::Text3)).child(kbd("/")); ``` | Option | What it does | |---|---| | `kbd(keys)` | The key, as `bind_key` names it (`"cmd-k"`, `"shift-enter"`, `"/"`) | ## Tooltip ![Tooltips, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-tooltip-dark.png) ![Tooltips, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-tooltip-light.png) `.tooltip("…")` works on any element, components included: Pitwall's own tooltip after the usual hover delay. An icon button gets its label as its tooltip (`icon_button(icon, label)`). Keep it to a few words that add something; don't hide what the user needs to act on. ```rust let tips = h_flex() .gap_2() .items_center() .child(button("Deploy").id("deploy").tooltip("Deploys main to staging")) .child(icon_button(Icon::Refresh, "Refresh runs").id("refresh")) .child(badge("3").id("failed").tone(Tone::Bad).tooltip("3 runs failed today")); ``` - **Accessibility.** An element with no text needs `.label("…")` as well; a tooltip isn't its name. - **Test.** The node's `tooltip` field holds it (`t.find_key("key").unwrap().node.tooltip`). --- Source: https://pitwalls.github.io/pitwall/docs/extensions/components-layout/ # Layout Split panes, disclosures, cards, dividers, breadcrumbs, toolbars, popovers and confirm sheets: the structure Pitwall's own screens are built from, for tiles. The examples come from the Layout page of the gallery tile (`crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs`), the screenshots from that tile drawn headless. See also [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/), [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/) and [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/); for rows and columns of boxes, [Elements](https://pitwalls.github.io/pitwall/docs/extensions/ui/#elements) and [Styles](https://pitwalls.github.io/pitwall/docs/extensions/ui/#styles). ## Split pane ![Split pane, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-split-dark.png) ![Split pane, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-split-light.png) Two panes with a bar between them the user drags: a list beside its detail, an editor over its output. `h_split()` puts them side by side, `v_split()` one above the other. ```rust let panes = h_split() .id("panes") .initial(0.4) .min_sizes(120., 160.) .first(v_flex().p(px(12.)).gap_1().child(text("Runs").font_semibold()).child(text("#412 main").text_sm()).child(text("#411 fix/login").text_sm())) .second(v_flex().p(px(12.)).gap_1().child(text("Run #412").font_semibold()).child(text("Passed in 3 min").text_color(Token::Text3))) .on_resize(cx.listener(|t: &mut Hello, share: &f64, cx| { t.widgets.split_share = Some(*share); cx.notify(); })); ``` | Option | What it does | |---|---| | `h_split()`, `v_split()` | A split, side by side or stacked | | `.first(element)`, `.second(element)` | The two panes (both are needed) | | `.initial(share)` | The first pane's share at first, 0.05–0.95 (default 0.5) | | `.min_sizes(first, second)` | The panes' smallest sizes in logical pixels (default 80 each) | | `.on_resize(listener)` | Hears the first pane's share (`&f64`) when a drag ends | - **The user's size.** Pitwall keeps the size the user dragged to for the view, by the split's key path, across restarts; the tile doesn't need to store it. `on_resize` is for a tile that wants to know. - **Events.** `value-changed` with `number(share)`, once at the end of a drag. - **Size.** Give it a size, or let it grow (`.flex_1()`). - **Limits.** Exactly two children. - **Test.** `t.resize_split("key", 0.7)` (kept within the minimum sizes, as Pitwall does). ## Disclosure ![Disclosure, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-disclosure-dark.png) ![Disclosure, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-disclosure-light.png) A section the user opens and closes, for detail most people don't need every time: an environment, advanced options. ```rust let env = disclosure("Environment", self.env_open) .id("env") .detail("3 variables") .on_toggle(cx.listener(|t: &mut Hello, open: &bool, cx| { t.widgets.env_open = *open; cx.notify(); })) .child(key_values().entry("CI", "true").mono().entry("NODE_ENV", "test").mono().entry("RUST_LOG", "info").mono()); ``` | Option | What it does | |---|---| | `disclosure(title, open)` | A section; its children are drawn under the header while `open` | | `.detail(text)` | Muted text at the header's right (a count, a summary) | | `.on_toggle(listener)` | Hears the new state (`&bool`: open) | - **Events.** `value-changed` with `on(open)`. - **Keyboard.** The header is a Tab stop; Enter or Space opens and closes it. - **Accessibility.** The title is its name; open or closed is read with it. - **Test.** `t.toggle("key")`; `t.key_on("key", "enter")`. ## Card ![Card, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-card-dark.png) ![Card, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-card-light.png) A bordered box on the raised surface, for one item among others: a run, a deploy, a service. With `on_click` the whole card is clickable. ```rust let run = card() .id("run") .title("Last run") .detail("main") .on_click(cx.listener(|t: &mut Hello, _: &Click, cx| said(t, "Opened run #412", cx))) .child(h_flex().gap_2().items_center().child(badge("passed").tone(Tone::Good)).child(text("#412 · 3 min").text_color(Token::Text2))); ``` | Option | What it does | |---|---| | `card()` | A card; its children are its body | | `.title(text)` | A title at its top | | `.detail(text)` | Muted text at the title's right | | `.on_click(listener)` | The card is clickable: hears `Click` | - **Keyboard.** A clickable card is a Tab stop; Enter or Space clicks it. - **Accessibility.** The title is its name. - **Test.** `t.click_key("key")`; `t.key_on("key", "enter")`. ## Divider ![Dividers, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-divider-dark.png) ![Dividers, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-divider-light.png) A hairline in the theme's line colour: `divider()` across stacked things, `vertical_divider()` between things in a row (give the row a height). ```rust let lines = v_flex() .gap_2() .w(px(280.)) .child(text("Today")) .child(divider()) .child(h_flex().gap_2().items_center().h(px(20.)).child(text("12 runs")).child(vertical_divider()).child(text("2 failed"))); ``` ## Breadcrumbs ![Breadcrumbs, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-breadcrumbs-dark.png) ![Breadcrumbs, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-breadcrumbs-light.png) Where the user is in something nested (an org, a repository, a run), each level but the last clickable to go back up. ```rust let crumbs = self .path .iter() .fold(breadcrumbs().id("crumbs"), |b, level| b.crumb(*level, *level)) .on_pick(cx.listener(|t: &mut Hello, key: &str, cx| { // Back up to the level clicked. if let Some(at) = t.widgets.path.iter().position(|p| *p == key) { t.widgets.path.truncate(at + 1); } cx.notify(); })); ``` | Option | What it does | |---|---| | `breadcrumbs()` | An empty trail | | `.crumb(key, label)` | A level; the last is where the user is | | `.on_pick(listener)` | Hears the key (`&str`) of the level clicked | - **Events.** `value-changed` with `choice(key)`. - **Keyboard.** With `on_pick`, a Tab stop; the levels are buttons. - **Limits.** 32 levels; keys unique. - **Test.** `t.choose("key", "level")` (the last level can't be picked). ## Toolbar row ![Toolbar row, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-toolbar-row-dark.png) ![Toolbar row, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-toolbar-row-light.png) A row of buttons and fields at the top of a tile, with Pitwall's bar look: its height, spacing and the hairline under it. Put a `div().flex_1()` in it to push what follows to the right. ```rust let bar = toolbar() .id("bar") .child(search_field("filter").placeholder("Filter").w(px(180.))) .child(segmented().id("which").option("all", "All").option("failed", "Failed").selected("all")) .child(div().flex_1()) .child(icon_button(Icon::Refresh, "Refresh").id("refresh")) .child(button("New run").id("new").small().primary()); ``` | Option | What it does | |---|---| | `toolbar()` | A toolbar; its children are laid out in a row | ## Popover ![Popover, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-popover-dark.png) ![Popover, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-popover-light.png) A floating panel anchored to an element: filters, a small form, details on demand. Pitwall draws it inside the tile, above everything else, and keeps it in sight. ```rust let mut filters = div().id("filters").child(button("Filters").id("open").icon(Icon::ChevronDown).on_click(cx.listener(|t: &mut Hello, _: &Click, cx| { t.widgets.popover_open = !t.widgets.popover_open; cx.notify(); }))); if self.popover_open { filters = filters.child( popover() .id("pop") .width(240.) .on_dismiss(cx.listener(|t: &mut Hello, _: &Dismissed, cx| { t.widgets.popover_open = false; cx.notify(); })) .child(v_flex().gap_2().p(px(12.)).child(text("Show").font_semibold()).child(checkbox("Failed runs").id("failed").checked(true)).child(checkbox("Cancelled runs").id("cancelled"))), ); } ``` | Option | What it does | |---|---| | `popover()` | A popover; its children are its content | | `.placement(Placement)` | `Below` (default), `Above`, `Start` or `End` of its anchor | | `.width(px)` | Its width (default: its content's, 160–480) | | `.at(x, y)` | Anchor it to that point of its parent (pixels from the parent's top-left corner, as a click's `at`) instead of the parent's edge | | `.on_dismiss(listener)` | Hears `Dismissed`: Esc, or a click outside it. Leave it out of the next render | - **Anchor.** It is open while it is in the frame, anchored to its parent: put it in a box with the button that opens it, as the example does. With `.at(x, y)` it hangs from a point of the parent instead, on the side `.placement` says; on a canvas (`canvas.popover(…)`), under the box that was clicked ([Canvas](https://pitwalls.github.io/pitwall/docs/extensions/canvas/#text)). - **Events.** `dismissed` on Esc or a click outside. - **Keyboard.** Esc closes it; Tab moves among its controls. - **Limits.** One popover a frame; it can't be the root. - **Test.** `t.key_on("key", "escape")`; `t.dismiss("key")`. The snapshot says `popover at (x, y)` for one anchored to a point. ## Confirm sheet ![Confirm sheet, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-confirm-sheet-dark.png) ![Confirm sheet, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-confirm-sheet-light.png) Asking the user to confirm before something that can't be undone. Tiles can't open the system's dialogs, so this is how a tile asks: a sheet over the tile, the rest of it dimmed and taking no input, in Pitwall's dialog look. ```rust let mut notes = v_flex().id("notes").size_full().gap_2().p(px(12.)).child(button("Delete 3 notes…").id("delete").danger().on_click(cx.listener(|t: &mut Hello, _: &Click, cx| { t.widgets.asking = true; cx.notify(); }))); if self.asking { notes = notes.child( confirm_sheet("Delete 3 notes?", "Delete") .id("ask") .text("They can't be brought back.") .danger() .on_confirm(cx.listener(|t: &mut Hello, _: &Click, cx| { t.widgets.deleted += 3; t.widgets.asking = false; cx.notify(); })) .on_cancel(cx.listener(|t: &mut Hello, _: &Dismissed, cx| { t.widgets.asking = false; cx.notify(); })), ); } ``` | Option | What it does | |---|---| | `confirm_sheet(title, confirm)` | A sheet asking `title`, with a button labelled `confirm` | | `.text(text)` | More about it | | `.cancel_label(text)` | The cancel button's label (default "Cancel") | | `.danger()` | The confirm button is red | | `.on_confirm(listener)` | Hears `Click` when the user confirms | | `.on_cancel(listener)` | Hears `Dismissed` on Cancel, Esc or a click on the dimmed tile | - **Placement.** Shown while it is in the frame, wherever it is in the tree. - **Events.** `click` to confirm; `dismissed` to cancel. Leave it out of the next render either way. - **Keyboard.** While it is open, Enter confirms and Esc cancels wherever focus is in the tile. - **Wording.** Say the action in the title and on the button ("Delete 3 notes?", "Delete"), not "Are you sure?" and "OK". - **Limits.** One confirm sheet a frame. - **Test.** `t.key_on("key", "enter")`; `t.key_on("key", "escape")`; `t.dismiss("key")`. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/components-data/ # Data display Key-value lists, avatars, relative times, copyable text and links: showing facts the way Pitwall shows its own. The examples come from the Data display page of the gallery tile (`crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs`), the screenshots from that tile drawn headless. See also [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/), [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/) and [Charts](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/); for long lists and tables, [Components](https://pitwalls.github.io/pitwall/docs/extensions/ui/#components). ## Key-value list ![Key-value list, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-key-values-dark.png) ![Key-value list, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-key-values-light.png) Facts about one thing, labels and values aligned in two columns: a run's branch, commit and runner. ```rust let facts = key_values().entry("Branch", "main").entry("Commit", "4f2a9c1e").mono().copyable().entry("Runner", "macos-14 (arm64)").entry("Started by", "Ada Lovelace"); ``` | Option | What it does | |---|---| | `key_values()` | An empty list | | `.entry(label, value)` | A line | | `.mono()` | The last line's value in the monospace font (ids, hashes, paths) | | `.copyable()` | The last line's value gets a copy button (see [Copyable text](https://pitwalls.github.io/pitwall/docs/extensions/components-data/#copyable-text)) | - **Accessibility.** Each line is read as its label and value. - **Limits.** 500 lines. - **Test.** The snapshot shows `key-values Branch="main" Commit="…"`. ## Avatar ![Avatars, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-avatar-dark.png) ![Avatars, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-avatar-light.png) A person or a bot, as their initials in a circle. The colour comes from the theme's set, chosen by the name: the same name gets the same colour everywhere, in dark and light. ```rust let people = h_flex().gap_2().items_center().child(avatar("Ada Lovelace").small()).child(avatar("Grace Hopper")).child(avatar("ci-bot")).child(avatar("Linus Torvalds").large()); ``` | Option | What it does | |---|---| | `avatar(name)` | Up to two initials of `name` ("Ada Lovelace": AL; "ci-bot": C) | | `.small()` | 20 px (default 28) | | `.large()` | 40 px | - **Accessibility.** The name is its accessible name and its tooltip. - **Network.** No pictures are fetched: tiles have no network for images ([Images](https://pitwalls.github.io/pitwall/docs/extensions/ui/#images)). ## Relative time ![Relative times, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-relative-time-dark.png) ![Relative times, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-relative-time-light.png) When something happened, as "just now", "5 min ago", "yesterday" or a date. Pitwall keeps it up to date as time passes: the tile sends the time once and needs no timer. Its tooltip is the full date and time. ```rust let times = v_flex() .gap_1() .child(h_flex().gap_1().child(text("Started")).child(relative_time_ms(now - 5 * 60_000).id("started"))) .child(h_flex().gap_1().child(text("Last failure")).child(relative_time_ms(now - 26 * 3_600_000).id("failed"))); ``` | Option | What it does | |---|---| | `relative_time(SystemTime)` | A time | | `relative_time_ms(ms)` | A time in milliseconds since 1970-01-01 UTC | - **Wording.** Under 45 seconds "just now"; then seconds, minutes and hours ("3 h ago"), "yesterday", days up to a week, then the date ("31 Jan 2026"). A time ahead reads "in 5 min". - **Test.** The harness draws it with its virtual clock, so `t.advance(…)` moves it: the snapshot shows `relative-time "5 min ago"`. ## Copyable text ![Copyable text, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-copyable-dark.png) ![Copyable text, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-copyable-light.png) A value the user will paste elsewhere (a commit, an id, an address), with a copy button. Pitwall writes the clipboard itself, and only when the user clicks: a tile can't write the clipboard on its own. ```rust let copies = v_flex().gap_2().child(copyable("4f2a9c1e7b").id("sha").mono()).child(copyable("https://ci.example.com/runs/412").id("url")); ``` | Option | What it does | |---|---| | `copyable(text)` | The text and its copy button | | `.mono()` | In the monospace font | | `.on_click(listener)` | Also hears the copy (`Click`), to say so | - **Events.** `click`, when it has a listener. The button shows a check for a moment after copying. - **Keyboard.** A Tab stop; Enter or Space copies. - **Limits.** 64 KiB of text. - **Test.** `t.copy("key")`, then `t.clipboard()`. ## Link ![Links, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-link-dark.png) ![Links, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-link-light.png) Text the user clicks to go somewhere: a web page, or another place in the tile. ```rust let links = v_flex() .gap_2() .child(link("Open run #412 in CI").id("web").url("https://ci.example.com/runs/412")) // No address: the click is the tile's. .child(link("Show all runs").id("all").on_click(cx.listener(|t: &mut Hello, _: &Click, cx| said(t, "All runs", cx)))); ``` | Option | What it does | |---|---| | `link(label)` | A link | | `.url(address)` | A web page to open | | `.on_click(listener)` | Hears `Click` | - **Opening pages.** With an `http` or `https` address and the extension's `show` permission ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/)), Pitwall opens the page in a web tile, as an agent's `show_web` does. Without the permission, or without an address, the click goes to the tile's listener instead, so it can show something itself. - **Keyboard.** A Tab stop; Enter or Space follows it. - **Accessibility.** The label is its name: make it say where it goes ("Open run #412 in CI", not "here"). - **Limits.** An address up to 2 048 bytes. - **Test.** `t.open_link("key")`, then `t.opened_pages()` (with `Harness::grant("show")`), or the listener heard it. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/components-charts/ # Charts Sparklines, bar charts, line charts and status timelines, drawn by Pitwall in the theme's colours with axes, legends and tooltips. A tile sends the data (series and a few options), never drawing instructions, so charts look the same in every tile, follow dark and light, and are drawn without a round trip while the user hovers. For a drawing of your own, use the [canvas](https://pitwalls.github.io/pitwall/docs/extensions/canvas/). The examples come from the Charts page of the gallery tile (`crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs`), the screenshots from that tile drawn headless. See also [Form controls](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/), [Feedback](https://pitwalls.github.io/pitwall/docs/extensions/components-feedback/), [Layout](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/) and [Data display](https://pitwalls.github.io/pitwall/docs/extensions/components-data/). What every chart shares: - **Colours.** A series without a colour of its own takes the next of the theme's series colours (`Focus`, `Done`, `Good`, `Warn`, `Bad`, `Text3`, in order). Give one by meaning with a `Token` (`series_colored(…, Token::Bad)` for failures). - **Size.** Give a chart a height (`.h(px(180.))`); it fills its width. - **Accessibility.** `.label("…")` names it ("Runs this week"). Pitwall also reads a summary made from the data: the kind, the series and their latest or largest values ("Bar chart of 5 labels: Passed up to 18 runs; Failed up to 3 runs"). Each bar, point and segment has a tooltip with its values, so nothing is shown by colour alone. - **Values.** A NaN or infinite value is a gap. - **Tests.** The snapshot shows each chart with its summary. ## Sparkline ![Sparkline, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-sparkline-dark.png) ![Sparkline, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-sparkline-light.png) A small line without axes, inline with text: a trend at a glance (build times, a queue's length). For values the user reads off, use a [line chart](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/#line-chart). ```rust let trend = h_flex() .gap_3() .items_center() .child(text("Build time").text_color(Token::Text3)) .child(sparkline([4.1, 3.8, 4.4, 5.0, 4.2, 3.9, 3.6, 3.7, 3.2, 3.4]).id("trend").label("Build time, last 10 runs").color(Token::Good).filled()) .child(text("3.4 min").font_mono()); ``` | Option | What it does | |---|---| | `sparkline(values)` | A line through `values`, oldest first | | `.color(Token)` | Its colour (default: the text colour) | | `.filled()` | The area under the line filled, faintly | - **Limits.** 1 000 values. ## Bar chart ![Bar chart, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-bar-chart-dark.png) ![Bar chart, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-bar-chart-light.png) Amounts by category: runs per day, failures per suite. One group of bars per label, one bar per series, or one stacked bar per label; a value axis, a legend for more than one series, and a tooltip per bar. ```rust let runs = bar_chart(["Mon", "Tue", "Wed", "Thu", "Fri"]) .id("runs") .label("Runs this week") .series_colored("Passed", [12., 18., 9., 14., 11.], Token::Good) .series_colored("Failed", [1., 0., 3., 2., 1.], Token::Bad) .stacked() .unit("runs") .h(px(180.)); ``` | Option | What it does | |---|---| | `bar_chart(labels)` | A chart over `labels` | | `.series(name, values)` | A series: one value per label | | `.series_colored(name, values, Token)` | A series in a colour of its own | | `.stacked()` | The series stacked in one bar per label | | `.unit(text)` | The values' unit, in the axis and tooltips (`"runs"`, `"ms"`) | - **Limits.** 200 labels; 8 series, each up to 200 values. ## Line chart ![Line chart, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-line-chart-dark.png) ![Line chart, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-line-chart-light.png) Values over time or another order: response times, coverage. Axes with round steps, a legend for more than one series, and a tooltip under the pointer listing each series' value at that label. ```rust let latency = line_chart(["1 Mar", "2 Mar", "3 Mar", "4 Mar", "5 Mar", "6 Mar", "7 Mar"]) .id("latency") .label("Response time") .series("p50", [210., 190., 230., 205., 180., 175., 182.]) .series("p95", [480., 520., 610., 450., 430., 470., 440.]) .unit("ms") .h(px(200.)); ``` | Option | What it does | |---|---| | `line_chart(labels)` | A chart over `labels` | | `.series(name, values)`, `.series_colored(name, values, Token)` | As in a [bar chart](https://pitwalls.github.io/pitwall/docs/extensions/components-charts/#bar-chart) | | `.unit(text)` | The values' unit | | `.min(v)`, `.max(v)` | The axis's ends (default: from the data, with 0 included, rounded out to round steps) | - **Limits.** 1 000 labels; 8 series, each up to 1 000 values. ## Status timeline ![Status timeline, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-status-timeline-dark.png) ![Status timeline, light](https://pitwalls.github.io/pitwall/docs/extensions/images/components/components-status-timeline-light.png) A row of coloured segments, oldest first: a CI pipeline's last runs, a service's uptime, deploys. Each segment has a tooltip and can be clicked. ```rust let timeline = runs .iter() .enumerate() .fold(status_timeline().id("history").label("Last 9 runs"), |line, (i, (tone, mins))| { let run = 404 + i; let what = match tone { Tone::Good => "passed", Tone::Bad => "failed", _ => "was slow", }; line.segment_weighted(run.to_string(), format!("#{run} {what} in {mins} min"), Some(*tone), *mins as f32) }) .on_pick(cx.listener(|t: &mut Hello, run: &str, cx| said(t, format!("Run #{run}"), cx))); ``` | Option | What it does | |---|---| | `status_timeline()` | An empty timeline | | `.segment(key, label, Option)` | A segment: `key` (sent when clicked), its tooltip and accessible name, its colour by meaning (`None`: neutral, a run not started) | | `.segment_weighted(key, label, tone, weight)` | A segment `weight` times as wide as one of 1 (a run's duration) | | `.on_pick(listener)` | Hears the key (`&str`) of the segment clicked | - **Events.** `value-changed` with `choice(key)`. - **Keyboard.** With `on_pick`, a Tab stop. - **Accessibility.** Its summary counts the runs and the failed ones and reads the latest segment's label. - **Limits.** 500 segments; keys unique. - **Test.** `t.choose("key", "segment")`. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/canvas/ # Canvas and drag **Preview.** A canvas is an element the tile draws on: rectangles, paths and text in theme colours, with zoom and pan, and clickable regions laid over what it drew. It is for diagrams, charts and maps, where boxes and lines don't follow a flex layout. This page also covers dragging things from one element of a tile to another. Everything below comes from `use pitwall_extension::prelude::*;`. ## Drawing `canvas()` is an element like `div()`: give it a key, a size and styles (`.id("diagram").flex_1()`). Then add what it draws, in order, each over the ones before: ```rust canvas() .id("diagram") .size_full() .draw(Shape::rect(0., 0., 168., 72.).fill(Token::Surface2).stroke(Token::Line, 1.).radius(8.)) .draw(Label::new("API", 84., 36.).size(14.).semibold().center().middle()) .draw(Shape::line(168., 36., 248., 36.).stroke(Token::Text3, 1.5).dash([5., 4.])) ``` | Made with | What it draws | |---|---| | `Shape::rect(x, y, w, h)` | A rectangle; `.radius(r)` rounds its corners | | `Shape::line(x1, y1, x2, y2)` | A straight line | | `Shape::path()` then `.move_to`, `.line_to`, `.quad_to`, `.cubic_to`, `.close()` | Any outline: arrowheads, curved links, chart lines | | `Label::new(text, x, y)` | One line of text ([below](https://pitwalls.github.io/pitwall/docs/extensions/canvas/#text)) | A shape is filled with `.fill(colour)`, outlined with `.stroke(colour, width)`, or both; `.dash([on, off, …])` dashes the outline (at most 16 numbers). Colours are theme colours (`Token::Text3`, `Token::Focus`, [the list](https://pitwalls.github.io/pitwall/docs/extensions/ui/#theme-colours)), so the drawing follows the user's light or dark theme like the rest of the tile. For data colours a theme doesn't have, `Paint::rgb(0x3b82f6)` gives a fixed colour; prefer tokens. `.clip_push(x, y, w, h)` and `.clip_pop()` limit what is drawn between them to a rectangle. Whatever is drawn, nothing leaves the canvas's own bounds. Positions are in canvas units: pixels at zoom 1, from the canvas's top-left corner. ### Text A label is drawn at its point with 13 px Inter in the text colour unless told otherwise: - `.size(px)`: any size, not only the kit's text sizes, so text zooms with the drawing. - `.color(token)`, `.medium()`, `.semibold()`, `.bold()`, `.mono()` (JetBrains Mono). - `.center()` / `.end()` place the point at the middle or the end of the text; `.middle()` / `.bottom()` place it at the text's middle or bottom (the default is its top). - `.max_width(w)` cuts longer text with "…". Text smaller than 2 px on screen isn't drawn. **Sizing boxes to their text.** `ui::measure_text(&texts, TextFont::Ui, 14.0, TextWeight::Semibold)` asks Pitwall how wide each text is in its fonts (Inter, or JetBrains Mono for `TextFont::Mono`) at that size and weight, kerned as Pitwall draws it, in canvas units at zoom 1; `label.width()` measures one label as it is set up. Measure all a drawing's labels in one call (at most 1 000 texts and 64 KiB): each call counts toward a tile's host calls. A width scales with the size, and a character Pitwall's fonts lack counts as an average letter, so still give a label a `.max_width` as a safety margin: if the measure is short by a few pixels, the text ends in "…" instead of running over the box. The test harness measures the same way, so tests see the same widths (`pitwall_extension_test::text_width`). The C4 tile keeps its own table of Inter's widths instead, because its layout runs without the SDK; a test checks that the table and Pitwall's measure agree. **A box's menu.** A popover can hang from a point of the canvas: `canvas.popover(popover().at(x, y).child(…))`, with (x, y) in the canvas node's pixels, from its top-left corner (map a box's corner with `viewport.to_view(x, y)`). The C4 tile opens its "which diagram?" menu this way, under the box that was clicked ([Popover](https://pitwalls.github.io/pitwall/docs/extensions/components-layout/#popover)). ## Zoom and pan A canvas has one transform, set with `.transform(viewport)`: everything drawn and every region is scaled and moved by it. `Viewport` keeps the zoom and position in the tile's state, and turns the user's pointer, wheel and pinch into zoom and pan: ```rust // In the tile's state: viewport: Viewport, canvas() .transform(self.viewport) .on_pointer(cx.listener(|t: &mut MyTile, p: &Pointer, cx| { if t.viewport.on_pointer(p) { cx.notify(); } })) .on_wheel(cx.listener(|t: &mut MyTile, p: &Pointer, cx| { if t.viewport.on_pointer(p) { cx.notify(); } })) ``` `on_pointer` pans while the user drags with the main button. The wheel or trackpad pans, ⌘-wheel (Ctrl elsewhere) zooms at the pointer, and a pinch zooms. It returns whether anything changed. | `Viewport` | | |---|---| | `fit(x, y, w, h, view_w, view_h, margin)` | Show the canvas rectangle (x, y, w, h) whole in a view of that size, centred | | `zoom_at(factor, x, y)` | Zoom by a factor, keeping the view point (x, y) still: for zoom buttons | | `pan(dx, dy)` | Move by view pixels | | `to_view(x, y)`, `to_canvas(x, y)` | Convert between canvas units and view pixels | | `min_scale`, `max_scale` | Bounds for the zoom (0.1 and 8 unless set) | A tile hears its size in `Tile::on_event` (`Event::Resize`), which is what `fit` needs. `on_wheel` is for any element, not only canvases: its `Pointer` is `PointerKind::Wheel { dx, dy }` (pixels, positive when scrolling down) or `PointerKind::Pinch(delta)` (0.1 is 10 % larger). ## Clickable regions What a canvas draws doesn't take clicks by itself. Lay regions over it, one per thing the user can click or point at: ```rust .region( Region::new("api", 248., 0., 168., 72., "API") .tooltip("API: Rust, axum") .on_click(cx.listener(|t: &mut MyTile, _: &Click, cx| { /* … */ })) .on_hover(cx.listener(|t: &mut MyTile, h: &Hover, cx| { /* … */ })), ) ``` A region has a key (unique in its canvas), a rectangle in canvas units (it follows the zoom and pan) and a label. The label is its accessible name: screen readers read it, and tests find regions by it. Later regions are over earlier ones. A press that moves more than a few pixels is a pan, not a click. Give the canvas itself a `.label("…")` saying what the drawing shows. ## Drag and drop Inside a tile, an element can be dragged onto another: a card onto a column, a name onto a list. ```rust text(item.name.clone()).id(item.id.clone()).draggable("item", item.id.clone(), item.name.clone()) v_flex().id("done").on_drop(["item"], cx.listener(|t: &mut MyTile, d: &Dropped, cx| { t.move_to_done(&d.data); cx.notify(); })) ``` `.draggable(kind, data, label)` makes an element a drag source: `kind` says what it is, `data` is the tile's own string for it (an id, at most 64 KiB) and `label` is what the chip under the pointer says. `.on_drop(kinds, handler)` makes an element take drops of those kinds; while something it takes is over it, Pitwall highlights it. The handler gets `Dropped`: the kind, the data and where in the element it was dropped. Drags stay inside one view of one tile: a drop target never takes something dragged from another tile or from outside Pitwall. ## Testing The harness ([quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#test-it)) shows canvases in the text snapshot with their regions, drag sources (`drag=item`) and drop targets (`drop=item`), and acts on them as the user would: | Call | Does | |---|---| | `t.canvas("diagram")` | What the canvas draws, its transform and regions, to assert on | | `t.click_region("API")`, `t.hover_region("API", true)` | Click or point at the region with that label | | `t.right_click_region("API")` | Right-click it (a box's menu) | | `t.wheel(key, dx, dy, x, y)`, `t.pinch(key, delta, x, y)` | Scroll or pinch over an element | | `t.drag_pointer(key, from, to)` | Press, move and let go: a pan | | `t.drag(from_key, to_key)`, `t.try_drag(…)` | Drag one element onto another; `try_drag` says why nothing was dropped | ## Limits | | Limit | |---|---| | Drawing operations in a canvas | 20 000 | | Regions in a canvas | 5 000 | | A dash pattern | 16 numbers | | A drag's data | 64 KiB | They count toward the frame's 2 MiB ([Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/#limits)). --- Source: https://pitwalls.github.io/pitwall/docs/extensions/blocks/ # Native building blocks **Preview.** Some parts of Pitwall are too big for a tile to rebuild from boxes and text: its code view and its diff view. A tile embeds them as elements with content it supplies, and they look and behave exactly as they do in Pitwall's files and review tiles: highlighting, line numbers, selection and copy, search, folding of unchanged runs. The tile gives the text; Pitwall does the drawing. Everything below comes from `use pitwall_extension::prelude::*;`. Both views are read-only. ## Code view ```rust code_view(source) .id("code") .language("rust") .flex_1() .mark(4..7, Mark::Added) .reveal(12) .on_line_click(cx.listener(|t: &mut MyTile, l: &LineClick, cx| { t.line = Some(l.line); cx.notify(); })) ``` | | | |---|---| | `code_view(text)` | The view of `text` (at most 1 MiB). Give it a size: `.flex_1()`, `.size_full()` or a height. It scrolls inside | | `.language(name)` | For highlighting: a name (`rust`, `typescript`, `python`, `go`, `markdown`, …) or a file name (`main.rs`). Unknown names show plain text | | `.mark(lines, mark)` | A bar in the margin by lines (0-based, end exclusive): `Mark::Added` (green), `Mark::Changed` (blue), or `Mark::Deleted` (a red mark where lines were removed) | | `.mark_with(lines, mark, message)` | A problem: `Mark::Error` (red) or `Mark::Warning` (yellow) bars the lines and tints them, and `message` (at most 500 bytes, its first line) is drawn after the first line's text, as an editor shows a compiler's errors | | `.reveal(line)` | Scroll that line (0-based) into the middle. Only when it differs from the last render's, so the user's own scrolling isn't undone | | `.on_line_click(handler)` | A click on a line number. `LineClick` has the `line` (0-based) and the `side` | | `.on_select(handler)` | The selection changed. `CodeSelection` has where it starts and ends (line and column, 0-based) and the selected text | ## Diff view ```rust diff_view(old, new).id("diff").language("rust").flex_1() diff_view_unified(patch).id("diff").inline() ``` | | | |---|---| | `diff_view(old, new)` | The diff of two texts (each at most 1 MiB): changed lines and the characters that changed in them, with unchanged runs folded | | `diff_view_unified(text)` | A unified diff of one file, as `git diff` prints it: `@@` hunks of `+`, `-` and context lines. Lines keep their numbers from the hunk headers, and what the diff doesn't show is folded | | `.language(name)` | As for the code view | | `.inline()` / `.side_by_side()` | One column with removed lines above added ones, or old on the left and new on the right (the default) | | `.reveal(line)` | Scroll a line of the new version into the middle | | `.on_line_click(handler)`, `.on_select(handler)` | As for the code view. `side` says which version: `Side::Old` or `Side::New` | ## How they are sent The text is part of the frame, so it counts toward the frame's 2 MiB, and the SDK sends it with each render. Pitwall reloads a view only when its text, language, layout or marks change, so a render that changes something else in the tile keeps the view's scroll position and selection. Keep a view's key the same across renders. The selection is told at most every 100 ms while the user drags it, and its text is cut at 64 KiB. ## Testing The harness shows the views in the text snapshot (`code-view language=rust lines=8 marks=3`, with each problem as `error@7 "message"` or `warning@2 "message"`; `diff-view texts side-by-side`) and acts on them: | Call | Does | |---|---| | `t.code_view(key)`, `t.diff_view(key)` | What the tile sent: text, language, marks, layout | | `t.click_line(key, Side::New, 4)` | Click a line number | | `t.select_code(key, Side::New, (1, 3), (1, 8))` | Select from (line, column) to (line, column) | ## Coming later A terminal, the file tree, a web view and a Markdown view come in later phases. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/ # Agent tools **Preview.** Tile tools are in the preview: opening a tile and showing content in it (SDK phase 2), and reading a tile back and acting outside it with your approval (phase 3). An extension gives your agents tools of its own, and Pitwall registers them with every agent it starts, through the MCP server it already gives them. You set up nothing in any agent. The first such tool opens the tile: an agent can open your tile next to its own terminal with content in it ("draft that as a note", "show me the diagram on the right"), the way it opens files and web pages in Pitwall with `show_files` and `show_web`. ## Every tile can be opened Pitwall offers `__open` for every extension with tiles, with no code from you. It takes the tile's declared `"input"` schema as content; without one, it opens the tile as it was. ```json { "id": "main", "title": "Notes", "wasm": "tile.wasm", "world": "pitwall:tile@0.1.0", "input": "input.schema.json" } ``` The schema is what agents read to decide what to send, so give it a `description` and describe each property. The tile reads the content in `on_content` with `Content::parse` ([Tiles and UI components](https://pitwalls.github.io/pitwall/docs/extensions/ui/#opening-a-tile-with-content)), the same way it reads content you open it with. A tile entry with `"agents": false` can't be opened by agents and has no tools. An extension with several tiles gets one `__open` that takes `tile` (which one) and `content`. ## Show tools of your own An extension may declare up to 16 tools, of four kinds: | Kind | Does | Who decides | Example | |---|---|---|---| | `show` | Opens or focuses the tile, maybe at something | Allowed | `show_issue`: an issue number in, the list scrolled to it | | `present` | Puts content into the tile, or changes content the same agent put there | Allowed: marked with the agent, and you can Undo it | `show_diagram`: Mermaid source in, a diagram on screen | | `read` | Returns what the tile has now, including your edits | You: asked the first time, then "Always" for that agent if you choose | `current_diagram` | | `act` | Has effects outside the tile: the network, files, other services | You, each call, unless you chose "Always" for that agent | `export_svg` | Declare each in the tile's entry in `extension.json`, with a JSON schema for its input: ```json "tools": [ { "name": "show_message", "kind": "present", "description": "Show a short message under the agent's item id (the same item again replaces it).", "input": { "type": "object", "required": ["message"], "properties": { "item": { "type": "string", "description": "Your id for the message" }, "message": { "type": "string", "maxLength": 200, "description": "The message" } } } } ] ``` A name is lowercase letters, digits and `_`, at most 32, and not `open`. With the extension's id it must fit in 50 characters (`notes__show_message`), which `pitwall extension check` tells you. The input is a JSON object; `where` and `of` are Pitwall's own, so you can't use them. The schema can use `type`, `properties`, `required`, `additionalProperties`, `enum`, `items`, `minLength`, `maxLength`, `minItems`, `maxItems`, `minimum`, `maximum` and `description`. Then write each one as a method in a `#[tools]` block, named after the tool: ```rust use pitwall_extension::prelude::*; use pitwall_extension::tools; use pitwall_extension::tools::{Call, Problem, Reply, ToolError}; #[derive(serde::Deserialize)] struct Message { message: String } #[tools] impl Hello { #[tool(kind = "present")] fn show_message(&mut self, call: Call, cx: &mut Cx) -> Result { let text = call.input().message.trim().to_string(); if text.is_empty() { return Err(ToolError::problems("Nothing was shown: the message is empty.", [Problem::new("`message` has no text")])); } self.messages.insert(call.key(), text); // `/`: one per agent and item cx.notify(); Ok(Reply::text("Shown")) } } ``` `pitwall_extension::export!` finds the `#[tools]` block itself. The method gets the call's input read into your type, and `call.item()`, `call.caller()` (the agent's id, name and project), `call.view()` and `call.key()`. The kinds in code and in the manifest must match. - **The reply** is what the agent reads: a short `Reply::text`, with `Reply::json` for a result and `.item(…)` when your tile picked the item id. Without a `#[tools]` method (the host's `__open`), Pitwall tells the agent where the tile opened. - **Errors change nothing.** Return `ToolError::plain` or `ToolError::problems` with `Problem::at(line, column, …)` for each problem in the input (a Mermaid syntax error at line 3). The agent reads them and can fix its call. Show nothing new when you return an error. - **Items.** The content's id is the agent's item id: a later call with the same item updates it in place, a new item adds one. Items are per agent, so two agents' item "a" are two items. - **The user's edits are safe.** When the user edits something an agent showed, call `tools::user_edited(call.origin())` (or with the `call` of the content it came in). From then on Pitwall refuses that agent's calls for that item, before your tile sees them, and tells the agent to show its version under a new item. `__open` content and a declared tool's call both arrive as view content: `on_view_opened` and then the content when the view wasn't open, or only the content when it was. `Content::from_agent()`, `call()`, `tool()` and `caller()` say which call, tool and agent it came from. For `__open`, `on_content` gets it; for a declared tool, your method does. ### An example: the C4 tile's `c4__show` The [C4 diagrams tile](https://pitwalls.github.io/pitwall/docs/extensions/seed-tiles/#c4-diagrams-ask-an-agent-to-draw-it) has one `present` tool. An agent sends Mermaid and the tile draws it; the same item again updates the drawing in place. Its `extension.json`; the description tells agents the convention: The [pinned manifest](https://github.com/pitwalls/pitwall-c4/blob/a80e11db0744e555a432a410bdab3ba03b87f72a/extension.json) and [input validation and presentation implementation](https://github.com/pitwalls/pitwall-c4/blob/a80e11db0744e555a432a410bdab3ba03b87f72a/src/tile.rs) are in C4’s standalone source repository. Its input is read completely before an update; a problem returns every error with its line and changes nothing. An agent's call, as Claude Code makes it (`mcp__pitwall__c4__show`): ```json { "item": "containers", "title": "Shop containers", "where": "right", "mermaid": "flowchart LR\n buyer[\"Buyer [Person]\"]\n subgraph shop[\"Shop [Software System]\"]\n web[\"Web app [Container]\"]\n api[\"Orders API [Container]\"]\n end\n buyer -->|uses| web\n web -->|calls| api\n" } ``` The reply: `Showing “Shop containers” in the C4 tile (item “containers”): 3 boxes, 2 arrows, 1 boundary.` A later call with `"item": "containers"` answers `Updated “Shop containers” in place …` with what changed since the last show. ## Where it opens Next to the calling agent's terminal, on the right by default, as `show_web` places a web page. Pitwall adds `where` (`right`, `left`, `above`, `below`, `replace` or `window`) and `of` (another agent's terminal) to every tile tool. A tile already in the layout is reused wherever you moved it; with `where` it moves there. A window of its own never comes in front of your work or takes the keyboard. When the agent's terminal isn't in any open window, the tile opens in a window of its own and the agent is told why. Pitwall marks the tile with "from " while it shows what that agent put in it; pressing the mark goes to the agent's terminal. ## Limits - 1 MiB of JSON input per call; larger is refused. - 10 seconds per call, from Pitwall handing it over to the tile's answer. - 10 calls in 10 seconds per agent and tile ("Busy" after that). - A reply's text is cut at 4 KiB and its JSON dropped over 256 KiB. - Pitwall checks the input against the tool's schema before the tile sees it, and answers a bad one itself, naming each problem (`` `message` is required ``). ## How agents get them - **Through Pitwall's MCP server.** [`pitwall mcp`](https://pitwalls.github.io/pitwall/docs/cli/mcp/) already gives the agents Pitwall starts `show_files`, `show_web` and the rest. Tile tools join that list, and agents are told when it changes (`notifications/tools/list_changed`: an extension or a switch turned on or off, an extension installed or updated). - **Every agent Pitwall starts with that server.** Pitwall adds it to each agent kind in the kind's own launch-time way, without editing your config files ([Showing files](https://pitwalls.github.io/pitwall/docs/agents/#showing-files)). So Claude Code, Codex and the others get tile tools with no setup. - **Names.** A tool is named `__`, such as `notes__open` and `hello__show_message`. Claude Code shows it as `mcp__pitwall__notes__open`. - **Hints and allow lists.** `show`, `present` and `read` tools carry MCP's read-only hint. An `act` tool doesn't, and carries `destructiveHint` and `idempotentHint` as its manifest says (`"destructive": false`, `"idempotent": true`; MCP's defaults, destructive and not idempotent, when it says nothing). Claude Code and Qwen Code get the `show` and `present` tools in the allow lists Pitwall passes at launch, beside `show_files`; `read` and `act` tools are never in them, and Pitwall asks you about those itself. A tool added after an agent started is offered to it but may ask once. - **Their description.** Pitwall puts " (a Pitwall tile):" before each tool's description, and adds one line per extension to the server's instructions. - **Only agents Pitwall started can put content in a tile** (`present`) or call `read` and `act` tools. `show` and `__open` also work from a shell an agent runs, as `show_files` does. ## What you control - **A switch per tile,** "Agents can use ", on the extension's card in Settings → Extensions, with the tool names. Off removes its tools from every agent's list at once. - **A switch for all tiles,** "Agents can use tiles" in Settings → Agents (`agents.tileTools`), beside "Agents can show you files". It lists the tools agents get now. - **The permission screen** lists a tile's tools under "Adds to Pitwall" before you turn the extension on. - **Activity.** Each call is in the extension's Activity on its card: when, which agent, which tool and item, the start of the input, and whether it was shown or why not. ## Testing them The harness calls a tool as an agent would, through the same checks: ```rust use pitwall_extension_test::{Called, Harness}; let mut tile = Harness::build(env!("CARGO_MANIFEST_DIR")).open("main"); let r = tile.call("claude", Some("show_message"), Some("a"), json!({ "message": "hi" })); assert_eq!(r, Called::Replied { text: "Shown".into(), json: None, item: None }); assert!(tile.call("claude", Some("show_message"), Some("b"), json!({})).text().contains("`message` is required")); assert!(tile.call("claude", None, Some("a"), json!({ "message": "hi" })).is_ok()); // `__open` ``` `None` as the tool is `__open`. The result is `Called::Shown`, `Replied`, `Failed` (your error), `Refused` (Pitwall's: the schema, an edited item, the rate, a denial) or `Waiting` (a `read` or `act` call answered later). `read` and `act` calls go through the user's approval as in Pitwall. Set what the user answers, and see what they were asked: ```rust use pitwall_extension_test::Approval; tile.approve(Approval::Deny); assert!(tile.call("claude", Some("current_messages"), None, json!({})).text().contains("denied")); tile.approve(Approval::Always); // "Always for claude": no question next time let r = tile.call("claude", Some("current_messages"), None, json!({})); assert!(r.json().is_some()); tile.run_command("send_message", json!({ "text": "hi" })); // the user, from a plain terminal assert_eq!(tile.approvals_asked().len(), 3); tile.undo(tile.last_call().unwrap()); // Undo beside the mark ``` `call_append` and `call_from_file` make a `present` call with `"mode": "append"` or a named file; `cancel_call` runs a call out of time. ## Reading and acting A `read` tool returns data, an `act` tool changes something outside the tile. Declare them like the others, with the kind, and for `act` its MCP hints: ```json { "name": "current_messages", "kind": "read", "description": "The messages Hello shows now, with the user's edits, as JSON by item." }, { "name": "send_message", "kind": "act", "description": "Send a message.", "destructive": false, "idempotent": false, "input": { "type": "object", "required": ["text"], "properties": { "text": { "type": "string" } } } } ``` ```rust #[tool(kind = "read")] fn current_messages(&mut self, _call: Call, _cx: &mut Cx) -> Result { let all: BTreeMap<_, _> = self.messages.iter().map(|(k, v)| (k.clone(), v.clone())).collect(); Reply::json(format!("{} messages", all.len()), &all) } ``` - **The user approves, in Pitwall.** The approval dialog names the agent, its project, the tool and its arguments, with **Deny**, **Always for ** and **Allow once**. When you aren't in Pitwall, the same request is a card in the floating control, with the same three answers; answered in one place, it goes from the other. ![An act's approval in the floating control, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/agent-tools/agent-tools-float-dark.png) ![The same card, light](https://pitwalls.github.io/pitwall/docs/extensions/images/agent-tools/agent-tools-float-light.png) A `read` asks until the user chooses "Always" for that agent; an `act` asks each time unless they did. "Always" is kept per extension, agent and tool, listed on the extension's card and in Settings → Agents, each with **Revoke**. A tile that holds `agents.queue` or `agents.start` gets no "Always" for its `act` tools: those ask every time. Unanswered in 2 minutes counts as a denial; a denied call changes nothing. - **The user's own calls.** From a plain Pitwall terminal (`pitwall extension run`), a `read` runs without asking; an `act` still asks, without "Always", so a script can't act behind their back. From outside Pitwall only `show` tools run. - **Answer later.** Return `Reply::later()` and reply with `tools::reply(call_id, …)` when the work is done (a request to a service, say). Past the time limit (`read` 10 seconds, `act` 2 minutes after the approval) the agent hears it timed out and your tile gets `Event::ToolCancelled(call)`. - **Without acting permissions.** During a `show`, `present` or `read` call the tile's acting permissions (`net`, its own server, `show`, `notify`, `agents.queue`, `agents.start`, `agents.focus`) are off; an `act` call has them all. So a tool's kind can't be a lie. - **Output.** Up to 256 KiB of text or JSON; more is cut and says so. A `read` tool should take a range or a cursor. - **Records.** Each call is in the extension's Activity: the agent, the tool, the input (all of it for `act`) and how it ended. ## Undo, appends and files - **Undo.** Next to the "from " mark, **Undo** takes back the agent's last `present` call: your tile gets `Event::UndoPresent(call)`. Keep presented items in `Presented` and it restores the value from before that call (or removes an item the call added) for you: `present(&call, value)`, `append(&call, |v| …)`, `edit_by_user(key, value)`, `undo(call)`. - **Appends.** A `present` tool takes `"mode": "append"` with an `item`: what it gives adds to that item (`Content::is_append()`, `Call::is_append()`). Appends close together are drawn at most four times a second. - **Large input from a file.** Instead of inline text, a `present` call can name `"from_file": "docs/flow.mmd"`, a file in the calling agent's project (relative, inside it, at most 16 MiB, UTF-8). Your tile reads it with `call.large_input()` (in parts of up to 1 MiB, joined for you). No `files.read` permission is needed: the agent chose a file of its own. ## Commands for the shell and the palette A tool is also a command. `expose` says where it is offered: `agents` (their MCP tools), `cli` (`pitwall extension run`) and `palette` (the command palette); the default is `["agents", "cli"]`. `palette` needs a `title`, at most 60 characters, and an input of plain properties (strings, numbers, booleans, enums): ```json { "name": "send_message", "kind": "act", "expose": ["agents", "cli", "palette"], "title": "Send a message", … } ``` ```sh pitwall extension tools hello # what agents get pitwall extension commands hello # what `run` takes, with arguments pitwall extension run hello send_message -- --text "Release 0.9 is out" pitwall extension run hello current_messages --human echo '{"text":"hi"}' | pitwall extension call hello send_message --input - ``` `run` prints the result's JSON (its text with `--human`); problems go to stderr. Exit status: 0 ok, 1 the tile answered with an error, 2 bad arguments, 3 refused or denied, 4 not available (Pitwall, the extension or the tile isn't there or on), 5 timed out. `--timeout ` may only shorten a tool's time. **In the palette** each palette tool is ": ", run as yours, without asking. One that needs input reads "<Extension>: <title>…" and opens a small form first: a field per property of its input, labelled from the property's name, with its `description` under it and a red mark on required ones. Strings are text fields (`maxLength` kept), numbers and integers are checked as you run, booleans are a checkbox, and an `enum` is a row of choices (a dropdown past four). **Run** (↵) sends it; Esc or **Cancel** closes. A tool whose input has anything else (a nested object, an array) isn't in the palette. ![The palette's form for Hello's "Send a message", dark](https://pitwalls.github.io/pitwall/docs/extensions/images/agent-tools/agent-tools-form-dark.png) ![The same form, light](https://pitwalls.github.io/pitwall/docs/extensions/images/agent-tools/agent-tools-form-light.png) ## A skill for agents Tools say what a tile can do; a skill tells agents when to use them. Put one in your package as `agents/SKILL.md`: ```markdown --- name: hello description: Show short messages to the user in Pitwall's Hello tile. --- When the user asks to see a message next to your terminal, call `hello__show_message` with an `item` id you reuse for later changes. Call `hello__send_message` only when the user asks you to send one. ``` - **Limits.** Text only, at most 16 KiB; `name` is your extension's id (or left out); it may name only your own tools (`<id>__…`). `pitwall extension check` says what is wrong. - **You choose the projects.** On the extension's card in Settings → Extensions, under **Skill for agents**, tick the projects whose agents get it. It is kept in Pitwall, never written into a project's tracked files. - **Agents get it with their rules.** Pitwall gives it to them the way it gives the skills in Settings → Rules & skills: through rulesync, into each agent's own folder (`.claude/skills/hello/` for Claude Code, `.agents/skills/hello/` for Codex, …), kept out of git. It starts with a line saying it is the Hello tile's. A new agent gets it when it starts; one already running shows "rules changed" until **Re-apply & restart**. Settings → Rules & skills lists it for each agent as "from Hello (a tile)". - **Off is off.** Turning the extension off, or its tile's "Agents can use <name>", or unticking a project, takes it away at the next apply. - **Agents without skills** (Gemini CLI, Aider) get its `description` in Pitwall's MCP server instructions instead. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/seed-tiles/ # C4 diagrams, Notes and Agention **Preview.** Three extensions built on the public Tile SDK, with independently maintained sources: [C4 diagrams](https://github.com/pitwalls/pitwall-c4), [Notes](https://github.com/pitwalls/pitwall-notes), and [Agention](https://github.com/pitwalls/pitwall-agention). They require Pitwall 0.9.0 or later. Agention is available from Pitwall’s bundled extensions. To build another extension from source, follow its repository’s README, then install its built folder with Settings → Extensions → Install from folder… or `pitwall extension install <folder>`. The public catalog is not activated yet. ## C4 diagrams: ask an agent to draw it Ask an agent Pitwall started to draw something: "draw the containers of this repo as a C4 diagram and show it on the right". It writes the diagram in Mermaid and calls `c4__show`; the diagram opens right of its terminal, with no setup. Ask for a change ("add a cache") and the same diagram updates in place, wherever you moved the tile. ![A container diagram an agent showed, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-drawn-dark.png) ![A container diagram an agent showed, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-drawn-light.png) - **What it draws.** Mermaid `flowchart` (or `graph`) and `sequenceDiagram`. In a flowchart, a box's label is read as C4: `Name [Kind]<br/>what it does` (`Orders API [Container]`), a `subgraph` is a boundary, `class x external` (or `new`, `changed`) colours it. Parts it doesn't draw (styles, links, icons) are skipped and listed under "Not shown" in the footer. - **Zoom.** The wheel or a pinch zooms, dragging pans; `+`, `-`, `F` (fit) and `0` do the same from the keyboard, the arrows move the selection, Enter opens it and `B` switches Now and Changes. - **Click to zoom in.** A box another shown diagram details (a "Shop [Software System]" box, and a diagram of Shop's containers) has a magnifier; clicking it opens that diagram, and the path back is in the bar. When several diagrams detail it, a menu under the box asks which. - **Changes since the last show.** When an agent updates a diagram, Now / Changes in the bar shows what it added (green), changed (amber) and removed (grey, dashed). ![The changes after an update: a cache added, the API changed, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-changes-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-changes-light.png) - **The list.** In a wide tile, the diagrams shown so far, by agent. Close one with its ×. They are kept across restarts, at most 50 a project; the oldest you haven't opened for a while makes room. ![Two diagrams detail Shop: the menu asks which, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-box-menu-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-box-menu-light.png) **Bad Mermaid changes nothing.** The agent is told each problem with its line and column, and fixes its call. You see a notice; Show the source shows the agent's text with each bad line marked as an error and what is wrong beside it. ![A call with a problem on line 4, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-error-line-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/c4-error-line-light.png) With file access allowed, C4 also discovers Mermaid diagrams in matching project Markdown files, follows edits and opens a diagram's source at its line. ## Notes: send a note to an agent Notes keeps private plain-text notes beside your agents. **Send to an agent** (the arrow in a note's bar) lists your agents and puts the text you selected in the note, the note, or one section of it under a heading, in that agent's Next up, waiting for your Send. Notes asks for "See your agents" and "Put text in an agent's Next up" for this; without them, the rest of Notes works. ![Send to an agent, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/notes-send-dark.png) ![Send to an agent, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/notes-send-light.png) With text selected, Send offers the selection first. ![Send with a selection, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/notes-send-selection-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/notes-send-selection-light.png) A note longer than 4 000 characters is too long to send whole: select a part or pick a section. ⌘/ switches a note between Edit and Preview. ## Agention: answer your agents in one inbox Agention 3.0.0 groups threads by agent and session. Pick a suggested answer, write your own words, decline, or reply to a thread. Sends have a five-second Undo window. Questions also appear in Pitwall's floating attention control; the toolbar shows their count. ![Agention inbox, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/agention-inbox-dark.png) ![Agention inbox, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/agention-inbox-light.png) Open **Set up**, enter your server address, and save an operator API key with `threads:read`, `threads:write` and `sessions:read`. The fields are host-owned: Pitwall keeps the key in its secure store and adds it to granted requests by reference. The extension never reads its value. Setup explains missing, expired or revoked keys and network refusals. ![Agention Setup, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/agention-setup-dark.png) ![Agention Setup, light](https://pitwalls.github.io/pitwall/docs/extensions/images/seed-tiles/agention-setup-light.png) Optionally install and supervise a local Agention 0.8.0 server using Node.js 24 or later and npm. Configure its public HTTPS origin and a reverse proxy or Tailscale Serve for the loopback listener. Each native command needs approval. First sign-in opens its one-time link privately in the browser. Setup can also check, install or remove the pinned Agention plugins for Claude Code and Codex's default profiles, and publish server/project/session environment variables to new agents when allowed. Restart existing agents to load changed plugins or environment. Named Pitwall accounts need their own plugin setup. See [Agention's README](https://github.com/pitwalls/pitwall-agention/blob/87c72935a4f3a65ea416564e51e29a5a41d64d8b/README.md) for setup, permissions and upgrading from 2.0.0 while retaining data and the saved API key. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/permissions/ # Permissions **Preview.** What an extension's tile may do, and how you decide. This page is written for people installing extensions first, and for authors after that. ## What a tile can do without asking A tile runs in a sandbox. It starts with no files, no network and no programs: it can't read your projects, reach the internet, start anything or see your agents' terminals. It can't read other extensions' data, settings or secrets. What every tile has, with no permission, reaches only its own things: - its own views in the layout, drawn by Pitwall; - its own Log; - its own timers, which pause while it is hidden; - its own stored data, at most 10 MiB, and its own database, at most 100 MiB; - its own settings and secrets, which you set in Settings; - toasts, at most 3 a minute; - one button in the top bar, if it declares one, which you can hide; - the extension's own server, if it has one. [Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/) describes each of these for authors. ## The grants | Permission | Gives | Starts | Risk | |---|---|---|---| | `memory` | More memory than the 64 MiB every tile gets, up to the size the extension names (at most 512 MiB) | granted | Low: it can use more of your computer's memory | | `sql` | A larger database than the 100 MiB every tile gets, up to the size the extension names (at most 2048 MiB) | granted | Low: it can use more of your disk | | `net` | Connections to the servers the extension names, listed on the permission screen | on | Medium: what it reads or sends goes to those servers | | `notify` | Notifications, at most 3 a minute | on | Low | | `show` | Opening a file in Pitwall's editor, or a web page in a web tile | off | Low: it shows you something; it gets nothing back | | `agents.read` | Your agents' names, kinds, projects, branches and states, whether one waits on you, and how many items wait in its Next up; badges on agents' rows; naming the agent a question is from | on | Medium: a state can say what an agent waits on. Never what is on their screens | | `agents.queue` | Putting text in an agent's Next up, marked with the extension's name. Nothing it puts there is sent until you press Send, unless you let it send without asking | off | High: text an agent gets becomes what it does, with its own permissions in your repositories | | `projects.read` | Your projects' folders; badges on projects' rows | on | Low | | `files.read` | Reading the files of the project each of its tiles is open in, and following their changes. Never `.git`, never another project | on | Medium: what it reads, a `.env` file too, can reach the servers it may connect to | | `files.write` | Writing, making, renaming and moving to the Trash files of the project each of its tiles is open in. Never `.git` or Pitwall's own files | off | High: you and your agents run what is in your projects; a file it changes changes what runs next | | `agents.env` | Variables on the agents Pitwall starts from now on, in the projects ticked under Projects on its card. The permission screen lists the variable names as the extension wrote them; its card shows their values. A value is plain text, one of its own settings or the agent's name, session and project, never a secret. Names Pitwall or an agent uses for its own setup (`PATH`, `HOME`, `PITWALL_*`, loader and runtime variables like `LD_*`, `DYLD_*` and `NODE_OPTIONS`, proxies, `GIT_*`, an agent's own login and server variables like `ANTHROPIC_*`, `OPENAI_*`, `CLAUDE_*`, `CODEX_*`, `COPILOT_*`, `GITHUB_*`) are refused | off | Medium: an agent and the tools it runs read them; a value that points somewhere else changes where they connect | | `programs` | Request native programs matching the declared command patterns, after exact-command approval; optionally download SHA-256-pinned executables from declared HTTPS URL patterns | off | High: approved native programs run as you outside the component sandbox | | `shortcut` | Keys that open one of its tiles from anywhere in Pitwall ([A shortcut to open a tile](https://pitwalls.github.io/pitwall/docs/extensions/ui/#a-shortcut-to-open-a-tile)). Never Pitwall's own keys; you can change them in its card | off | Low: its keys open its tile instead of doing what they did before | Badges on sidebar rows and questions in the floating control need no permission: the extension declares them (`"badges": true`, `"asks": true`), and the permission screen lists them under "Adds to Pitwall" ("badges and short notes on agents' and projects' rows in the sidebar", "questions in the floating control, answered there or in its tile"). A connection status on its card (`"status": true`) needs none either. `memory` and `sql` are granted with the extension when you turn it on: the permission screen and the extension's card show them with their size ("256 MiB"), not as a switch. `pitwall extension check` shows the sizes an extension asks for. ### net The permission screen lists each server the extension may reach, as its manifest writes it (`api.example.com`, `*.example.org` for its subdomains). Only these, over HTTPS; plain `http` only to your own computer, when listed. Pitwall checks each address before connecting and on every redirect, and sends no cookies or passwords of its own. An approved supervised program can give its component temporary HTTP access to its declared loopback listen address while running, without `net`. The legacy service block keeps its own-server exception until its migration. ### programs This permission allows an extension to request native helpers outside the tile sandbox. Its screen lists 1–16 command patterns and up to 16 optional HTTPS download patterns, exactly as written. It starts off. Patterns bound what it may request; each resolved command still needs **Run**, **Always** or **Deny** on Pitwall's own sheet. The sheet names the executable, arguments, working folder, environment references and temporary loopback HTTP access. Always is tied to that exact request, including timeout or supervised mode, private-output mode and listen address. Changing any of these asks again. Allowed lines are on the extension's page under Programs with Remove; removing a line affects future requests, not a process already started. Permission, settings, patterns and resolved paths are rechecked after approval, so a stale approval cannot authorize a changed command. Approved programs receive a minimal environment plus the variables the extension explicitly requests. Declared secret settings are supplied by reference in that environment, resolved by the host after approval and redacted from returned output and Log. A private-output command returns its bounded text once without keeping it in Log, Activity, status or Debug; authors must consume and discard it rather than store or display it. There are four shared pending/running one-shot and download slots, plus four supervised programs per extension. Runs last at most ten minutes; stdout and stderr are each limited to 1 MiB. Supervised exits retry after 1, 5 and 30 seconds. Stop, revoke, turning the extension off, update, remove and quitting Pitwall stop its managed process groups and their children. A server already listening is used only after exact approval; Pitwall never kills that unrelated process, and Stop or revoke still removes its temporary HTTP reach. Hidden program components may tick at most once a second without rendering hidden views. Downloads check the current permission, exact HTTPS-origin/path patterns on every redirect, a pinned SHA-256, and bounded archives before publishing a new path under the extension's data folder. Existing paths are never replaced; use a new version's path. Downloading does not authorize running the result. [Programs and servers](https://pitwalls.github.io/pitwall/docs/extensions/servers/) has the manifest, SDK APIs and harness examples. ### notify A notification is the system's when you aren't looking at Pitwall, and a toast in Pitwall's window. At most 3 a minute, and the same words only once in 10 minutes. ### files.read and files.write A tile reaches only the project it is open in: its space's project, the project of the agent it was opened next to, or the project whose sidebar menu opened it. It never picks a folder of its own, and a tile open in no project reaches none. The permission screen names the project folders its open tiles are in now ("the project its tile is open in" before any is open). Every change it makes to a project's files, and every refusal, is in its Activity. `.git` is never read or changed, Pitwall's own `.pitwall.json` and `.pitwall/` never changed, and deleted files go to the Trash. More grants come with the services that need them, each with its own risk note on the permission screen: git in your projects and the clipboard, each when a tile needs it ([what comes later](https://pitwalls.github.io/pitwall/docs/extensions/permissions/#what-comes-later)). ## The permission screen An installed extension is off until you turn it on in Settings → Extensions. Before installing, Pitwall lists the tiles it adds and each permission it asks for, with the author's reason and, for `memory`, the size. When you turn it on, the permission screen shows the same permissions, to grant or refuse each, and for an extension that only adds tiles it says that its tiles run sealed off from your computer and get only what you grant there. After that, the extension's card in Settings → Extensions lists each permission and whether it is granted. A permission with a switch can be taken back at any time, and it applies to the running tile at once, with no restart: the tile hears it (`GrantsChanged`), its next call that needs it is refused, and what it started under the grant ends. A request still on its way when `net` is taken back arrives refused (`denied`), and its answer is dropped; its watches in a project end when `files.read` is taken back; its badges on agents or projects go with `agents.read` or `projects.read`. Granting works the same way (a permission an update added, allowed on the card, applies at once), and so does a setting that changes the address `net` may reach. `memory` and `sql` have no switch; they are set when the tile starts, so a new size (after an update) takes effect when it starts again. Turning the extension off stops its tiles at once, and its badges and questions go. Every call a tile makes to your agents is in the extension's Activity, marked "tile". ## Agents opening a tile Agents need no permission from the extension to open its tiles: every tile can be opened by the agents Pitwall starts, with content in it, and an extension can declare tools that show things in its tile ([Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/)). These `show` and `present` tools only change what the sandboxed tile shows: the agent gets nothing of the tile back, what it put there is marked with its name and you can Undo it, and Pitwall refuses to let it replace anything you edited there. So they are on by default and allowed in agents without asking. Tools that give agents more ask you, in Pitwall's approval dialog: - **`read`** returns what the tile has, your edits included. It asks the first time; **Always for <agent>** lets that agent read again without asking. - **`act`** does something outside the tile (the network, a service). It asks each call, with the agent, its project, the tool and its arguments; **Always for <agent>** is offered too, except for a tile that can put text in your agents' Next up or start agents, whose `act` tools ask every time. - Neither is ever in the allow lists Pitwall passes agents at launch. Your "Always" answers are on the extension's card ("Allowed without asking") and in Settings → Agents, each with **Revoke**. - During a `show`, `present` or `read` call the tile runs without its acting permissions (`net`, `show`, `notify`, `files.write`, `agents.queue`, `agents.start`, `agents.focus`, `programs`), so a tool can't act while it says it only reads. You decide which tiles agents may use: - **Per tile:** "Agents can use <name>" on the extension's card in Settings → Extensions, with the names of its tools. Off, its tools are gone from every agent's list at once. - **All tiles:** "Agents can use tiles" in Settings → Agents (`agents.tileTools`). - **Before turning it on:** the permission screen lists a tile's tools under "Adds to Pitwall", and an author can keep a tile from agents with `"agents": false`. Each call is in the extension's Activity on its card: which agent, which tool and item, the input (all of it for `act`), and whether it ran or why not. ## Signed packages and updates A tile extension usually comes as a signed `.pwtile` file ([Install](https://pitwalls.github.io/pitwall/docs/extensions/install/)). Installing it trusts its signing key for that extension, and every update must be signed by the same key. An update grants nothing new by itself: new permissions, more memory, a larger database and new `net` servers each wait on the card until you allow them. Added or changed program/download patterns also require a new `programs` grant; exact-command approvals still apply. When new servers are added, you are asked about `net` again. ## Unsigned preview tiles An author can also share a tile as an unsigned package or as a folder. A folder is installed from Settings → Extensions → Install from folder…, or with `pitwall extension install <folder>` which you install from Settings → Extensions → Install from folder… or with `pitwall extension install <folder>` ([Quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#share-a-preview-tile)). The folder must add tiles and contain no adapter, legacy service, setup actions or legacy agent environment block. A component may declare the new `programs` permission; installing its folder grants neither that permission nor its exact native commands. Such an extension comes from an "unsigned preview folder", and its install review and permission screen carry the warning "Unsigned, preview: only install tiles from people you trust". Nobody has checked who made it or what it contains. It runs in the same sandbox with the same limits as any tile, and it can do only what you grant it. A folder is never updated: installing a newer folder replaces it. An unsigned package shows "Unsigned: nobody vouches for this file" and installs only with Install unsigned. Installing from the address of a folder served over HTTPS is coming in this preview. With `agents.env` granted, its card shows what agents get under the permission, and a Projects list with a tick for each of your projects. Every project is ticked, those you add later too; untick one and agents started there get neither its variables nor its skill for agents. Agents already running keep the variables they started with: they are listed as running agents that use an old setup, and restarted as "After its updates, restart agents that use the old setup" says. ![The agents.env permission with its names and the values agents get, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/agents-env-permission-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/agents-env-permission-light.png) ![The Projects ticks, one project unticked, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/agents-env-projects-dark.png) ![The same, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/agents-env-projects-light.png) A tile loaded with `pitwall extension dev` is a development extension: it is listed as one in Settings → Extensions and runs from the author's folder, where it is. ## For authors Every permission names your reason: one line the user reads before granting it. Ask only for what the tile uses. In `extension.json`, a permission's value is its reason, or an object with the reason and the permission's settings: - `memory`: its size in MiB, more than 64 and at most 512: `"memory": { "reason": "To hold large diagrams", "mib": 128 }`. - `sql`: its size in MiB, more than 100 and at most 2048: `"sql": { "reason": "To keep a year of builds", "mib": 500 }`. - `net`: the hosts, at most 32: `"net": { "reason": "To read your builds", "hosts": ["ci.example.com"] }`. A host the user sets is named by its `url` setting, `"{setting:server}"` ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/)). - `programs`: command and optional download patterns: `"programs": { "reason": "Run its local helper", "commands": [{ "command": "helper", "args": ["--version"] }], "downloads": ["https://downloads.example.com/helper/*"] }`. Programs are names on PATH or paths under `{data}`; argument patterns use literals, `*` for one argument or final `**` for the rest. Unrestricted `**` is refused for shells/interpreters. See [Programs and servers](https://pitwalls.github.io/pitwall/docs/extensions/servers/). - `agents.env`: the variable names, 1 to 16, upper-case letters, digits and `_`: `"agents.env": { "reason": "So its plugin finds the server", "names": ["MY_SERVER_URL", "MY_SESSION"] }`. The tile sets their values with `agents::set_env` ([Platform services](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#variables-on-agents)). An update that adds a name asks the user again. - `notify`, `show`, `files.read`, `files.write` and `shortcut`: the reason alone (`shortcut` with a tile that has a `"shortcut"`). In the tile, `cx.is_granted("memory")` and `cx.granted()` say what the user granted. When it changes, the tile hears `Event::GrantsChanged`, and by default it renders again. A call that needs a permission the tile wasn't granted fails with `HostError::Denied`; the tile should carry on without it and say what is missing. A setting referenced by a network host or program permission pattern can only be changed through the host-owned setting field. The component's `settings::set` returns `Denied` for that key or a secret. A valid field edit updates a granted dynamic network host and preserves an explicit network refusal; it never regrants the other declared hosts. Test both cases with the harness: `Harness::build(…).grant("memory")` starts the tile with the grant. ## What comes later | Phase | Grants | |---|---| | On demand | `git.read`, `git.write`, `git.remote`, `clipboard.read`, each when a tile needs it | A "Run tiles from others" switch in Settings → Extensions will stop every tile not made by Pitwall at once. ## External browser links `show.browser` lets a component use `show::browser(url)` to open an HTTPS link (or HTTP to this computer) in the external browser. It starts off and may bring the browser forward. It is separate from `show`, which opens files and web tiles inside Pitwall. Existing `show` grants do not grant it. Pitwall does not save the browser URL as a web location or include it in Log, Activity or diagnostics. The browser controls its own history. An action can therefore open a one-time sign-in link without keeping that credential in Pitwall. Do not put the link in the component's own logs or saved state. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/packaging/ # Packaging **Preview.** How to turn a tile project into a `.pwtile` package, sign it, and pass it on. [Install](https://pitwalls.github.io/pitwall/docs/extensions/install/) covers what the person who gets it sees. A package is one file holding the tile and everything it needs. A signature file sits beside it. Pitwall checks the signature before it unpacks anything. The person who installs it then knows the file wasn't changed on the way, and that later versions come from the same author. ## Pack Build the tile first, then pack it: ```bash pitwall extension dev --once pitwall extension pack ``` `pack` writes `<id>-<version>.pwtile` into the project folder, or to the path given with `-o`. It checks the component the way `pitwall extension check` does, then copies in these files and nothing else: | File | | |---|---| | `extension.json` | Required. Its `version` is required too. | | `tile.wasm` | Required. The component, at most 20 MiB. | | `README.md` | Required. | | `LICENSE`, `LICENSE.md`, `LICENSE.txt`, `NOTICE` | Optional. | | `CHANGELOG.md` | Optional. | | the input schemas its tiles name | Required when named. | | `agents/SKILL.md` | Optional. An agent skill, text only, at most 16 KiB. | | `assets/` | Optional. svg, png and webp only. Fonts are refused. | | `screenshots/` | Optional. png or webp, at most 8, at most 2 MiB each. A `-dark` and `-light` pair counts once. | | `media/` | Optional. The images your README shows: png, webp, jpeg or gif, at most 2 MiB each. | | its icon file | When `"icon"` names one (below). | Sources, `target/` and hidden files stay out. A symbolic link stops the pack. File names may use only ASCII letters, digits, `.`, `_`, `-` and `/`. The whole package may be at most 50 MiB. The same files always give the same package, byte for byte. Two people who build the same component and pack it get identical files. A package holds tiles only. An extension that also runs a program (an adapter or a service) is still installed from Git, npm or a folder. ## Adding images There is no upload service: an extension's images are files in its folder, packed with it, and linked by relative path. Browse and the detail page show them before and after install. - **Its icon.** `"icon": "assets/icon.png"` in `extension.json`: a square png or webp, 64 to 1024 px, at most 256 KiB. No SVG. Pitwall shows it on its card, in Browse, in the Tiles menu, on its toolbar button and in the command palette. An icon name (`"grid"`) still works; an icon that doesn't check is replaced by the standard one. - **Screenshots.** Files in `screenshots/`, png or webp, at most 8. `main-dark.png` and `main-light.png` are one screenshot: Pitwall shows the one of your theme. To give them an order and captions, list them: ```json "screenshots": [ { "path": "screenshots/main.png", "caption": "The board, beside its agent" } ] ``` (`main.png` names the pair.) Captions are at most 120 characters. Click one to see it larger. - **README images.** Put them in `media/` (or `assets/`, `screenshots/`) and link them relatively: `![How it works](https://github.com/pitwalls/pitwall/blob/main/docs/reference/extensions/media/flow.png)` or `<img src="media/flow.png">`. Each is checked by its content, not its name. Pitwall never fetches an image from the network: `![Build](https://…)` shows as a link to it. A path that leaves the folder (`../`) or isn't packed isn't shown. GitHub's `#gh-dark-mode-only` and `#gh-light-mode-only` work too. - **Listing fields.** `"tagline"` (at most 80 characters, shown under the name), `"categories"` (1 to 3 of the [index's](https://pitwalls.github.io/pitwall/docs/extensions/publishing/#what-the-index-needs)), `"homepage"` and `"repository"` (https), and `"license"` (its SPDX name). The detail page shows them. `pitwall extension check` checks all of this and warns about what a listing lacks (an icon, screenshots, a tagline, categories, a licence, a network image). ## Make a signing key Make keys with Pitwall itself, outside every source repository: ```bash pitwall catalog setup --directory "$HOME/.config/pitwall-signing" ``` The directory must not already exist. Pitwall asks for a password and confirmation, then writes encrypted private keys and matching public files for the publisher, current catalog, next catalog, and review roles. Use the publisher key for your extension packages; the other roles are for operating a catalog. No separate signing tool is needed. - **Keep private `.key` files out of every repository** and back them up securely. Losing the publisher key means installed users must explicitly trust a new one. - **Publish `publisher.pub`** in your project's README or website so people can compare it with the key Pitwall shows. Its public key starts with `pwp1:`. - For unattended commands, supply the password through `PITWALL_SIGN_PASSWORD` in your secret store. Never put a password in a command-line argument. ## Sign ```bash pitwall extension sign my-tile-0.1.0.pwtile \ --key "$HOME/.config/pitwall-signing/publisher.key" ``` `sign` writes `my-tile-0.1.0.pwtile.pwsig` beside the package. It uses the explicit `--key` path, or `PITWALL_SIGN_KEY`, and asks for the password unless `PITWALL_SIGN_PASSWORD` supplies it. It prints the public key and fingerprint, never the private key. Pitwall's versioned signature envelope carries the public key and a standard Ed25519 signature over a package-specific context and the package's exact bytes. The catalog, blocked list and review statements use separate contexts, so their signatures cannot be reused as package signatures. The public key carried by a package enables first-install verification; it does not by itself make the publisher trusted. Catalog and review signatures must match keys already trusted by Pitwall. ## Pass it on Send both files, the `.pwtile` and its `.pwsig`, and keep them side by side. The person installs it from Settings → Extensions → Install from file…, or with `pitwall extension install <file>`. To list it in the extensions index for Browse, release both files on GitHub and run `pitwall extension publish` ([Publishing](https://pitwalls.github.io/pitwall/docs/extensions/publishing/)). The index also needs a `LICENSE` file and a `"description"` in `extension.json`: `pack` tells you when either is missing. ## Updates Pack and sign each new version with **the same key**, and raise `version` in `extension.json`. Pitwall refuses: - a version signed by another key, unless the person explicitly trusts the new key; - an older version (they use Go back for that instead); - the version already installed. When a version asks for new permissions, more memory, a larger database or new `net` hosts, Pitwall lists the changes before the update. It grants none of them until the person allows each one. Say why in each permission's reason, and in `CHANGELOG.md`. If you must change keys, tell people first, through the same place where you published the old key. Pitwall will show them the new key and ask whether to trust it. ## Folders still work While you develop, use `pitwall extension dev`. To share a quick preview without a key, a folder works as before ([Quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#share-a-preview-tile)), and so does an unsigned package. Both are marked as previews. Neither can replace a signed install. ## What Pitwall checks When it opens a package, Pitwall checks it in this order and stops at the first problem: 1. The file is at most 50 MiB. 2. The signature matches the file's bytes, and the key is the one trusted for this extension, if one is. 3. The zip is plain: no zip64, encryption or comment, stored or deflate only, and headers that agree with each other. 4. Every name passes the rules above. There are no duplicates (ignoring case), no `..`, no absolute paths, and no links or special files. 5. Every size is within its limit before anything is inflated, and each file's checksum matches. 6. The manifest is valid, its files are the ones allowed, and `tile.wasm` is a component that needs only what this Pitwall provides. Only then is the package unpacked, into a new hidden folder, and shown to the person. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/install/ # Install, update and remove **Preview.** How to install a tile extension from a `.pwtile` file, keep it up to date, go back to the version you had, and remove it. [Packaging](https://pitwalls.github.io/pitwall/docs/extensions/packaging/) is the author's side. ## Install from a file You need the package, `<id>-<version>.pwtile`, and normally its signature, `<id>-<version>.pwtile.pwsig`, in the same folder. - **In Pitwall:** Settings → Extensions → Install from file…, then pick the `.pwtile`. To install from the extensions index instead, use Browse in the Extensions tile ([Extensions in Settings](https://pitwalls.github.io/pitwall/docs/extensions/settings/)): it goes through the same trust screen. - **From a terminal:** `pitwall extension install ./my-tile-0.1.0.pwtile`. It prints who signed it and what it asks for, then you approve it in Pitwall. Pitwall checks the signature before it unpacks anything. A package that was changed after it was signed is refused, and Pitwall says why. Installing turns nothing on. Turn the extension on in Settings → Extensions, or with `pitwall extension on <id>`, and answer its permission screen ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/)). ![A signed package, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-trust-dark.png) ![A signed package, light](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-trust-light.png) ## Who signed it The install screen shows one of these: - **Signed.** Pitwall shows the key id (16 characters) and the full public key. Compare it with the key the author publishes, for example in their README. Installing trusts this key for this extension: every later version must be signed by it. - **Signed by the same key as the installed version.** This is an update from the same author. - **Signed by another key.** Someone else may have signed it. Install it only if the author told you that their key changed. To go ahead, turn on "Trust the new key for its updates from now on". From a terminal, add `--new-key`. - **Not signed.** Nobody vouches for the file. Install it only if you trust whoever gave it to you. The button reads "Install unsigned". From a terminal, add `--unsigned`. It is marked as a preview wherever it shows, as a folder install is. ![Signed by another key, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-new-key-dark.png) ![Signed by another key, light](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-new-key-light.png) ![Not signed, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-unsigned-dark.png) ![Not signed, light](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-unsigned-light.png) ## Updates To update, install the newer file the same way. The screen reads "Update Hello 0.1.0 → 0.2.0" and lists what changes: - **New** permissions, and **More**: new servers for `net`, more memory or a larger database. None of these is granted by updating. Each waits on the extension's card until you allow or refuse it, and new servers mean you are asked about `net` again. - Permissions it **no longer** asks for. - What installing changes on this computer. ![An update asking for two new permissions, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-update-more-dark.png) ![An update asking for two new permissions, light](https://pitwalls.github.io/pitwall/docs/extensions/images/packages/packages-update-more-light.png) Pitwall refuses an older version (use Go back instead), and refuses the version already installed. A folder can't replace a signed package. An extension installed from a file has no automatic update check yet. Its card says to update it with Install from file… and a newer package. ## Go back The version before the last update is kept. Go back to `<version>` on the extension's card puts it back, together with the key it was signed with. Your settings and the extension's data stay as they are. ## Remove Remove on the extension's card asks first. If the extension stored anything, the confirmation also offers "Also delete its data (size)". That is off by default, so its data stays for a later install. Removing deletes the installed files and the kept previous version, and forgets its settings, secrets and permission answers. `pitwall extension remove <id>` removes it the same way, after you approve it in Pitwall, and keeps the data. ## From a folder An author can also share a tile as a folder: Settings → Extensions → Install from folder…, or `pitwall extension install ./folder`. A folder is never signed and always marked as a preview ([Quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#share-a-preview-tile)). ## Troubleshooting ### "Pitwall closed unexpectedly last time while … was running" Tiles run inside Pitwall. If Pitwall quits unexpectedly (crashes, or macOS stops it) while an extension's tiles are starting or have just started, the next launch doesn't start them again: they would likely take Pitwall down again. A note says which extension it was, and its tiles show **paused**: - **Resume** starts its tiles again. - **Keep paused** leaves them off until Pitwall starts again. - **Turn … off** turns the extension off. Its card in Settings → Extensions says the same, and has **Go back to …** when it was just updated and the version before is kept: an update can't undo itself once Pitwall was stopped mid-way, so going back is offered here. If Pitwall closes again the next time those tiles start, the extension is turned off, with a note on its card. Turn it on again when you want to try it again (after an update, for example). A launch where its tiles run normally for a while clears the count. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/settings/ # Extensions in Settings > Tile SDK preview. Browse opens to everyone after the outside security review; until then it reads an index only when one is set up (below). Everything about your extensions is in one place: the **Extensions tile**. Open it with **Extensions** in the command palette (⌘K), the last entry of a project's Tiles menu in the sidebar, or **Open Extensions** on Settings → Extensions. It is a tile like the others: move it, maximise it (⌘⏎), or give it a window of its own, and it is back where you left it after a restart. When the tile is wide, the list is on the left and the page you pick is on the right. When it is narrow, you get one column: the list, and a page in its place with a way back. ![The Extensions tile, wide, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-installed-dark.png) ![The Extensions tile, wide, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-installed-light.png) Settings → Extensions in the Settings dialog shows only the short list: each installed extension with its switch, a search, and Open Extensions. Picking one opens its page in the Extensions tile. The Settings dialog fits itself to your window, and you can drag its bottom-right corner to resize it. Pitwall remembers the size. ![Settings → Extensions in the dialog, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-dialog-dark.png) ![Settings → Extensions in the dialog, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-dialog-light.png) ## Installed - **Search.** Type words in any order: they match the name, the line under it, the author and the names of its tiles, as the palette matches. ⌘F (Ctrl+F) puts the cursor in the search. - **Filters.** All, On or Off; then Updates, Needs attention (a setup to finish, a new permission to answer, agents on its previous setup, something failed), Tiles, Agent tools and Services. - **Order.** By name, or most recently updated first. - **Cards or rows.** Cards have each extension's setup in place. Rows are compact. The wide tile always shows rows. - **Keys.** ↑ and ↓ move the selection, and Enter opens its page. When nothing is installed, or nothing matches, the list says so and offers to clear the search and filters. ## An extension's page ![An extension's page, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-detail-dark.png) ![An extension's page, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-detail-light.png) - **Head.** Its icon, name, author, version, who signed it (and Verified, when the index says so of that very file), and its switch. - **Its Setup view**, when it has one: its own setup screen, drawn by the extension, under the head and above everything Pitwall draws ([The Setup view](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#the-setup-view)). While it is off, a placeholder stands in its place; if it stops, the page says "Setup stopped" with Restart. ![An extension's page with its Setup view, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/setup-page-dark.png) ![An extension's page with its Setup view, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/setup-page-light.png) - **Its line and categories**, then its **screenshots** (your theme's, with their captions; click one to see it larger, with ← and →), then its **README** from its own folder. The README is drawn inert: no HTML runs. Its images from its own folder are shown; one from the network is a link instead, never fetched, and one outside its folder isn't shown. See [Adding images](https://pitwalls.github.io/pitwall/docs/extensions/packaging/#adding-images). - **Permissions**, each with the reason the extension gives and, for those that act on your agents or files, what can go wrong. When it is on, each permission has its switch. - **What it adds**: its tiles, inbox, services and agent tools (with their switches), and the projects its skills are installed in. - **Versions and changelog**: the one installed, the one Go back returns to, the versions the index lists with how each stands, and its CHANGELOG.md. - **Licence, homepage and source**, and **Update**, **Go back**, **Remove** and its activity. A copy installed from the index says so. If the index later blocks that version, Pitwall turns it off and its card gives the reason. A version withdrawn by its author, or an extension no longer listed, says so too. It keeps working, but gets no more updates from the index. ## Browse ![Browse, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-browse-dark.png) ![Browse, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-browse-light.png) Browse reads the [extensions index](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/). Pitwall checks its signature against the keys built into Pitwall and searches it on your computer. It sends nothing: there are no install counts or ratings. - **Search** by name, line, author and category, a **category** (Git, CI, Databases, APIs, Notes, Monitoring, Docs, Fun, Other), **Verified only** (on at first) and **Works with this Pitwall**. - **Cards** have the extension's own icon, name, author, Verified, its tagline (or line), its first screenshot, what it may do in words ("Connects to api.github.com · Reads your agents"), and **Install**, **Installed** or **Update**. - **States.** Browse says when it is loading or offline, when the index couldn't be read or checked, when it shows the copy Pitwall kept from before, and when the index is more than 14 days old and may be out of date. ### A listing's page and Install ![A listing's page, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-browse-detail-dark.png) ![A listing's page, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-browse-detail-light.png) A listing's page has its screenshots, its README with its images (copied into the index, so nothing comes from anywhere else; a listing without one links to its README on GitHub), its permissions with their reasons and risk notes, its versions (Verified, not yet reviewed, withdrawn or blocked), its licence and repository, and **Report a problem**. **Install** downloads the version the index offers: the newest Verified one, or the newest when none is Verified. Pitwall refuses a blocked or withdrawn version. It checks that the file is the one listed (its SHA-256) and that it is signed by one of its author's keys in the index. Then you get the same trust screen as [Install from a file](https://pitwalls.github.io/pitwall/docs/extensions/install/), and nothing is installed until you press Install there. Pitwall records that the copy came from the index, so its updates come from there too. ![The trust screen for a download, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-trust-dark.png) ![The trust screen for a download, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-trust-light.png) **Report a problem** lets you pick what is wrong (malware, misleading, broken, other). It then opens a new issue on the index's GitHub repository in your browser, filled in with the extension's id, version and file SHA-256. Pitwall itself sends nothing. For security problems, the index's SECURITY.md gives a private address. ### Trying an index (authors) Until Browse opens to everyone, set `PITWALL_EXTENSION_INDEX` to an index's https base (the folder that holds `index.json`) or to a built `dist/v1/` folder. Set `PITWALL_EXTENSION_INDEX_KEY` to the public key it is signed with. Without both, Browse says it isn't open yet and fetches nothing. ## Narrow ![The Extensions tile, narrow, dark](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-narrow-dark.png) ![The Extensions tile, narrow, light](https://pitwalls.github.io/pitwall/docs/extensions/images/settings/extensions-page-narrow-light.png) --- Source: https://pitwalls.github.io/pitwall/docs/extensions/marketplace/ # Marketplace **Preview.** The extensions index is the list of tiles that Settings → Extensions → Browse shows. This page covers what the index is, how Pitwall checks it, what Verified means, and what happens when a version is withdrawn, blocked or no longer listed. [Publishing](https://pitwalls.github.io/pitwall/docs/extensions/publishing/) is the author's side. The index isn't open yet. Until the [outside security review](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/#before-it-opens) is done, it lists only tiles by authors on the SDK preview. ## What the index is The index is a public GitHub repository, `pitwalls/pitwall-extensions`. It holds one small file per extension: its author, its source repository, its categories, its licence, and each version's download address, SHA-256 and the commit it was built from. Changes come in as pull requests. A check runs on each one, then a maintainer, or for a plain update a bot, merges it. The packages stay on their authors' GitHub releases. The index doesn't copy or rebuild them. It pins each one by its SHA-256 and by the author's signature. On every change, and once a day, the index's CI builds `index.json` (the listings) and `blocked.json` (takedowns), and signs both with the index key. ## What Pitwall checks Pitwall reads the two files at start and once a day. It sends a conditional request, so an unchanged index costs almost nothing. Before it uses or keeps either file, it checks: - **The signature**, against the index keys built into Pitwall. A key named inside the file doesn't count. A file that doesn't check is refused, and Pitwall keeps the copy it had. - **That it isn't older** than the copy Pitwall already has. An old index that was validly signed, served again, is refused too. - **Strict limits.** Sizes and counts are bounded. Names and descriptions must be plain text, with no control characters and no characters that reverse text direction. Addresses must be https GitHub release assets of the extension's own repository. Hashes must be hex, and categories must come from the fixed list. Anything else rejects the whole file. When Pitwall is offline, or the index server fails, Pitwall uses its cached copy and says why. A fetch that fails changes nothing. When you install from the index, the package must match the listed SHA-256 and be signed by one of the author's keys. Then it goes through the same checks and install screen as a file ([Install](https://pitwalls.github.io/pitwall/docs/extensions/install/)). ## Verified **Verified** means a Pitwall maintainer read that version's source and found that it does what it says: - the component, rebuilt from the tagged source, came out byte for byte the same; - the source matches the permissions it asks for: the hosts it contacts, the files it touches, the text it queues to agents; - each permission's reason is accurate; - it has no obfuscated code and no bundled programs. Verified is per version, not per author. The maintainer signs a short statement that names the extension, the version and the package's SHA-256. Pitwall checks that signature against review keys that are built into Pitwall, not against anything in the index. A stolen index key alone can't make a version Verified. A new version isn't Verified until someone reviews it. Until then it shows as **Not yet reviewed**, and Install offers the last Verified version by default. Browse's "Verified only" filter is on by default. Listing isn't endorsement: a tile that isn't Verified was checked by machines and glanced at by a maintainer, not reviewed. ## Withdrawn, blocked, no longer listed | Mark | Who sets it | What Pitwall does | |---|---|---| | **Withdrawn** | The author, or a maintainer | The version isn't offered for new installs or updates. An installed copy keeps working. Its card says "1.0.0 was withdrawn by its author." | | **Blocked** | Maintainers, for malware or abuse | Installs and updates of the version are refused, with the reason. An installed copy is turned off at the next daily check, with the reason, and Remove is offered. It can't be turned back on. | | **No longer listed** | Maintainers (unmaintained, a licence problem) | It leaves Browse. An installed copy keeps working, but gets no more updates. | A block can name a whole extension, some versions, or particular packages by their SHA-256. ## Report a problem "Report a problem" on an extension's page opens a new issue on the index repository in your browser. The issue is filled in with the extension's id, version and package SHA-256, plus what is wrong: it does something harmful, it isn't what it says it is, it doesn't work, or something else. Pitwall sends nothing itself. You review the issue and submit it on GitHub. To report something privately, such as a security problem, use the address in the index's `SECURITY.md`. ## Before it opens Browse opens to everyone only after two things are done: a threat model of the marketplace, and a security review by someone outside the project. The threat model covers a compromised index, key rotation, look-alike names and malicious updates. It is written; the review hasn't started yet. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/publishing/ # Publishing **Preview.** How to list your tile in the extensions index, so that people find it in Settings → Extensions → Browse. [Marketplace](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/) covers what the index is and what Verified means. The index isn't open yet: until the outside security review is done, it takes tiles only from authors on the SDK preview. You need a signed package ([Packaging](https://pitwalls.github.io/pitwall/docs/extensions/packaging/)) and a public GitHub repository with the tile's source. ## What the index needs On top of what every package needs: - **A `LICENSE` file** in the package, and its SPDX name (`MIT`, `Apache-2.0`…) in the entry. - **A `"description"`** in `extension.json`: the one line Browse shows. - **A GitHub release** of the tile's repository with the `.pwtile` and its `.pwsig` as assets. - **The commit** the component was built from, so that it can be rebuilt for Verified. - **1 to 3 categories:** `git`, `ci`, `databases`, `apis`, `notes`, `monitoring`, `docs`, `fun`, `other`. `pitwall extension publish` takes the categories and licence from `extension.json` (`"categories"`, `"license"`) when you don't give them. `pitwall extension pack` reminds you when the license or the description is missing. Its icon, screenshots, README and the README's own images ([Adding images](https://pitwalls.github.io/pitwall/docs/extensions/packaging/#adding-images)) go into the index too: its build copies them out of the package to `media/<id>/<sha256>.<ext>`, so Browse shows them before anyone installs it, from the index's own address and nowhere else. ## Release ```bash pitwall extension dev --once pitwall extension pack pitwall extension sign my-tile-1.0.0.pwtile ``` Tag the commit you built from, then make a GitHub release with both files, `my-tile-1.0.0.pwtile` and `my-tile-1.0.0.pwtile.pwsig`. Once a version is in the index, its file must never change. To fix something, release a new version. ## Publish `pitwall extension publish` writes the index entry for the package and prints the link that opens the pull request. It never commits, pushes or uploads anything. **The first time**, run it beside the package: ```bash pitwall extension publish my-tile-1.0.0.pwtile \ --repository https://github.com/you/pitwall-my-tile \ --author you --category ci --license MIT ``` It writes `index-entry/extensions/my-tile.toml` and `index-entry/authors/you.toml`, the latter holding your public key. It then prints GitHub's new-file link, prefilled with the entry. Saving the file on GitHub makes a fork and opens the pull request. Add your author file to the same pull request. **With a clone of the index** (your fork), give `--index-dir`. The entry is written there, or the new version is added to it, and the index's own checks run before you push: ```bash pitwall extension publish my-tile-1.1.0.pwtile \ --repository https://github.com/you/pitwall-my-tile --author you \ --index-dir ~/src/pitwall-extensions ``` It prints the git commands to commit and push a branch, and a link that opens the pull request with its title filled in. **An update without a clone:** add `--update`. It prints the `[[versions]]` block to add to your entry, and the link to edit the entry on GitHub. By default the download address is `<repository>/releases/download/v<version>/<file>`, and the commit is the folder's `git rev-parse HEAD`. Use `--url` or `--commit` when yours differ. `--github` sets your GitHub login (by default, the repository's owner), and `--index` names another index repository. ## What the check does The index's `check` workflow runs on your pull request, with no secrets and a read-only token: 1. Every file in the index is checked: ids and handles match their file names, versions are well formed, downloads are release assets of your repository, keys are valid. 2. The change is compared with the index as it was. An extension stays with its author. A listed version is never changed or removed: set `yanked = true` instead. A new version must be newer than the listed ones. Ids that look like an existing one (`ci-statu5` next to `ci-status`) are flagged for a maintainer. 3. Each new version is downloaded and checked: at most 50 MiB, its SHA-256 the one in the entry, its signature by one of your keys in `authors/<you>.toml`, the package rules, a licence and a description, and a manifest that matches the entry. 4. Each tile is loaded headless in Pitwall's tile runtime, with no permissions granted. It must start and draw a first frame. 5. Each new version is compared with the one before it: its permissions, hosts, memory and signing key. The check posts its report as the job's summary. ## Who merges - **A new extension:** a maintainer, after a light look. They check that the name isn't misleading or someone else's, and that a licence is there. - **An update by you that changes no permission, host, memory or key:** the bot, once every check passes. - **Anything else** (new permissions or hosts, a new key, another repository, a pull request by someone other than you): a maintainer. ## Withdraw a version Set `yanked = true` on its `[[versions]]` entry in a pull request. It is no longer offered for new installs or updates, and installed copies keep working. Only a maintainer can undo it. ## Change your key Add the new public key to `authors/<you>.toml` in a pull request; a maintainer checks that it is really you. Sign the next version with it. People who installed your tile are asked to trust the new key when they update ([Install](https://pitwalls.github.io/pitwall/docs/extensions/install/#who-signed-it)). If your key was stolen, tell the maintainers privately (see the index's `SECURITY.md`) so the versions signed with it can be blocked. ## Verified A maintainer may review a version for Verified ([Marketplace](https://pitwalls.github.io/pitwall/docs/extensions/marketplace/#verified)). To make that easy, keep the source of each version tagged, make builds reproducible (the same `cargo build --release --target wasm32-wasip2` gives the same `tile.wasm`), and give accurate reasons for every permission. A review covers one version. An update that changes no permission, host or key is reviewed quickly. One that does goes back to a full review. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/platform-services/ # Platform services **Preview.** What Pitwall gives every tile, so authors don't build it themselves. Without a permission, each reaching only the tile's own things: timers (`tasks`), a key-value store (`storage`), settings and secrets (`settings`), the Log (`log`), requests about the tile's own views (`ui`), a SQLite database (`sql`), a toolbar button (`toolbar`) and the extension's own server (`service`). With a permission: the network, to the hosts the manifest names (`net`), notifications (`notify`), opening a file or a web page (`show`), the files of the project a view is open in (`files`), and the agents' questions group: your agents and their Next up (`agents`), badges on sidebar rows (`badges`) and questions in the floating control (`asks`) ([below](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#agents-badges-and-questions)). Pitwall adds a service only when a tile can't reasonably do without one. Each is checked by Pitwall, not by the SDK: a call without its permission fails with `Denied` and a line in the Log. ## Errors The calls that can fail return `Result<_, HostError>`: | Error | Means | |---|---| | `Denied` | The tile isn't granted the permission this needs | | `Busy` | Too many calls or things at once (over 200 calls a second, or 32 timers); try again later | | `TooLarge` | Over a size limit or a quota | | `Invalid(why)` | An argument isn't valid; the text says which and why | | `Failed(why)` | Pitwall couldn't do it, such as a disk error | | `Decode(why)` | Stored data couldn't be read as the type asked for | Each has a plain message (`Display`), fit for the Log. ## Tasks: timers Timers are on the tile's context, since they call back into the tile: | Call | Does | |---|---| | `cx.after(delay, f)` | Calls `f` once, after `delay` (a `Duration`) | | `cx.every(period, f)` | Calls `f` every `period` until cancelled | | `cx.cancel(timer)` | Stops a timer; one already finished is ignored | `f` gets the tile and the context, like a listener. Both return `Option<Timer>`: `None` (and a Log line) when it can't be made. A delay or period is at least 100 ms, and a tile has at most 32 timers at once. Call `cx.notify()` in the closure when what the tile shows changed. Timers pause while the tile is hidden and go on when it is shown again. A repeating timer that was due while hidden fires once, not once per missed period. There is no background work while hidden: a tile polls only while you can see it. ### Clocks `std::time::Instant` and `SystemTime` work (WASI's clocks), so a tile can time a debounce or stamp what it stores; `std::thread::sleep` blocks the whole tile, so wait with a timer instead. In tests time is virtual: it stands still until the test moves it, with `advance(duration)` (`wait` is the same), which fires each timer due on the way at its own time, and moves `Instant` and `SystemTime` with it. `wait_for_text(text, timeout)` moves it in small steps until the tile shows something. `Harness::wall_clock()` runs a test on the computer's clock instead. ## Storage The tile's own key-value store, in `storage`. Use it for what the user must not lose: it is written to disk after each call into the tile that changed it, and kept across restarts and updates, outside the extension's folder. | Call | Does | |---|---| | `storage::get(key)` | The bytes of `key`, or `None` | | `storage::get_many(&keys)` | The bytes of each key, in order (`None` for a missing one), at most 1024 keys: one call, for reading many at once | | `storage::entries(prefix)`, `storage::entries_json(prefix)` | Every key that starts with `prefix` with its value (bytes, or JSON with `serde`), in byte order: a `list` and `get_many` calls, so a tile reads all its records in a few calls | | `storage::set(key, value)` | Sets `key` to bytes | | `storage::delete(key)` | Removes `key` (a missing key is no error) | | `storage::list(prefix)` | The keys that start with `prefix` (all for `""`), in byte order | | `storage::usage()` | The bytes the store takes now | | `storage::get_json(key)`, `storage::set_json(key, &value)` | The same, as JSON with `serde` | | `storage::get_string(key)` | The value as text | The store holds at most 10 MiB in all; a write past that fails with `TooLarge`. Keys are 1 to 256 bytes of UTF-8 without control characters. The `blank` template reads its count when it starts: ```rust fn new(_cx: &mut Cx<Self>) -> Self { // What the user must not lose goes in storage: on disk at once, // kept across restarts and updates. let clicks = storage::get_json("clicks").ok().flatten().unwrap_or(0); App { clicks } } ``` The `list` template keeps its whole list as JSON and notes a failed write in the Log: ```rust fn save(&self) { if let Err(e) = storage::set_json("list", self) { log::warn(format!("the list wasn't saved: {e}")); } } ``` For state that only has to survive a reload (what is being typed, a scroll position), use `save_state` instead ([Quick start](https://pitwalls.github.io/pitwall/docs/extensions/quick-start/#develop-with-pitwall-extension-dev)). In tests, `stored(key)` and `stored_json(key)` read what the tile stored, and `Harness::stored(key, value)` (or `stored_json`) starts the tile with values already stored. `restart()` starts it again with the same storage and no saved state; `reload()` keeps the saved state too. ## Settings An extension declares its settings schema in the manifest's `settings` list. Its Setup view draws ordinary controls and places Pitwall's host-owned fields for values that grant access. Pitwall keeps the values and reports changes. Extensions without a Setup view retain the legacy generated form during this preview. Each setting needs a `key` and `type`, with an optional `default`. Legacy `label`, `placeholder`, `hint` and `required` keys are still accepted for the generated form; host-owned fields use the schema key. The types: | Type | Read with | Drawn as | |---|---|---| | `text` | `settings::text(key)` | A text field | | `url` | `settings::text(key)` | A text field for a URL | | `number` | `settings::number(key)` | A number field (with `min` and `max`) | | `bool` | `settings::flag(key)` | A switch | | `choice` | `settings::text(key)`, which gives the option's value | A list of `options`, each with a `value` and a `label` | | `secret` | `settings::secret(key)` | A password field, kept in the system's secure store | `settings::get(key)` returns the value as a `Value` (`Text`, `Number` or `Flag`): what the user set, else the manifest's default, else `None`. A secret is never returned by `get`. Use `settings::secret_set(key)` to learn whether a secret is set, and a [secure field](https://pitwalls.github.io/pitwall/docs/extensions/components-forms/#secure-field) in the Setup view to let the user enter or remove it. The component receives only `Event::SecretChanged { key, set }`, without the value. For HTTP, reference the secret instead of reading it: ```rust let request = net::Request::get("https://api.example.com/items") .bearer("apiKey"); // Or: .secret_header("X-API-Key", "apiKey") ``` At the WIT boundary, an entire header value `bearer(apiKey)` means `Bearer <value>`; `secret(apiKey)` means the raw value. These two forms are reserved for references. Pitwall checks that the key is a declared secret and resolves it only for an explicitly granted `net` host, immediately before each send, including redirects. A missing secret or invalid header value is refused. A denied destination sends nothing; the legacy own-server bypass does not authorize secret headers. Known secret values are redacted from Log lines and request error text. A server that echoes a secret in its response can still give that value to the component; use hosts you trust with the credential. Ordinary tile visuals can imitate a secure field, so enter credentials only through Pitwall's field behavior on the extension's page. The legacy `settings::secret(key)` remains until the adapter migration removes it (plan 8c4), but returns `Denied` for a key entered through a secure field. Before writing the keychain, Pitwall durably marks that key as reference-only in host-owned extension data. A failed marker write refuses the secret save. The marker survives restarts, updates, Go back, and removing or replacing just the value. Existing legacy keys never entered through a secure field keep their old API behavior, so old tiles continue working; new extensions should use references. `settings::open()` opens the extension's page in the Extensions tile, at its Setup view when it has one (below), for a "Set up" button when something the tile needs isn't set. ### The Setup view An extension can draw its own setup screen: its **Setup view**. Name it in the manifest: ```json "contributes": { "setup": { "view": "setup" } } ``` The extension's page in the [Extensions tile](https://pitwalls.github.io/pitwall/docs/extensions/settings/#an-extension-s-page) then shows, top to bottom: its header (name, version, switch, status), its Setup view, and Pitwall's own parts (permissions, agent tools, Activity, Log). Pitwall draws those parts itself, so a Setup view can't hide or restyle them. An extension without a Setup view shows its header and Pitwall's parts. The Setup view is an ordinary view of the extension's component (the one its tiles name, so it needs at least one tile). Its view id is the id the manifest gives, and `ViewInfo::tile` is that id too: draw it in `render` like any view (`SETUP_VIEW` is `"setup"`, the usual id). It can use everything a tile can: events, timers, `net`, storage. It is as tall as its content, up to 560 px, then it scrolls inside, and it follows the theme and focus as a tile does. While its first frame is on its way, or while the extension is off, the page shows a placeholder in its place; if the component stops, the page says "Setup stopped" with Restart. It is open while the page shows, and let go when the page closes. ```rust fn render(&mut self, view: &str, cx: &mut Cx<Self>) -> impl IntoElement { if view == SETUP_VIEW { return v_flex().gap(px(12.0)).p(px(14.0)) .child(text("Hello greets you in its tiles.")) .child(key_values().entry("Greeting", self.greeting.clone())) .into_any(); } self.main(cx).into_any() } ``` While an extension has a Setup view, Pitwall doesn't draw a form for its settings on its page. In tests, `Harness::setup()` starts it with its Setup view open, and `Session::open_setup()` opens it beside a tile's view. ### Saving settings from a Setup view The manifest may declare settings with just a key and type. Save ordinary settings with `settings::set("greeting", settings::Value::Text("Hi".into()))`. The type must match the schema; numbers and choices obey their bounds and options, URLs must parse as complete http(s) addresses, and unknown keys are refused. Empty text restores a default. Every open view receives `Event::SettingsChanged(Some(key))`; `None` means a bulk refresh. Secrets and settings used in `net` hosts or program patterns cannot be changed by the component. Place the host's field instead: ```rust,ignore v_flex().child(setting_field("server").placeholder("https://example.com")) ``` Pitwall owns that field's value and saves it on Enter or blur. A valid URL updates the dynamic host of an already-granted network permission. An explicit network refusal stays refused. The field cannot edit secrets; unknown and secret keys show an error. Program execution is still planned. Test a field with `tile.enter_setting("server-field", "https://example.com")`; the harness validates and saves it without delivering an input event to the component. When the user changes a setting, the tile hears `Event::SettingsChanged(Some(key))` (`None` for a bulk refresh) and, by default, renders again. The `form` template signs each note with its "Signed as" setting, read while rendering: ```rust let author = settings::text("author").unwrap_or_else(|| "me".into()); ``` In tests, `Harness::setting(key, value)` and `secret(key, value)` start the tile with settings, and `set_setting(key, value)` changes one while it runs: ```rust #[test] fn a_note_needs_a_title_and_is_saved_signed() { let mut tile = Harness::build(env!("CARGO_MANIFEST_DIR")).setting("author", "Ana").open("main"); tile.click_text("Save"); assert!(tile.find_text("Give it a title.").is_some(), "{}", tile.text_snapshot()); tile.type_into("title", "Standup").type_into("body", "Ship the beta"); tile.click_text("Save"); assert!(tile.find_text("Give it a title.").is_none()); assert!(tile.find_text("by Ana").is_some()); assert_eq!(tile.toasts(), vec![("Saved".to_string(), Tone::Good)]); let notes: serde_json::Value = tile.stored_json("notes").expect("stored"); assert_eq!(notes[0]["title"], "Standup"); // The setting changes in Settings: the form follows. tile.set_setting("author", Some("Bo")); assert!(tile.find_text("Signed as Bo").is_some()); } ``` ## Log Each tile has a Log: open it from the extension's card in Settings → Extensions, or print it with `pitwall extension log <id>`. It also notes when the tile started, stopped or was reloaded. Pitwall keeps the newest 500 lines. | Call | For | |---|---| | `log::debug(…)` | Detail for whoever is debugging the tile | | `log::info(…)` | Something worth knowing happened | | `log::warn(…)` | Something went wrong, and the tile carried on | | `log::error(…)` | Something failed | `println!` and `eprintln!` reach the same Log, as info and warnings. A line is at most 4 KiB; longer lines are cut. Pitwall adds its own notes, such as a slow call or a dropped toast. In tests, `log_text()` gives the whole Log and `logged(level, text)` checks for a line. ## UI Requests about the tile's own views, in `ui`. They act only inside the tile's own area of the window. | Call | Does | |---|---| | `ui::toast(text, tone)` | Shows a short message, labelled with the tile's name. `Tone::Info`, `Good`, `Warn` or `Bad`. At most 200 characters and 3 toasts a minute; more are dropped and noted in the Log | | `ui::open_view(tile)` | Opens one of the extension's tiles (an id from `contributes.tiles`), or focuses its view when one is open | | `ui::scroll_to(view, key_path)` | Scrolls the element at that key path into sight after the view's next render. The key path is the one `cx.focus` takes: keys from the root down, without the root's (`"list/rows/n4"`) | | `ui::request_render(view)` | Renders the view again after this call; in a listener, `cx.notify()` is simpler | | `ui::put_image(name, &bytes)` | Hands Pitwall an image (PNG, JPEG, GIF, WebP or SVG, at most 8 MiB) for `image_data(name)` ([Images](https://pitwalls.github.io/pitwall/docs/extensions/ui/#images)). Kept until put again or dropped; at most 64 MiB for all of a tile's. `Invalid` when the bytes aren't one of those formats, `TooLarge` over a limit | | `ui::drop_image(name)` | Forgets an image put under `name` | The `form` template saves a note and says so in a toast: ```rust self.notes.push(Note { title, body: self.body.trim().to_string(), by }); if let Err(e) = storage::set_json("notes", &self.notes) { self.error = Some(format!("It wasn't saved: {e}")); return; } (self.title, self.body, self.error) = (String::new(), String::new(), None); ui::toast("Saved", Tone::Good); ``` In tests, `toasts()` lists the toasts and `ui_requests()` the other requests. ## Network `net` fetches from the hosts the manifest names, with the `net` permission ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/#net)). Declare them with the reason: ```json "permissions": { "net": { "reason": "To read your builds from the CI server", "hosts": ["ci.example.com", "*.example.org"] } } ``` A host is a name (`api.example.com`), a name with a port (`api.example.com:8443`), or `*.example.org` for its subdomains (not `example.org` itself). At most 32. Only `https` reaches them; `http` only to this computer (`localhost`, `127.0.0.1`, `[::1]`), and only when the list names it with its port. When the server is the user's own, name it by a `url` setting instead: `"{setting:KEY}"`, where `KEY` is one of the extension's settings of type `url`. ```json "settings": [{ "key": "server", "type": "url", "label": "Server address", "required": true }], "permissions": { "net": { "reason": "To read your builds from your CI server", "hosts": ["{setting:server}"] } } ``` The tile may then reach the host and port of that setting's value: `https://ci.example.com:8443/` allows `ci.example.com:8443`; `http://127.0.0.1:8080` allows this computer on that port. Nothing is allowed while the setting is empty or isn't such an address. The permission screen shows it as "the server in Server address" and, once set, its host. When the user changes the setting, the grant follows the new host and the tile hears `Event::GrantsChanged` and `Event::SettingsChanged(Some(key))`. In the harness, `Harness::build(…).setting("server", "https://ci.example.com")` sets it, and `.serve(|request, reply| …)` answers the tile's requests from a fake server, at once or later (a long poll). A request is made on the context, since its answer calls back into the tile: ```rust let req = net::Request::get("https://ci.example.com/api/builds?limit=20").header("Accept", "application/json"); cx.fetch(req, |tile, answer, cx| { match answer.and_then(|r| r.json::<Vec<Build>>()) { Ok(builds) => tile.builds = builds, Err(e) => tile.error = Some(e.to_string()), } cx.notify(); })?; ``` `cx.fetch` returns a `RequestId` at once, or an error when the request is refused before anything is sent (`Denied` names the host). The answer comes later: `Ok(Response)` for any status (`ok()` is 200 to 299), or `Err(net::Error)`: `TimedOut`, `Failed` (no connection), `TooLarge`, `Denied` (a redirect to a host not listed). `cx.cancel_fetch(id)` drops one. | Limit | | |---|---| | At once | 8 requests | | Request body | 8 MiB | | Answer | 32 MiB | | Time | 30 s, at most 120 s with `.timeout(…)` | | Redirects | 5, each checked against the hosts again | Pitwall checks the address before looking up the name, and again on every redirect. It sends no cookies and no credentials of its own, and uses no proxy. There are no raw sockets. In tests, `Harness::respond(url, status, body)` answers a request (the whole address, query included), `respond_error(url, error)` fails it, and nothing leaves the test; others get a 404. `requests()` lists what the tile sent. The tile still needs the grant (`grant("net")`) and the host in its manifest, as in Pitwall. ## Database `sql` is a SQLite database run by Pitwall, one per extension, kept outside its folder across restarts and updates. No permission: 100 MiB. A larger one, at most 2048 MiB, is asked for with the `sql` permission and granted with the extension, shown with its size: `"sql": { "reason": "To keep a year of builds", "mib": 500 }`. Declare the schema as migrations, in order, and run them when the tile starts. Pitwall keeps the schema's version and runs each step not yet run in a transaction of its own: ```rust const MIGRATIONS: &[&str] = &[ "CREATE TABLE builds (id INTEGER PRIMARY KEY, name TEXT NOT NULL, state TEXT NOT NULL)", "ALTER TABLE builds ADD COLUMN url TEXT", ]; fn new(cx: &mut Cx<Self>) -> Self { if let Err(e) = sql::migrate(MIGRATIONS) { log::error(format!("the database couldn't be set up: {e}")); } // … } ``` | Call | Does | |---|---| | `sql::execute(statement, params)` | Runs one statement; the rows it changed | | `sql::query(statement, params)` | Runs one query; its `Rows` (`row.get::<i64>("n")`, or by index) | | `sql::transaction(\|\| …)` | Runs the closure in a transaction: committed when it returns `Ok`, rolled back on `Err` | | `sql::migrate(steps)` | Runs the steps not run yet; the schema's version | | `sql::usage()`, `sql::quota()` | The bytes it takes and may take | Parameters are `()`, a tuple (`("a note", 3)`) or a `Vec<sql::Value>`; `?` marks each place. A query returns at most 10 000 rows and 8 MiB; page with `LIMIT`. A write past the quota fails with `TooLarge`. A transaction lasts one call into the tile: one left open when the call returns is rolled back, with a line in the Log. The database can't reach anything else: no `ATTACH`, no extensions, no `PRAGMA` that changes how the file is kept (`table_info`, `foreign_keys` and other read-only ones work). A statement still running at the call's deadline is stopped (`Busy`). In tests the database is in the test's temporary folder; `database()` gives its file. ## Notifications `notify::send(title, body)` shows a notification, with the `notify` permission. It is the system's notification when you aren't looking at Pitwall (as for an agent that needs you) and a toast in Pitwall's window, with Open. At most 3 a minute; the same words within 10 minutes are shown once. A title is at most 80 characters, the text 200. In tests, `notifications()` lists what it sent. ## Opening a file or a page Files and in-app pages need `show`; the external browser needs its own `show.browser` permission. Both start off until the user allows them. | Call | Does | |---|---| | `show::file(path, line)` | Opens the file (a whole path) in Pitwall's editor, at the line when given | | `show::view(path, line)` | Shows the file in Pitwall's file viewer, scrolled to the line, as an agent's `show_files` does: with its git repository's tree (else its folder's) and git status, in the extension's own viewer window, which opens behind the front window without taking the keyboard. Later calls add tabs to it | | `show::web(url)` | Opens the page in a new web tile, in the extension's own browser store. `https` only, `http` only to this computer | | `show::browser(url)` | Opens the external browser, which may come forward. Requires the separate `show.browser` permission, off until allowed. Pitwall saves no web location and records no URL in Log, Activity or diagnostics; the browser controls its own history | None gives the tile anything back. In tests, `ui_requests()` lists them (`OpenFile`, `OpenWeb`, `ViewFile`). ## Files in the project A view is open in a project: its space's, the one of the agent it was opened next to, or the one whose sidebar menu opened it. `files` reaches that project's folder, and the extension's own files folder. A tile never names a folder of its own. | Call | Does | |---|---| | `files::project(view)` | The view's project, `Project { name, folder }`, or `None` (no project, or neither `files.read` nor `projects.read`) | | `files::read(&root, path)`, `read_text` | A file's bytes, or its text | | `files::stat(&root, path)` | An `Entry`: `path`, `kind` (`File`, `Folder`), `size`, `modified` (ms) | | `files::list(&root, folder, deep)` | The entries in a folder (`""` for the root), every level down with `deep`, sorted by path | | `files::watch(&root, folder)`, `unwatch(id)` | Follow a folder and everything under it: `Event::FilesChanged { watch, paths }`, changes close together in one event (a quarter second quiet, at most a second late) | | `files::write(&root, path, bytes)`, `write_text` | Write a file whole (made with its folders when missing, replaced at once, never half written) | | `files::create(&root, path, bytes)` | Write a new file; `Exists` when one is there | | `files::make_folder(&root, path)`, `rename(&root, from, to)` | A folder with its parents; move a file or folder (`Exists` when the target is there) | | `files::delete(&root, path)` | To the Trash, in a project; for good, in its own folder | `Root::project(view)` is the view's project; `Root::Data` the extension's own files folder, kept across updates, at most 100 MiB, needing no permission. Reading a project (`project`, `read`, `stat`, `list`, `watch`) needs `files.read`; changing it needs `files.write`, which starts off. During an agent's `show`, `present` or `read` call, writes are refused. Paths are relative, with `/` between parts. Pitwall refuses (`NotAllowed`, with why) an absolute path, `..`, a link that leads out of the root, anything in `.git` (never listed, read or changed), and a change to Pitwall's own `.pitwall.json` or `.pitwall/`. `list` and `watch` leave out what the project's `.gitignore` files and `.git/info/exclude` ignore; `read` and `stat` still reach those files by name. A file read or written is at most 8 MiB (`TooLarge`), a list at most 10 000 entries, and a tile has at most 8 watches. ```rust let root = files::Root::project(view); for e in files::list(&root, "docs", true)?.iter().filter(|e| e.path.ends_with(".md")) { let text = files::read_text(&root, &e.path)?; // … } let watch = files::watch(&root, "docs")?; ``` When the view moves to another project, or out of every project, the tile hears `Event::ProjectChanged(view)`: its watches there have ended; read the new project. Every change to a project, and every refusal, is a line in the extension's Activity. In tests, `Harness::project("shop")` starts the tile's view in a project folder of the test's, `project_file(path, text)` puts files in it, and `.grant("files.read")` grants it. Then `write_project_file`, `remove_project_file` and `rename_project_file` change it (the watches hear it at once), `project_file(path)` reads it back, `trashed()` lists what went to the Trash, `watches()` counts the watches, `move_to_project(view, Some("api"))` moves a view, and `activity()` lists its Activity lines. ## Toolbar button An extension may put one button in Pitwall's top bar, in a group of its own after the counts. Declare it in `contributes.toolbar`; the user can hide it, and an update never shows it again ([Tiles and UI](https://pitwalls.github.io/pitwall/docs/extensions/ui/#toolbar-button)). | Call | Does | |---|---| | `toolbar::set_badge(badge, tone)` | Its badge: `Badge::None`, `Dot` or `Count(n)`; `Tone::Normal` or `Attention`. At most 4 changes a second | | `toolbar::set_project_badge(project, badge, tone)` | A project's badge, for a button with `"scope": "project"` (needs `projects.read`) | | `toolbar::set_tooltip(text)` | Its tooltip, at most 80 characters | | `toolbar::set_shown(shown)` | Hides or shows the button for a while (at most one change in 5 s); the user's Hide wins | | `toolbar::close_popover()` | Closes its popover | The badge shows only while the tile runs. With `"badge": true`, Pitwall keeps the tile running with no view open, so the badge stays current. A press runs its action; the tile hears `Event::ToolbarClicked { project }`. Its popover is a view of the tile, `toolbar::POPOVER_VIEW`: render it in `render` when `view` is that id. In tests, `toolbar()` gives the badge, tooltip and whether the popover is open; `click_toolbar(project)` presses the button and `click_in_popover(key)` clicks inside the popover. ## Programs and local servers With the off-by-default `programs` permission, a component asks Pitwall to run a command once or keep a named process group running. Each exact resolved command asks Run, Always or Deny. `programs::Command` builds argv directly, with optional environment references and a folder under `{data}`. Completion is `Event::ProgramFinished`; supervised changes are `Event::ProgramChanged`. A supervised loopback `listen` address gives the component HTTP reach only while that approved program is running. Stop, revoke, off, update, removal and quit end that reach. `programs::download` fetches a SHA-256-pinned HTTPS file to a new destination under `{data}`, optionally unpacking with the host's bounded readers. Running it still asks. See [Programs and servers](https://pitwalls.github.io/pitwall/docs/extensions/servers/) for manifest patterns, private one-shot output, limits, lifecycle and harness examples. ## Its own server (legacy) An extension with a `service` (a program Pitwall keeps running, such as the server its agents talk to) reaches that server from its tile without `net` ([Servers in extensions](https://pitwalls.github.io/pitwall/docs/extensions/servers/)): | Call | Does | |---|---| | `service::info()` | Its state (`Up`, `Starting`, `Off`, `NeedsInstall`, `Stopped`, `Failed`), its address, its version, and why when it isn't up | | `service::url(path)` | The address with `path`, for `cx.fetch`; `None` when it doesn't listen | | `service::restart()` | Starts it again, as Restart on the card does | | `service::open_card()` | Opens the extension's card, where the user installs and starts it | The tile hears `Event::ServiceChanged(info)` when its state changes. In tests, `Harness::own_server("127.0.0.1:8790")` says it is up there, and `set_service(info)` changes its state. ## Agents, badges and questions The agents' questions group: what an inbox-style tile needs to show questions from a service or from agents, have them answered in the floating control, and send an answer to an agent. The same rules as extensions' adapters have: the same permissions, limits and Activity. ### Agents With the `agents.read` permission, `agents::list()` gives every agent Pitwall shows, in the sidebar's order: its `id`, `name`, `kind` and `kind_name` ("Claude Code"), `project` (its folder), `branch`, `state` (`Working`, `Blocked`, `Idle`, `Done`, `Stopped`, `Unknown`), `waiting_on_you` (it is blocked on an approval or a question) and `queued` (items in its Next up). When that changes, the tile hears `Event::AgentsChanged` and reads them again; changes close together arrive as one. With `agents.queue`, `agents::queue_add(agent_id, text)` puts text in an agent's Next up, marked "From <extension name>" on its "N queued" chip and in the popover it opens. It waits for the user's Send: Auto-send sends it only when the user lets the extension send without asking, in its card. At most 4 000 characters (`TooLarge`); at most 3 of the extension's items wait in one agent's Next up, and one is queued per agent every 10 seconds (`Busy`, with the reason in the Log). ```rust let waiting: Vec<Agent> = agents::list()?.into_iter().filter(|a| a.waiting_on_you).collect(); agents::queue_add(&waiting[0].id, "Rebase on main and run the tests")?; ``` #### Nudging an agent when something happens Use `agents::queue_add` to push an event notification to a specific agent. For example, when the extension receives a reply from its service, queue “A reply arrived for item 123; read it through the extension's tool.” The agent does not need to poll the extension to discover the event. Keep the message short, identify the item, and let the agent fetch the current details through the extension's tools. Pitwall owns delivery through the agent's session. Extensions need no terminal scripts or tmux integration. A successful call means the message was accepted into Next up; it is not a delivery receipt or confirmation that the agent acted on it. Automatic delivery requires both the extension's **send without asking** opt-in and the agent's **Auto-send** setting. It waits until the running agent is Idle or Done and has settled; it does not interrupt Working agents or restart Stopped agents. The user can also send or remove the queued item manually. Queue once for each relevant event, coalesce bursts, and respect the limits above. Do not repeatedly queue the same event while waiting for a reply. The extension still needs its own supported event source and runtime lifecycle; `queue_add` does not create a webhook receiver or keep an otherwise suspended extension running. There is no SDK call for reading agents' terminals. Native Programs carry the user's OS authority, a separate trust decision described in [Programs and servers](https://pitwalls.github.io/pitwall/docs/extensions/servers/). ### Variables on agents With the `agents.env` permission, `agents::set_env(&[(name, value), …])` sets variables on the agents Pitwall starts from now on, in the projects the extension is on for (every project but those unticked on its card). The whole set each time, at most 16; `&[]` sets none. Each name must be one the permission lists ([Permissions](https://pitwalls.github.io/pitwall/docs/extensions/permissions/#for-authors)). A value is: - plain text, - one of its plain settings, `{setting:KEY}` (its value as the user set it, else its default), never a secret, - the agent's own identity, filled in for each agent: `{agent_name}`, `{agent_id}` (its session, kept across restarts) and `{project}` (its project's folder name). A name it doesn't list, a secret, another placeholder or a brace is `Invalid`, with the reason in its Log, and the set stays as it was. Pitwall keeps the set across restarts and shows it on the extension's card. Agents already running keep what they started with: a new set or a changed setting makes them running agents that use an old setup, restarted as its card's "After its updates" setting says. Agents Pitwall didn't start never get them. ```rust agents::set_env(&[("MY_SERVER_URL", "{setting:server}"), ("MY_SESSION", "{agent_id}")])?; ``` ### Badges With `"badges": true` in `contributes`, `badges::set(&[…])` puts a count or a few words on sidebar rows, beside Pitwall's own waiting badges: on an agent's row by its id (needs `agents.read`) or on a project's row by its folder (needs `projects.read`). The whole set each time; `&[]` clears them. ```rust badges::set(&[Badge::count(Row::Agent(agent.id.clone()), 2).tone(Tone::Bad).tooltip("2 failing runs").open("main")])?; ``` A count is at most 9999, a note (`Badge::note`) at most 16 characters, a tooltip (shown after the extension's name) at most 120. `open` names one of the extension's tiles, opened by a click. At most 500 badges, and at most four sets a second are shown (the newest waits for its turn). A badge on a row the tile may not name is dropped and noted once in its Log. They go when the extension is turned off or its last tile closes. ### Questions With `"asks": true` in `contributes`, `asks::set(&[…])` shows the tile's open questions in the floating control, after agents' own prompts, as an inbox's are: a card with who asks, the question, the suggestions, a field for the user's own words, Send, Decline and "Open <tile>". A blocking question comes first, marked "Waiting on you". The whole set each time; at most 50. ```rust asks::set(&[Ask::new("deploy-42", "Deploy api to staging?") .title("Release 0.9") .from_agent(agent.id.clone()) // shown by its name; needs agents.read .suggest_with("Deploy", "Ship 0.9 to staging now") .suggest("Not now") .blocking()])?; ``` An answer arrives as `Event::AskAnswered(Answer { id, picks, text, declined })`, `picks` by place from 0. Reply with `asks::reply(id, None)` when it was taken, then send a set without the question; or with `asks::reply(id, Some("why"))` to refuse it: the card says "Not sent: why" and the user can answer again. Until the reply, the card says "Sending…". A title is at most 200 characters, a question 2 000, a suggestion's label 80 and its description 200, and an ask has at most 8 suggestions; longer text is cut. Pitwall keeps the questions while the tile is hidden or let go to save memory, and an answer to a tile that was let go starts it again first. ### Status With `"status": true` in `contributes`, `status::set(state, message)` reports the extension's connection to its service, shown where an adapter's is: the pill on its card in Settings → Extensions ("Connecting", "Connected", "Signed out", "Error", with the message under it), the Connected step of its checklist, and the update's check that it connects again as it did before. `state` is `State::Connecting`, `Ready`, `SignedOut` (a credential is missing, wrong or expired) or `Error`; the message is at most 500 characters, usually empty when ready. ```rust match api.check() { Ok(()) => status::set(status::State::Ready, ""), Err(e) if e.is_auth() => status::set(status::State::SignedOut, "The server refused the API key: paste a new one in Settings."), Err(e) => status::set(status::State::Error, &format!("Can't reach the server: {e}")), } ``` Until its first report, and each time its component starts again, the card says "Connecting"; a component that stops says "Stopped", and Restart on the card starts it again. Report from a component that runs while the extension is on: with a toolbar button with `"badge": true`, Pitwall keeps it running with no view open. Without the contribution a call is ignored, with a line in the Log. ### Send with take-back `TakeBack<T>` holds what the user sent for a few seconds (5 by default, `TakeBack::with_seconds(n)` for 1 to 30) with a countdown and Undo, before the tile's own send runs: an answer, a message, anything the user may want back. ```rust struct Desk { reply: String, sending: TakeBack<String> } fn sending(d: &mut Desk) -> &mut TakeBack<String> { &mut d.sending } // On Send: let text = std::mem::take(&mut self.reply); self.sending.hold(text, "Your reply", cx, sending, |d, text, cx| d.post(text, cx)); // In render: "Your reply: sending in 4 s", with Undo, which puts the text back. .child(self.sending.view(cx, sending, |d, text, _| d.reply = text)) ``` `held()` lists what waits, `undo(id)` and `send_now(id)` act on one by its id. Its countdown runs on the tile's timers: it stands still while the tile is hidden, and a test lets it pass with `advance`. ### In tests The harness has a fake Pitwall side: `Harness::agent(agent("a1", "web"))` (or `waiting_agent`) adds an agent, `set_agents(…)` changes them and sends `AgentsChanged`, `queued()` lists what the tile queued, `badges()` and `asks()` give its newest sets, `answer(id, &[0])`, `answer_text(id, "…")` and `decline(id)` answer, `reply(id)` says what the tile replied, `agent_env()` gives the variables it sets on agents now, and `status()` gives the status it reports now (`None` before its first). ```rust let mut t = Harness::build(env!("CARGO_MANIFEST_DIR")).grant("agents.read").agent(waiting_agent("a2", "api")).open("main"); assert_eq!(t.asks()[0].from.as_deref(), Some("a2")); t.answer("deploy", &[0]); assert_eq!(t.reply("deploy"), Some(None)); ``` ## Not provided - **Direct OS file or process access from the component.** Use `files`, `storage`, `sql` or the approved [Programs capability](https://pitwalls.github.io/pitwall/docs/extensions/servers/). - **Raw sockets**, and the network beyond the hosts the manifest names. - **A terminal-reading host API.** Terminal contents can include secrets and prompts. - **Other extensions' data, settings or secrets.** - **Unconditional background lifetime.** Toolbar badges can keep a component running; a Programs grant also keeps it available, with hidden timers limited to once a second. Other hidden views follow the normal suspension lifecycle. These limits describe the component sandbox and host APIs. Approved native Programs run as the OS user; the host API restrictions do not confine a helper's own file, socket or process access. ## What comes later | Phase | Services | |---|---| | On demand | Git in your projects, file pickers, the clipboard, starting agents, and more, each when a tile needs it | --- Source: https://pitwalls.github.io/pitwall/docs/extensions/servers/ # Programs and servers **Preview.** An extension can ask Pitwall to run a native helper, keep a local server running, or download a pinned executable. Its component stays in the tile sandbox; native programs run as you, outside that sandbox. The `programs` permission bounds the commands it may request, and you approve each exact command before it runs. Use a [Setup view](https://pitwalls.github.io/pitwall/docs/extensions/platform-services/#the-setup-view) for Install, Start, Stop and connection state. Pitwall owns the approval sheet and the Programs section on the extension's page. ## Declare the allowed commands ```json "settings": [ { "key": "listen", "type": "text", "default": "127.0.0.1:8790" }, { "key": "apiKey", "type": "secret" } ], "permissions": { "programs": { "reason": "Check the local helper and run its server", "commands": [ { "command": "helper", "args": ["--version"] }, { "command": "helper", "args": ["serve", "--data", "{data}", "--listen", "{setting:listen}"] } ], "downloads": ["https://downloads.example.com/helper/*"] } } ``` The permission starts off. Its screen lists the patterns exactly as written, and `pitwall extension check .` validates them. - Declare 1–16 command patterns. A program is a name resolved on the user's login PATH, or a path under `{data}`, such as `"{data}/bin/helper-1.2.3"`. It is never a shell command or an absolute path elsewhere. - Arguments are literals, `*` for exactly one argument, or a final `**` for the remaining arguments. Shells and interpreters cannot use an unrestricted `**` pattern. A wildcard permits a request; it never replaces the exact-command approval. - `{data}` is the extension's data folder, kept across updates and Go back. `{setting:KEY}` fills a declared non-secret setting. A setting used by a command is changed through a host-owned setting field; changing it can require a new approval. Secrets cannot appear in arguments or setting substitutions. - Download patterns are optional, at most 16. Each names an exact HTTPS origin; `*` matches only its path or query, never a different host. ## Run once ```rust use std::time::Duration; use pitwall_extension::programs::{self, Command}; let task = programs::run( &Command::new("helper").arg("--version"), Duration::from_secs(30), )?; ``` The task id is returned while approval may still be pending. A matching `Event::ProgramFinished(done)` later carries `done.task`, `exit`, `stdout` and `stderr`. A rejected request can complete without an exit code. Show the refusal or failure in the Setup view and let the user try again. A run lasts at most ten minutes. At most four one-shot runs and downloads may wait or run together; a fifth returns `HostError::Busy`. Stdout and stderr are bounded to 1 MiB each, with supplied secrets redacted. Ordinary output also goes to the extension's Log. ## Keep a server running ```rust let listen = settings::text("listen") .unwrap_or_else(|| "127.0.0.1:8790".into()); let command = Command::new("helper") .args(["serve", "--data", "{data}", "--listen", "{setting:listen}"]) .env_secret("HELPER_API_KEY", "apiKey"); programs::start("server", &command, Some(&listen))?; ``` `start` supervises a named process group, with at most four supervised programs per extension, separate from the four one-shot/download slots. `programs::status("server")` reads its state, and `Event::ProgramChanged(change)` reports changes. States include Asking, Starting, Running, Exited, Failed, Stopped and Denied. Use `programs::stop("server")` to stop its group, including children. A supervised program that exits is retried after 1, 5 and 30 seconds, then left failed after the fourth stop. Running for ten minutes resets that sequence. Its page shows Stop, Restart and Log. The optional `listen` must be a loopback address with a port. Once the approved program is running, the component can reach exactly that address over HTTP without a separate `net` grant. Check readiness yourself with `cx.fetch`; Running alone does not prove your server has answered. This automatic loopback reach ends when the program stops or its permission is revoked. If something already listens there, the exact start command still needs approval first. After approval, the state says Running elsewhere with no PID: Pitwall neither starts nor kills that unrelated process. Stop or revoke removes the component's temporary HTTP reach without killing it. Hiding or closing a tile does not stop the program. While `programs` is granted, its component can continue background work without drawing hidden views; hidden timer ticks are coalesced to at most once a second. Programs stop when the permission is revoked, the extension is turned off, updated or removed, or Pitwall quits. Updates stop the programs before backing up `{data}` and replacing the extension. ## Exact approval and environment The sheet offers **Run**, **Always** and **Deny**, showing the resolved command, folder, environment references and any loopback HTTP access. A supervised request says that Pitwall will keep it running. Always applies to that exact request: the resolved path, arguments, working folder, environment references, one-shot timeout or supervised mode, output privacy and listen address. A changed request asks again. Allowed lines appear under Programs on the extension's page with Remove; removing one makes future requests ask again and does not cancel a run already started. Pitwall rechecks the current grant, settings, patterns and resolved path when an approval is answered and before starting. If a valid exact line changed while the sheet was open it asks again; a disallowed one does not run. Revoking permission or turning the extension off also cancels pending approvals. Programs receive a minimal host environment, including the login PATH and platform essentials such as home, user, locale and temporary-folder variables, plus variables explicitly supplied by `Command::env` or `Command::env_secret`. Other inherited credentials, proxies and runtime injection variables are not copied. Explicit environment values are shown on the approval sheet; secret values are represented only by their keys and filled by the host after approval. The component never receives PATH or those secret values through this API. `Command::cwd("relative/path")` selects an existing folder inside `{data}`; the default is `{data}`. ## Private one-time output For a command that returns a one-time sign-in link or another transient credential, add `.private_output()` to its `Command` and declare that command's pattern too. The result still has the same output limits and known-secret redaction, but its text is delivered once in `Event::ProgramFinished` and is not put in Log, Activity, status snapshots or the completion type's Debug output. The host drops its capture after delivery. Consume it promptly and discard it: do not copy it into a tile, storage, logs or an agent reply. This option does not make an untrusted native program safe. ## Download a pinned release ```rust use pitwall_extension::programs::Unpack; // RELEASE_SHA256 is a 64-digit hash pinned in your component's source. let task = programs::download( "https://downloads.example.com/helper/1.2.3/helper.gz", RELEASE_SHA256, "bin/helper-1.2.3", Unpack::Gzip, )?; ``` `Event::DownloadFinished(done)` carries the task id and `outcome`: the new relative path or an error. Downloads use HTTPS without inherited credentials, cookies or proxies. Every redirect must match a declared download pattern too. The SHA-256 covers the downloaded bytes, before unpacking; a mismatch installs nothing. Use `Unpack::None`, `Zip`, `TarGz` or `Gzip`. Compressed and unpacked data are each limited to 50 MiB, with at most 5,000 archive entries. Pitwall's readers refuse paths out, links and special files. Plain and gzip file downloads are marked executable; archive files retain their executable bits. The destination must be a new relative path under `{data}`, with no symlink parents. A download never replaces an existing path: use a new version's destination. Permission revocation cancels the download and prevents publication. Downloading never runs the result. To execute it, declare a corresponding command pattern such as `"{data}/bin/helper-1.2.3"` and request `run` or `start`; its exact command still asks for approval. ## Test without native processes The harness uses fake program and download tables with the real matching, approval and archive rules. No native helper is spawned. ```rust use pitwall_extension_test::{Approval, Harness, ProgramOutput}; let mut tile = Harness::load(".") .grant("programs") .program("helper", ProgramOutput { exit: 0, stdout: "1.2.3".into(), stderr: String::new(), }) .open("main"); tile.approve_programs(Approval::Deny); // Exercise your Setup view's Run button and assert nothing ran. assert!(tile.programs_run().is_empty()); ``` Test Run, Deny, Always, a changed command and removal of Always with `approve_programs`, `program_approvals`, `programs_run` and `revoke_program_always`. Use `crash_program(name)` and virtual `advance(Duration)` for the 1/5/30-second restart sequence, `program_status(name)` for state, and `program_elsewhere(address)` for an already-listening server. `download_bytes(url, bytes)` supplies a fake release: test a correct hash, a wrong hash, a hostile archive and an existing destination. Also test off/revoke, hidden work and private output not appearing in snapshots or logs. ## Legacy service blocks The adapter-era manifest `service` block and SDK `service::*` API remain until migration item 8c3 removes them. Existing extensions keep their install action, version probe, confirmed service command, `ready.listen` loopback reach and `Event::ServiceChanged` behavior during that transition. New extensions should use `programs` from their Setup view instead; the legacy service block is not the API described above. --- Source: https://pitwalls.github.io/pitwall/docs/extensions/wit/ # WIT reference 0.1 **Preview.** Every interface, type and function of the tile world `pitwall:tile@0.1.0`: the contract between a tile and Pitwall, written in WIT (the WebAssembly Interface Type language). It is generated from the WIT files' doc comments when the site is built, so it can't disagree with them. ## Reading it - **You don't write WIT.** The `pitwall-extension` crate turns it into Rust: elements, the `Tile` trait, typed events and the `storage`, `settings`, `log`, `ui`, `agents`, `badges` and `asks` modules, and `tools` (over `agent-tools`). Read this page to see exactly what crosses between a tile and Pitwall, such as each limit and each error. - **The world** says what a tile imports from Pitwall (`ui`, `log`, `tasks`, `storage`, `settings`, `agents`, `badges`, `asks`, `agent-tools`) and what it exports (`guest`). The SDK's `export!` writes the export for you. - **Names.** WIT names use kebab case; the SDK's use Rust's (`request-render` is `ui::request_render`, `text-2` is `Token::Text2`). - **What a tile gets besides.** WASI 0.2 for what Rust's standard library needs: clocks, random numbers, and stdout and stderr, which go to the tile's Log. There are no files, sockets, environment variables or arguments. - **Versions.** A 0.x world may change between minor versions, and Pitwall keeps the last two 0.x worlds working. A tile names the world it was built for in its manifest (`"world": "pitwall:tile@0.1.0"`). WIT 1.0 ends the Preview. The WIT files are in [`crates/pitwall-tile-host/wit/`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/world.wit), and a copy ships with the SDK. Package `pitwall:tile@0.1.0`, generated from [`agent-tools.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/agent-tools.wit), [`agents.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/agents.wit), [`asks.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/asks.wit), [`badges.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/badges.wit), [`files.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/files.wit), [`guest.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/guest.wit), [`log.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/log.wit), [`net.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/net.wit), [`notify.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/notify.wit), [`programs.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/programs.wit), [`service.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/service.wit), [`settings.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/settings.wit), [`show.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/show.wit), [`sql.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/sql.wit), [`status.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/status.wit), [`storage.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/storage.wit), [`tasks.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/tasks.wit), [`toolbar.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/toolbar.wit), [`types.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/types.wit), [`ui.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/ui.wit), [`world.wit`](https://github.com/pitwalls/pitwall/blob/main/crates/pitwall-tile-host/wit/world.wit). Pitwall's tile API, version 0.1 (docs/spec/tile-sdk/runtime.md §3). A tile is a WebAssembly component that Pitwall runs in a sandbox and draws with its own UI code. The component describes what to show as a tree of elements ([`types`]); Pitwall lays it out, draws it in its own theme, and sends back what the user did as events. The component never draws pixels and never sees Pitwall's process. Version 0.x worlds may change between minor versions; Pitwall keeps the last two 0.x worlds working (runtime.md §8.2). A component records the world it was built for in its manifest's tile entry (`"world": "pitwall:tile@0.1.0"`). ## World `tile` What a tile's component imports from Pitwall and exports to it. Most imports here work without a permission: each one reaches only the tile's own things (its tree, its log, its timers, its stored data and database, its settings, its toolbar button, its own server). Those that reach Pitwall's agents need a permission the user grants (`agents.read`, `agents.queue`), and badges and questions need the manifest to contribute them; `net`, `notify` and `show` need the permission of that name, and a project's files need `files.read` or `files.write`. A tile that isn't granted one gets `denied` from it instead of failing to load, and can ask again later (a `grants-changed` event says when the user changed them). Besides these, the host provides WASI 0.2 for what Rust's standard library needs: the wall and monotonic clocks (`std::time::SystemTime` and `Instant` work), random numbers, and stdout and stderr, whose lines go to the tile's Log (stdout as info, stderr as warnings). There are no environment variables, arguments, files or sockets through WASI: keep data with [`storage`], and reach files through [`files`]. In the test harness both clocks are virtual: they move only when the test lets time pass. ### `tile.ui` *import, interface* Ask for renders, scroll a node into view, show a toast, open a view. ```wit import ui; ``` ### `tile.log` *import, interface* Lines for the tile's Log. ```wit import log; ``` ### `tile.tasks` *import, interface* Timers. ```wit import tasks; ``` ### `tile.storage` *import, interface* The tile's own key-value store. ```wit import storage; ``` ### `tile.settings` *import, interface* The tile's settings, as the user set them in Settings. ```wit import settings; ``` ### `tile.agents` *import, interface* Pitwall's agents and their Next up (`agents.read`, `agents.queue`). ```wit import agents; ``` ### `tile.badges` *import, interface* Counts and notes on sidebar rows (`"badges": true`). ```wit import badges; ``` ### `tile.asks` *import, interface* Questions in the floating control (`"asks": true`). ```wit import asks; ``` ### `tile.net` *import, interface* HTTP requests to the hosts the user granted (`net`). ```wit import net; ``` ### `tile.sql` *import, interface* The extension's own SQLite database. ```wit import sql; ``` ### `tile.notify` *import, interface* System notifications (`notify`). ```wit import notify; ``` ### `tile.show` *import, interface* Open a file in the editor or a page in a web tile (`show`). ```wit import show; ``` ### `tile.toolbar` *import, interface* The extension's toolbar button. ```wit import toolbar; ``` ### `tile.service` *import, interface* The extension's own server. ```wit import service; ``` ### `tile.status` *import, interface* Its connection's status on its card (`"status": true`). ```wit import status; ``` ### `tile.agent-tools` *import, interface* Agents' calls of the tile's tools: answers to show-only calls, large inputs. ```wit import agent-tools; ``` ### `tile.files` *import, interface* Files in the project a view is open in (`files.read`, `files.write`), and the extension's own files folder. ```wit import files; ``` ### `tile.programs` *import, interface* Approved native programs and pinned downloads. ```wit import programs; ``` ### `tile.guest` *export, interface* What Pitwall calls in the tile. ```wit export guest; ``` ## Interface `agent-tools` Agents' calls of the tile's tools (agent-tools.md §11.2–11.7): the answers to show-only calls, and the `read` and `act` calls themselves. No permission: what a tile may do while it answers is decided by the tool's kind (below), and whether an agent may call `read` and `act` tools at all is the user's decision in Pitwall. Every tile can be opened by an agent with Pitwall's own `<extension-id>__open`, and a manifest may declare show tools of kind `show` or `present` (`tools` on its tile entry). A call reaches the tile as `view-opened` (it opened a view) or `view-content` (it went to the view that is open), with the call's id, the tool and the agent in the `content` record. Pitwall has already checked the input against the tool's schema. A `present` call is all or nothing: input with problems changes nothing, and the reply says why. Pitwall refuses, before the tile sees it, a call that would replace an item the user changed since (`user-edited`). `read` and `act` calls arrive through the guest's `tool` export instead, as a `tool-call`: a `read` returns what the tile has (with the user's edits), an `act` changes something outside the tile. Pitwall asks the user before it delivers either: a `read` until the user allows that agent always, an `act` each time unless they did. While a `show`, `present` or `read` call runs, the tile's acting calls (`net`, `show`, `notify`, `agents.queue-add`) return `denied`; only an `act` call has the tile's full grants. ### `agent-tools.problem` *record* A problem in the agent's input, at a place in it when there is one (lines and columns from 1). ```wit record problem { line: option<u32>, column: option<u32>, message: string, } ``` ### `agent-tools.tool-ok` *record* What a call did: a short text for the agent (at most 4 KiB, cut beyond; say what is shown, never the tile's data), optional JSON of the same, and the item id it was shown under (when the tile chose it). ```wit record tool-ok { text: string, json: option<string>, item: option<string>, } ``` ### `agent-tools.tool-error` *record* Why a call changed nothing: a message first, then each problem. ```wit record tool-error { message: string, problems: list<problem>, } ``` ### `agent-tools.tool-output` *variant* A call's answer. ```wit variant tool-output { ok(tool-ok), error(tool-error), } ``` ### `agent-tools.reply` *function* Answer call `call` (from `content.call`, or a `tool-call`'s `id`). Only the first answer counts, and only while Pitwall still waits for it: for a show-only call, during the `handle` that delivered it (without one, Pitwall answers with what opened and where); for a `read` or `act` call the tile's `tool` export didn't answer at once, until its time limit (10 s for `read`, 120 s for `act`), after which the tile gets `tool-cancelled`. ```wit reply: func(call: u64, out: tool-output); ``` ### `agent-tools.user-edited` *function* The user changed what call `call` put in the tile (they typed in an agent's draft, moved its boxes). From now on that agent's calls with the same item are refused, before the tile sees them, with "The user changed this; show it under a new item id", so an agent never overwrites the user's edits. ```wit user-edited: func(call: u64); ``` ### `agent-tools.tool-kind` *enum* What a tool does, as its manifest entry declares it. ```wit enum tool-kind { show, present, read, act, } ``` | Case | Description | |---|---| | `show` | Opens or focuses the tile. | | `present` | Puts content into the tile, or changes content the same agent put there. | | `read` | Returns what the tile has now, with the user's edits. | | `act` | Has effects outside the tile (the network, files, other services). | ### `agent-tools.tool-call` *record* A call of a `read` or `act` tool, delivered to `guest.tool`. Pitwall has checked the input against the tool's schema, and the user has allowed it. ```wit record tool-call { id: u64, tool: string, kind: tool-kind, caller: option<caller>, input: string, view: option<view-id>, } ``` | Field | Type | Description | |---|---|---| | `id` | `u64` | The call's id: answer it with `reply` when `tool` returned `none`. | | `tool` | `string` | The tool's name in the manifest. | | `kind` | `tool-kind` | | | `caller` | `option<caller>` | The agent that called, as Pitwall identified it; `none`: the user ran it themselves (the command palette, or `pitwall extension run` in one of Pitwall's own terminals). | | `input` | `string` | The input, as JSON text. | | `view` | `option<view-id>` | The open view of the tool's tile, if one is open (a `read` or `act` call never opens one). | ### `agent-tools.input-part` *function* Part of a large input: up to `len` bytes (at most 1 MiB) from byte `offset` of the file a `present` call named instead of inline text (`content.large` says how long it is), as UTF-8 text ending at a character boundary (so a part may be a little shorter). Only while the event that delivered the call is handled; an error says why not. ```wit input-part: func(call: u64, offset: u64, len: u32) -> result<string, string>; ``` ## Interface `agents` Pitwall's agents as a tile may see them, and their Next up (platform-services.md §14.2, the agents' questions group). The same methods and permissions as adapters' `agent.list` and `queue.add`, with the same limits, recorded in the extension's Activity. ### `agents.agent-state` *enum* What an agent is doing now, as Pitwall reads it. ```wit enum agent-state { working, blocked, idle, done, stopped, unknown, } ``` | Case | Description | |---|---| | `working` | Working on its turn. | | `blocked` | It asks the user something (an approval, a question) and is held up until it is answered. | | `idle` | Waiting for its next prompt. | | `done` | Done with its turn. | | `stopped` | Not running: it exited or was stopped. | | `unknown` | Pitwall can't tell yet. | ### `agents.agent` *record* An agent (or a terminal) Pitwall shows. ```wit record agent { id: string, name: string, kind: string, kind-name: string, project: string, branch: option<string>, state: agent-state, waiting-on-you: bool, queued: u32, } ``` | Field | Type | Description | |---|---|---| | `id` | `string` | Pitwall's id for it: what `queue-add` and a badge's row take. | | `name` | `string` | Its name, as the sidebar shows it. | | `kind` | `string` | Its kind's id (`claude`, `codex`, `shell` for a plain terminal…). | | `kind-name` | `string` | Its kind's name ("Claude Code"). | | `project` | `string` | Its project's folder. | | `branch` | `option<string>` | The git branch it works on, when known. | | `state` | `agent-state` | What it is doing. | | `waiting-on-you` | `bool` | It waits on the user: the sidebar's and the Dock's "needs you" (`blocked`). | | `queued` | `u32` | Items waiting in its Next up (the "N queued" chip on its tile). | ### `agents.list` *function* Every agent Pitwall shows, in the sidebar's order. Needs the `agents.read` permission (`host-error.denied` without it). The tile gets `agents-changed` when this changes. ```wit list: func() -> result<list<agent>, host-error>; ``` ### `agents.queue-add` *function* Put `text` in agent `agent`'s Next up, marked "From <extension name>", waiting for the user's Send (Auto-send sends it only when the user lets the extension send without asking). Needs the `agents.queue` permission. At most 4 000 characters (`host-error.too-large` over that), not empty (`invalid`); at most 3 of the extension's items wait in one agent's Next up and one is queued per agent every 10 seconds (`busy`); `invalid` for an agent that isn't there. Use for event-driven nudges: identify the changed item and how to read it, so the agent need not poll for events. Success means queued, not delivered or acted on. Automatic sending also needs the agent's Auto-send setting and waits for a settled Idle/Done session; it does not interrupt Working agents or restart Stopped agents. This call does not grant a background lifetime or an inbound event listener. ```wit queue-add: func(agent: string, text: string) -> result<_, host-error>; ``` ### `agents.env-var` *record* A variable for agents (`set-env`): its name, one the `agents.env` permission lists, and its value as a template. ```wit record env-var { name: string, value: string, } ``` | Field | Type | Description | |---|---|---| | `name` | `string` | | | `value` | `string` | Plain text, a plain setting (`{setting:KEY}`, never a secret), and the agent's own identity: `{agent_name}`, `{agent_id}` (Pitwall's id for its session, kept across restarts), `{project}` (its project's folder name). Filled in for each agent; one line, at most 1 000 characters. | ### `agents.set-env` *function* Set these variables on the agents Pitwall starts from now on in the projects the extension is on for (the ticks on its card): the whole set each time, at most 16; an empty list sets none. Needs the `agents.env` permission (`host-error.denied` without it); a name it doesn't list, a secret setting, another placeholder or a brace is `invalid`, with the reason in its Log. Pitwall keeps the set across restarts and shows it on the extension's card; running agents started under another set are "running agents that use an old setup". ```wit set-env: func(vars: list<env-var>) -> result<_, host-error>; ``` ## Interface `asks` Questions in Pitwall's floating control (platform-services.md §14.2), shown as an inbox's are: a card with who asks, the question, the suggestions, a field, Send, Decline and "Open <tile>". Only when the manifest says `"asks": true` in `contributes`. The answer comes back as the `ask-answered` event. ### `asks.suggestion` *record* An answer the user can pick with one click. ```wit record suggestion { label: string, description: option<string>, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | Its words (at most 80 characters). | | `description` | `option<string>` | A line under it (at most 200 characters). | ### `asks.ask` *record* A question the tile asks the user. ```wit record ask { id: string, from: option<string>, title: string, question: string, suggestions: list<suggestion>, multiple: bool, blocking: bool, } ``` | Field | Type | Description | |---|---|---| | `id` | `string` | The tile's own id for it, stable while it is open (1 to 128 characters): `ask-answered` names it. | | `from` | `option<string>` | Who asks: an agent by Pitwall's id (needs `agents.read`), shown by its name; `none`: the extension asks. | | `title` | `string` | What it is about, after who asks (at most 200 characters). | | `question` | `string` | The question (at most 2 000 characters). | | `suggestions` | `list<suggestion>` | Answers to pick (at most 8). | | `multiple` | `bool` | Several suggestions may be picked. | | `blocking` | `bool` | It holds an agent or a job up: shown first, marked "Waiting on you". | ### `asks.set` *function* The whole set of open questions, each time (an empty list clears them). At most 50 (`host-error.too-large` over that); the control shows them after agents' own prompts. `denied` when the manifest doesn't contribute `asks`; `invalid` for an ask with no id, two with the same id, or no question. Longer text is cut. Pitwall keeps the set while the tile is hidden or let go to save memory, so the questions stay in the control; an answer to a tile that was let go starts it again first. ```wit set: func(open: list<ask>) -> result<_, host-error>; ``` ### `asks.reply` *function* After `ask-answered`: `none` when the answer was taken (send a set without the question), or why it wasn't, which the card shows under its buttons ("Not sent: …"), letting the user answer again. ```wit reply: func(id: string, refused: option<string>); ``` ## Interface `badges` Counts and short notes on sidebar rows (platform-services.md §14.2), beside Pitwall's own waiting badges, as adapters' `badges` do. Only when the manifest says `"badges": true` in `contributes`; gone when the extension is turned off or its last tile closes. ### `badges.row` *variant* Which sidebar row a badge is on. ```wit variant row { agent(string), project(string), } ``` | Case | Payload | Description | |---|---|---| | `agent` | `string` | An agent, by Pitwall's id (`agents.list`). Needs `agents.read`. | | `project` | `string` | A project, by its folder. Needs `projects.read`. | ### `badges.badge` *record* A count and/or a few words on a row. ```wit record badge { row: row, count: option<u32>, note: option<string>, tone: tone, tooltip: option<string>, open: option<string>, } ``` | Field | Type | Description | |---|---|---| | `row` | `row` | The row. | | `count` | `option<u32>` | A number (at most 9999). | | `note` | `option<string>` | A few words (at most 16 characters; longer is cut). A badge needs a count or a note. | | `tone` | `tone` | Its colour by meaning: `info` is neutral. | | `tooltip` | `option<string>` | Shown on hover after the extension's name (at most 120 characters). | | `open` | `option<string>` | One of the extension's tiles (an id from `contributes.tiles`) that a click on the badge opens. | ### `badges.set` *function* The whole set of badges, each time (an empty list clears them). At most 500 (`host-error.too-large` over that); at most four sets a second are shown (the newest waits for its turn). `denied` when the manifest doesn't contribute `badges`. A badge on a row the tile may not name (a missing permission) is dropped and noted in its Log. ```wit set: func(badges: list<badge>) -> result<_, host-error>; ``` ## Interface `files` Files in the project a view is open in, and in the extension's own files folder (platform-services.md §14.3, permissions.md §5.1). **The project.** Every view is open somewhere in Pitwall's layout: in a project's space, next to an agent working in a project, or opened from a project's menu in the sidebar. That project is the view's (`project`), and the only project folder its tile may reach: a tile never names a folder of its own choosing, and never reaches a project none of its views is in. A view moved to another project's space, or out of every project, sends `project-changed` with its id. **Permissions.** Reading a project (`read`, `stat`, `list`, `watch`) needs `files.read`; changing it (`write`, `create`, `make-folder`, `rename`, `delete`) needs `files.write`, off until the user turns it on. The extension's own files folder (`root.data`, `<data>/extension-data/<id>/files/`) needs neither: it is its own, like its key-value store, and holds at most 100 MiB. **What is never reached.** Paths are relative to the root, with `/` between parts. Absolute paths and `..` are refused (`not-allowed`); links are followed and refused when they lead out of the root. A `.git` folder is neither listed, read nor changed, and Pitwall's own files in a project (`.pitwall.json`, `.pitwall/`) are never changed. `list` and `watch` leave out what the project's `.gitignore` files (and `.git/info/exclude`) ignore; `read` and `stat` still reach those files by name. **Limits.** A file read or written is at most 8 MiB; `list` gives at most 10 000 entries; a tile has at most 8 watches at once. Changing calls (and refusals) are listed in the extension's Activity. ### `files.project-info` *record* A project, as Pitwall shows it. ```wit record project-info { name: string, folder: string, } ``` | Field | Type | Description | |---|---|---| | `name` | `string` | Its name, as the sidebar shows it (`checkout-web`). | | `folder` | `string` | Its folder, absolute, as this computer writes it. | ### `files.root` *variant* Where a call's path starts. ```wit variant root { project(string), data, } ``` | Case | Payload | Description | |---|---|---| | `project` | `string` | The folder of the project the view with this id is open in (`project`). `no-project` when the view isn't open, or isn't in a project. | | `data` | | The extension's own files folder: no permission needed, kept across updates, at most 100 MiB. | ### `files.entry-kind` *enum* What an entry is. ```wit enum entry-kind { file, folder, } ``` ### `files.entry` *record* A file or folder. ```wit record entry { path: string, kind: entry-kind, size: u64, modified: u64, } ``` | Field | Type | Description | |---|---|---| | `path` | `string` | Its path from the root, with `/` between parts (`docs/arch.md`). | | `kind` | `entry-kind` | A file or a folder (a link is what it leads to). | | `size` | `u64` | Its size in bytes (0 for a folder). | | `modified` | `u64` | When it last changed, in milliseconds since 1970 (UTC). | ### `files.file-error` *variant* Why a call didn't do what was asked. ```wit variant file-error { denied, no-project, not-found, exists, not-allowed(string), too-large, busy, invalid(string), failed(string), } ``` | Case | Payload | Description | |---|---|---| | `denied` | | The tile isn't granted `files.read` (to read) or `files.write` (to change), or an agent's call runs without the tile's acting permissions (writing needs an act call). | | `no-project` | | The view isn't open, or isn't in a project. | | `not-found` | | Nothing is at that path. | | `exists` | | Something is already at that path (`create`, `make-folder`, `rename`'s target). | | `not-allowed` | `string` | The path is outside the root (an absolute path, `..`, a link that leads out), inside `.git`, or one of Pitwall's own files; the text says which. | | `too-large` | | Over a limit: a file over 8 MiB, more than 10 000 entries, the files folder over 100 MiB. | | `busy` | | Too many calls this second, or 8 watches already. | | `invalid` | `string` | A path that isn't valid (empty where a file is needed, a NUL); the text says why. | | `failed` | `string` | The disk said no (a permission of the system, a full disk); the text says what happened. | ### `files.watch-id` *type* A watch's number, unique while the tile runs. ```wit type watch-id = u32; ``` ### `files.files-changed` *record* What `files-changed` carries. ```wit record files-changed { watch: watch-id, paths: list<string>, } ``` | Field | Type | Description | |---|---|---| | `watch` | `watch-id` | The watch. | | `paths` | `list<string>` | The paths that changed (were written, made, renamed or removed), from the watch's root, each once, sorted. Changes close together arrive as one event, about a quarter of a second after the last. | ### `files.project` *function* The project view `view` is open in, if any. Needs `files.read` (or `projects.read`); without either, `none`. ```wit project: func(view: string) -> option<project-info>; ``` ### `files.read` *function* A file's bytes (at most 8 MiB). ```wit read: func(root: root, path: string) -> result<list<u8>, file-error>; ``` ### `files.stat` *function* A file or folder: what it is, its size and last change. `""` is the root itself. ```wit stat: func(root: root, path: string) -> result<entry, file-error>; ``` ### `files.list` *function* What folder `folder` holds (`""`: the root): its files and folders, sorted by path; with `deep`, everything under it too. Ignored entries and `.git` are left out. At most 10 000 entries, else `too-large`: list a smaller folder. ```wit list: func(root: root, folder: string, deep: bool) -> result<list<entry>, file-error>; ``` ### `files.watch` *function* Follow changes under folder `folder` (`""`: the root), everything under it: each change arrives as a `files-changed` event with the number returned here. Ignored paths and `.git` are left out. At most 8 watches at once (`busy`). A watch ends with `unwatch`, when its view closes or leaves the project, or when the tile stops. ```wit watch: func(root: root, folder: string) -> result<watch-id, file-error>; ``` ### `files.unwatch` *function* Stop watch `id`; a number that isn't watching is ignored. ```wit unwatch: func(id: watch-id); ``` ### `files.write` *function* Write `contents` to file `path`, replacing what is there; its folders are made when missing. The file is written whole or not at all (a reader never sees half of it). Needs `files.write` for a project. ```wit write: func(root: root, path: string, contents: list<u8>) -> result<_, file-error>; ``` ### `files.create` *function* Make a new file `path` with `contents`; `exists` when something is there already. Its folders are made when missing. ```wit create: func(root: root, path: string, contents: list<u8>) -> result<_, file-error>; ``` ### `files.make-folder` *function* Make folder `path` (and the folders above it); `exists` when something is there already. ```wit make-folder: func(root: root, path: string) -> result<_, file-error>; ``` ### `files.rename` *function* Move or rename `from` to `to`, in the same root; `exists` when something is at `to`. ```wit rename: func(root: root, %from: string, to: string) -> result<_, file-error>; ``` ### `files.delete` *function* Move file or folder `path` of a project to the system's Trash, where the user can put it back. In the files folder it is deleted. ```wit delete: func(root: root, path: string) -> result<_, file-error>; ``` ## Interface `guest` What Pitwall calls in a tile (runtime.md §3.2). Pitwall calls these one at a time, from one thread per running tile, never the UI's: a tile is never called again while one of its calls runs, and a slow call slows only that tile. Every call has a deadline; a call that runs past it is stopped, the tile shows "stopped" with the reason, and the user can restart it. ### `guest.init` *function* Start: called once, before anything else, with the theme, the granted permissions and the state saved last time. An error stops the tile and its text is shown to the user. Deadline: 2 s. ```wit init: func(cx: init-context) -> result<_, string>; ``` ### `guest.render` *function* The whole tree of view `view`. Called after `init`, after every handled event that returned true, after `ui.request-render`, and when a view is opened or shown again; several changes in one frame make one render. Deadline: 250 ms; keep it under 8 ms so the tile keeps up with the display. ```wit render: func(view: view-id) -> frame; ``` ### `guest.handle` *function* Handle one event. Return true when what the tile shows changed, so Pitwall renders its open views again. Deadline: 1 s; calls over 50 ms are noted in the tile's Log. ```wit handle: func(event: event) -> bool; ``` ### `guest.save-state` *function* State to keep while the tile is dropped (to save memory after it was hidden for a while) or reloaded during development; given back in `init-context.state`. At most 1 MiB; deadline 50 ms. Data the user must not lose belongs in `storage`, which is kept on disk at once. ```wit save-state: func() -> list<u8>; ``` ### `guest.rows` *function* Rows `start` to `start + count` (fewer at the end) of the virtual list, table or tree at `key-path` in view `view` (keys from the root down, joined by `/`, as `ui.scroll-to`), as the rows come into sight (runtime.md §2.7). Pitwall asks again when the list's `revision` moves. At most 256 rows a call, each at most 64 nodes. Deadline: 250 ms, as `render`. ```wit rows: func(view: view-id, key-path: string, start: u32, count: u32) -> list<row>; ``` ### `guest.tool` *function* A `read` or `act` call of one of the tile's declared tools (agent-tools.md §11.2). Return the answer, or `none` and call `agent-tools.reply` later (an `act` that waits on the network), within the call's time limit: 10 s for `read`, 120 s for `act`. Deadline of this call itself: 1 s, as `handle`. Calls arrive one at a time, in order, like events. ```wit tool: func(call: tool-call) -> option<tool-output>; ``` ## Interface `log` Lines for the tile's Log, which the user and `pitwall extension dev` can read (runtime.md §3.8). No permission. Each line is at most 4 KiB (longer lines are cut); lines over the host-call limit (200 calls a second) are dropped, and the Log says how many. `println!` and `eprintln!` reach the same Log through WASI's stdout and stderr. ### `log.debug` *function* Detail for whoever is debugging the tile. ```wit debug: func(message: string); ``` ### `log.info` *function* Something worth knowing happened. ```wit info: func(message: string); ``` ### `log.warn` *function* Something went wrong, and the tile carried on. ```wit warn: func(message: string); ``` ### `log.error` *function* Something failed. ```wit error: func(message: string); ``` ## Interface `net` HTTP requests to the hosts the user granted (platform-services.md §14.2, permissions.md §5.1). Needs the `net` permission: the manifest lists its hosts (`"net": {"reason": …, "hosts": ["api.github.com", "*.example.com"]}`), the user sees them as written and may refuse. Without the grant every request is refused with `denied`. Pitwall makes the request, not the tile: no sockets, no DNS, no TLS of its own. The URL is parsed by Pitwall and its host compared with the list (after IDNA, before any name lookup); `https://` to a listed host, plain `http://` only to this computer (`localhost`, `127.0.0.1`, `[::1]`) and only when listed. A host without a port in the list is reached on the scheme's own port only. Redirects are followed by Pitwall (at most 5), only to listed hosts. No cookies, no proxy, no credentials are added. A request runs while the tile goes on: `fetch` returns at once with the request's number, and the answer arrives as a `fetched` event. At most 8 requests at once, a body of at most 8 MiB, an answer of at most 32 MiB, 30 s unless the request asks for less (at most 120 s). A tile that talks to its extension's own server (a `service` in the manifest) may reach that server's address without `net`: see [`service`]. ### `net.header` *record* A header, as sent or received. ```wit record header { name: string, value: string, } ``` | Field | Type | Description | |---|---|---| | `name` | `string` | | | `value` | `string` | An entire value `secret(key)` or `bearer(key)` references a declared secret setting. The host fills it in only after checking the current explicit net host grant, including every redirect. Other values stay literal; responses always contain literal text. | ### `net.request` *record* A request. ```wit record request { method: string, url: string, headers: list<header>, body: option<list<u8>>, timeout-ms: option<u32>, } ``` | Field | Type | Description | |---|---|---| | `method` | `string` | `GET`, `POST`, `PUT`, `PATCH`, `DELETE` or `HEAD`. | | `url` | `string` | The whole address, `https://…` (or `http://localhost…`). | | `headers` | `list<header>` | Headers to send. `Host`, `Content-Length`, `Connection`, `Cookie` and `Proxy-*` are Pitwall's and refused. | | `body` | `option<list<u8>>` | The body, at most 8 MiB. | | `timeout-ms` | `option<u32>` | Give up after this many milliseconds (default and most: 30 000; at most 120 000 when asked for). | ### `net.response` *record* An answer: any HTTP status, 404 and 500 included. ```wit record response { status: u16, headers: list<header>, body: list<u8>, url: string, } ``` | Field | Type | Description | |---|---|---| | `status` | `u16` | The status code. | | `headers` | `list<header>` | The answer's headers (`Set-Cookie` left out). | | `body` | `list<u8>` | The body, at most 32 MiB. | | `url` | `string` | The address that answered, after redirects. | ### `net.fetch-error` *variant* Why a request got no answer. ```wit variant fetch-error { denied(string), too-large, invalid(string), timed-out, failed(string), } ``` | Case | Payload | Description | |---|---|---| | `denied` | `string` | The tile isn't granted `net`, or the host isn't one it may reach (the text names the host). | | `too-large` | | Over a limit: 8 requests at once, a body over 8 MiB, an answer over 32 MiB. | | `invalid` | `string` | The request isn't valid (a bad URL, method or header); the text says why. | | `timed-out` | | No answer in time. | | `failed` | `string` | It couldn't be sent or the connection failed (offline, a name that doesn't resolve, a TLS error); the text says what happened. | ### `net.request-id` *type* A request's number, unique while the tile runs. ```wit type request-id = u32; ``` ### `net.fetched` *record* What `fetched` carries: the request's number and its answer. ```wit record fetched { id: request-id, outcome: result<response, fetch-error>, } ``` | Field | Type | Description | |---|---|---| | `id` | `request-id` | The number `fetch` returned. | | `outcome` | `result<response, fetch-error>` | The answer, or why there is none. | ### `net.fetch` *function* Send `request`; its answer arrives as a `fetched` event with the number returned here. Refused at once (`denied`, `invalid`, `too-large`) when it can't be sent. ```wit fetch: func(request: request) -> result<request-id, fetch-error>; ``` ### `net.cancel` *function* Stop waiting for request `id`: no `fetched` arrives for it. A number that isn't waiting is ignored. ```wit cancel: func(id: request-id); ``` ## Interface `notify` System notifications (platform-services.md §14.2). Needs the `notify` permission; without it, `denied`. For news inside Pitwall, a toast (`ui.toast`) needs nothing. Labelled with the extension's name. Shown by the system while Pitwall isn't in front, and as a toast in Pitwall either way; clicking either opens the tile that sent it. At most 3 a minute (`busy` over that); the same title and text again within 10 minutes is shown once. ### `notify.send` *function* Notify the user: a title (at most 80 characters) and a line of text (at most 200; longer is cut). ```wit send: func(title: string, body: string) -> result<_, host-error>; ``` ## Interface `programs` Native programs, outside the tile sandbox. Needs `programs`, its declared patterns, and the user's approval of every exact command. ### `programs.unpack` *enum* ```wit enum unpack { none, zip, tar-gz, gzip, } ``` ### `programs.run` *function* Run once, at most four at once and ten minutes; output is cut to one MiB per stream. Returns a task even while approval is pending. ```wit run: func(cmd: command, timeout-ms: u32) -> result<u32, host-error>; ``` ### `programs.start` *function* Keep a named process group running, with 1/5/30 s restart delays. A loopback listen address is reachable only while it runs. ```wit start: func(name: string, cmd: command, listen: option<string>) -> result<_, host-error>; ``` ### `programs.stop` *function* ```wit stop: func(name: string); ``` ### `programs.status` *function* ```wit status: func(name: string) -> info; ``` ### `programs.download` *function* HTTPS, a declared download pattern, SHA-256, then a new destination under the extension's data folder. Never the user's other files. ```wit download: func(url: string, sha256: string, to: string, unpack: unpack) -> result<u32, host-error>; ``` ## Interface `service` The extension's own server, when its manifest declares a `service` (services.md §13.2): a program on this computer that Pitwall installs with one of the extension's actions, starts while the extension is on and restarts when it stops. No permission: only its own server. The tile may reach the server's address (its `ready.listen`, as the user's settings make it) with `net.fetch`, over `http`, without the `net` permission; nothing else on this computer. Hiding or closing the tile doesn't stop the server; turning the extension off stops both. ### `service.state` *enum* How the server stands. ```wit enum state { none, off, needs-install, starting, up, stopped, failed, } ``` | Case | Description | |---|---| | `none` | The extension declares no service. | | `off` | Not started yet: the user hasn't confirmed its commands. | | `needs-install` | Its program isn't installed (or too old): the card offers its install action. | | `starting` | Started, not answering yet. | | `up` | Running and answering. | | `stopped` | Stopped by the user. | | `failed` | It stopped by itself and isn't coming back on its own. | ### `service.service-info` *record* The server's state now. ```wit record service-info { state: state, address: option<string>, version: option<string>, why: option<string>, } ``` | Field | Type | Description | |---|---|---| | `state` | `state` | | | `address` | `option<string>` | Where it listens, `http://127.0.0.1:8790` (no trailing `/`), when it declares `ready.listen`. | | `version` | `option<string>` | The version its `version` check found. | | `why` | `option<string>` | Why it is off, failed or needs installing, in plain words. | ### `service.info` *function* The server's state now (a `service-changed` event follows each change). ```wit info: func() -> service-info; ``` ### `service.restart` *function* Ask Pitwall to start the server again, as the card's Restart does. ```wit restart: func(); ``` ### `service.open-card` *function* Show the extension's card in Settings, where the user installs, confirms and starts the server. ```wit open-card: func(); ``` ## Interface `settings` The tile's settings (platform-services.md §14.2). No permission: only the extension's own settings. The manifest declares them (`settings`: key, type, label, default); Pitwall draws the form in Settings, keeps the values and sends `settings-changed` when the user changes them. ### `settings.setting-value` *variant* A setting's value. ```wit variant setting-value { text(string), number(f64), flag(bool), } ``` | Case | Payload | Description | |---|---|---| | `text` | `string` | A `text`, `url` or `choice` setting (a choice gives its value, not its label). | | `number` | `f64` | A `number` setting. | | `flag` | `bool` | A `bool` setting (a switch). | ### `settings.get` *function* The value of setting `key`: what the user set, else the manifest's default; `none` when it has neither, or when `key` isn't one of the manifest's settings. A `secret` setting is never returned here: use `secret`. ```wit get: func(key: string) -> option<setting-value>; ``` ### `settings.secret` *function* The value of `secret` setting `key`, from the system's secure store: `none` when the user hasn't set it. `host-error.invalid` when `key` isn't one of the manifest's secret settings. `denied` for keys the user has saved or removed through a host-owned secure field (the reference-only boundary persists across restarts and updates). Legacy keys keep this API until the adapter migration. Keep it in memory only: never store it, log it or show it. ```wit secret: func(key: string) -> result<option<string>, host-error>; ``` ### `settings.open` *function* Open the extension's page in the Extensions tile, at its Setup view when the manifest names one (`contributes.setup`), where the user sets these (for a "Set up" button when something it needs isn't set). ```wit open: func(); ``` ### `settings.secret-set` *function* Whether this declared secret is set; never returns its value. ```wit secret-set: func(key: string) -> bool; ``` ### `settings.set` *function* Save an ordinary setting, validated against its schema. Secrets and keys referenced by net/program permission patterns are denied: only the host-owned fields may change those. Empty text restores a default. ```wit set: func(key: string, value: setting-value) -> result<_, host-error>; ``` ## Interface `show` Show the user a file or a web page in Pitwall (platform-services.md §14.2). Needs the `show` permission, off until the user turns it on; without it, `denied`. These only show: the tile gets nothing back, and Pitwall never comes forward or takes the keyboard from a terminal. `browser` uses the separate `show.browser` permission and may activate the external browser. ### `show.file` *function* Open the file at `path` (absolute, on this computer) in Pitwall's editor, at `line` (1 is the first) when given; the editor opens in the front window when it isn't open. `invalid` for a path that isn't absolute. Opening the editor is all it does: the tile can't read the file through it. ```wit file: func(path: string, line: option<u32>) -> result<_, host-error>; ``` ### `show.web` *function* Open `url` (`https://`, or `http://` to this computer) in a new web tile next to the tile's own. `invalid` for another kind of address. ```wit web: func(url: string) -> result<_, host-error>; ``` ### `show.view` *function* Show the file at `path` (absolute, on this computer) in Pitwall's file viewer, scrolled to `line` (1 is the first) when given, as an agent's `show_files` shows files: with its folder's tree (its git repository's, when it is in one) and git status, in a window of the viewer's own that opens behind the front window and doesn't take the keyboard. One viewer per tile: a later call adds a tab to it. `invalid` for a path that isn't absolute. As `file`, it only shows. ```wit view: func(path: string, line: option<u32>) -> result<_, host-error>; ``` ### `show.browser` *function* Open an HTTPS (or loopback HTTP) URL in the user's external browser. Unlike web, this creates no tile or stored location. Pitwall doesn't record the URL in its Log, Activity or Debug output. Requires `show.browser` (off until allowed), independently of `show`. The browser has its own history/privacy behavior. Useful for one-time sign-in links. ```wit browser: func(url: string) -> result<_, host-error>; ``` ## Interface `sql` The extension's own SQLite database, run by Pitwall (platform-services.md §14.2). No permission: only this extension's data, in `<data>/extension-data/<id>/`, outside its folder, so updates and going back keep it. Every tile of the extension shares it. At most 100 MiB unless the manifest asks for more with the `sql` permission (`{"reason": …, "mib": 500}`, at most 2 GiB, shown on the permission screen); over it, writes fail with `too-large`. A statement runs within the deadline of the call it is made in (`handle` 1 s, `init` 2 s): a longer one is stopped and fails with `busy`. A transaction lasts at most one call into the tile: `begin`, then statements, then `commit` or `rollback`, all while handling one event; one still open when the call returns is rolled back, with a line in the Log. Answers hold at most 10 000 rows and 8 MiB. ### `sql.value` *variant* A value in a row or a parameter, as SQLite keeps it. ```wit variant value { null, integer(s64), real(f64), text(string), blob(list<u8>), } ``` ### `sql.rows` *record* A query's answer. ```wit record rows { columns: list<string>, rows: list<list<value>>, } ``` | Field | Type | Description | |---|---|---| | `columns` | `list<string>` | The columns' names, in order. | | `rows` | `list<list<value>>` | Each row's values, in the columns' order. | ### `sql.execute` *function* Run one statement with `params` bound to its `?` (or `?1`, `?2`…) placeholders; the number of rows it changed. Errors: `invalid` with SQLite's words for a statement that is wrong or breaks a constraint, `too-large` over the quota, `busy` over the deadline. ```wit execute: func(statement: string, params: list<value>) -> result<u64, host-error>; ``` ### `sql.query` *function* Run one statement and return its rows. ```wit query: func(statement: string, params: list<value>) -> result<rows, host-error>; ``` ### `sql.migrate` *function* Bring the database's schema up to date: `steps` are the migrations in order (each one or more statements; step 1 first). The database keeps how many it ran (SQLite's `user_version`); the ones after that run now, each in its own transaction. Returns the version now. A step that fails is rolled back and stops the rest (`invalid`, with its number). Fewer steps than the database has run is `invalid`: a tile can't go back a schema. ```wit migrate: func(steps: list<string>) -> result<u32, host-error>; ``` ### `sql.begin` *function* Start a transaction (`invalid` when one is open). ```wit begin: func() -> result<_, host-error>; ``` ### `sql.commit` *function* Keep what the open transaction did. ```wit commit: func() -> result<_, host-error>; ``` ### `sql.rollback` *function* Undo what the open transaction did. ```wit rollback: func() -> result<_, host-error>; ``` ### `sql.usage` *function* The bytes the database takes now. ```wit usage: func() -> u64; ``` ### `sql.quota` *function* The most it may take, in bytes. ```wit quota: func() -> u64; ``` ## Interface `status` The extension's connection to its service, as the user sees it (platform-services.md, "Status"): the pill on its card in Settings, the Connected step of its checklist, and the update's check that it connects again, the same as an adapter's status. Only when the manifest says `"status": true` in `contributes`. ### `status.state` *enum* How the connection is. ```wit enum state { connecting, ready, signed-out, error, } ``` | Case | Description | |---|---| | `connecting` | Starting to connect, or connecting again. | | `ready` | Connected and working. | | `signed-out` | A credential is missing, wrong, expired or lacks access. | | `error` | It can't connect, or the service failed. | ### `status.set` *function* The connection now, with a sentence for the user (at most 500 characters; for `ready`, usually empty). Until the first call it is `connecting`. Ignored without the contribution (noted in the Log). ```wit set: func(state: state, message: string); ``` ## Interface `storage` The tile's own key-value store (platform-services.md §14.2). No permission: it holds only this extension's data, and no other extension can read it. Kept on disk outside the extension's folder, so it survives updates and going back to an earlier version; written after each call into the tile that changed it. At most 10 MiB in all (keys and values); keys are 1 to 256 bytes of UTF-8, without control characters. ### `storage.get` *function* The value of `key`, or `none` when it has none. ```wit get: func(key: string) -> result<option<list<u8>>, host-error>; ``` ### `storage.get-many` *function* The values of `keys`, in the same order (`none` for a key with no value), in one host call: a tile loads hundreds of keys at start with `list` and this. At most 1024 keys a call (`host-error.too-large` over that); `host-error.invalid` for a key that isn't valid. ```wit get-many: func(keys: list<string>) -> result<list<option<list<u8>>>, host-error>; ``` ### `storage.set` *function* Set `key` to `value`. `host-error.too-large` when it would take the store over 10 MiB; `host-error.invalid` for a key that isn't valid. ```wit set: func(key: string, value: list<u8>) -> result<_, host-error>; ``` ### `storage.delete` *function* Remove `key`. A key with no value is no error. ```wit delete: func(key: string) -> result<_, host-error>; ``` ### `storage.list` *function* The keys that start with `prefix` (all keys for `""`), in byte order. ```wit list: func(prefix: string) -> result<list<string>, host-error>; ``` ### `storage.usage` *function* The bytes the store takes now (keys and values), out of its 10 MiB. ```wit usage: func() -> u64; ``` ## Interface `tasks` Timers (platform-services.md §14.2). No permission. Timers pause while the tile is hidden and go on when it is shown again; a repeating timer that was due while hidden fires once, not once per missed period. ### `tasks.timer` *function* Fire a `timer` event after `ms` milliseconds, once or, with `repeat`, every `ms` milliseconds until cancelled. At least 100 ms (shorter is raised to 100). At most 32 timers at once: one more gives `host-error.busy`. ```wit timer: func(ms: u32, repeat: bool) -> result<timer-id, host-error>; ``` ### `tasks.cancel` *function* Stop a timer. An id that isn't running (fired once, or cancelled already) is ignored. ```wit cancel: func(id: timer-id); ``` ## Interface `toolbar` The extension's button in Pitwall's top bar (ui.md §3.9), when its manifest declares one (`contributes.toolbar`). Pitwall draws it: an icon, a tooltip and maybe a badge. No permission; an extension without a toolbar item gets nothing from these (they are ignored). A click with the `popover` action opens a small view of the tile under the button: it arrives as `view-opened` with the view id `toolbar:popover` and closes with `view-closed`. With `tile` or `popover`, the tile also gets `toolbar-clicked`. ### `toolbar.badge` *variant* A badge on the button. ```wit variant badge { none, dot, count(u32), } ``` | Case | Payload | Description | |---|---|---| | `none` | | No badge. | | `dot` | | A dot. | | `count` | `u32` | A number (shown up to 99, then "99+"). | ### `toolbar.badge-tone` *enum* A badge's colour. ```wit enum badge-tone { normal, attention, } ``` | Case | Description | |---|---| | `normal` | The accent colour. | | `attention` | Amber, like "needs you". | ### `toolbar.set-badge` *function* The button's badge, in every window (for a per-project item: in spaces that aren't a project's). At most 4 changes a second: more are merged into the newest. The badge shows while the component runs; a manifest with `"badge": true` keeps it running while no tile shows. ```wit set-badge: func(badge: badge, tone: badge-tone); ``` ### `toolbar.set-project-badge` *function* A project's badge, for an item with `"scope": "project"` (shown while that project's space is the window's). `project` is the id `toolbar-clicked` gives. ```wit set-project-badge: func(project: string, badge: badge, tone: badge-tone); ``` ### `toolbar.set-tooltip` *function* Change the tooltip (for example "3 unread"). At most 80 characters. ```wit set-tooltip: func(text: string); ``` ### `toolbar.set-shown` *function* Show or hide the button. The user's choice is stronger: a button the user hid stays hidden. At most one change in 5 seconds; each start begins from the manifest's `visibleByDefault`. ```wit set-shown: func(shown: bool); ``` ### `toolbar.close-popover` *function* Close the popover, if it is open (after a pick or a send). ```wit close-popover: func(); ``` ## Interface `types` The UI description a tile sends, the events it gets back, and the types the other interfaces share (docs/spec/tile-sdk/ui.md §3.3–3.5). A view is drawn from a `frame`: a flat list of nodes, each naming its parent by index, so a tree is one list with no recursion. Pitwall compares each frame with the one before by key path and keeps what the user sees (scroll position, focus, hover, text being typed) for nodes whose key path stays the same. Colours, sizes of text, fonts and corner radii are Pitwall's own tokens, named by meaning, so a tile looks native in light and dark themes and follows the user's appearance settings. There are no raw colours in 0.1. ### `types.view-id` *type* One open view of the tile: a place in Pitwall's layout showing one of the manifest's tiles (`contributes.tiles`). Chosen by Pitwall and stable while the view is open; a tile opened once has the tile's id as its view id (for example `"main"`), and a tile opened several times (by the user, or by agents with different content) gets one view id per place. Pitwall renders each open view separately; the guest learns of each from `view-opened`. ```wit type view-id = string; ``` ### `types.content` *record* Content given to a view when it opens or later, by the user or an agent (as Pitwall's own viewers take a file or a page). The tile's manifest declares what it accepts (`"input"`: a JSON schema in its folder); Pitwall checks the payload against it before delivering. ```wit record content { id: option<string>, json: option<string>, bytes: option<list<u8>>, call: option<u64>, tool: option<string>, caller: option<caller>, append: bool, large: option<u64>, } ``` | Field | Type | Description | |---|---|---| | `id` | `option<string>` | The caller's id for this content. A later call with the same id updates the view showing it in place instead of opening another. | | `json` | `option<string>` | The payload, as JSON text matching the tile's input schema. | | `bytes` | `option<list<u8>>` | Binary payload (an image, a file's bytes), when the schema says so. At most 8 MiB. | | `call` | `option<u64>` | The agent's call that brought this content (agent-tools.md §11.3): its id, also the origin id of what it put in the tile. Answer it with `agent-tools.reply` to return problems in the input; without a reply, Pitwall tells the agent what opened and where once `handle` returns. `none`: the user opened the view. | | `tool` | `option<string>` | The tool called: a show tool the manifest declares (`tools`), or `none` for the open Pitwall gives every tile (`<extension-id>__open`), whose content is the tile's `"input"`. | | `caller` | `option<caller>` | The agent that called, as Pitwall identified it (never what the agent says about itself). `none`: the user opened the view. Items are per agent: key what an agent shows by its agent id and `id`, so two agents never replace each other's. | | `append` | `bool` | The call adds to the item instead of replacing it (`"mode": "append"` in a `present` call, with the same `id`): `json` is the part to add. | | `large` | `option<u64>` | The call named a file instead of inline text (`"from_file"`): its size in bytes, read in parts with `agent-tools.input-part` while the event is handled. | ### `types.caller` *record* An agent calling a tile's tool, as Pitwall identified it from the calling process. ```wit record caller { agent-id: string, agent-name: string, project: option<string>, } ``` | Field | Type | Description | |---|---|---| | `agent-id` | `string` | The agent's id in Pitwall (stable while the agent exists). | | `agent-name` | `string` | The agent's name, as the user sees it (`api`, `web`). | | `project` | `option<string>` | The agent's project folder, when it has one. | ### `types.view-opened` *record* A view was opened. ```wit record view-opened { view: view-id, tile: string, content: option<content>, } ``` | Field | Type | Description | |---|---|---| | `view` | `view-id` | The new view's id. | | `tile` | `string` | Which of the manifest's tiles it shows. | | `content` | `option<content>` | What it was opened with, if anything. | ### `types.view-content` *record* An open view was given new content. ```wit record view-content { view: view-id, content: content, } ``` | Field | Type | Description | |---|---|---| | `view` | `view-id` | The view. | | `content` | `content` | Its content now. | ### `types.handler` *type* A function of the tile, by number. The tile chooses the numbers when it renders, keeps the function they stand for, and gets the number back in the event when the user acts. A number from an older frame may still arrive once after a render; a tile ignores numbers it no longer knows. ```wit type handler = u32; ``` ### `types.timer-id` *type* A timer, by the number `tasks.timer` gave. ```wit type timer-id = u32; ``` ### `types.host-error` *variant* Why a host call didn't do what was asked. ```wit variant host-error { denied, busy, too-large, invalid(string), failed(string), } ``` | Case | Payload | Description | |---|---|---| | `denied` | | The tile isn't granted the permission this needs. | | `busy` | | Too many calls or things at once (over 200 host calls a second, or 32 timers); try again later. | | `too-large` | | Over a size limit or a quota; the limits are in each function's documentation. | | `invalid` | `string` | An argument isn't valid; the text says which and why. | | `failed` | `string` | The host couldn't do it (for example a disk error); the text says what happened. | ### `types.token` *enum* A colour of Pitwall's theme, by meaning. Each has a light and a dark value; the user's theme decides which is drawn. ```wit enum token { bg, surface, surface-2, surface-3, raised, line, line-strong, text, text-2, text-3, text-4, focus, good, good-soft, warn, warn-soft, bad, bad-soft, done, done-soft, diff-add-bg, diff-del-bg, } ``` | Case | Description | |---|---| | `bg` | The window's background, behind tiles. | | `surface` | A tile's own background. | | `surface-2` | A raised area inside a tile: a header, a selected row. | | `surface-3` | A further raised area: a hovered selected row, a field. | | `raised` | Floating surfaces: menus, popovers. | | `line` | Hairlines and borders. | | `line-strong` | Stronger borders: a focused field, a divider that must be seen. | | `text` | Main text. | | `text-2` | Secondary text: details, labels. | | `text-3` | Muted text: hints, timestamps. | | `text-4` | Faint text: placeholders, disabled. | | `focus` | The focus ring. | | `good` | Success: passed, running well. | | `good-soft` | A soft background for good things. | | `warn` | Needs attention. | | `warn-soft` | A soft background for warnings. | | `bad` | Failed, destructive. | | `bad-soft` | A soft background for failures. | | `done` | Finished. | | `done-soft` | A soft background for finished things. | | `diff-add-bg` | The background of an added line in a diff. | | `diff-del-bg` | The background of a removed line in a diff. | ### `types.length` *variant* A length. ```wit variant length { px(f32), rem(f32), fraction(f32), auto, } ``` | Case | Payload | Description | |---|---|---| | `px` | `f32` | Logical pixels (they scale with the display). | | `rem` | `f32` | Multiples of Pitwall's base text size, so the length follows the user's font size. | | `fraction` | `f32` | A fraction of the parent's size, from 0.0 to 1.0. | | `auto` | | Whatever the content needs. | ### `types.edges` *record* A length for each side, for padding, margin and borders. ```wit record edges { top: length, right: length, bottom: length, left: length, } ``` | Field | Type | Description | |---|---|---| | `top` | `length` | The top side. | | `right` | `length` | The right side. | | `bottom` | `length` | The bottom side. | | `left` | `length` | The left side. | ### `types.text-size` *enum* Pitwall's text sizes. ```wit enum text-size { xs, sm, md, lg, xl, } ``` | Case | Description | |---|---| | `xs` | The smallest: badges, counts. | | `sm` | Small: details, labels. | | `md` | The body size. | | `lg` | Headings inside a tile. | | `xl` | Large headings. | ### `types.font` *enum* Pitwall's fonts. ```wit enum font { ui, mono, } ``` | Case | Description | |---|---| | `ui` | The interface font. | | `mono` | The monospace font, for code and numbers that line up. | ### `types.weight` *enum* Text weight. ```wit enum weight { normal, medium, semibold, bold, } ``` | Case | Description | |---|---| | `normal` | Regular text. | | `medium` | Slightly heavier: labels. | | `semibold` | Headings. | | `bold` | Strong emphasis. | ### `types.radius` *enum* Pitwall's corner radii. ```wit enum radius { square, sm, md, lg, full, } ``` | Case | Description | |---|---| | `square` | Square corners. | | `sm` | Small (4 px). | | `md` | The usual radius (6 px). | | `lg` | Large (10 px). | | `full` | Fully round: pills and circles. | ### `types.align` *enum* How children line up across a flex box's main direction. ```wit enum align { start, center, end, stretch, baseline, } ``` | Case | Description | |---|---| | `start` | At the start. | | `center` | Centred. | | `end` | At the end. | | `stretch` | Stretched to fill. | | `baseline` | Along their text's baseline. | ### `types.justify` *enum* How children are spread along a flex box's main direction. ```wit enum justify { start, center, end, space-between, space-around, } ``` | Case | Description | |---|---| | `start` | Packed at the start. | | `center` | Packed in the centre. | | `end` | Packed at the end. | | `space-between` | The first at the start, the last at the end, equal space between. | | `space-around` | Equal space around each. | ### `types.overflow` *enum* What happens to content larger than its box. ```wit enum overflow { visible, hidden, scroll, } ``` | Case | Description | |---|---| | `visible` | It shows outside the box. | | `hidden` | It is cut off at the box's edge. | | `scroll` | The box scrolls (prefer the `scroll` element, which keeps its position across frames). | ### `types.cursor` *enum* The pointer's shape over a node. ```wit enum cursor { default, pointer, text, } ``` | Case | Description | |---|---| | `default` | The usual arrow. | | `pointer` | A hand: something clickable. | | `text` | A text cursor: selectable text. | ### `types.style` *variant* One style of a node. A node has a list of these; a later entry wins over an earlier one of the same kind. Layout is flexbox, as in CSS. ```wit variant style { flex-row, flex-col, wrap, grow(f32), shrink(f32), gap(length), padding(edges), margin(edges), width(length), height(length), min-width(length), max-width(length), min-height(length), max-height(length), align-items(align), justify(justify), self-align(align), overflow-x(overflow), overflow-y(overflow), border(edges), border-color(token), radius(radius), background(token), color(token), opacity(f32), text-size(text-size), font(font), weight(weight), italic, underline, truncate, line-clamp(u8), selectable, hover-background(token), cursor(cursor), group(string), visible-on-group-hover(string), drag(drag-source), drop-target(drop-target), } ``` | Case | Payload | Description | |---|---|---| | `flex-row` | | Lay children out in a row. | | `flex-col` | | Lay children out in a column (the default for a box). | | `wrap` | | Wrap children onto more lines when they don't fit. | | `grow` | `f32` | Take this share of the free space along the parent's direction. | | `shrink` | `f32` | Give up this share of the space when there isn't enough. | | `gap` | `length` | Space between children. | | `padding` | `edges` | Space inside the node's border. | | `margin` | `edges` | Space outside the node's border. | | `width` | `length` | Width. | | `height` | `length` | Height. | | `min-width` | `length` | Smallest width. | | `max-width` | `length` | Largest width. | | `min-height` | `length` | Smallest height. | | `max-height` | `length` | Largest height. | | `align-items` | `align` | How children line up across the main direction. | | `justify` | `justify` | How children are spread along the main direction. | | `self-align` | `align` | How this node lines up in its parent, over the parent's `align-items`. | | `overflow-x` | `overflow` | Horizontal overflow. | | `overflow-y` | `overflow` | Vertical overflow. | | `border` | `edges` | Border widths (in px or rem; fractions and auto count as none). | | `border-color` | `token` | Border colour. | | `radius` | `radius` | Corner radius. | | `background` | `token` | Background colour. | | `color` | `token` | Text and icon colour, inherited by children. | | `opacity` | `f32` | Opacity, from 0.0 (invisible) to 1.0. | | `text-size` | `text-size` | Text size, inherited by children. | | `font` | `font` | Font, inherited by children. | | `weight` | `weight` | Text weight, inherited by children. | | `italic` | | Italic text. | | `underline` | | Underlined text. | | `truncate` | | One line, cut with an ellipsis when too long. | | `line-clamp` | `u8` | At most this many lines, the last one cut with an ellipsis. | | `selectable` | | The user can select and copy this text. | | `hover-background` | `token` | Background while the pointer is over the node. | | `cursor` | `cursor` | The pointer's shape over the node. | | `group` | `string` | Names this node a hover group, for `visible-on-group-hover` in the nodes under it (a list row and its actions). Names are the tile's own; the same name on several rows is fine: each node looks at its nearest ancestor of that name. | | `visible-on-group-hover` | `string` | Hidden until the pointer is over the nearest ancestor `group` of this name (a Delete on a list row that shows on hover). Pitwall draws it on hover with no call into the tile; while hidden it takes no clicks. Keyboard users reach it as usual (show it while the row has focus if it matters). | | `drag` | `drag-source` | The user can drag this node to a node of the same view with a `drop-target` that accepts its kind. Pitwall draws the drag: a chip with the source's label under the pointer. | | `drop-target` | `drop-target` | Drags of the kinds it accepts can be dropped here; Pitwall marks it while one is over it and sends `dropped` with its handler. | ### `types.button-kind` *enum* A button's look, as Pitwall's own buttons. ```wit enum button-kind { primary, ghost, danger, link, } ``` | Case | Description | |---|---| | `primary` | The main action of a tile or a form; one per area. | | `ghost` | An ordinary action: a hairline button (at `small` size: Pitwall's small row and toolbar button). | | `danger` | A destructive action. | | `link` | A button that looks like a link. | ### `types.button-size` *enum* A button's size, apart from its look: any kind comes in both. ```wit enum button-size { regular, small, } ``` | Case | Description | |---|---| | `regular` | The usual height (30 px). | | `small` | Smaller (26 px), for rows, toolbars and a tile's bars. | ### `types.button` *record* A button. Its click arrives as a `click` event for the node's `click` listener. ```wit record button { label: string, kind: button-kind, size: button-size, icon: option<icon>, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | The text on it. | | `kind` | `button-kind` | Its look. | | `size` | `button-size` | Its size. | | `icon` | `option<icon>` | An icon before the label. | | `disabled` | `bool` | Drawn dimmed, and clicks aren't sent. | ### `types.icon` *variant* An icon. Drawn in the node's text colour (`color` style), at the node's text size unless it has a width and height. ```wit variant icon { named(string), } ``` | Case | Payload | Description | |---|---|---| | `named` | `string` | One of Pitwall's icons by name: `sidebar`, `search`, `gear`, `plus`, `x`, `send`, `stop`, `restart`, `refresh`, `trash`, `branch`, `folder`, `chevron`, `grid`, `wall`, `maximize`, `restore`, `window`, `more`, `review`, `terminal`, `file`, `expand`, `copy`, `chevron-down`, `check`, `headset`, `user`, `laptop`, `server`, `eye`, `external`, `image`, `browser`, `back`, `phone`, `inspect`, `page-right`, `page-left`, `page-below`, `pin`, `grip`, `minus`, `chevron-up`, `lock`, `alert`, `extension`, `inbox`, `bell`, `chat`, `list` (the SDK's `Icon` enum). An unknown name draws nothing; the test harness notes it. | ### `types.axis` *enum* The directions a `scroll` element scrolls in. ```wit enum axis { vertical, horizontal, both, } ``` | Case | Description | |---|---| | `vertical` | Up and down. | | `horizontal` | Left and right. | | `both` | Both. | ### `types.scroll` *record* A scrolling container: its children scroll inside it. Pitwall keeps its position by key path across frames and draws its scrollbars. ```wit record scroll { axis: axis, } ``` | Field | Type | Description | |---|---|---| | `axis` | `axis` | Which ways it scrolls. | ### `types.text-range` *record* A range of a text field's value, in UTF-8 byte offsets (`start` ≤ `end`; equal for a bare cursor). ```wit record text-range { start: u32, end: u32, } ``` | Field | Type | Description | |---|---|---| | `start` | `u32` | Where it starts. | | `end` | `u32` | Where it ends (exclusive). | ### `types.input` *record* A text field: one line, or several (`multiline`). Its font is the node's `font` style (`mono` for code), its text size the node's `text-size`. **Pitwall owns the value.** Typing, selection, undo and IME are handled by Pitwall, so they never wait for the tile, and the text is kept by key path across frames. The tile hears about edits afterwards (`input-changed`, `input-selected`) and doesn't send the text back in each frame: `value` is `none` in a frame unless the tile wants to replace the text. So a large text (up to 1 MiB) crosses the boundary only when it changes, not in every frame. Enter submits a one-line field. In a multi-line field Enter adds a line and ⌘Enter (Ctrl+Enter off macOS) submits, as in Pitwall's own text fields; while such a field has focus, ⌘Enter is the field's and doesn't maximise the tile (ui.md §3.5). ```wit record input { value: option<string>, revision: u64, selection: option<text-range>, placeholder: option<string>, multiline: bool, rows: option<u16>, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `value` | `option<string>` | Text to put in the field, replacing what it holds; `none` keeps what it holds (the usual case). Applied only when `revision` is newer than the revision of the user's latest edit, so a frame built before an edit arrived never undoes it. The first frame that has the field gives its starting text here. | | `revision` | `u64` | The revision of `value`: the revision of the last `input-changed` the tile has seen (0 at first), plus one. Ignored when `value` is `none`. | | `selection` | `option<text-range>` | Where to put the cursor or selection when `value` is applied (`none`: at the end). | | `placeholder` | `option<string>` | Shown in faint text while it is empty. | | `multiline` | `bool` | Several lines. | | `rows` | `option<u16>` | For a multi-line field, its height in lines when its node has no height style (`none`: 3). It scrolls past that. | | `disabled` | `bool` | Drawn dimmed and can't be edited. | ### `types.virtual-list` *record* A list too long to send whole: the frame names how many rows there are and how tall each is, and Pitwall asks the tile for the rows it is about to show with `guest.rows`, a page at a time, as the user scrolls (runtime.md §2.7). Drawn with Pitwall's own list: only the rows in sight are laid out, so 100 000 rows scroll as smoothly as 100. A click selects a row, a double click or Enter activates it, and Up, Down, Home, End, Page Up and Page Down move the selection while the list has focus (each sends `select`). ```wit record virtual-list { count: u32, row-height: f32, revision: u64, selected: list<string>, } ``` | Field | Type | Description | |---|---|---| | `count` | `u32` | How many rows (at most 1 000 000). | | `row-height` | `f32` | Each row's height, in logical pixels (12–200); every row has it. | | `revision` | `u64` | Moves when rows Pitwall already has may be out of date: it asks for the rows in sight again, and keeps showing the old ones until they arrive, so nothing flickers. | | `selected` | `list<string>` | The selected rows' keys (`row.key`), drawn selected. | ### `types.row` *record* A row of a virtual list, table or tree, as `guest.rows` returns it. ```wit record row { key: string, nodes: list<node>, depth: u16, expanded: option<bool>, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | The row's item, stable while the item is the same (an id, not its index): selection and events name it. At most 128 bytes. | | `nodes` | `list<node>` | What the row shows: a small tree as in a frame (node 0 is the row's root, filling the row). Boxes, text, icons, buttons, images, context menus, badges, avatars and relative times only (no fields, scrolls or nested lists); at most 64 nodes. In a table, the root's children are the cells, one per column in order. | | `depth` | `u16` | A tree's row: how deep it is (0 at the top); 0 elsewhere. | | `expanded` | `option<bool>` | A tree's row: `none` for a leaf, `some(true)` for an open branch, `some(false)` for a closed one. `none` elsewhere. | ### `types.sort-direction` *enum* Which way a table column is sorted. ```wit enum sort-direction { ascending, descending, } ``` ### `types.column` *record* A table's column. ```wit record column { key: string, title: string, width: option<f32>, align: align, sortable: bool, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, unique in the table; events name it. | | `title` | `string` | Its title in the header. | | `width` | `option<f32>` | Its width in logical pixels (`none`: it shares the room left with the other columns without one). The user can drag a column's edge; Pitwall then keeps their width until this value changes, and sends `column-resized`. | | `align` | `align` | Its cells' alignment across: `start`, `center` or `end`. | | `sortable` | `bool` | Its header can be clicked to sort (sends `sort`). | ### `types.sort-state` *record* A table's sort: by which column, which way. ```wit record sort-state { column: string, direction: sort-direction, } ``` ### `types.table` *record* A table: a header of columns over a virtual list of rows, whose roots' children are the cells. Columns can be resized and sorted; rows are selected as in a virtual list. ```wit record table { columns: list<column>, sort: option<sort-state>, rows: virtual-list, } ``` | Field | Type | Description | |---|---|---| | `columns` | `list<column>` | | | `sort` | `option<sort-state>` | The column sorted by and how, drawn with an arrow in its header. | | `rows` | `virtual-list` | The rows: count, height, revision, selection. | ### `types.tree` *record* A tree: a virtual list of the open nodes, flattened in order, each row with its depth and whether it is a branch (`row.depth`, `row.expanded`). Pitwall draws the indent and the disclosure chevron; a click on the chevron, Left or Right, or a double click on a branch sends `toggle`; the tile opens or closes it and renders again with the new count. ```wit record tree { rows: virtual-list, } ``` ### `types.tab` *record* One tab of a tab strip. ```wit record tab { key: string, label: string, icon: option<icon>, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `select`. | | `label` | `string` | | | `icon` | `option<icon>` | | ### `types.tabs` *record* A row of tabs, drawn as Pitwall's own; the tile shows the selected one's content below it. Choosing a tab sends `select`. ```wit record tabs { items: list<tab>, selected: option<string>, } ``` | Field | Type | Description | |---|---|---| | `items` | `list<tab>` | | | `selected` | `option<string>` | The selected tab's key. | ### `types.select-option` *record* One choice of a select. ```wit record select-option { key: string, label: string, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `select`. | | `label` | `string` | | ### `types.select` *record* A dropdown, drawn as Pitwall's own: a button showing the choice, opening a list of the options. Choosing one sends `select`. ```wit record select { options: list<select-option>, selected: option<string>, placeholder: option<string>, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `options` | `list<select-option>` | | | `selected` | `option<string>` | The chosen option's key. | | `placeholder` | `option<string>` | Shown while nothing is chosen. | | `disabled` | `bool` | | ### `types.menu-item` *record* A choice in a menu. ```wit record menu-item { key: string, label: string, icon: option<icon>, hint: option<string>, disabled: bool, danger: bool, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `select`. | | `label` | `string` | | | `icon` | `option<icon>` | | | `hint` | `option<string>` | A shortcut shown at its right, as text (`"⌘D"`). Only shown: bind the key in the frame's keymap. | | `disabled` | `bool` | Drawn dimmed and can't be chosen. | | `danger` | `bool` | A destructive choice, drawn in red. | ### `types.menu-entry` *variant* A line of a menu. ```wit variant menu-entry { item(menu-item), separator, } ``` | Case | Payload | Description | |---|---|---| | `item` | `menu-item` | | | `separator` | | A thin line between groups of items. | ### `types.menu-button` *record* A button that opens a menu under it, drawn by Pitwall with its own menus' look. Choosing an item sends `select`. An empty label with an icon makes a small square icon button (give the node a `label`). ```wit record menu-button { label: string, icon: option<icon>, entries: list<menu-entry>, disabled: bool, } ``` ### `types.markdown` *record* Markdown, drawn as Pitwall's own Preview draws it (headings, lists, task lists, tables, code with highlighting, quotes), and inert: no HTML runs, no image or link is fetched. A link click is `link` (with no `link` listener, web and mail links open in the browser and others do nothing); a task's checkbox click is `toggle` with its line (with no `toggle` listener, checkboxes can't be clicked). At most 1 MiB. ```wit record markdown { text: string, } ``` ### `types.image-fit` *enum* How an image fills its box. ```wit enum image-fit { contain, cover, fill, } ``` | Case | Description | |---|---| | `contain` | Whole, as large as fits. | | `cover` | Filling the box, cut at the edges. | | `fill` | Stretched to the box. | ### `types.image-source` *variant* Where an image's bytes come from. ```wit variant image-source { asset(string), data(string), } ``` | Case | Payload | Description | |---|---|---| | `asset` | `string` | A file in the extension's folder, by its path there (`"assets/logo.png"`): PNG, JPEG, GIF, WebP or SVG, at most 16 MiB. | | `data` | `string` | Bytes the tile handed over with `ui.put-image` under this name. | ### `types.image` *record* An image, sized by the node's styles (without a width, as wide as its box). Images never come from the network. The node's `label` is read as its description. ```wit record image { source: image-source, fit: image-fit, } ``` ### `types.setting-field` *record* A setting edited and saved by Pitwall. The component names only its schema key, never its displayed value or the user's typed text. ```wit record setting-field { key: string, placeholder: option<string>, } ``` ### `types.secret-field` *record* What a node is. A host-owned field: its value never crosses into the component. ```wit record secret-field { key: string, placeholder: option<string>, } ``` ### `types.element` *variant* ```wit variant element { box, text(string), button(button), icon(icon), scroll(scroll), input(input), canvas(canvas), code-view(code-view), diff-view(diff-view), virtual-list(virtual-list), table(table), tree(tree), tabs(tabs), select(select), menu-button(menu-button), context-menu(list<menu-entry>), markdown(markdown), image(image), checkbox(check), switch(check), radio-group(choice-group), segmented(choice-group), slider(slider), number-field(number-field), search-field(search-field), form-row(form-row), progress(progress), spinner, skeleton(skeleton), empty-state(empty-state), banner(banner), badge(badge), chip(chip), kbd(string), split(split), disclosure(disclosure), card(card), divider(orientation), breadcrumbs(list<crumb>), toolbar, popover(popover), confirm-sheet(confirm-sheet), key-values(list<key-value>), avatar(avatar), relative-time(relative-time), copyable(copyable), link(link), sparkline(sparkline), bar-chart(bar-chart), line-chart(line-chart), status-timeline(status-timeline), secret-field(secret-field), setting-field(setting-field), } ``` | Case | Payload | Description | |---|---|---| | `box` | | A box: a flex container with no look of its own beyond its styles. The usual root. | | `text` | `string` | Text. A text node whose children are text nodes draws them as inline runs of one paragraph (each run with its own styles), so `"Built in "` + bold `"3 s"` wrap as one line of text. | | `button` | `button` | A button. | | `icon` | `icon` | An icon. | | `scroll` | `scroll` | A scrolling container. | | `input` | `input` | A text field. | | `canvas` | `canvas` | A drawing: shapes, lines and text the tile places itself, with clickable regions over them. Give it a size (width and height, or grow). | | `code-view` | `code-view` | Pitwall's read-only code view, with the text the tile gives: highlighting, line numbers, selection and copy, Find. | | `diff-view` | `diff-view` | Pitwall's diff view of two versions of a text, as Review draws it. | | `virtual-list` | `virtual-list` | A long list, its rows fetched as they come into sight. | | `table` | `table` | A table: columns over a virtual list of rows. | | `tree` | `tree` | A tree: a virtual list of the open nodes. | | `tabs` | `tabs` | A row of tabs. | | `select` | `select` | A dropdown. | | `menu-button` | `menu-button` | A button that opens a menu. | | `context-menu` | `list<menu-entry>` | The menu a right-click opens on this node's parent, drawn by Pitwall. Not drawn in place; a parent has at most one. Choosing an item sends `select` with this node's `select` handler. | | `markdown` | `markdown` | Markdown, drawn and inert. | | `image` | `image` | An image. | | `checkbox` | `check` | A checkbox with its label. | | `switch` | `check` | A switch (an on/off toggle) with its label. | | `radio-group` | `choice-group` | A group of radio buttons: one of several choices. | | `segmented` | `choice-group` | A segmented control: one of a few choices, side by side. | | `slider` | `slider` | A slider: a number in a range, dragged or moved with the keys. | | `number-field` | `number-field` | A number field with − and + steps. | | `search-field` | `search-field` | A search field: a text field with a magnifier and a clear button. | | `form-row` | `form-row` | A form row: a label over (or beside) the control under it, with help text, a validation message and a required mark. | | `progress` | `progress` | A progress bar, with a known share done or still going. | | `spinner` | | A spinning ring: something is loading. | | `skeleton` | `skeleton` | A grey placeholder where content is loading. | | `empty-state` | `empty-state` | An empty state: an icon, a title, a line of text and an action. | | `banner` | `banner` | An inline banner: information, success, a warning or an error. | | `badge` | `badge` | A small count or status label. | | `chip` | `chip` | A chip (a tag): a label that can be picked or removed. | | `kbd` | `string` | A key or shortcut, drawn as Pitwall draws its own (`cmd-k`: ⌘K). | | `split` | `split` | Two panes with a bar between them the user drags. | | `disclosure` | `disclosure` | A section with a header that opens and closes it. | | `card` | `card` | A card: a bordered box, with a title. | | `divider` | `orientation` | A thin line between things. | | `breadcrumbs` | `list<crumb>` | Breadcrumbs: where the user is, each level clickable. | | `toolbar` | | A toolbar row: Pitwall's bar look for the buttons and fields in it. | | `popover` | `popover` | A popover anchored to its parent node, drawn by Pitwall. | | `confirm-sheet` | `confirm-sheet` | A sheet over the tile asking the user to confirm. | | `key-values` | `list<key-value>` | A list of labels and their values. | | `avatar` | `avatar` | An avatar: a person's initials in a circle. | | `relative-time` | `relative-time` | A time drawn as "5 min ago", kept up to date by Pitwall. | | `copyable` | `copyable` | Text with a button that copies it. | | `link` | `link` | A link: opens a web page, or tells the tile. | | `sparkline` | `sparkline` | A small line chart without axes, inline with text. | | `bar-chart` | `bar-chart` | A bar chart. | | `line-chart` | `line-chart` | A line chart with axes. | | `status-timeline` | `status-timeline` | A row of coloured segments, one per run (CI runs, deploys). | | `secret-field` | `secret-field` | A secret kept by the host, never delivered as input text. | | `setting-field` | `setting-field` | Host-owned setting editor (including keys which grant access). | ### `types.listen` *enum* The events a node can ask for, each with the handler it should carry. ```wit enum listen { click, change, select, submit, scroll, hover, pointer, wheel, line-click, toggle, link, sort, column-resized, value, dismiss, } ``` | Case | Description | |---|---| | `click` | A click (or Space or Enter while the node has focus). Buttons and any other node. | | `change` | A text field's value changed. | | `select` | A text field's cursor or selection moved without its value changing. | | `submit` | Enter (⌘Enter when multi-line) in a text field. | | `scroll` | A scroll container was scrolled (for loading more at the end). | | `hover` | The pointer entered or left the node. | | `pointer` | Pointer presses, releases and moves over the node, with their position (for drawing and dragging inside a node). | | `wheel` | The wheel or trackpad scrolled, or a pinch, over the node: sent as `pointer` events with the `wheel` and `pinch` kinds, carrying the `wheel` listener's handler. A node listening for it takes the wheel, so a scroll container around it doesn't scroll. | | `line-click` | A click on a line number of a code or diff view. | | `toggle` | A tree's branch opened or closed; a Markdown task's checkbox clicked. | | `link` | A link in Markdown clicked. | | `sort` | A table's header clicked to sort. | | `column-resized` | A table's column resized by the user. | | `value` | A control's value changed: a checkbox, switch, radio group, segmented control, slider, number field, disclosure, split, breadcrumb or status timeline (`value-changed`). | | `dismiss` | The user closed or removed it: a banner, a chip, a popover, a confirm sheet's Cancel (`dismissed`). | ### `types.listener` *record* An event a node asks for, and the handler it should carry. ```wit record listener { on: listen, handler: handler, } ``` | Field | Type | Description | |---|---|---| | `on` | `listen` | Which event. | | `handler` | `handler` | The handler it carries. | ### `types.node` *record* One node of a frame. ```wit record node { parent: option<u32>, key: string, element: element, style: list<style>, on: list<listener>, focusable: bool, tooltip: option<string>, label: option<string>, } ``` | Field | Type | Description | |---|---|---| | `parent` | `option<u32>` | The parent's index in `frame.nodes`: always lower than this node's own. `none` only for the first node, the root. | | `key` | `string` | Stable among its siblings: Pitwall matches nodes across frames by key path (the keys from the root down), so a node keeps its scroll position, focus and typed text while its key path stays the same. Unique among siblings; at most 128 bytes. | | `element` | `element` | What it is. | | `style` | `list<style>` | How it looks and lays out. | | `on` | `list<listener>` | The events it wants. | | `focusable` | `bool` | It can take keyboard focus (Tab moves among focusable nodes in tree order). Buttons and text fields are focusable whatever this says. | | `tooltip` | `option<string>` | Text shown when the pointer rests on it. | | `label` | `option<string>` | Its accessible name, read by screen readers. Required for a button with only an icon. | ### `types.binding` *record* A key binding the tile handles while it has focus. Pitwall's own keys are reserved: a frame that binds one has that binding dropped, with a line in the tile's Log. They are `escape`, `tab`, `shift-tab`, `ctrl-enter`; `cmd-` with any of `enter`, `0`–`9`, `=`, `+`, `-`, `,`, `a`, `b`, `c`, `e`, `h`, `i`, `j`, `k`, `l`, `m`, `n`, `p`, `q`, `r`, `t`, `v`, `w`, `x`, `z`, alone or with `shift` (Pitwall's shortcuts are Ctrl+Shift off macOS); and `cmd-shift-f`, `cmd-alt-h`, `cmd-ctrl-f`, `cmd-shift-alt-` `e`, `n`, `r`, `t`. Modifiers may come in any order. While a text field of the tile has focus, a binding without `cmd`, `ctrl` or `alt` doesn't fire: the key types into the field. ```wit record binding { keys: string, handler: handler, } ``` | Field | Type | Description | |---|---|---| | `keys` | `string` | The keys, as Pitwall writes them: `j`, `enter`, `cmd-s`, `shift-tab`, `/`. `cmd` is ⌘ on macOS and Ctrl elsewhere. | | `handler` | `handler` | The handler a `key` event carries when they are pressed. | ### `types.frame` *record* What a view shows: its whole tree, sent after every change. At most 20 000 nodes and about 2 MiB of data; a larger frame stops the tile. ```wit record frame { nodes: list<node>, focus: option<string>, keymap: list<binding>, } ``` | Field | Type | Description | |---|---|---| | `nodes` | `list<node>` | The nodes, root first, each after its parent. | | `focus` | `option<string>` | The key path (keys from the root down, joined by `/`, without the root's) of the node the tile wants focused. Honoured only while the tile already has focus, so a tile can't take the keyboard from a terminal. | | `keymap` | `list<binding>` | The keys the tile handles while it has focus. | ### `types.modifiers` *flags* Keys held during a click. ```wit flags modifiers { shift, ctrl, alt, platform, } ``` | Flag | Description | |---|---| | `shift` | Shift. | | `ctrl` | Control. | | `alt` | Option on macOS, Alt elsewhere. | | `platform` | ⌘ on macOS, the Windows key or Super elsewhere. | ### `types.mouse-button` *enum* Which mouse button. ```wit enum mouse-button { left, right, middle, } ``` | Case | Description | |---|---| | `left` | The main button. | | `right` | The secondary button. | | `middle` | The middle button or wheel. | ### `types.point` *record* A point in a node, in logical pixels from the node's top-left corner. ```wit record point { x: f32, y: f32, } ``` | Field | Type | Description | |---|---|---| | `x` | `f32` | From the left edge. | | `y` | `f32` | From the top edge. | ### `types.click` *record* A click. ```wit record click { handler: handler, button: mouse-button, modifiers: modifiers, count: u32, at: point, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the node's `click` listener. | | `button` | `mouse-button` | Which button. | | `modifiers` | `modifiers` | Keys held. | | `count` | `u32` | 1 for a single click, 2 for a double click, and so on. | | `at` | `point` | Where in the node (for a click from the keyboard: its centre). | ### `types.pointer-kind` *variant* What the pointer did. Later versions add cases at the end (a wheel, a pinch) without breaking tiles built for this one; a tile ignores cases it doesn't know. ```wit variant pointer-kind { down(mouse-button), up(mouse-button), move, wheel(delta), pinch(f32), } ``` | Case | Payload | Description | |---|---|---| | `down` | `mouse-button` | A button went down. | | `up` | `mouse-button` | A button came up. | | `move` | | The pointer moved (coalesced: the newest position). | | `wheel` | `delta` | The wheel or a trackpad scrolled by this many pixels (positive `y`: the content moves up, as scrolling down; positive `x`: scrolling right). For a node with a `wheel` listener. | | `pinch` | `f32` | A trackpad pinch: zoom by this fraction (0.1: 10 % larger; -0.1: smaller), around `at`. For a node with a `wheel` listener. | ### `types.pointer-event` *record* A pointer event over a node with a `pointer` listener. While a button is held after a `down` on the node, its moves and the `up` go to the same node even outside it (positions may then be negative or past its size). ```wit record pointer-event { handler: handler, kind: pointer-kind, at: point, modifiers: modifiers, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the node's `pointer` listener. | | `kind` | `pointer-kind` | What happened. | | `at` | `point` | Where, from the node's top-left corner. | | `modifiers` | `modifiers` | Keys held. | ### `types.input-change` *record* A text field's new value. ```wit record input-change { handler: handler, value: string, revision: u64, selection: text-range, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the field's `change` listener. | | `value` | `string` | What the field holds now. | | `revision` | `u64` | The edit's revision. To replace the text later, send `input.revision` above it (runtime.md §2.4). | | `selection` | `text-range` | The cursor or selection after the edit. | ### `types.input-selection` *record* A text field's cursor or selection moved, its value unchanged. ```wit record input-selection { handler: handler, selection: text-range, revision: u64, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the field's `select` listener. | | `selection` | `text-range` | The cursor or selection now, in the value of the field's latest `input-changed` (or the value the tile last set). | | `revision` | `u64` | The revision of the value it applies to. | ### `types.key-event` *record* A key binding fired. ```wit record key-event { handler: handler, keys: string, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The binding's handler. | | `keys` | `string` | The binding's keys, as written in the keymap. | ### `types.scroll-position` *record* Where a scroll container is scrolled to. ```wit record scroll-position { handler: handler, x: f32, y: f32, content-width: f32, content-height: f32, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of its `scroll` listener. | | `x` | `f32` | Pixels scrolled from the left. | | `y` | `f32` | Pixels scrolled from the top. | | `content-width` | `f32` | The content's width, in pixels. | | `content-height` | `f32` | The content's height, in pixels. | ### `types.hover` *record* The pointer entered or left a node. ```wit record hover { handler: handler, inside: bool, at: point, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the node's `hover` listener. | | `inside` | `bool` | True when it entered, false when it left. | | `at` | `point` | Where, from the node's top-left corner. | ### `types.size` *record* A size in logical pixels. ```wit record size { width: f32, height: f32, } ``` | Field | Type | Description | |---|---|---| | `width` | `f32` | Width. | | `height` | `f32` | Height. | ### `types.view-size` *record* A view's new size. ```wit record view-size { view: view-id, size: size, } ``` | Field | Type | Description | |---|---|---| | `view` | `view-id` | The view. | | `size` | `size` | Its size now. | ### `types.node-focus` *record* Which node of a view has keyboard focus now. ```wit record node-focus { view: view-id, key-path: option<string>, } ``` | Field | Type | Description | |---|---|---| | `view` | `view-id` | The view. | | `key-path` | `option<string>` | The focused node's key path (keys from the root down, joined by `/`, without the root's, as `frame.focus`), or `none` when no node of the view has focus (the tile itself may still have it). | ### `types.theme-mode` *enum* Light or dark. ```wit enum theme-mode { light, dark, } ``` | Case | Description | |---|---| | `light` | The light theme. | | `dark` | The dark theme. | ### `types.density` *enum* How much space Pitwall puts around things (Settings → Appearance). ```wit enum density { comfortable, compact, dense, } ``` | Case | Description | |---|---| | `comfortable` | The most space. | | `compact` | The default. | | `dense` | The least space. | ### `types.theme-info` *record* The user's appearance settings that matter to a tile. ```wit record theme-info { mode: theme-mode, density: density, reduce-motion: bool, } ``` | Field | Type | Description | |---|---|---| | `mode` | `theme-mode` | Light or dark. | | `density` | `density` | How much space to leave. | | `reduce-motion` | `bool` | The user asked for less motion: don't animate. | ### `types.tone` *enum* A toast's tone. ```wit enum tone { info, good, warn, bad, } ``` | Case | Description | |---|---| | `info` | Neutral news. | | `good` | Something worked. | | `warn` | Something needs attention. | | `bad` | Something failed. | ### `types.selection` *record* A row, tab, option or menu item chosen (`select`): in a virtual list, table or tree, a row clicked or moved to with the keys; in tabs, a select or a menu, the item chosen. ```wit record selection { handler: handler, key: string, index: u32, modifiers: modifiers, activate: bool, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | | | `key` | `string` | The item's key: the row's, tab's, option's or menu item's. | | `index` | `u32` | The row's index (lists, tables, trees), or the item's place among its siblings (tabs, options, menu items; separators not counted). | | `modifiers` | `modifiers` | Keys held (⌘/Ctrl or Shift, to add to a selection). | | `activate` | `bool` | The row was activated: a double click, or Enter. | ### `types.toggled` *record* A tree's branch opened or closed, or a Markdown task ticked (`toggle`). ```wit record toggled { handler: handler, key: string, index: u32, on: bool, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | | | `key` | `string` | A tree: the row's key. Markdown: empty. | | `index` | `u32` | A tree: the row's index. Markdown: the task's line in the text (0-based). | | `on` | `bool` | Open (or ticked) now. | ### `types.link-click` *record* A link in Markdown clicked (`link`). ```wit record link-click { handler: handler, url: string, modifiers: modifiers, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | | | `url` | `string` | The link's target as written. | | `modifiers` | `modifiers` | | ### `types.sort-change` *record* A table's header clicked to sort (`sort`): the column, and the direction asked for (the other way when it was sorted by it). ```wit record sort-change { handler: handler, column: string, direction: sort-direction, } ``` ### `types.column-width` *record* A table's column resized by the user (`column-resized`), when the drag ends. ```wit record column-width { handler: handler, column: string, width: f32, } ``` ### `types.secret-change` *record* Something that happened, sent to `guest.handle`. A secret was saved or removed, without its value. ```wit record secret-change { key: string, set: bool, } ``` ### `types.program-env-value` *variant* References passed to a native program. Secret text never enters Wasm. ```wit variant program-env-value { text(string), secret(string), } ``` ### `types.program-env-var` *record* ```wit record program-env-var { name: string, value: program-env-value, } ``` ### `types.program-command` *record* ```wit record program-command { program: string, args: list<string>, env: list<program-env-var>, cwd: option<string>, private-output: bool, } ``` | Field | Type | Description | |---|---|---| | `program` | `string` | | | `args` | `list<string>` | | | `env` | `list<program-env-var>` | | | `cwd` | `option<string>` | | | `private-output` | `bool` | Return output once, without retaining it in Log or Debug. | ### `types.program-state` *enum* ```wit enum program-state { asking, starting, running, exited, failed, stopped, denied, } ``` ### `types.program-status` *record* ```wit record program-status { state: program-state, pid: option<u32>, exit: option<s32>, why: option<string>, } ``` ### `types.program-changed` *record* ```wit record program-changed { name: string, status: program-status, } ``` ### `types.program-finished` *record* ```wit record program-finished { task: u32, exit: option<s32>, stdout: string, stderr: string, private-output: bool, } ``` ### `types.program-downloaded` *record* ```wit record program-downloaded { task: u32, outcome: result<string, string>, } ``` ### `types.event` *variant* ```wit variant event { click(click), input-changed(input-change), input-selected(input-selection), submit(handler), key(key-event), scroll(scroll-position), hover(hover), pointer(pointer-event), resize(view-size), visibility(bool), focus(bool), focus-changed(node-focus), theme(theme-info), timer(timer-id), settings-changed(option<string>), grants-changed(list<string>), view-opened(view-opened), view-content(view-content), view-closed(view-id), dropped(drop-event), line-clicked(line-click), code-selected(code-selection), agents-changed, ask-answered(ask-answer), select(selection), toggle(toggled), link(link-click), sort(sort-change), column-resized(column-width), fetched(fetched), toolbar-clicked(option<string>), service-changed(service-info), value-changed(value-change), dismissed(handler), undo-present(u64), tool-cancelled(u64), files-changed(files-changed), project-changed(view-id), secret-changed(secret-change), program-changed(program-changed), program-finished(program-finished), download-finished(program-downloaded), } ``` | Case | Payload | Description | |---|---|---| | `click` | `click` | A node with a `click` listener was clicked. | | `input-changed` | `input-change` | A text field's value changed. Changes are coalesced: several between two calls arrive as one with the newest value, and Pitwall sends at most one per field every 50 ms while the user types, plus one when the field loses focus or submits, so a large text isn't sent on every keystroke. | | `input-selected` | `input-selection` | A text field with a `select` listener moved its cursor or selection without changing its value (coalesced: the newest). | | `submit` | `handler` | Enter in a text field with a `submit` listener; carries its handler. | | `key` | `key-event` | A key binding of the frame's keymap fired. | | `scroll` | `scroll-position` | A scroll container with a `scroll` listener moved (coalesced: the newest position). | | `hover` | `hover` | The pointer entered or left a node with a `hover` listener. | | `pointer` | `pointer-event` | A press, release or move over a node with a `pointer` listener. | | `resize` | `view-size` | A view's size changed (coalesced: the newest size). | | `visibility` | `bool` | The tile was shown (true) or hidden (false). While hidden, timers pause and nothing is rendered. `visibility(false)` is handled like any event: host calls made while handling it complete (storage writes reach the disk), and suspension starts when `handle` returns; a timer started then waits until the tile is shown. | | `focus` | `bool` | The tile got (true) or lost (false) keyboard focus. | | `focus-changed` | `node-focus` | The focus moved from one node of a view to another (a text field, a focusable node), or off the view's nodes: sent after the move, once per change. Leaving a text field this way is its blur (save what was typed). When the tile loses focus, this comes first with `none`, then `focus(false)`. | | `theme` | `theme-info` | The user changed their appearance settings. | | `timer` | `timer-id` | A timer fired. | | `settings-changed` | `option<string>` | A setting changed: its key, or none for a bulk refresh. Read its value again with `settings.get`. | | `grants-changed` | `list<string>` | The user granted or took back permissions; the list is what is granted now. | | `view-opened` | `view-opened` | A view was opened; its first render follows. Every view gets this, the ones open at start too (right after `init`). | | `view-content` | `view-content` | An open view was given new content (a later call with the same content id); return true to render it again. | | `view-closed` | `view-id` | A view was closed; it is no longer rendered. | | `dropped` | `drop-event` | A drag was dropped on a node with a `drop-target`. | | `line-clicked` | `line-click` | A line number of a code or diff view with a `line-click` listener was clicked. | | `code-selected` | `code-selection` | The selection in a code or diff view with a `select` listener changed (coalesced: the newest, at most one every 100 ms). | | `agents-changed` | | Pitwall's agents changed (one came or went; a name, a state or a Next up changed): read them again with `agents.list`. Only with `agents.read`; changes close together arrive as one. | | `ask-answered` | `ask-answer` | The user answered one of the tile's questions (`asks.set`), in the floating control. Reply with `asks.reply`. | | `select` | `selection` | A row, tab, option or menu item was chosen. | | `toggle` | `toggled` | A tree's branch opened or closed; a Markdown task ticked. | | `link` | `link-click` | A link in Markdown was clicked. | | `sort` | `sort-change` | A table's header was clicked to sort. | | `column-resized` | `column-width` | A table's column was resized. | | `fetched` | `fetched` | The answer to a `net.fetch` request (or why there is none). | | `toolbar-clicked` | `option<string>` | The extension's toolbar button was clicked (its action is `tile` or `popover`): the id of the project whose space the window shows, if any (for a per-project item). | | `service-changed` | `service-info` | The extension's own server changed state (`service.info`). | | `value-changed` | `value-change` | A control with a `value` listener was changed by the user. | | `dismissed` | `handler` | A node with a `dismiss` listener was closed or removed by the user; carries its handler. | | `undo-present` | `u64` | The user pressed Undo on what agent call `u64` (a `present` call's `content.call`) put in the tile: restore what was there before it, or remove the item if the call created it. | | `tool-cancelled` | `u64` | A `read` or `act` call the tile didn't answer in time was given up (the agent was told): stop working on it; a `reply` to it is dropped. | | `files-changed` | `files-changed` | Files changed under a folder the tile watches (`files.watch`). | | `project-changed` | `view-id` | The view with this id is now in another project, or in none (it was moved to another space): read `files.project` again. Its watches on the old project ended. | | `secret-changed` | `secret-change` | A secret was saved or removed by the user. | | `program-changed` | `program-changed` | A supervised program changed state. | | `program-finished` | `program-finished` | A one-shot run ended, with redacted bounded output. | | `download-finished` | `program-downloaded` | A pinned download finished or was refused. | ### `types.init-context` *record* What the tile gets when it starts. ```wit record init-context { extension: string, version: string, theme: theme-info, granted: list<string>, state: option<list<u8>>, } ``` | Field | Type | Description | |---|---|---| | `extension` | `string` | The extension's id. | | `version` | `string` | The extension's version, from its manifest. | | `theme` | `theme-info` | The user's appearance settings. | | `granted` | `list<string>` | The permissions the user granted, by name. | | `state` | `option<list<u8>>` | What `guest.save-state` returned before the tile was last dropped (to save memory while hidden, or for a reload during development); `none` on a fresh start. | ### `types.delta` *record* An amount moved, in logical pixels. ```wit record delta { x: f32, y: f32, } ``` | Field | Type | Description | |---|---|---| | `x` | `f32` | Rightwards. | | `y` | `f32` | Downwards. | ### `types.drag-source` *record* What a node can be dragged as, inside its view. ```wit record drag-source { kind: string, data: string, label: string, } ``` | Field | Type | Description | |---|---|---| | `kind` | `string` | A kind of the tile's own (`"card"`, `"column"`): drop targets name the kinds they accept. | | `data` | `string` | What the drop target gets back (an item's id, JSON). At most 64 KiB. | | `label` | `string` | Shown in the chip under the pointer while dragging. | ### `types.drop-target` *record* A place drags can be dropped on. ```wit record drop-target { accepts: list<string>, handler: handler, } ``` | Field | Type | Description | |---|---|---| | `accepts` | `list<string>` | The kinds of drag it takes (`drag-source.kind`). | | `handler` | `handler` | The handler `dropped` carries. | ### `types.drop-event` *record* A drag dropped on a drop target. ```wit record drop-event { handler: handler, kind: string, data: string, at: point, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The target's handler. | | `kind` | `string` | The dragged node's kind. | | `data` | `string` | The dragged node's data. | | `at` | `point` | Where it was dropped, from the target's top-left corner. | ### `types.paint` *variant* A colour in a canvas: one of the theme's tokens (best: the drawing follows light and dark and the user's theme), or a fixed colour. ```wit variant paint { token(token), rgba(u32), } ``` | Case | Payload | Description | |---|---|---| | `token` | `token` | A theme colour. | | `rgba` | `u32` | A fixed colour, `0xRRGGBBAA`. The same in both themes. | ### `types.rect` *record* A rectangle, in logical pixels. ```wit record rect { x: f32, y: f32, width: f32, height: f32, } ``` | Field | Type | Description | |---|---|---| | `x` | `f32` | Its left edge. | | `y` | `f32` | Its top edge. | | `width` | `f32` | Its width. | | `height` | `f32` | Its height. | ### `types.stroke` *record* How a line is drawn. ```wit record stroke { color: paint, width: f32, dash: list<f32>, } ``` | Field | Type | Description | |---|---|---| | `color` | `paint` | Its colour. | | `width` | `f32` | Its width, in logical pixels (scaled with the canvas's transform). | | `dash` | `list<f32>` | A dash pattern: lengths drawn and left out, in turn (`[4, 3]`); empty for a solid line. At most 16 lengths. | ### `types.draw-rect` *record* A rectangle drawn in a canvas. ```wit record draw-rect { rect: rect, fill: option<paint>, stroke: option<stroke>, radius: f32, } ``` | Field | Type | Description | |---|---|---| | `rect` | `rect` | Where. | | `fill` | `option<paint>` | Its fill, if any. | | `stroke` | `option<stroke>` | Its outline, if any. | | `radius` | `f32` | Its corner radius, in logical pixels. | ### `types.quad-to` *record* A quadratic curve's step. ```wit record quad-to { control: point, to: point, } ``` | Field | Type | Description | |---|---|---| | `control` | `point` | The control point. | | `to` | `point` | Where it ends. | ### `types.cubic-to` *record* A cubic curve's step. ```wit record cubic-to { control1: point, control2: point, to: point, } ``` | Field | Type | Description | |---|---|---| | `control1` | `point` | The first control point. | | `control2` | `point` | The second control point. | | `to` | `point` | Where it ends. | ### `types.path-step` *variant* One step of a path. ```wit variant path-step { move-to(point), line-to(point), quad-to(quad-to), cubic-to(cubic-to), close, } ``` | Case | Payload | Description | |---|---|---| | `move-to` | `point` | Start a new piece here. | | `line-to` | `point` | A straight line to here. | | `quad-to` | `quad-to` | A quadratic curve. | | `cubic-to` | `cubic-to` | A cubic curve. | | `close` | | A line back to the piece's start. | ### `types.draw-path` *record* A path drawn in a canvas: lines and curves, filled or stroked. ```wit record draw-path { steps: list<path-step>, fill: option<paint>, stroke: option<stroke>, } ``` | Field | Type | Description | |---|---|---| | `steps` | `list<path-step>` | Its steps, starting with `move-to`. | | `fill` | `option<paint>` | Its fill, if any. | | `stroke` | `option<stroke>` | Its line, if any. | ### `types.text-align` *enum* Where text lies across its point. ```wit enum text-align { start, center, end, } ``` | Case | Description | |---|---| | `start` | It starts at the point. | | `center` | It is centred on the point. | | `end` | It ends at the point. | ### `types.text-baseline` *enum* Where text lies up and down from its point. ```wit enum text-baseline { top, middle, bottom, } ``` | Case | Description | |---|---| | `top` | Its line's top is at the point. | | `middle` | Its line's middle is at the point. | | `bottom` | Its line's bottom is at the point. | ### `types.draw-text` *record* One line of text drawn in a canvas, shaped by Pitwall in its fonts. ```wit record draw-text { text: string, at: point, size: f32, color: paint, font: font, weight: weight, align: text-align, baseline: text-baseline, max-width: option<f32>, } ``` | Field | Type | Description | |---|---|---| | `text` | `string` | The text (one line: line breaks are drawn as spaces). | | `at` | `point` | Where, as `align` and `baseline` say. | | `size` | `f32` | Its size in logical pixels (scaled with the canvas's transform). Pitwall's body text is 13; its other sizes 11, 12, 16 and 20. | | `color` | `paint` | Its colour. | | `font` | `font` | Its font. | | `weight` | `weight` | Its weight. | | `align` | `text-align` | Across the point. | | `baseline` | `text-baseline` | Up and down from the point. | | `max-width` | `option<f32>` | The widest it may be, in the canvas's coordinates: longer text is cut with an ellipsis. | ### `types.draw-op` *variant* One thing a canvas draws, in order (later on top). ```wit variant draw-op { rect(draw-rect), path(draw-path), text(draw-text), clip-push(rect), clip-pop, } ``` | Case | Payload | Description | |---|---|---| | `rect` | `draw-rect` | A rectangle. | | `path` | `draw-path` | A path. | | `text` | `draw-text` | Text. | | `clip-push` | `rect` | Draw only inside this rectangle until the matching `clip-pop`. | | `clip-pop` | | End the newest `clip-push`. | ### `types.transform` *record* How a canvas's coordinates map to its node: a point (x, y) is drawn at (x × scale + dx, y × scale + dy) from the node's top-left corner. Ops and regions are given in the canvas's coordinates; events come in the node's. ```wit record transform { scale: f32, dx: f32, dy: f32, } ``` | Field | Type | Description | |---|---|---| | `scale` | `f32` | The zoom (1.0: as given). | | `dx` | `f32` | Moved right by this. | | `dy` | `f32` | Moved down by this. | ### `types.hit-region` *record* A clickable area of a canvas, over what it draws: a box of a diagram. Screen readers read its label (accessible structure inside a canvas). ```wit record hit-region { key: string, rect: rect, label: string, tooltip: option<string>, click: option<handler>, hover: option<handler>, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Stable among the canvas's regions, at most 128 bytes. | | `rect` | `rect` | Where, in the canvas's coordinates. | | `label` | `string` | Its accessible name, and its tooltip unless it has one. | | `tooltip` | `option<string>` | Text shown when the pointer rests on it. | | `click` | `option<handler>` | Sent as a `click` event (its `at` from the canvas node's corner). | | `hover` | `option<handler>` | Sent as a `hover` event when the pointer enters or leaves it. | ### `types.canvas` *record* A drawing. At most 20 000 ops and 5 000 regions. ```wit record canvas { ops: list<draw-op>, transform: transform, regions: list<hit-region>, } ``` | Field | Type | Description | |---|---|---| | `ops` | `list<draw-op>` | What it draws, in order. | | `transform` | `transform` | How its coordinates map to the node (zoom and pan). | | `regions` | `list<hit-region>` | Its clickable areas; where they overlap, the last one listed wins. | ### `types.line-range` *record* A range of lines, 0-based (`start` ≤ `end`, `end` exclusive). ```wit record line-range { start: u32, end: u32, } ``` | Field | Type | Description | |---|---|---| | `start` | `u32` | The first line. | | `end` | `u32` | The line after the last. | ### `types.line-mark-kind` *enum* What a line mark says, drawn in the margin as Pitwall's editor marks changes since the last commit. ```wit enum line-mark-kind { added, changed, deleted, error, warning, } ``` | Case | Description | |---|---| | `added` | Added lines (a green bar). | | `changed` | Changed lines (a blue bar). | | `deleted` | Lines were deleted before `start` (a red mark between lines). | | `error` | An error on these lines (a red bar, the lines tinted, its `message` at the end of the first line). | | `warning` | A warning on these lines (a yellow bar, the lines tinted, its `message` at the end of the first line). | ### `types.line-mark` *record* A mark in a code view's margin. ```wit record line-mark { lines: line-range, kind: line-mark-kind, message: option<string>, } ``` | Field | Type | Description | |---|---|---| | `lines` | `line-range` | Which lines. | | `kind` | `line-mark-kind` | What it says. | | `message` | `option<string>` | For an error or a warning: what is wrong, drawn after the first line's text (at most 500 bytes; longer is cut). Ignored for the other kinds. | ### `types.code-view` *record* Pitwall's read-only code view, showing the tile's text. The text is sent in each frame (at most 1 MiB); a frame with the same text and language keeps the user's scroll position and selection. ```wit record code-view { text: string, language: option<string>, marks: list<line-mark>, reveal: option<u32>, } ``` | Field | Type | Description | |---|---|---| | `text` | `string` | The text. | | `language` | `option<string>` | Its language, for highlighting: a name (`rust`, `typescript`, `python`, `markdown`, …) or a file name (`main.rs`); `none` or an unknown one: plain text. | | `marks` | `list<line-mark>` | Marks in the margin. | | `reveal` | `option<u32>` | Scroll this line (0-based) into the middle and put the cursor on it, when it differs from the last frame's. | ### `types.diff-side` *enum* Which version of a diff. ```wit enum diff-side { old, new, } ``` | Case | Description | |---|---| | `old` | The original (left, or the removed lines). | | `new` | The changed version (right, or the added lines). A code view's lines are this side. | ### `types.diff-layout` *enum* How a diff is laid out. ```wit enum diff-layout { side-by-side, inline, } ``` | Case | Description | |---|---| | `side-by-side` | Old on the left, new on the right. | | `inline` | One column, removed lines above added ones. | ### `types.diff-texts` *record* Both versions of a text. ```wit record diff-texts { old: string, new: string, } ``` | Field | Type | Description | |---|---|---| | `old` | `string` | The original. | | `new` | `string` | The changed version. | ### `types.diff-source` *variant* What a diff view compares. ```wit variant diff-source { texts(diff-texts), unified(string), } ``` | Case | Payload | Description | |---|---|---| | `texts` | `diff-texts` | Two whole texts (each at most 1 MiB): unchanged runs fold. | | `unified` | `string` | A unified diff of one file (`git diff` output: `@@` hunks, `+`, `-` and context lines; header lines are skipped), at most 1 MiB. Lines keep their numbers from the hunk headers; what the diff doesn't show is folded. | ### `types.diff-view` *record* Pitwall's diff view, as Review draws a file's changes: line and character changes, folded unchanged runs. ```wit record diff-view { source: diff-source, language: option<string>, layout: diff-layout, reveal: option<u32>, } ``` | Field | Type | Description | |---|---|---| | `source` | `diff-source` | What it compares. | | `language` | `option<string>` | The language, as `code-view.language` takes it. | | `layout` | `diff-layout` | Side by side or inline. | | `reveal` | `option<u32>` | Scroll this line of the new version (0-based) into the middle, when it differs from the last frame's. | ### `types.line-click` *record* A line number of a code or diff view was clicked. ```wit record line-click { handler: handler, side: diff-side, line: u32, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the view's `line-click` listener. | | `side` | `diff-side` | Which version's line (`new` in a code view). | | `line` | `u32` | The line, 0-based. | ### `types.text-pos` *record* A place in a code or diff view's text. ```wit record text-pos { line: u32, column: u32, } ``` | Field | Type | Description | |---|---|---| | `line` | `u32` | The line, 0-based. | | `column` | `u32` | The column, in UTF-8 bytes from the line's start. | ### `types.code-selection` *record* The selection in a code or diff view. ```wit record code-selection { handler: handler, side: diff-side, start: text-pos, end: text-pos, text: string, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the view's `select` listener. | | `side` | `diff-side` | Which version it is in (`new` in a code view). | | `start` | `text-pos` | Where it starts (the earlier end). | | `end` | `text-pos` | Where it ends; equal to `start` for a bare cursor. | | `text` | `string` | The selected text, cut at 64 KiB. | ### `types.ask-answer` *record* An answer to one of the tile's questions (`asks.set`). ```wit record ask-answer { id: string, picks: list<u32>, text: option<string>, declined: bool, } ``` | Field | Type | Description | |---|---|---| | `id` | `string` | The question's id. | | `picks` | `list<u32>` | The suggestions picked, by their place in its list (from 0). | | `text` | `option<string>` | What the user typed, when anything. | | `declined` | `bool` | The user declined to answer. | ### `types.control-value` *variant* A control's new value, as `value-changed` carries it. ```wit variant control-value { on(bool), number(f64), choice(string), empty, } ``` | Case | Payload | Description | |---|---|---| | `on` | `bool` | A checkbox or switch is on (true) or off; a disclosure is open. | | `number` | `f64` | A slider's, number field's or split's number (a split's: the first pane's share, 0.0–1.0). | | `choice` | `string` | The key of the radio button, segment, breadcrumb or timeline segment chosen. | | `empty` | | A number field was emptied. | ### `types.value-change` *record* A control's value changed (`value`). ```wit record value-change { handler: handler, value: control-value, } ``` | Field | Type | Description | |---|---|---| | `handler` | `handler` | The handler of the node's `value` listener. | | `value` | `control-value` | What it is now. | ### `types.check` *record* A checkbox or a switch. A click on it or its label, or Space while it has focus, sends `value-changed` with `on` and the other state; without a `value` listener it can't be changed. ```wit record check { label: string, checked: bool, mixed: bool, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | Its label, drawn after the box (or before the switch); empty for none (then give the node a `label`, its accessible name). | | `checked` | `bool` | On. | | `mixed` | `bool` | A checkbox that stands for a group of which only some are on: drawn with a dash. A click sends `on(true)`. | | `disabled` | `bool` | Drawn dimmed; takes no clicks and no focus. | ### `types.choice-item` *record* One choice of a radio group or a segmented control. ```wit record choice-item { key: string, label: string, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `value-changed` (`choice`). Unique in the group, at most 128 bytes. | | `label` | `string` | What it says. | | `disabled` | `bool` | Drawn dimmed and can't be chosen. | ### `types.choice-group` *record* One of several choices: a radio group (a column, or a row when `horizontal`) or a segmented control. One focus stop: the arrow keys move to the next choice and choose it, Home and End to the first and last. At most 64 choices. ```wit record choice-group { items: list<choice-item>, selected: option<string>, horizontal: bool, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `items` | `list<choice-item>` | The choices, in order. | | `selected` | `option<string>` | The chosen one's key; `none`: none yet. | | `horizontal` | `bool` | A radio group laid out in a row (a segmented control always is). | | `disabled` | `bool` | The whole group is dimmed and can't be changed. | ### `types.slider` *record* A slider. Dragging moves it at once; `value-changed` follows as it moves (at most one every 50 ms) and when it is let go. Left and Down step down, Right and Up step up, Page Up and Page Down by a tenth, Home and End to the ends. ```wit record slider { value: f64, min: f64, max: f64, step: f64, show-value: bool, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `value` | `f64` | Its value, kept between `min` and `max`. | | `min` | `f64` | The lowest value. | | `max` | `f64` | The highest value (above `min`). | | `step` | `f64` | The steps it snaps to (0: none; the keys then move a hundredth). | | `show-value` | `bool` | Draw the value at its right. | | `disabled` | `bool` | Dimmed and can't be changed. | ### `types.number-field` *record* A number field. Typing a number and pressing Enter (or leaving the field) sends `value-changed` with it, kept within `min` and `max` and rounded to `decimals`; text that isn't a number is put back. − and + (and Up and Down while it has focus) step by `step`. ```wit record number-field { value: option<f64>, min: option<f64>, max: option<f64>, step: f64, decimals: u8, placeholder: option<string>, readonly: bool, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `value` | `option<f64>` | What it shows; `none`: empty. | | `min` | `option<f64>` | The lowest value it takes. | | `max` | `option<f64>` | The highest value it takes. | | `step` | `f64` | What − and + add (above 0; 1 is usual). | | `decimals` | `u8` | Digits after the point, 0–6. | | `placeholder` | `option<string>` | Shown in faint text while it is empty. | | `readonly` | `bool` | Shown, selectable, but not changed (no steps). | | `disabled` | `bool` | Dimmed and can't be changed or focused. | ### `types.search-field` *record* A search field: one line of text with a magnifier before it and a clear button while it holds text. It is a text field (`input`): Pitwall owns what is typed, `change` and `submit` listeners hear it as they do from `input`, and the clear button sends `input-changed` with an empty value. ```wit record search-field { value: option<string>, revision: u64, placeholder: option<string>, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `value` | `option<string>` | Text to put in it, as `input.value` (`none` keeps what it holds). | | `revision` | `u64` | The revision of `value`, as `input.revision`. | | `placeholder` | `option<string>` | Shown in faint text while it is empty (default: "Search"). | | `disabled` | `bool` | Dimmed and can't be edited. | ### `types.form-row` *record* A form row: its label over its children (the control), or beside them, with help text under them, and a validation message in place of the help while there is one. The label is the control's accessible name when the control has none. ```wit record form-row { label: string, help: option<string>, error: option<string>, required: bool, inline: bool, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | The label. | | `help` | `option<string>` | Help under the control, in muted text. | | `error` | `option<string>` | A validation message, in red, in place of the help; the control is marked invalid. | | `required` | `bool` | A required field: a mark after the label. | | `inline` | `bool` | The label beside the control (a fixed column) instead of over it. | ### `types.progress` *record* A progress bar. ```wit record progress { value: option<f32>, tone: option<tone>, } ``` | Field | Type | Description | |---|---|---| | `value` | `option<f32>` | The share done, 0.0–1.0; `none` while it can't be known (a bar that moves, or a still one with Reduce motion). | | `tone` | `option<tone>` | Its colour by meaning (`none`: the text colour). | ### `types.skeleton` *variant* A grey placeholder where content is loading, sized by the node's styles (a `block` without a size is a line tall and fills the row). It shimmers unless Reduce motion is on. ```wit variant skeleton { lines(u8), block, circle, } ``` | Case | Payload | Description | |---|---|---| | `lines` | `u8` | This many lines of text (1–20), the last one shorter. | | `block` | | A box (give it a size). | | `circle` | | A circle (an avatar), as tall as its width. | ### `types.empty-state` *record* An empty state, centred in its box: an icon, a title, a line of text and an action button, as Pitwall's own lists say they're empty. The action's click is the node's `click` listener. ```wit record empty-state { icon: option<icon>, title: string, text: option<string>, action: option<string>, } ``` | Field | Type | Description | |---|---|---| | `icon` | `option<icon>` | An icon over the title. | | `title` | `string` | What is empty ("No runs yet"). | | `text` | `option<string>` | What to do about it. | | `action` | `option<string>` | The action button's label (needs a `click` listener). | ### `types.banner` *record* An inline banner in the tile's flow (not a toast). Its action's click is the node's `click` listener; its close button (when `dismissible`) sends `dismissed`. ```wit record banner { tone: tone, title: option<string>, text: string, action: option<string>, dismissible: bool, } ``` | Field | Type | Description | |---|---|---| | `tone` | `tone` | Information (`info`), success (`good`), a warning (`warn`) or an error (`bad`). | | `title` | `option<string>` | A bold first line. | | `text` | `string` | The message. | | `action` | `option<string>` | An action button's label (needs a `click` listener). | | `dismissible` | `bool` | It has a close button (needs a `dismiss` listener). | ### `types.badge` *record* A small count or status label, as Pitwall's own. ```wit record badge { text: string, tone: option<tone>, } ``` | Field | Type | Description | |---|---|---| | `text` | `string` | What it says ("3", "beta"); at most 32 bytes. | | `tone` | `option<tone>` | Its colour by meaning (`none`: neutral). | ### `types.chip` *record* A chip (a tag). With a `click` listener it can be picked (drawn `selected`); `removable` gives it a × that sends `dismissed` (as do Backspace and Delete while it has focus). ```wit record chip { label: string, icon: option<icon>, tone: option<tone>, selected: bool, removable: bool, disabled: bool, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | What it says. | | `icon` | `option<icon>` | An icon before the label. | | `tone` | `option<tone>` | Its colour by meaning (`none`: neutral). | | `selected` | `bool` | Drawn picked. | | `removable` | `bool` | It has a ×. | | `disabled` | `bool` | Dimmed; takes no clicks. | ### `types.orientation` *enum* Which way something runs. ```wit enum orientation { horizontal, vertical, } ``` | Case | Description | |---|---| | `horizontal` | Left to right. | | `vertical` | Top to bottom. | ### `types.split` *record* Two panes (the node's first two children) with a bar between them that the user drags. Pitwall keeps the user's size for the view by the node's key path, across restarts, and sends it as `value-changed` (`number`: the first pane's share) when a drag ends. ```wit record split { orientation: orientation, initial: f32, min-first: f32, min-second: f32, } ``` | Field | Type | Description | |---|---|---| | `orientation` | `orientation` | Side by side (`horizontal`) or one above the other. | | `initial` | `f32` | The first pane's share at first, 0.05–0.95. | | `min-first` | `f32` | The first pane's smallest size, in logical pixels. | | `min-second` | `f32` | The second pane's smallest size, in logical pixels. | ### `types.disclosure` *record* A section with a header that opens and closes it: the header is a button (Enter or Space while it has focus) that sends `value-changed` with `on` and the other state; the node's children are drawn under it while `open`. ```wit record disclosure { title: string, detail: option<string>, open: bool, } ``` | Field | Type | Description | |---|---|---| | `title` | `string` | The header. | | `detail` | `option<string>` | Muted text at the header's right (a count, a summary). | | `open` | `bool` | Open. | ### `types.card` *record* A card: a bordered box on the raised surface with its children in it, under a title when it has one. With a `click` listener the whole card is clickable and focusable. ```wit record card { title: option<string>, detail: option<string>, } ``` | Field | Type | Description | |---|---|---| | `title` | `option<string>` | A title at its top. | | `detail` | `option<string>` | Muted text at the title's right. | ### `types.crumb` *record* One level of breadcrumbs. ```wit record crumb { key: string, label: string, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `value-changed` (`choice`). | | `label` | `string` | What it says. | ### `types.placement` *enum* Where a popover opens from its anchor. ```wit enum placement { below, above, start, end, } ``` | Case | Description | |---|---| | `below` | Under it (the default place). | | `above` | Over it. | | `start` | At its left. | | `end` | At its right. | ### `types.popover` *record* A popover: the node's children in a floating panel anchored to the node's parent, drawn by Pitwall inside the tile and kept in the window. It is open while it is in the frame. Esc and a click outside it send `dismissed` (the tile then leaves it out). At most one a frame. ```wit record popover { placement: placement, width: option<f32>, at: option<point>, } ``` | Field | Type | Description | |---|---|---| | `placement` | `placement` | Where it opens. | | `width` | `option<f32>` | Its width in logical pixels (`none`: its content's, 160–480). | | `at` | `option<point>` | Anchor it to this point of its parent instead of the parent's edge, in logical pixels from the parent's top-left corner (as a `click`'s `at`): under a box of a canvas, say. `placement` then says which side of the point it opens on. `none`: the parent's edge, as before. | ### `types.confirm-sheet` *record* A sheet over the tile asking the user to confirm, in place of the system dialogs a tile can't open. Shown while it is in the frame; the rest of the tile is dimmed and takes no input. Its confirm button is the node's `click` listener (Enter); Cancel, Esc and a click on the dimmed tile send `dismissed`. At most one a frame. ```wit record confirm-sheet { title: string, text: option<string>, confirm: string, cancel: option<string>, danger: bool, } ``` | Field | Type | Description | |---|---|---| | `title` | `string` | The question ("Delete 3 notes?"). | | `text` | `option<string>` | More about it. | | `confirm` | `string` | The confirm button's label ("Delete"). | | `cancel` | `option<string>` | The cancel button's label (`none`: "Cancel"). | | `danger` | `bool` | A destructive action: the confirm button is red. | ### `types.key-value` *record* One line of a key-value list. ```wit record key-value { key: string, value: string, mono: bool, copyable: bool, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | The label ("Branch"). | | `value` | `string` | The value ("main"). | | `mono` | `bool` | The value in the monospace font (ids, hashes, paths). | | `copyable` | `bool` | The value has a copy button. | ### `types.avatar-size` *enum* An avatar's size. ```wit enum avatar-size { small, medium, large, } ``` | Case | Description | |---|---| | `small` | 20 px. | | `medium` | 28 px. | | `large` | 40 px. | ### `types.avatar` *record* An avatar: the initials of `name` in a circle, coloured from the theme by the name, so a person has the same colour everywhere. Its accessible name and tooltip are `name` unless the node has its own. ```wit record avatar { name: string, size: avatar-size, } ``` | Field | Type | Description | |---|---|---| | `name` | `string` | The person's or thing's name ("Ada Lovelace": AL). | | `size` | `avatar-size` | Its size. | ### `types.relative-time` *record* A time, drawn relative to now ("just now", "5 min ago", "3 h ago", "yesterday", then the date) and kept up to date by Pitwall, so the tile needs no timer. Its tooltip is the date and time in full. ```wit record relative-time { at: s64, } ``` | Field | Type | Description | |---|---|---| | `at` | `s64` | The time, in milliseconds since 1970-01-01 UTC. | ### `types.copyable` *record* Text with a copy button. Pitwall writes the text to the clipboard only when the user clicks the button (or presses Enter while it has focus), and says "Copied"; a `click` listener hears it too. ```wit record copyable { text: string, mono: bool, } ``` | Field | Type | Description | |---|---|---| | `text` | `string` | The text shown and copied (at most 64 KiB). | | `mono` | `bool` | In the monospace font. | ### `types.link` *record* A link. With `url` (https, or http on this computer) and the `show` permission, a click opens the page in a Pitwall web tile, as `web.open` does; otherwise it is the node's `click` listener (a link to somewhere in the tile). ```wit record link { label: string, url: option<string>, } ``` | Field | Type | Description | |---|---|---| | `label` | `string` | What it says. | | `url` | `option<string>` | The page it opens. | ### `types.chart-series` *record* A series of a chart. ```wit record chart-series { name: string, values: list<f64>, color: option<token>, } ``` | Field | Type | Description | |---|---|---| | `name` | `string` | Its name, in the legend and tooltips. | | `values` | `list<f64>` | Its values, one per label (a NaN or infinite value is a gap). | | `color` | `option<token>` | Its colour (`none`: the next of Pitwall's chart colours). | ### `types.sparkline` *record* A sparkline: a small line without axes, sized by the node's styles (default 80 × 20). ```wit record sparkline { values: list<f64>, color: option<token>, filled: bool, } ``` | Field | Type | Description | |---|---|---| | `values` | `list<f64>` | The values, oldest first (at most 1 000). | | `color` | `option<token>` | Its colour (`none`: the text colour). | | `filled` | `bool` | The area under the line is filled, faintly. | ### `types.bar-chart` *record* A bar chart: one group of bars per label, one bar per series in it (or one stacked bar), with a value axis, and a tooltip per bar. ```wit record bar-chart { labels: list<string>, series: list<chart-series>, stacked: bool, unit: option<string>, } ``` | Field | Type | Description | |---|---|---| | `labels` | `list<string>` | The labels along the bottom (at most 200). | | `series` | `list<chart-series>` | The series (at most 8), each with one value per label. | | `stacked` | `bool` | Stack the series in one bar per label. | | `unit` | `option<string>` | The values' unit, in the axis and tooltips ("ms", "%"). | ### `types.line-chart` *record* A line chart: one line per series over the labels, with axes and a tooltip on hover that lists each series' value at the label under the pointer. ```wit record line-chart { labels: list<string>, series: list<chart-series>, unit: option<string>, min: option<f64>, max: option<f64>, } ``` | Field | Type | Description | |---|---|---| | `labels` | `list<string>` | The labels along the bottom (at most 1 000; Pitwall draws as many as fit). | | `series` | `list<chart-series>` | The series (at most 8), each with one value per label. | | `unit` | `option<string>` | The values' unit, in the axis and tooltips. | | `min` | `option<f64>` | The axis's lowest value (`none`: from the data, or 0). | | `max` | `option<f64>` | The axis's highest value (`none`: from the data). | ### `types.timeline-segment` *record* One segment of a status timeline. ```wit record timeline-segment { key: string, label: string, tone: option<tone>, weight: f32, } ``` | Field | Type | Description | |---|---|---| | `key` | `string` | Its key, sent in `value-changed` (`choice`) when it is clicked. | | `label` | `string` | Its tooltip and accessible name ("#412 passed in 3 min"). | | `tone` | `option<tone>` | Its colour by meaning (`none`: neutral, as for a run not started). | | `weight` | `f32` | Its width relative to the others (a run's duration; 1.0 for all alike). | ### `types.status-timeline` *record* A status timeline: a row of coloured segments, oldest first, each with a tooltip, as a CI tile shows its last runs. At most 500. ```wit record status-timeline { segments: list<timeline-segment>, } ``` | Field | Type | Description | |---|---|---| | `segments` | `list<timeline-segment>` | The segments. | ## Interface `ui` Requests about the tile's own views (runtime.md §3.8). No permission: these act only inside the tile's own area of the window. ### `ui.request-render` *function* Render `view` again once the current call returns (when it is hidden: once it is shown). For changes that didn't come from an event, since `handle` returning true already renders. ```wit request-render: func(view: view-id); ``` ### `ui.scroll-to` *function* Scroll the scroll containers around the node at `key-path` (keys from the root down, joined by `/`, without the root's, as `frame.focus`) so the node is in sight, after the next render of `view`. A path with no node is ignored. ```wit scroll-to: func(view: view-id, key-path: string); ``` ### `ui.toast` *function* Show a short message in a toast, labelled with the tile's name. At most 200 characters (longer text is cut); at most 3 toasts a minute, more are dropped and noted in the Log. ```wit toast: func(text: string, tone: tone); ``` ### `ui.open-view` *function* Open one of the extension's tiles (an id from its manifest's `contributes.tiles`) where Pitwall opens tiles, or focus its view when one is already open; a `view-opened` event follows. An unknown id is ignored and noted in the Log. ```wit open-view: func(tile: string); ``` ### `ui.put-image` *function* Hand Pitwall an image's bytes (PNG, JPEG, GIF, WebP or SVG; at most 8 MiB) under `name`, for `image` nodes with source `data(name)`. Kept until replaced or dropped; at most 64 MiB for all a tile's images. `invalid` when the bytes aren't one of those formats; `too-large` over a limit. ```wit put-image: func(name: string, bytes: list<u8>) -> result<_, host-error>; ``` ### `ui.drop-image` *function* Forget the image put under `name`. ```wit drop-image: func(name: string); ``` ### `ui.measure-text` *function* How wide each of `texts` is on one line in Pitwall's `font` (Inter for `ui`, JetBrains Mono for `mono`) at `size` logical pixels (4–200) and `weight`, in logical pixels: to size boxes on a canvas around their labels. Kerned as Pitwall draws it; a character Pitwall's font lacks counts as an average letter. One width per text, in order; at most 1 000 texts and 64 KiB in all a call (more: an empty list, noted in the Log). The same numbers in the test harness. ```wit measure-text: func(texts: list<string>, font: font, size: f32, weight: weight) -> list<f32>; ``` --- Source: https://pitwalls.github.io/pitwall/docs/extensions/for-agents/ # For coding agents **Preview.** Many tiles will be built with a coding agent such as Claude Code or Codex. Two files let an agent build one from the docs alone, without Pitwall's source: the authoring skill, and `llms.txt`. ## The authoring skill [`SKILL.md`](https://pitwalls.github.io/pitwall/sdk/pitwall-extension-authoring/SKILL.md) is a short guide for the agent working on a tile: the commands, the project's layout, the manifest, the `Tile` trait and elements, content from agents, the platform services, and testing with the harness. It ships with the SDK and is the same file on this site. **In a project made with `pitwall extension new`, the agent already has it.** `new` writes the skill to `.claude/skills/pitwall-extension-authoring/` (where Claude Code finds skills) and `.agents/skills/pitwall-extension-authoring/` (where other agents look), and an `AGENTS.md` that points to it, which Codex and most other agents read first. Nothing to set up. **In another project,** download the skill into one of those folders: | Agent | Put `SKILL.md` in | |---|---| | Claude Code | `.claude/skills/pitwall-extension-authoring/` in the project, or `~/.claude/skills/pitwall-extension-authoring/` for all your projects | | Codex and other agents | `.agents/skills/pitwall-extension-authoring/`, and a line in the project's `AGENTS.md` that says to read it before changing the tile | The skill tells the agent to run `pitwall extension check .` and `cargo test` before it says a change is done. ## `llms.txt` [`/sdk/llms.txt`](https://pitwalls.github.io/pitwall/sdk/llms.txt) is every Extensions page on this site as one plain Markdown file, with the examples and the [WIT reference](https://pitwalls.github.io/pitwall/docs/extensions/wit/) filled in and every link absolute. It is built with the site, from the same sources as these pages, so it matches them and the WIT. Point an agent at it when it needs more than the skill: the exact API, a limit, or what WIT 0.1 does and doesn't have. For example, ask it to "read Pitwall's extension docs at the llms.txt link on the For coding agents page before you start", with the link copied from above. An agent with a web fetch tool reads it directly; otherwise download it into the project and name the file. Only the newest version is published for now. A copy per WIT version comes with the next world. ## Which to use - **Building or changing a tile:** the skill, which `new` already put in the project. - **A question the skill doesn't answer:** `llms.txt`. - **Exactly what a tile and Pitwall exchange:** the [WIT reference](https://pitwalls.github.io/pitwall/docs/extensions/wit/), which is in `llms.txt` too. Agent tools that let your agents open and use tiles in Pitwall are a different thing: see [Agent tools](https://pitwalls.github.io/pitwall/docs/extensions/agent-tools/).