Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ The table is static imports, not a runtime glob, so `bun build --compile` (`scri
- The binary needs `process.env.NODE_ENV` defined as `"production"` at build time (`scripts/build-binary.ts`): a plain `bun build --compile` inlines `"development"`, and the server then never writes the daemon's link. `npm run smoke -- --binary` catches that (no session lists).
- `Bun.serve` turns on `SO_REUSEPORT` when `development` is false, so a second omp-web would share the port instead of failing; `startServer` passes `reusePort: false`, and `startProduction` (`server/app.ts`) reports an `EADDRINUSE` in one line.
- The web-server in-app update worker runs on Node (`OMP_WEB_NODE_BIN`, the launcher's `process.execPath`), not Bun. The compiled web server updates by download (`lib/self-update.ts`). Host-daemon updates use their own helper in `lib/hosts/update-worker.ts`, including for binary hosts; never reuse the web-server worker to restart a host.
- Bun's `fs.watch` drops an event that follows the previous one within ~2 ms, so the file channel (`openFileChannel`, `lib/event-stream-hub.ts`) re-stats the file ~50 ms after every event.
- The daemon-owned watcher (`lib/hosts/workspace-watch.ts`) re-stats ~50 ms after every event to catch burst saves (Bun may drop native events within ~2 ms); main only routes its sequenced watch events.
- `bun:sqlite` `.get()` returns `null` for no row (not `undefined`).
- `bun:sqlite` `close()` keeps the database file open while prepared statements are alive (until GC), so Windows cannot remove or replace it: the stores close with `close(true)`, which finalizes them (`closeNotificationStore`, `closeUsageDatabase`).
- `readSttConfig` lives in server-only `lib/stt-jobs.ts`; the browser bundle must never import it.
Expand Down Expand Up @@ -525,11 +525,16 @@ The table is static imports, not a runtime glob, so `bun build --compile` (`scri
(`confirmFromServer`). Local callers never ask for this machine. A remote
caller asks before any other host unless that host allows agent starts, and
always before this machine, for `new_session` and `send_to_session` alike.
- **Not yet remote:** Explorer, Git, Worktrees, the Skills/Plugins/Agents/MCP
settings tabs and directory browsing show "Not available on remote hosts
yet". Archive is refused for a remote session (501 `remote_unavailable`, the
menu item disabled): the Archived Sessions browser reads this machine's archive
only, so it could not be restored. Sub-projects 2 and 3 of the spec add ops for them.
- **Workspace operations are daemon-owned** (`lib/workspace-types.ts`,
`lib/hosts/workspace-ops.ts`; design `docs/specs/2026-11-03-remote-workspaces-design.md`).
Files/index/shell output/watch, Git/worktrees, browsing/default cwd and clone
APIs use `Host.workspaceOps` for every host, including local. Optional hello
capabilities gate old daemons; unavailable operations never fall back to main.
File tabs retain host/cwd/session ownership. Upload publication extends the
existing staged 2 GiB uploader; its workspace receipts are not session attachments.
- **Not yet remote:** Skills/Plugins/Agents/MCP settings and session archiving.
Archive remains 501 `remote_unavailable` with its menu item disabled; transcript
search and the archive browser still read this machine's files.

#### Local daemon (`docs/specs/2026-10-29-local-daemon-design.md`)
- **Two services.** `ompweb` (web) and `ompweb-host` (`ompweb host`, the daemon) are installed together by `ompweb systemd install`, `ompweb launchd install` and the Windows tray install; uninstall removes both, `ompweb systemd restart` restarts the web unit only. The daemon owns this machine's omp children, so a web restart, update or redeploy leaves runs going; restarting the daemon ends them (auto-resume then resumes the sessions that were running). An upgrade restarts the daemon only when the running daemon's link version is outside the new release's `[MIN_LINK_PROTOCOL_VERSION, LINK_PROTOCOL_VERSION]` range (it would get 4426 or 426 and exit); a daemon inside the range keeps running.
Expand Down Expand Up @@ -1014,11 +1019,11 @@ during the wait.

