# Project workspace: files, tabs and sessions

1. **Sessions** grouped by project
2. **Tabs** strip, active tab's toolbar, content
3. **File tree** one level per request

One layout, no workspace mode and no separate route: anything new becomes a tab, not a pane. The panes live in the persistent AppShell. Interactive sketch: [prototype](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/workspace/project-workspace-prototype.html).

## Tab model

| Tab | Toolbar and content |
| --- | --- |
| `session` | Project, model, thinking and permission settings travel with the tab. Bookmark over the single chat surface: switching a tab uses the session-switch path. |
| `file` | Breadcrumb and view controls. Code and text with line numbers and highlight, Markdown rendered or source, images, PDF inline via `/files/raw`, anything else a download. |
| `run` (planned) | Live graph of a program or workflow derived from recorded events (`openprogram/runtime/execution/projections/dag.py`, `openprogram/state/store/session/graph/builder.py`). Workflows stay plain Python: no graph DSL, no instrumentation; click a node for inputs and outputs. |

- + opens a new-tab page: new session, run agent, project settings.
- Tabs persist in `localStorage`.
- File paths in transcript tool calls open in center tabs.
- History, Context and Executions live in an overlay opened from the session toolbar; legacy DOM mounts and `window.rightDock` shims stay underneath.

## Project file API

| Action | Request and reply |
| --- | --- |
| `project_file_tree` | `project_id`, `path` (relative, `""` for root). One directory level. |
| `project_file_search` | Names and relative paths, paged by opaque cursor over immutable snapshots; skips ignored build directories, follows no symlinks. |
| `project_file_read` | `{content, size, mtime, truncated}`, or `binary` / `too_large` |
| `project_file_write` | UTF-8 text, 5 MB cap, parent must exist. `expected_mtime` mismatch answers `conflict`. |
| `project_file_create` `rename` `copy` `delete` `reveal` | File management; also `project_file_info`, `project_folder_size`, `project_file_operation_status`. |
| `GET /files/raw` | `?project_id=&path=` Images, PDF inline, everything else a download. `nosniff`; `CSP: sandbox` except PDF. |

Every path passes `_resolve`: known project, location check, no absolute paths, `realpath` inside the project root. Reads cap at 1 MB. Binary: NUL in the first 8 KiB. Dotfiles are listed; `.git/`, `node_modules/`, `.venv/`, `__pycache__/` are not prefetched. Code: `openprogram/interfaces/server/ws_actions/files/`.

## Reused pieces

| Piece | Location |
| --- | --- |
| Project store, settings.json | `openprogram/state/store/project/project_store.py` |
| Project actions, including `list_project_sessions`, `set_session_project` | `openprogram/interfaces/server/ws_actions/project.py` |
| Projects page | `apps/web/components/projects/projects-page.tsx` |
| Chat, right sidebar | `apps/web/components/chat/`, `apps/web/components/right-sidebar/` |
| `wsRequest` | `apps/web/lib/net/ws/ws-request.ts` |
| `/api/pick-folder` | `openprogram/interfaces/server/routes/files/workdir.py` |

## Non-goals

- No git panel: the agent does that through chat.
- No fs-events tree watching; open folders re-list on window focus (see [project location](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/workspace/project-location.html)).

## Implementation status

| Part | Status |
| --- | --- |
| File API, tree, viewers, file tabs, write path | Implemented |
| Session Overview panel | Planned. Right sidebar view from `session_artifacts` plus live events: Outputs (files touched by `write`/`edit`, deduped, newest first, click to open), Subagents (label, status, click to focus branch), Sources (files read, URLs from `web_search`/`fetch`, deduped). Derived from persisted tool calls, no new storage. |
| Projects list as a table | Planned. Name, Sources, Updated; a row expands to its sessions; actions open, new session, ⋯ (rename, settings, remove). Needs `updated_at` (max of session timestamps, else registry ctime) and `rename_project`. Pinning later. |
| `run` tabs | Planned |
