# oneapp docs, all pages (OneApp 1.0.0) Every page of https://recursiveai.org/oneapp/docs/ as markdown, getting started first. Index: https://recursiveai.org/oneapp/llms.txt # Getting started with OneApp Make a desktop app from the `dotnet new` template, run it, and drive it from the command line. Then run the same component in a browser. This guide was run on the OneApp 1.0.0 packages from NuGet with the .NET 10 SDK on Ubuntu 26.04: the window on X11 (a virtual display, Vulkan on an NVIDIA GPU), the browser part in headless Chrome. ## Make an app You need the .NET 10 SDK. Install the template and make an app: ```shell dotnet new install RecursiveAI.OneApp.Templates@1.0.0 dotnet new oneapp -n MyApp cd MyApp dotnet tool restore ``` `MyApp.csproj` references `RecursiveAI.OneApp` and `RecursiveAI.OneApp.Kit` 1.0.0 and nothing else, and `dotnet tool restore` installs the `oneapp` tool from the app’s tool manifest. The window’s page is one component, a template and a partial class with the same name, built from the kit. `MainPage.html`: ```html
Hello, {Name} Edit MainPage.html and MainPage.cs to change this window.
``` `MainPage.cs`: ```csharp using OneApp.Kit; using OneUI.Components; namespace MyApp; /// The window's page: a greeting card with a name field and a counter button. public partial class MainPage { [State] private partial string Name { get; set; } [State] private partial int Clicks { get; set; } /// protected override void OnMounted() { Name = "World"; } } ``` `Program.cs` creates the app host with the component as its root and runs the loop until the window closes: ```csharp using MyApp; using OneApp; // The development harness (`oneapp run`, `oneapp click ...`) is on in Debug builds and compiled out of Release builds. // `--headless` runs without a window or GPU, for driving the app through the harness only. bool headless = args.Contains("--headless"); using var host = AppHost.Create(new AppOptions(new MainPage()) { Title = "MyApp", AppId = "dev.example.myapp", Width = 480, Height = 360, Backend = headless ? OnePlatform.PlatformBackendKind.Headless : OnePlatform.PlatformBackendKind.Auto, UseGpu = !headless, }); host.Run(); return 0; ``` The markup compiler in [OneUI](https://recursiveai.org/oneui/) checks every binding, event and CSS property when the project builds, so a misspelled name is a build error. The window itself comes from [OnePlatform](https://recursiveai.org/oneplatform/). ## Run it ```shell dotnet run ``` A 480 by 360 window titled MyApp opens, with the card and the counter button. ## Drive it from the command line `dotnet oneapp run . --detach` builds and starts the app in Debug, where it listens for the `oneapp` tool on a local socket; a Release build has no listener. The other commands talk to the running app and print JSON. ```shell dotnet oneapp run . --detach dotnet oneapp call status dotnet oneapp click '#count' dotnet oneapp click '#count' dotnet oneapp type Ada --into '#name' --clear dotnet oneapp query '#count' dotnet oneapp capture --out window.png ``` `call status` printed: ```json {"pid":3404732,"backend":"X11","gpu":true,"presenter":"gpu","presentedFrames":1,"pageCreations":1,"accessibility":{"state":"active"},"animating":false,"viewport":{"width":480,"height":360,"scale":1},"focused":null} ``` `query '#count'` answers with each matching element: its tag, id, classes, text, attributes, bounds and states. Before the clicks its text was `"Clicked 0 times"`; after them, `"Clicked 2 times"`. The title then read `"Hello, Ada"`. The clicks and the typing go through the window’s own event queue, as a mouse and keyboard would. `capture` wrote this: ![The MyApp window: a card titled “Hello, Ada” with the name field holding “Ada” and a button reading “Clicked 2 times”](https://recursiveai.org/oneapp/myapp-x11.png) The [test harness](https://recursiveai.org/oneapp/docs/harness/) lists every command, and the same commands are offered to any tool that speaks MCP (`dotnet oneapp mcp`). ## The same component in a browser `RecursiveAI.OneApp.Browser` registers a component as a custom element on `browser-wasm`; the browser does the layout and drawing. Make a folder `MyApp.Web` next to `MyApp`, copy `MainPage.html`, `MainPage.css` and `MainPage.cs` into it, and add these three files. `MyApp.Web.csproj`: ```xml net10.0 enable enable true false ``` `Program.cs`: ```csharp using System.Runtime.Versioning; using MyApp; using OneApp.Browser; [assembly: SupportedOSPlatform("browser")] BrowserApp.Define("my-app", _ => new MainPage()); ``` `wwwroot/index.html`: ```html MyApp ``` Publish it (the `wasm-tools` workload must be installed) and serve the folder with any static file server: ```shell dotnet publish -c Release -o out cd out/wwwroot python3 -m http.server 8080 ``` `out/wwwroot` holds `index.html`, `oneui-browser.js`, which the package’s build step copies in, and `_framework/`. In Chrome, the element rendered the same card. Two clicks on the button and “Ada” entered in the field gave the same result as in the window: ![The same card in Chrome: “Hello, Ada”, the name field holding “Ada” and a button reading “Clicked 2 times”](https://recursiveai.org/oneapp/myapp-browser.png) ## Next - [The dotnet new template](https://recursiveai.org/oneapp/docs/templates/): its files and options. - [Component kit](https://recursiveai.org/oneapp/docs/kit/): the components, their parameters and the theme tokens. - [Desktop shell](https://recursiveai.org/oneapp/docs/shell/): more windows, dialogs, overlays, menus, tray, notifications, file dialogs and hotkeys. - [Packaging](https://recursiveai.org/oneapp/docs/packaging/): `oneapp install`, `.deb`, AppImage, `.app` and `.dmg`, `.msix`, and signing. # OneApp A framework for desktop apps in .NET whose UI is HTML and CSS, drawn natively with no web view. It is five packages built from this repository: | Package | What it is | |---|---| | `RecursiveAI.OneApp` | The app host: windows, the loop, input, the desktop shell, the harness, accessibility bridges | | `RecursiveAI.OneApp.Kit` | A component kit with a shadcn/ui-style look, as OneUI markup components | | `RecursiveAI.OneApp.Browser` | Runs the same components in the browser as custom elements on `browser-wasm` | | `RecursiveAI.OneApp.Cli` | The `oneapp` tool: run, drive, install and package apps | | `RecursiveAI.OneApp.Templates` | The `dotnet new oneapp` template | ## Start an app ``` dotnet new install RecursiveAI.OneApp.Templates dotnet new oneapp -n MyApp cd MyApp && dotnet tool restore && dotnet run ``` The new app has one kit-based markup component, the app host, an app id and icon, and the `oneapp` tool. [docs/templates.md](https://recursiveai.org/oneapp/docs/templates/) ## A minimal app A component is a template, an optional stylesheet and a partial class with the same name; the markup compiler in [RecursiveAI.OneUI](https://www.nuget.org/packages/RecursiveAI.OneUI) checks every binding, event and CSS property when the project builds. `Counter.html` ```html