### Worktrees and project grouping
- `lib/worktree.ts` resolves linked worktree top-levels back to the main repo `projectRoot`; `listAllSessions()` attaches that to each `SessionInfo` so all worktrees for one repo are grouped together in the sidebar.
- Worktree operations are served by `/api/worktrees` and guarded by the same allowed-root rules as `/api/files`.
- `/api/worktrees` delegates authorized operations and root grants to the owning daemon; only that host's session-list cache is invalidated on main.
- New worktrees are created under `<repoRoot>-worktrees/<sanitized-branch>`. Existing branches are reused; otherwise `git worktree add -b` creates the branch.
- Removing a dirty worktree returns `409` with `{ dirty: true }` so the UI can ask before retrying with `force`.
- The file panel's **Worktrees** tab (`components/WorktreesPanel.tsx`) switches, creates, and removes worktrees; the new-session screen's worktree `<select>` (AppShell, shown when the selected workspace has 2+ worktrees) only switches. `SessionSidebar` owns the per-repo worktree cache and the actions and emits them as a `WorktreeContext` (`onWorktreeContextChange`, null unless the active workspace is a Git top-level repo); AppShell hands it to both. Switching moves the sidebar's effective cwd (where a new session starts), not the open session.
- Explorer, Git, and file viewers use `explorerCwd` in AppShell: the open session's cwd first, then the sidebar's cwd, then the new-session cwd. Mention/copy-path helpers resolve relative paths against the same value.
- Explorer and Git pair `explorerCwd` with its owning host. Each file tab instead retains its source host/cwd/session; relative links and downloads use that source after chat switches. Worktree caches, contexts and pending actions also include host identity.
- Sessions whose cwd points at a removed worktree are inferred back into the main project instead of becoming a phantom project row.

### Managed projects sidebar (`lib/project-registry.ts`, `/api/projects`)
Expand Down Expand Up @@ -1060,18 +1065,28 @@ during the wait.
- Only `https://`, `ssh://` and scp-like `user@host:path` URLs are accepted
(`cloneDirectoryName`); git also runs with `GIT_ALLOW_PROTOCOL=https:ssh`
and `GIT_TERMINAL_PROMPT=0`, so credentials must come from helpers/agents.
- The POST streams NDJSON (`output` chunks, then one of `done` / `cancelled` /
`error`). Cancel is `DELETE { id }`: the POST stream stays open until the
partial clone is deleted, so the UI can confirm the cleanup. A client
disconnect cancels and cleans up too. An existing target is refused (409).
- The POST streams NDJSON from daemon-owned jobs (`lib/hosts/workspace-clone.ts`);
DELETE carries `{ id, hostId }` and waits for process exit and identity-checked
cleanup. Cleanup captures into a private quarantine, verifies identity there,
and removes only the owned clone. A raced replacement is preserved and its
recovery location is shown. Existing targets are refused (409). Link/main
restarts leave jobs alive, but the UI reports uncertain
outcomes on a lost stream. Unobserved jobs cancel after two minutes; an unknown
job on a replacement daemon never means successful cancellation.

### File access allow-list
- `/api/files` is intentionally not a general filesystem browser. Allowed roots come from this machine's session cwds and their resolved project roots (as its daemon lists them: `hostSessions("local")`, the last list while the daemon is offline), `~/omp-cwd-*`, and roots explicitly added with `allowFileRoot()`. Other hosts' paths never reach it.
- `/api/cwd/validate`, `/api/default-cwd`, and `/api/worktrees` call `allowFileRoot()` when they make a new location browsable.
- `/api/files` is not a general filesystem browser. `workspace-roots.ts` discovers
that daemon's sessions/projects, explicit validated grants, scratch directories
and instruction roots. Reads and watches share explicit-root authorization;
session references grant reads only, not listing or writes. Credential exclusions
apply to canonical targets too.
- Successful selection, default cwd and worktree operations grant roots on the
owning daemon. Browsing alone grants nothing. Main's `getAllowedFileRoots()`
remains for the unrelated local config/import/skills readers, not workspace APIs.
- The session-id → file path cache (`cacheSessionPath`, `lib/session-reader.ts`) on main is filled by main's own scans and by wrappers on the local host; it only serves the readers listed under "Session list caching".

