# Resource panel and preview

Groups come from the resource type. Names belong to entries. Hiding a preview never touches the resource.

## Groups

| Label, in panel order | Kind |
| --- | --- |
| Webpage | `web`; sources `web` and `browser` map here. |
| Desktop | `desktop`: what a call operates on this computer |
| Machine | `machine`: what a call operates on another machine |
| Terminal | `terminal` |
| Application | `application` |
| Other resources | Any other kind; details keep the original type and source |

A group, header included, appears only when it has resources; with none at all the panel shows one line saying so.

| Aspect | Rule |
| --- | --- |
| Entry title | The actual resource name. A page-title change updates the entry, not its group. |
| Entry subtitle | State (operating, running, connection failed), the owning Agent when needed, source, branch and connection. No session-title level. |
| External | A source, not a type: external pages stay under Webpage |
| Scope | Only resources tied to the current session. Same-type resources across branches share one group. |
| Count | Valid resources of that type. Agent switches and renames do not reorder groups. |
| Closed or exited | Leave the active list; history may show them in details |
| Uncertain status | Stays under its type and shows an error; not treated as closed |
| Refresh failure | Known types and entries stay; nothing is said and the status is read again behind them. No renaming, no selecting another resource, no retrying a close of unknown outcome. |

## Actions

| Action | View | Resource |
| --- | --- | --- |
| Entry | Shown in the conversation; repeated clicks keep it open | Same instance |
| Row: Preview in conversation | Reopens the preview | Unchanged |
| Row: Open in tab | Switches to the existing tab | Unchanged |
| Row: Close webpage | Entry and its preview go away | Closed |
| Preview: Open page | Full view of the same resource; web pages use the top tabs. Hidden without a full view. | No duplicate |
| Preview: Close preview (X) | Preview hidden; entry stays | Page exists; environment keeps running |
| Preview: Review request | Shown while the Agent waits for confirmation | Unchanged |
| More: Automatically show what the Agent is using | On: shows the page being operated in this session. Off: keeps the current page. | Agent targets and tasks unchanged |
| Terminate environment | Explicit named action in a text menu; only where supported | Existing confirmation and permission rules apply |

### Preview title bar

- **Contents**: Resource name, Open page (outward arrow), More (dots), Close preview (X). All have hover hints and accessible names. No pin or expand buttons.
- **Kept**: Dragging, edge resizing, saved dimensions
- **Narrow window**: The title truncates first; every action stays
- **Input-area badge**: Page name only, without Left, Right or Center; hover still explains Agent access

### More menu

| Aspect | Behaviour |
| --- | --- |
| Items on web pages | Automatically show what the Agent is using (checkbox, wrapping title, visible description); Show actions (checkbox); Operation history (submenu). Desktops, machines, terminals and applications show only what they support. |
| Surface | The application's own menu. Desktop draws it in the HTML overlay above native pages, through the one native-menu service shared by main-process IPC and control overlays. Web uses the same content and styling. |
| Toggling | Menu stays open and checks update at once; automatic page switches also keep it open |
| Dismissed by | Escape, outside click, More again, closing the preview |
| Follow with no operated page | Keeps the current page |

## States

| Now | Event | Result |
| --- | --- | --- |
| Preview hidden | Click an entry | Shows it. Selecting a page by hand turns follow off. |
| Preview visible | Close preview | Hides the view only; selection and mode stay. Later Agent activity does not reopen it. |
| Follow on, preview visible | Agent switches page | Preview updates, only to pages allowed in this session |
| Viewing a desktop, machine, terminal or application | Agent switches page | Page following does not replace it |
| Web page reopened | Reopen | The session's saved display policy applies; an explicitly chosen page stays |
| Any | Switch resource | Replaces the one preview's view |
| Any | Switch session | Hides the old preview; restores the new session's own selection and visibility |
| No preview capability | Open | Existing details, no fake preview or connected state. Unknown, connecting and failed are explicit states. |

- Resource identity, session ownership and access rights do not change with grouping or view switches.
- Group collapse, panel hiding and preview hiding persist independently. Collapsing hides rows only; hiding the panel leaves the preview. Group collapse is per session and type.

## Implementation

| Part | Code | Must hold |
| --- | --- | --- |
| Type grouping | [`session-resources.ts`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/lib/chat/resources/session-resources.ts): `groupSessionResources`, resource types, preview preferences. [`session-resources-panel.tsx`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/session-resources/session-resources-panel.tsx): labels, row actions, collapse. | Pages and machines are separate groups; renaming changes no group; branches of one type stay together |
| Preview and menu | [`web-tab-pip.tsx`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/center-tabs/pip/web-tab-pip.tsx) | X hides; the row's Preview button reopens; row buttons unchanged; follow semantics agree |
| Resource-specific views | Existing Terminal and Application views, provider capabilities | Shared show and hide semantics; no new machine-control backend; unsupported preview falls back to details |
| State | Resource store, session selection, saved preferences | Session isolation, no reopening after hiding, restore on refresh, Close preview unobstructed at minimum width |
| Desktop menu | Native-menu service | Popup in authorized windows, selection return, cancellation cleanup |

[Session resources](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/resources/session-resources.html) · [Browser control](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/browser/browser-control-surfaces.html)
