# Session resources

The right-dock panel of complete software and environment objects a session uses. Code executions, commands and output belong to Activity; files to file views. Preview behaviour is in [Resources and operation preview](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/resources/resource-preview.html); web behaviour in [built-in browser](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/browser/built-in-browser.html).

## Panel

- **Entry**: A Session resources row in the vertical right-sidebar navigation beside Files and Activity, with their row, icon and label classes. The dock toggle collapses to the icon rail.
- **Groups**: The eight in [Desktop](https://fzkuji.github.io/OpenProgram/docs/interfaces/desktop.html). Webpage, Application and Terminal always show, folded and uncounted until loaded; other empty groups are omitted, as are closed or exited resources.
- **One row per Page**: A Page used on several branches is listed once: the viewed branch's row if it used it, otherwise the newest. Unknown connection state stays in its type.
- **Filter**: Only resources whose recorded owner matches the selected session, children under their type with actual owner shown. Drafts and unassigned views show none. Missing branch names create no group.
- **Switching session**: Clears details and the selected view, and aborts previous requests.
- **Persistence**: Type collapse per session; selected dock view across reloads. Collapsing the dock or choosing another view stops polling.
- **Selecting**: A web row previews read-only, without activating or recreating the Page. A non-web row shows details, hiding the web preview without closing its Page. A Terminal row attaches a view to its existing PTY and never creates a shell.

## Sources and ownership

| Resource | Authority | Lifetime |
| --- | --- | --- |
| Webpages | `CenterTab` records and recorded session provenance; a tab the Agent opens carries the trusted runtime session ID through the desktop command | Until the webpage closes. Agent pages stay in Resources; user-opened and pinned pages stay in the strip. |
| Desktop, machine | Trusted usage registry: what a `computer_use` call operates, as its target reports it (`desktop`: a window, the screen or the user's browser on this computer; `machine`: another machine) | While a call operates it |
| Other integrations | `resource_use(kind, title, target)` with the same trusted context | The reported period of use |
| Background terminal | A command a bash call left running (`background` set), the one `ProcessStore` projection; see [command sessions](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/execution/command-sessions.html) | Until exit; read-only row with Stop |

Integrations must name the actual application or machine. Per-command Docker invocations and SSH subprocesses do not register, and the registry neither scans the host nor infers objects from shell text.

**Authorization and display limits**

| Item | Rule |
| --- | --- |
| Authorization | The server checks session and execution authorization before returning resources. Rows from authorized descendant scopes are still filtered by actual owner. |
| Browser rows | Browser rows stay renderer-owned; backend requests cover only the selected session. |
| Registry payloads | Registry payloads hold bounded display fields; URLs omit credentials, query parameters and fragments. |
| Native bounds | Native browser bounds resize with the remaining center area. |
| Reuse | Reuses the right dock, center-tab store, authorized resource route and native bounds reporting. No second browser manager or generic destructive-action protocol. |

## Preview and Page access

| Rule | Behaviour |
| --- | --- |
| Preview scope | Stored by conversation ID, independent of the chat tab. Navigating a tab shows only the selected conversation's preview. |
| Private Page | A retained agent Page not opened as a top tab belongs to its conversation. Inventory, turn context, screenshot, resolve, activation and close enforce this by trusted execution attribution. |
| Open page | Makes it a regular tab: others may discover it and acquire it when the exclusive Page lease permits. Provenance and preview ownership do not change. |
| Pending results | Must still match the current access scope before delivery |

## Views made when wanted

A page's native view is a whole browser process, about 100 MB. A window retains the pages of every conversation that opened one: 99 pages measured, 10 GB when each had its view.

| Page | Its view is made |
| --- | --- |
| The user's own tab | When the App starts |
| Page of a conversation on screen | When the App starts, or when the conversation comes on screen |
| Page of another conversation | When its conversation comes on screen, a pane shows it, or an Agent lists or uses it |

A page waiting for its view is `dormant` in the store and reads as open, with no notice: the renderer's restore inventory names its tab in `dormant_tabs`, so the Worker does not call it failed. Its row moves to the new page when the view is made. A dormant page whose tab is gone reads as failed.

## Closing a tab

| Action | Page | Effect |
| --- | --- | --- |
| Close tab or split pane | Session-associated | Hidden; native view, navigation and associations stay; reopen from Resources |
| Close tab or split pane | Standalone | Removed; native view destroyed |
| Close webpage, authorized Agent close | Any open Page, tab or not | Destroyed |
| Close a conversation | Its retained Pages | Stay open |

| Step | Result |
| --- | --- |
| Close webpage | Hides the row at once and closes its tab |
| `POST /api/session/{id}/resources/{resource_id}/close` | Closes the Page record and retires its bindings, independent of the renderer's destroy receipt |
| Failed request | The row is restored |
| Socket down | Native closes confirmed meanwhile are reported after the next window register |
| Animation end | Ownership resolves; hidden Pages leave split groups and cannot be the active fallback |

## Resource interface

| Operation | Terminal | Application |
| --- | --- | --- |
| `list`, `describe` | Native host inventory and generation | Installed, enabled manifest and declared operations |
| `open` | Create a private shell explicitly | Open the installed instance |
| `observe` | Independent output cursor, input revision | Instance state, operation status |
| `act` | Input or interrupt with observed revision | Declared Agent-visible operations only |
| `release` | Release Agent binding, keep process | Detach association |
| `close` | Request termination, wait for exit | Only when declared |

Unsupported actions return a capability error; nothing is invented. Web pages are not a provider here: `computer_use(type="browser")` lists, opens, operates and closes them. `terminal_use` remains a public entry. A resource identifier is not an access grant. Hiding a view, releasing Agent access and terminating an environment are separate.

**Trust and failures**

| Item | Rule |
| --- | --- |
| Context | The worker derives session, execution and originating window from trusted context. |
| Providers | Providers keep tool approval, sandbox checks, private-resource checks, exclusive bindings, generation checks and input revisions. |
| Manifests | Manifests cannot supply host code through a renderer request. Third-party resources come from installed, explicitly trusted packages. |
| Desktop availability | Desktop availability is reported without substituting another host. Uncertain writes are never replayed. |
| Terminal | Terminal output is untrusted; an input acknowledgement does not mean the command finished. |

**What is reused**

| Component | Role |
| --- | --- |
| Page registry | Native target ownership and observation freshness |
| Terminal manager | Generation, binding, output cursors, native receipt correlation |
| Applications runtime | Manifests, instances and declared operations |
| `resource_use` | Display-only lifetime; gives no control |
| Rejected | A second browser registry, a universal shell fallback, an unrestricted renderer plugin loader: each duplicates authority or bypasses provider limits |

## Backend operations and installed applications

- **Parity**: Every product operation has an authenticated backend entry: HTTP from the registered schema, WebSocket commands through a request/response adapter on the same handlers. The Agent invokes operations by name without touching the interface.
- **Authority**: Requires owner authority and tool approval, refuses an active sandbox or nonlocal backend, never returns owner credentials. Authentication, native receipt and connection-registration endpoints are not callable.
- **Window commands**: Renderer preferences, navigation and native window functions address one connected window, with replies correlated to it. Disconnects and uncertain mutations do not retry. Window presentation needs a connected view; business and application operations do not.
- **Applications**: An enabled installed application provides `application.<id>` with no restart or registry edit. `open` binds its durable instance, `observe` reads state and runs, `act` submits a declared operation, `release` removes only the association.
- **Lifecycle**: Cancellation and answers target the exact instance and run. Disabled, removed or updated applications revoke stale descriptors. A scaffold command creates a runnable package.

**Where the code lives**

| Path | Holds |
| --- | --- |
| `openprogram/host/resources` | Contracts and dispatch; adapters in `providers` |
| `openprogram/programs/_host/framework` | Discovery, authority, client calls |
| `openprogram/interfaces/server/routes` | Server routes, by control responsibility |
| `apps/web/lib/framework` | Interface command handlers |
| `apps/web/components/session-resources` | Resource views |

## Split canvases

| Item | Rule |
| --- | --- |
| Shared scope | Files, Activity, Resources, the snapshot request and drop targets share one conversation scope; the sidebar owns the single window-level projection. |
| Selection | Clicking a conversation selects it. Focusing a webpage or file pane keeps the last selected visible conversation. Hidden or unrelated conversations are never fallbacks. |
| Drop on Resources | Dropping a webpage on Resources attaches it to that panel's conversation. A split with several webpages needs the page's pane handle. |
| Drag feedback | Tab and pane drags use the canvas docking's blue region with a release-to-add label; hovering the Resources row highlights it and its panel. |
| Release | Release waits for native transfer cancellation and the confirmed association, then opens Resources with a success notice. Failure shows a retry message and keeps the page. Association does not change provenance. |

## Implementation status

| Part | Status |
| --- | --- |
| In place | Usage registry, session projection, panel, common resource tool, Web, Terminal and application providers, backend operations, window commands, scaffold, split-canvas scope, tab closing |
| Controlled tests only | Real Docker engines and VM endpoints |
| Planned | Native application and VM controller adapters; operating-system desktop input control is separate from application operations |

**Acceptance**

- Right-sidebar placement, per-session isolation, type grouping, session switching, collapse, pointer and keyboard use, native-browser coexistence.
- Row-click preview, Open page of the same Page, preview hidden while that tab is active, no Pin control, no code, process or file entries beyond Background terminal.
- Cross-session authorization; normal, exceptional and stale-owner release; reload.
- Private-page discovery and exact-ID rejection, public opening, busy-Page rejection, acquisition after release, access changes during native operations.
- Capability rejection before effects; user and Agent on one Terminal cwd and output; release without termination; changed-generation rejection; no write replay; actual exit before restart.
- Backend discovery and invocation with no rendered frontend; invalid, unauthorized and unsafe calls rejected before effects; install, disable, update and remove discovery.
- Chat and web splits, two chats plus a webpage, hidden conversations, drag hover, cancel and release, correct session IDs.
- Reveal, navigate, close and reopen for Agent and manually associated Pages; split and bulk closure; standalone and explicit destruction.