### Explorer hidden items
- The tree skip-list (`IGNORED_NAMES`/`IGNORED_SUFFIXES`) is **duplicated** in `app/api/files/[...path]/route.ts` and `app/api/file-index/route.ts` — edit both or extract a shared module.
- The tree and index share `isIgnoredFileEntry` in `lib/file-dirent.ts`.
- The Explorer's "Show hidden items" toggle sends `?hidden=1`, which bypasses the skip-list for `type=list` only. It deliberately does NOT touch `/api/file-index` — @-mentions and file search keep ignoring those paths. State is AppShell-owned (localStorage `omp-web:show-hidden-files`, off by default); flipping it makes `FileExplorer` drop its cached listings and re-read the visible directories, keeping expansion.

### Session list caching — new sessions must appear immediately
Expand All @@ -1085,7 +1100,7 @@ during the wait.
`invalidateSessionFileListCache()` — never add a session-mutation path that
forgets this. Regression test: `session-reader.test.mjs`.
- A mutation that main triggers calls `invalidateLocalSessionLists()`: it clears main's per-host entry and sends the daemon `invalidateSessionLists` (the daemon runs the invalidation above). A route that changes this machine's session files and does not call it leaves the sidebar stale for up to 30 s.
- **Still read on main, from this machine's own files** (main and the daemon share a machine, so these see the same sessions): transcript search (`session-content-search.ts`, `/api/sessions/search`), the session file watcher (`session-watcher.ts`), archive list/restore (`/api/sessions/archive`), import (`/api/sessions/import`), usage (`usage-db.ts`), and the bash-output, subagent-history and file-reference readers (`session-file-references.ts`, `subagent-history.ts`). They use main's own copies of `session-reader` and its caches, so they are invalidated separately (`invalidateSessionListCache()`); a new reader of session files on main for a session that may be remote is a bug.
- **Still read on main, from this machine's own files:** transcript search (`session-content-search.ts`, `/api/sessions/search`), the session watcher (`session-watcher.ts`), archive list/restore, import, usage (`usage-db.ts`), subagent history and local file-reference readers. Their main-side session caches are invalidated separately. Workspace shell-output authorization and bytes now come from the owning daemon; new remote-capable readers must use the host seam.

### Chat scroll-follow
- `useAgentSession` follows the conversation: the effect depends on both
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
### Added

