Skip to content
Open
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
64 changes: 31 additions & 33 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ server/
app/
index.html the SPA shell, the bundler entry; #root holds static copies of RouteLoadingFallback and (swapped in on /login by an inline script) LoginForm's first render, painted before the bundle runs
client.tsx browser entry: renders `LoginForm` on `/login`, else `AppShell` (a path check, no router)
boot.ts runs first in client.tsx: installs the sidebar history bridge before AppShell registers popstate listeners
app/api/
sessions/route.ts GET list all sessions
sessions/search/route.ts GET ?q= — NDJSON { scores } batches (titles + transcripts); closing the request stops the scan
Expand Down Expand Up @@ -151,6 +150,8 @@ app/api/
lib/
dynamic.tsx `dynamic()` over `React.lazy` + `Suspense`
navigation.ts `useRouter`/`useSearchParams` over the History API
browser-history.ts single native History API owner: view positions, traversal, reload bounds and root exit guard
session-links.ts session URL builder and same-origin session-link classification
omp/ shared omp foundations (paths, CLI probe, RpcProcess)
plugins-cli.ts `runOmpCli`, `listPlugins` (`omp plugin list --json` as `PluginEntry[]`), `parseJsonLoose`, `ANSI_RE`; loaded by the daemon too (relative imports only); used by `app/api/plugins/route.ts`, `cluster-config-server.ts` and `daemon-cluster-config.ts`
hosts/ hosts and the local daemon (see "Remote hosts"); none of the daemon-loaded files may import `@/` (the daemon runs on Node through `jiti`)
Expand Down Expand Up @@ -224,7 +225,7 @@ lib/
tool-presets.ts PRESET_NONE/DEFAULT/FULL + getToolNamesForPreset()
types.ts shared TypeScript types
normalize.ts normalizeToolCalls() — field name mismatch between file format and our types
navigation-history.ts pure back/forward view-history stack + shortcut matcher (⌘[/⌘], Alt+←/→)
navigation-history.ts platform and shortcut matching (⌘[/⌘], Alt+←/→)
word-prediction.ts pure ghost-text arithmetic (advance/accept) for composer word prediction
worktree.ts project/worktree resolution and git worktree operations