Counter

``` `Counter.cs` ```csharp using OneUI.Components; public partial class Counter { [State] public partial int Count { get; set; } private void Increment() => Count++; } ``` `Program.cs` ```csharp using OneApp; using var host = AppHost.Create(new AppOptions(new Counter()) { Title = "Counter", AppId = "org.example.Counter" }); host.Run(); ``` `AppHost` opens the window, mounts the component and runs the loop until the window closes. The loop sleeps in the operating system until input, a timer the page asked for, or a posted action arrives, and it draws a frame only when the page changed, so an idle window uses no CPU. Pages written as plain HTML work the same way: `new AppOptions("

Hello

")`. ## Platforms | Platform | Window and drawing | Desktop services | Accessibility | Packaging | |---|---|---|---|---| | Linux | Wayland (server-side decorations, layer-shell overlays) and X11; Vulkan | tray, notifications, file dialogs, global hotkeys, screenshots and single instance through the desktop portals and the session bus | AT-SPI | `.deb`, AppImage, desktop entry | | macOS (Apple silicon) | Cocoa; Metal | menu bar, status item, notifications, file dialogs, single instance | NSAccessibility | `.app` bundle, `.dmg` | | Windows | Win32; Vulkan where the driver has it, otherwise OneRender's CPU rasterizer shown through GDI | menu bar, tray icon, notifications, file dialogs, global hotkeys, screenshots, single instance | UI Automation | `.msix` (signed with your certificate, a store thumbprint or Microsoft's cloud signing; `oneapp install` adds a Start-menu entry) | | Browser | Components only, in `RecursiveAI.OneApp.Browser`: custom elements on `browser-wasm`, drawn by the browser | | the browser's | static folder | Native apps are NativeAOT- and trim-compatible. `AppHost` with HTML pages is native only. ## Everything else - **Harness.** Debug builds listen for MCP on a local socket, so tests and automation tools can click, type, query the DOM and accessibility tree and capture pixels; Release builds contain no listener. [docs/harness.md](https://recursiveai.org/oneapp/docs/harness/) - **Accessibility.** AT-SPI on Linux and NSAccessibility on macOS, from OneHtml's accessibility tree. [docs/accessibility.md](https://recursiveai.org/oneapp/docs/accessibility/) - **Desktop shell.** Windows, dialogs, overlays, menus, tray, notifications, file dialogs, hotkeys, screenshots, single instance. [docs/shell.md](https://recursiveai.org/oneapp/docs/shell/) - **Components in a native window.** [docs/components.md](https://recursiveai.org/oneapp/docs/components/) - **Kit.** Tokens, components and parameters; the look follows shadcn/ui's published design and is not affiliated with it. [docs/kit.md](https://recursiveai.org/oneapp/docs/kit/) - **Browser.** [docs/browser.md](https://recursiveai.org/oneapp/docs/browser/) - **Template.** `dotnet new oneapp`. [docs/templates.md](https://recursiveai.org/oneapp/docs/templates/) - **Packaging.** `.deb`, AppImage, `.app` and `.dmg`. [docs/packaging.md](https://recursiveai.org/oneapp/docs/packaging/) ## Building from source ``` dotnet build OneApp.slnx dotnet test --project tests/OneApp.Tests ``` `RecursiveAI.OnePlatform` and `RecursiveAI.OneUI` are referenced one of two ways, chosen by the MSBuild property `OneAppSiblingSources` (default in `Directory.Build.props`). With `true` the projects reference sibling checkouts (`../oneplatform-csharp`, `../oneui-csharp`), for developing the three together. With `false` they are package references, at `OnePlatformVersion` and `OneUIVersion` from `Directory.Packages.props`, and the repository builds on its own: `dotnet build -p:OneAppSiblingSources=false`. To try that against unreleased packages, pack the two libraries into a folder and add `-p:OnePlatformVersion= -p:OneUIVersion= -p:RestoreAdditionalProjectSources=`. `samples/` has a hello window (`Hello`), the kit gallery, a native component sample, a desktop-shell demo and two browser samples. Set `ONEAPP_ARTIFACTS` to choose where build output goes. Licensed under MIT OR Apache-2.0. # The `dotnet new` template ``` dotnet new install RecursiveAI.OneApp.Templates dotnet new oneapp -n MyApp cd MyApp dotnet tool restore # the oneapp tool, from .config/dotnet-tools.json dotnet run # the window ``` ## What you get | File | | |---|---| | `MyApp.csproj` | NativeAOT on, warnings as errors, the app's identity (`OneAppId`, `OneAppName`, `OneAppVersion`, `OneAppIcon`, see [packaging](https://recursiveai.org/oneapp/docs/packaging/)). References `RecursiveAI.OneApp` and `RecursiveAI.OneApp.Kit` and nothing else. | | `Program.cs` | Creates the app host with the root component and runs it. `--headless` runs without a window or GPU, for driving through the harness. | | `MainPage.html`, `.css`, `.cs` | One component built from the kit: a card with a text field and a counter button. Every binding is checked when the project builds. | | `icon.png` | The launcher icon; replace it. | | `.config/dotnet-tools.json` | The `oneapp` tool, so a clone builds and drives the app with `dotnet oneapp ...`. | The markup compiler and the build step that makes each `.html` file and its `.css` neighbour a component template come with `RecursiveAI.OneUI`, which the two packages bring in. ## Options | Option | Default | | |---|---|---| | `-n`, `--name` | `MyApp` | Project, namespace and window title. | | `--appId` | `dev.example.myapp` | Application id: the desktop entry name on Linux, the bundle identifier on macOS. Use your own reverse-DNS name. | | `--oneappVersion` | the version of the template package (set when it is packed) | The version of the three OneApp packages to reference. | ## Driving it ``` dotnet oneapp run . --headless --detach # a Debug build with the development listener on dotnet oneapp call status dotnet oneapp click '#count' dotnet oneapp query '#count' # "Clicked 1 times" dotnet oneapp capture --out page.png dotnet oneapp install . # NativeAOT publish and a launcher entry ``` See [harness](https://recursiveai.org/oneapp/docs/harness/) for the verbs and [packaging](https://recursiveai.org/oneapp/docs/packaging/) for install and package formats. ## Building the template from source `dotnet pack src/OneApp.Templates` writes the package; `dotnet new install ` installs it from a folder. To try a generated app against unreleased packages, pack the OneApp packages into a folder, add that folder as a source in a `nuget.config` above the app, and pass `--oneappVersion` with the packed version. # OneUI components in a native window An app window can show a OneUI component tree instead of an HTML page. The window mounts the root component; every state change the components make is one change-set commit (see OneUI's `docs/change-sets.md`, protocol versions 1 and 2), which OneApp applies to a OneHtml `MutableDocument` that a OneRender `InteractivePage` follows. The page restyles and lays out only what the edit reaches, and the window draws on damage only: an idle component window uses no CPU and draws nothing. ```csharp using var host = AppHost.Create(new AppOptions(new TodoApp()) { Title = "Todo" }); host.Run(); ``` `AppWindowOptions(Component root)` does the same for further windows of `AppHost.OpenWindow`. HTML windows are unchanged. ## API | | | |---|---| | `new AppOptions(Component root)`, `new AppWindowOptions(Component root)` | Show a component tree. `Html` is empty then. | | `AppWindow.Root`, `AppWindow.Components` | The mounted component and its `UiContext` (to batch state changes or read state by path); null for an HTML window. | | `AppWindow.Page` | The `InteractivePage`; it shows the components' pending edits before you read it. `Page.MutableDocument` is the document. | Everything runs on the UI thread. A state change made from another thread goes through `AppHost.Post`. ## What the sink does - **Document.** Node 1 is the body. A `style` element in the head holds `html,body{margin:0}`; each `AddStyleSheet` adds a `