- **Identify untagged builds from the logo.** Clicking or tapping the ompweb logo still reveals the version; builds made from an untagged Git commit also show its full hash and commit date (`YYYY-MM-DD`). Builds made on a tag keep the version-only display. The metadata is embedded in the browser bundle, so installed packages and binaries do not need Git.
- **Run sessions on other machines from one ompweb.** Link a machine (for example a MacBook) with **Settings → Hosts → Add host**, then run `ompweb host login --url <server url>` (the token is read from stdin) and `ompweb host` there. The remote machine keeps its own `omp`, agent directory and credentials; ompweb routes. The sidebar groups sessions by host, the new-session screen has a host picker, and chat, history, notifications and resume work on every host. If the link drops, the run continues on the remote machine and the chat shows an offline banner until the host reconnects. Agents can pass `host` to `new_session` (it defaults to the agent's own host), which asks for confirmation on a remote host unless the host allows it; an agent on a remote host always asks before it starts or messages a session on this machine. Explorer, Git, worktrees and the skills, plugins, agents and MCP settings are not available on remote hosts yet.
- **Workspace file APIs run on the owning host.** Directory listings, file metadata and previews, downloads, file search and referenced shell output go through that machine's daemon, including This machine. File downloads stream in bounded chunks rather than being limited by the host link's per-result size. A stopped or older daemon reports unavailable or unsupported instead of reading a path on the web server.
- **File tabs keep their owning workspace.** Files with the same path on different hosts open in separate tabs. Switching chats does not redirect a tab's reads, Markdown links, images or downloads to the new host. Explorer and composer file suggestions follow the selected host, and confirming an agent's file-open request keeps that request's source host. Mention and reveal actions are disabled while the active chat belongs to another host.
- **Explorer uploads use the shared 2 GiB-per-file uploader on every host.** The old 25 MiB file and 100 MiB batch caps are gone. Files stream into host staging before authorized publication into the selected workspace. Conflict choices preserve existing files until replacement is ready; cancellation removes pending staging, not files already saved. Preview limits are unchanged.
- **Live file watching follows the file's host.** The owning daemon watches and reauthorizes the file, including atomic editor saves. Reconnecting creates a fresh watch and refreshes bytes missed while offline. Closing a tab releases only its watch; no file watcher on the web server substitutes for a disconnected host.
- **Git and worktrees work on linked hosts.** Status, patches and GitHub references use the repository on that machine. Worktree create/select/remove keeps its host identity, grants new paths only there, and retains dirty-removal confirmation. Late results from another selected host cannot replace the current workspace state.
- **Browse and clone workspaces on linked hosts.** The Add workspace picker navigates the chosen machine, validates clone destinations there, and registers completed clones on that host. Clone jobs retain bounded progress across a web restart; cancellation confirms process exit and safe cleanup, while interrupted connections report uncertain outcomes. Workspace URLs can retain their host with `?cwd=...&hostId=...`.
- **Run sessions on other machines from one ompweb.** Link a machine (for example a MacBook) with **Settings → Hosts → Add host**, then run `ompweb host login --url <server url>` (the token is read from stdin) and `ompweb host` there. The remote machine keeps its own `omp`, agent directory and credentials; ompweb routes. The sidebar groups sessions by host, the new-session screen has a host picker, and chat, history, notifications and resume work on every host. If the link drops, the run continues on the remote machine and the chat shows an offline banner until the host reconnects. Agents can pass `host` to `new_session` (it defaults to the agent's own host), which asks for confirmation on a remote host unless the host allows it; an agent on a remote host always asks before it starts or messages a session on this machine. Session archiving and the skills, plugins, agents and MCP settings remain unavailable on remote hosts.
- **Restarting or redeploying ompweb no longer interrupts a run on this machine.** "This machine" now runs through a local `ompweb host` daemon, installed as a second service (`ompweb-host`) by `ompweb systemd install`, `ompweb launchd install` and the Windows tray install. The daemon keeps the omp processes; a restarted web server adopts them, with no resume prompt, and the dialogs and browser tool calls omp was waiting on come back. The daemon is required: until it is installed and linked, "This machine" shows offline (with a banner showing the install command) and new sessions there cannot start. An `ompweb` run in a terminal or with npx installs no service: keep `ompweb host` running in a second terminal. Restarting the daemon still ends runs, and `ompweb systemd restart` leaves it alone. If the web server comes back on another port, the daemon follows it. A `npm run dev` server does not take over the daemon. "This machine" can be renamed in **Settings → Hosts**.
- **ompweb as a single binary, with no Node or npm.** Each release now also carries `ompweb-linux-x64`, `ompweb-linux-arm64`, `ompweb-darwin-x64`, `ompweb-darwin-arm64` (`.tar.gz`) and `ompweb-windows-x64` (`.zip`): one `ompweb` program with the web files beside it. It takes the same options and environment variables as the npm `ompweb`, and runs the daemon too (`ompweb host`). It has no tray, service installers or in-app update: the README's "Single binary" section shows the service units, and Settings → System links the release page when an update is out. Build one with `npm run build:binary`.
- **Binary prereleases from `main`.** Each commit on `main` that passes CI is published as a GitHub prerelease titled with its build time in ISO 8601 UTC (for example `2026-11-01T10:30:00Z`; tag `20261101T103000Z-<short sha>`) with the five single-binary archives. Prereleases are never marked latest, publish no npm package and trigger no update notice.
Expand All @@ -26,6 +32,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

### Fixes & Improvements

- **Windows host updates allow more time for safety checks.** The process inventory gets up to 20 seconds to start and finish on a busy machine, instead of five. Shared installations and failed or unreadable inventories still block the update before the daemon is stopped.
- **Table charts show every numeric column at once.** Columns that share a unit are drawn as grouped bars with a legend, instead of one column at a time behind a selector, and columns with different units each get their own chart in the same panel. Rows are labelled with the first descriptive column, so an index column such as `#` is no longer used as the label or charted. Values that start with `about`, `approx.`, `approximately`, `around` or `roughly` are read as estimates instead of making the column unchartable. The axis labels now line up with the bars, and the SVG export contains all of the charts.
Charts remain readable on browsers without CSS subgrid. Tables with more than five same-unit measures are split into additional charts so no legend repeats a colour.
- **Finished background tool calls no longer show up as running.** A `bash` or `task` call that omp moved to the background kept reporting progress after it returned, and ompweb counted each report as a running tool. Opening the chat mid-run then listed those long-finished calls as empty running rows below the transcript until the next event, and an open chat could briefly show a finished call as running again. Calls that returned before an ompweb server restart can still show this once.
Expand Down
Loading
Loading