Expand Down Expand Up @@ -271,7 +272,8 @@ hooks/
useIsMobile.ts responsive breakpoint hook
usePrefersReducedMotion.ts OS reduce-motion preference (SMIL-safe)
useTheme.ts theme state (localStorage key "omp-theme"; top bar color → theme-color meta, "omp-theme-color" cookie and the manifest link's ?theme=, see lib/manifest-theme.ts)
useNavigationHistory.ts in-app back/forward stack (record/peek/commit/drop) for visited chat views
useNavigationHistory.ts native browser Back/Forward and owned-view bounds
useSidebarHistory.ts document-exit draft protection; does not own sidebar state
useWordPrediction.ts debounced omp predict_word ghost text + feedback
useBtw.ts /btw records/active panel/history dialog fed by btw_* SSE frames
useChatSearchHighlights.ts find-in-page for the sidebar search: CSS Custom Highlight API paint + jump to a picked hit
Expand Down Expand Up @@ -1738,36 +1740,32 @@ during the wait.
- The Models panel reads and writes `models.yml` in the omp agent directory (`~/.omp/agent/models.yml`, `.yaml` fallback).
- API-key status endpoints must never return the raw key.

### Navigate back / forward (`lib/navigation-history.ts`, `hooks/useNavigationHistory.ts`)
- Browser-style back/forward over visited chat views (sessions + the new-chat
composer), in-memory per page load. It is **omp-web's own stack**, never the
browser History API — the app only ever `router.replace`s `?session=`, and
the real history stack belongs to the mobile back-gesture / exit-guard
machinery (`useSidebarHistory` + the popstate bridge).
- AppShell records views from one effect keyed on
`(selectedSession?.id, newSessionCwd)`: recording the entry the cursor
already sits on is a no-op, which is what makes back/forward
self-suppressing — `navigateInHistory` commits the step, the view lands, the
effect re-records the target, nothing is pushed. Any other view change
(sidebar/palette select, new chat, session created, fork, project-switch
close) pushes normally and truncates the forward branch, browser-style.
- Applying a step: peek → resolve the session id via `/api/sessions` →
commit + `handleSelectSession`, or `handleNewSession` for new-chat entries.
A dead id (deleted session) drops that entry and tries the next one in the
same direction; a failed list fetch aborts without dropping. A view change
during the await (versioned ref) aborts the navigation so a slow fetch
never yanks the chat away.
- Shortcuts live in `useGlobalKeyboardShortcuts`: ⌘[/⌘] (macOS standard),
Alt+←/Alt+→ (Windows/Linux standard; on macOS Alt+Arrow stays free — it is
word-wise caret movement), plus the mouse back/forward buttons
(`BrowserBack`/`BrowserForward`). The keystroke is always swallowed while a
handler is registered — an exhausted stack stops dead rather than falling
through to the browser's own back/forward, so the app is never backed out
of by accident — and shortcuts are skipped entirely while a
`[role="dialog"]` modal is open. The sidebar header buttons (before Archived
Sessions, wrapped in `.sidebar-nav-buttons`) disable on stack bounds, show
the platform shortcut in their tooltip, and hide below a 240px sidebar via
the `.sidebar-shell` container query (the keyboard shortcuts still work).
### Session URLs and browser history (`lib/browser-history.ts`, `lib/navigation.ts`)
- The browser owns session, new-chat and sidebar view history. `?session=ID`
selects a session; `?cwd=...&hostId=...` selects a new-chat workspace.
`sidebar=open|closed` restores explicit visibility, including on mobile.
AppShell pushes user view changes and replaces new-session promotion or
same-conversation identity moves. Sidebar-only traversal keeps the chat mounted.
- Pooled new chats use `poolId`, `projectId` and `creationId` instead of a worker
path. Restore the logical project and the same creation ID; a worker cwd is
never a fallback. `rememberCreationInitialization` freezes the first native
initialization in tab-local sessionStorage so older sidebar entries and reloads
cannot replay that creation with changed model defaults. It is not URL data.
- `lib/browser-history.ts` is the sole history owner. It preserves unrelated
`history.state`, stores positions (not view copies) in sessionStorage for
reloadable bounds, and keeps a non-view root sentinel for document-exit
confirmation. Canceled exits restore the accepted URL without truncating
forward history. `useSidebarHistory` supplies the draft guard and beforeunload
warning; it never intercepts sidebar/session navigation.
- The sidebar resolves each requested URL session against its list, resetting
restore attempts on target changes. Async workspace validation cancels on
navigation. Identity moves replace the URL without remounting the composer.
- Sidebar session titles are real anchors. `sessionLinkHref` recognizes internal
session URLs before Markdown file-link classification; ordinary clicks push
SPA history, while modified/middle clicks retain native browser behavior.
- Header navigation buttons and keyboard shortcuts use the same native owner,
stop at owned-view bounds, and preserve the existing modal shortcut exclusion.
Native browser Back can leave the app at the root, subject to draft protection.

### Composer word prediction (`hooks/useWordPrediction.ts`, `components/GhostMirror.tsx`)
- Ghost text comes from omp's `predict_word` command (engine = omp's
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
**Before upgrading:** after this update, every linked host already in the first pool uses this machine's provider logins (it can read their access tokens and stored API keys) without a confirmation having been shown. This includes a first pool disabled through the API, and a host added to the first pool later through `PUT /api/hosts` or by editing `pools.json`. Each linked member needs an updated ompweb host daemon (link protocol 9 at that release; cluster members now need link protocol 10, see the first entry) and omp 15.13.1 or newer; until its daemon is updated, cluster placement skips that member, and a start fails when no other member is eligible. Before updating, remove a host that should not receive the logins from the first pool using `PUT /api/hosts` or editing `~/.omp/agent/omp-web/pools.json`; the old version has no membership switch.
- **Hosts can use the server's provider logins.** **Settings → Hosts** has a per-host toggle, **Use this server's provider logins**, off by default; turning it on asks for confirmation. Sessions started on that host then use the logins stored on the ompweb server instead of the host's own, through `omp auth-broker serve` on the server and a loopback forwarder in the host daemon. The host token never enters an omp process's environment, and OAuth refresh tokens never leave the server machine; the host can read current access tokens and stored API keys. Starting a session on a sharing host needs a daemon on link protocol v9 and omp 15.13.1 or newer, and is refused otherwise rather than falling back to the host's own logins. Custom providers in `models.yml`, environment-variable API keys and omp settings are not shared. A reverse proxy must let `/api/hosts/broker/` through without its own authentication, response buffering or redirects.
- **Windows hosts can be pool workers and accept local maintenance controls.** `ompweb host status`, `drain` and `resume` now work on Windows through a named pipe with a random name and a per-start token, kept in `<agent dir>/omp-web/host-control.json`; requests without the current token are refused. Windows hosts also report CPU busy time and available memory, so pools can place sessions on them. Windows reports no load average, so CPU pressure there comes from busy time alone.
- **Share session links and navigate with browser Back/Forward.** Session titles in the sidebar are real links, supporting Copy link and opening in another tab. Session links in chat open the conversation rather than the file viewer. The URL records the selected session or new-chat workspace and sidebar visibility, and Back/Forward restores those views on desktop and mobile. Sidebar-only navigation keeps the composer mounted, per-session drafts survive switches, and leaving the app still warns about unsent drafts.
- **Archive and restore sessions on linked hosts.** Archiving now works for sessions on any linked machine, not only this one. The Archived Sessions browser lists every host's archive, shows which host each session is on, and restores it on that host. A host that is offline or runs an older ompweb host is named in the browser instead of hiding its archive silently. Restore rejects a session ID already active on any registered host, so every registered host must be online to restore, even an archive on this machine; the browser names the offline host that blocks it. A per-session claim stops web-server processes that share one agent directory from restoring the same session together; it does not coordinate separate web servers that share a daemon. A restore on another host keeps running when the web server stops waiting for it (after 30 s, or when the link drops), so the session stays claimed until that host's daemon process confirms it stopped: restoring the same ID again, on any host, is refused until then instead of creating a second active copy. Only the daemon process that took the restore can confirm that, so if the daemon was replaced, restarted or shut down meanwhile, or its host was unregistered, the session stays blocked: there is no timeout and no automatic clearing, and recovery is manual (see AGENTS.md). A restored session's attachments and other files are put back before the session becomes visible, so a file attached from another tab at that moment can no longer fail the restore or block retrying it. Restore streams archives with fixed 256 MiB compressed and expanded limits and rejects unsupported session IDs before consuming the archive.
- **Traditional Chinese (`zh-TW`) interface language.** Select Traditional Chinese (繁體中文) in the top-bar language menu. On compact layouts, open **More controls** first. Alternatively, let omp-web pick it automatically when the browser language is `zh-TW`, `zh-HK`, `zh-MO`, or `zh-Hant`. Localized Web Push notifications and a Traditional Chinese README (`README.zh-TW.md`) are included.
- **Several web apps can share one host daemon and the same live sessions.** Link additional servers with `ompweb host login --add --url <server>` (token from stdin). Prompts, tool progress, results and dialogs stay synchronized, and restarting one web app leaves the other connected to the same omp process. Link protocol v7 moves session startup, idle cleanup and interrupted-run recovery into the host; older links remain supported without sharing their processes. Schedule the first daemon upgrade while its host is quiescent.
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ The **Steer**, **Delete** and **Edit** actions on a queued message are commands

The queue panel shows omp's own queue (`queuedMessages` in `get_state` and `queue_update` events), so every device viewing a session sees the same queued messages. **Stop** moves the text of messages still waiting in the queue back into the composer instead of letting the agent run them; a steer the model already picked up through live steering still runs.

## Shareable navigation

Each session has a URL such as `/?session=<id>`. Session titles in the sidebar
are links: use your browser's Copy link or open-in-new-tab controls. Session
links in chat navigate within the app.

Browser Back/Forward and the sidebar navigation buttons restore session changes
and sidebar visibility (`&sidebar=open` or `&sidebar=closed`). New-chat URLs keep
their workspace in `?cwd=...`, with `hostId` for another machine, or
`?poolId=...&projectId=...&creationId=...` for a pooled creation. Reloading restores
the URL's view; sidebar-only changes do not reset the composer. Frozen pooled
initialization stays in this tab's session storage, not in shared URLs.
Drafts remain separate from URLs, and leaving the app warns about unsent drafts.

## App installation behind authentication

To install the web app, sign in first and use your browser's installation menu.
Expand Down
6 changes: 0 additions & 6 deletions app/boot.ts

This file was deleted.

1 change: 0 additions & 1 deletion app/client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./boot";
import { StrictMode, Suspense } from "react";
import { createRoot } from "react-dom/client";
import { AppErrorBoundary } from "@/components/AppErrorBoundary";
Expand Down
Loading
Loading