Skip to content

Commit cca5b14

Browse files
authored
feat(ui): path-based session and dashboard URLs (#113883)
* feat(ui): path-based session and dashboard URLs * docs(ui): document control UI URLs * fix(ui): finalize session path routing * feat(ui): anchor session URLs on stable keys * docs(ui): clarify stable session URL identity * fix(ui): resolve session prefixes with full prefix and pagination Query sessions.list with the full supplied prefix instead of an eight-char truncation, and paginate up to a bounded page count so longer disambiguation links resolve instead of being reported ambiguous. Zero strict-prefix matches now fall through to literal-key resolution rather than rendering an empty ambiguity view. Also document the ~dot/~dotdot segment escape: peer ids reach session keys trimmed and lowercased only (src/routing/session-key.ts), so a literal '.' or '..' segment is reachable and browsers would normalize it away. * fix(ui): synchronize committed session routes * test(ui): split native shell host coverage * fix(ui): thread configured mainKey through session URL builders Reserved-set disambiguation needs the operator-configured mainKey at runtime, so thread it from agentsList through every session path builder and the ClickClack control URL. Unambiguous non-hex single-segment rests now resolve literally while short-id-shaped rests still fail closed, which restores ClickClack channel compatibility detection and control-link reconciliation. Also bound prefix-resolution retries, preserve catalog thread identity, and keep draft state on ambiguous candidate links. * fix(ui): repair session URL CI integration * perf(ui): lazy-load session route resolution * perf(ui): isolate session prefix resolution * perf(ui): defer session path parsing * perf(ui): defer session navigation startup * fix(ui): preserve first-run and literal session navigation * fix(ui): satisfy session routing type and export gates * fix(clickclack): preserve unscoped control link agent * style(ui): satisfy chat page line limit * refactor(ui): move chat page helpers to owning modules * fix(ui): preserve destination session route identity * fix(ui): preserve agent identity in session routes * fix(ui): escape dots in literal session path segments encodeURIComponent leaves periods intact, so a literal key segment like channel:release.js produced /chat/main/channel/release.js. In-app navigation is intercepted by the SPA, but a refresh, an external link, or a ClickClack link would be served as a static asset request and never reach the app. pathForWorkboardBoard already escapes dots for this reason; mirror it in both the session URL contract and the ClickClack encoder, route the agent id through the same segment encoder, and pin the case in both shared vector tables. * fix(ui): stop bootstrap after teardown race * refactor(ui): centralize session navigation targets * fix(ui): consume bootstrap teardown abort * fix(ui): canonicalize configured main session routes * fix(ui): preserve distinct session references * fix(ui): redirect released session query links * fix(ui): make bootstrap teardown abort-safe
1 parent bba7e30 commit cca5b14

115 files changed

Lines changed: 4913 additions & 903 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/channels/clickclack.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ setup token cannot create or synchronize channels.
220220
`discussions.workspace` accepts the same workspace id, slug, or display name
221221
as the account-level `workspace` and defaults to that value. `section` controls
222222
the ClickClack sidebar section and defaults to `Sessions`. When
223-
`controlUrlBase` is set, the managed channel links back to the real Control UI
224-
session route, `/chat?session=<encoded-session-key>`.
223+
`controlUrlBase` is set, the managed channel links back to the canonical
224+
[Control UI session path](/web/urls#session-and-dashboard-urls).
225225

226226
Enable discussions on exactly one ClickClack account. The gateway provider has
227227
no account selector, so multiple enabled discussion accounts are rejected

‎docs/docs.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,7 @@
17621762
"pages": [
17631763
"web/index",
17641764
"web/control-ui",
1765+
"web/urls",
17651766
"web/dashboard",
17661767
"web/dashboards",
17671768
"web/dashboard-architecture",

‎docs/docs_map.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10858,6 +10858,17 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
1085810858
- H2: Connection troubleshooting
1085910859
- H2: Related
1086010860

10861+
## web/urls.md
10862+
10863+
- Route: /web/urls
10864+
- Headings:
10865+
- H2: Session and dashboard URLs
10866+
- H3: Stability contract
10867+
- H2: Route table
10868+
- H2: Special documents and startup modes
10869+
- H2: Remote Gateway handoff
10870+
- H2: Related
10871+
1086110872
## web/webchat.md
1086210873

1086310874
- Route: /web/webchat

‎docs/web/control-ui.md‎

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ On multi-user gateways, only admin-scope connections can create or view incognit
231231

232232
Inside **Settings**, the dedicated sidebar includes **Ask OpenClaw** and starts with a **Search settings** field for quickly finding settings sections.
233233

234-
On desktop web, a fixed control cluster at the top-left of the content area — the web counterpart of the macOS titlebar strip — holds the sidebar collapse toggle (⌘B) and the command-palette search button (⌘K). Clicking the agent identity row at the top of the sidebar opens the agent menu; **Home** opens the main session. When something needs action — failed or overdue cron jobs, expiring or expired model auth — compact attention chips appear above the sidebar footer and click through to the owning page. The identity row shows the agent's avatar (identity image or emoji), name, connection dot, and a live subtitle. Its agent-scoped menu contains the inline agent switcher (multi-agent setups), **New agent**, "What can this agent do?", and **Agent settings**. Rosters above ten agents get a filter field and list pinned agents first; pin or unpin agents from the Agents settings page, with the pinned set stored in the browser profile. Choosing an agent scopes Chat plus Usage, Automations, Tasks, Workboard, and Sessions to that agent. Each scoped page exposes an **Agent** control with **All agents** as an escape; this widens the shared page scope without changing the concrete chat agent, while direct session links still open their target. The Agents settings page keeps its own `?agent=` selection and does not follow the shared page scope. The footer is one full-width identity card that remains available offline and shows **Reconnecting…** beneath the last-known account name. It opens the app/account menu, whose profile identity header is followed by **Settings**, **Usage**, mobile pairing, **Get the apps**, **Help** (help, Discord, Docs, and the changelog), an offline retry action when needed, the version/build chip, and the color-mode toggle. The build chip opens the About page. When the gateway runs from a source checkout on a branch other than `main`, the footer also shows that branch name in red so a non-release gateway is obvious at a glance (release installs never show it). Shift-Command-Comma on Apple platforms or Ctrl-Shift-Comma elsewhere opens **Settings** without overriding the browser's plain Command-Comma shortcut. Collapsing the sidebar (⌘B or the cluster's toggle) hides it entirely for a full-width workspace; while collapsed, the top-left cluster keeps the expand toggle and search and gains a new-thread button — mirroring what the macOS app hosts natively in its titlebar. The sidebar is the only navigation chrome on desktop, with no top bar. Narrow viewports swap the sidebar for a slide-over drawer behind a compact header row holding the drawer toggle, brand, and command-palette search; on phones, Chat absorbs that navigation row into its title bar, with the menu and search controls beside the session title. In the macOS app the separate header row folds the titlebar clearance into a single compact strip beside the window controls. Navigation uses regular browser history, so the browser's back/forward buttons traverse it; the macOS app adds a native sidebar toggle next to the window controls plus trackpad swipe gestures, with back/forward buttons at the sidebar's right edge while it is expanded and native search (command palette) and new-session buttons while it is collapsed.
234+
On desktop web, a fixed control cluster at the top-left of the content area — the web counterpart of the macOS titlebar strip — holds the sidebar collapse toggle (⌘B) and the command-palette search button (⌘K). Clicking the agent identity row at the top of the sidebar opens the agent menu; **Home** opens the main session. When something needs action — failed or overdue cron jobs, expiring or expired model auth — compact attention chips appear above the sidebar footer and click through to the owning page. The identity row shows the agent's avatar (identity image or emoji), name, connection dot, and a live subtitle. Its agent-scoped menu contains the inline agent switcher (multi-agent setups), **New agent**, "What can this agent do?", and **Agent settings**. Rosters above ten agents get a filter field and list pinned agents first; pin or unpin agents from the Agents settings page, with the pinned set stored in the browser profile. Choosing an agent scopes Chat plus Usage, Automations, Tasks, Workboard, and Sessions to that agent. Each scoped page exposes an **Agent** control with **All agents** as an escape; this widens the shared page scope without changing the concrete chat agent, while direct session links still open their target. The Agents settings page keeps its own [URL selection](/web/urls#route-table) and does not follow the shared page scope. The footer is one full-width identity card that remains available offline and shows **Reconnecting…** beneath the last-known account name. It opens the app/account menu, whose profile identity header is followed by **Settings**, **Usage**, mobile pairing, **Get the apps**, **Help** (help, Discord, Docs, and the changelog), an offline retry action when needed, the version/build chip, and the color-mode toggle. The build chip opens the About page. When the gateway runs from a source checkout on a branch other than `main`, the footer also shows that branch name in red so a non-release gateway is obvious at a glance (release installs never show it). Shift-Command-Comma on Apple platforms or Ctrl-Shift-Comma elsewhere opens **Settings** without overriding the browser's plain Command-Comma shortcut. Collapsing the sidebar (⌘B or the cluster's toggle) hides it entirely for a full-width workspace; while collapsed, the top-left cluster keeps the expand toggle and search and gains a new-thread button — mirroring what the macOS app hosts natively in its titlebar. The sidebar is the only navigation chrome on desktop, with no top bar. Narrow viewports swap the sidebar for a slide-over drawer behind a compact header row holding the drawer toggle, brand, and command-palette search; on phones, Chat absorbs that navigation row into its title bar, with the menu and search controls beside the session title. In the macOS app the separate header row folds the titlebar clearance into a single compact strip beside the window controls. Navigation uses regular browser history, so the browser's back/forward buttons traverse it; the macOS app adds a native sidebar toggle next to the window controls plus trackpad swipe gestures, with back/forward buttons at the sidebar's right edge while it is expanded and native search (command palette) and new-session buttons while it is collapsed.
235235

236236
Pending approvals also contribute an attention chip above the sidebar footer;
237237
select it to open the owning Approvals page.
@@ -258,7 +258,7 @@ select it to open the owning Approvals page.
258258
- Session grouping: a Group by control organizes the sessions table into sections by custom groups, channel, kind, agent, or date. Custom groups persist per session via `sessions.patch` (`category`), so sessions started from message channels (Discord, Telegram, WhatsApp, ...) can be categorized too; assign groups by dragging rows onto a section, or with the per-row group selector, and create groups with the New group action.
259259
- Memory (a tab on the Agents page, scoped to the selected agent): dreaming status, enable/disable toggle, and Dream Diary reader (`doctor.memory.status`, `doctor.memory.dreamDiary`, `config.patch`).
260260
- Import Memory (`/memory-import`, reached from the Agents page's Memory tab): preview and copy local Claude Code auto-memory, Codex consolidated memory, or Hermes memory files into the selected agent workspace (`migrations.memory.plan`, `migrations.memory.apply`).
261-
- Onboarding memory offer: when the Control UI opens in onboarding mode (`?onboarding=1`, used by the Linux companion app after its first-run install), a one-page dialog offers to import detected memories with the same plan/apply flow; skipping leaves the settings page as the later entry point.
261+
- Onboarding memory offer: when the Control UI opens in [onboarding mode](/web/urls#special-documents-and-startup-modes), a one-page dialog offers to import detected memories with the same plan/apply flow; skipping leaves the settings page as the later entry point.
262262

263263
</Accordion>
264264
<Accordion title="Cron, tasks, plugins, skills, devices, exec approvals">
@@ -395,7 +395,7 @@ Connection-owned sessions survive disconnects: a page reload, laptop sleep, or n
395395

396396
Agent-owned sessions are not bound to a browser connection. `terminal.attach` adds each browser as a viewer without taking ownership, and closing a viewer tab detaches only that browser. The PTY remains until the owning agent closes it, its process exits, policy disables it, or the Gateway shuts down. `terminal.list` marks each entry as connection- or agent-owned, and `terminal.text` lets an admin connection read recent plain-text output without attaching.
397397

398-
The terminal is also available as a full-screen, terminal-only document at `/?view=terminal`. The iOS and Android apps embed this page in their Terminal screens, reusing the stored gateway credentials; availability follows the same `gateway.terminal.enabled` and `operator.admin` gate, and the page shows a notice when the connected Gateway does not offer the terminal.
398+
The terminal is also available as a [full-screen terminal document](/web/urls#special-documents-and-startup-modes). The iOS and Android apps embed this page in their Terminal screens, reusing the stored gateway credentials; availability follows the same `gateway.terminal.enabled` and `operator.admin` gate, and the page shows a notice when the connected Gateway does not offer the terminal.
399399

400400
## Browser panel
401401

@@ -665,9 +665,9 @@ This keeps media rendering compatible with browser-native media elements without
665665

666666
## Approval links
667667

668-
Operator approval notifications can deep-link to a standalone approval document served under the reserved `${controlUiBasePath}/approve/{approvalId}` namespace (for example `/approve/<approvalId>`, or `/openclaw/approve/<approvalId>` with a configured base path). The URL is stable for the lifetime of the approval and safe to forward between your own devices: it identifies the approval, never authorizes it.
668+
Operator approval notifications can deep-link to a [standalone approval document](/web/urls#special-documents-and-startup-modes). The URL is stable for the lifetime of the approval and safe to forward between your own devices: it identifies the approval, never authorizes it.
669669

670-
- The one-segment `/approve/<approvalId>` namespace is reserved by the Gateway ahead of plugin HTTP routes for **all** HTTP methods, so a plugin route can never shadow or intercept an approval document.
670+
- The approval namespace is reserved by the Gateway ahead of plugin HTTP routes for **all** HTTP methods, so a plugin route can never shadow or intercept an approval document.
671671
- Opening an approval document requires the same gateway auth as the rest of the Control UI (token/password, Tailscale Serve identity, or trusted-proxy identity); credentials are never part of the approval URL.
672672
- When Control UI serving is disabled, requests to the namespace return `404` instead of falling through to plugin handlers.
673673
- Signing in on an approval document is ephemeral for that page: it does not overwrite the gateway selection or settings saved by the full Control UI in the same browser.
@@ -712,29 +712,14 @@ The Control UI is static files; the WebSocket target is configurable and can dif
712712
pnpm ui:dev
713713
```
714714
</Step>
715-
<Step title="Open with gatewayUrl">
716-
```text
717-
http://localhost:5173/?gatewayUrl=ws%3A%2F%2F<gateway-host>%3A18789
718-
```
719-
720-
Optional one-time auth (if needed):
721-
722-
```text
723-
http://localhost:5173/?gatewayUrl=wss%3A%2F%2F<gateway-host>%3A18789#token=<gateway-token>
724-
```
725-
715+
<Step title="Connect the remote Gateway">
716+
Follow the [remote Gateway URL handoff](/web/urls#remote-gateway-handoff)
717+
reference for the encoded Gateway URL and optional one-time credentials.
726718
</Step>
727719
</Steps>
728720

729721
<AccordionGroup>
730-
<Accordion title="Notes">
731-
- `gatewayUrl` is stored in localStorage after load and removed from the URL.
732-
- If you pass a full `ws://` or `wss://` endpoint via `gatewayUrl`, URL-encode the value so the browser parses the query string correctly.
733-
- `token` should be passed via the URL fragment (`#token=...`) whenever possible. Fragments are not sent to the server, which avoids request-log and Referer leakage. Legacy `?token=` query params are still imported once for compatibility, but only as a fallback, and are stripped immediately after bootstrap.
734-
- `password` is kept in memory only.
735-
- When `gatewayUrl` is set, the UI does not fall back to config or environment credentials. Provide `token` (or `password`) explicitly; missing explicit credentials is an error.
736-
- Use `wss://` when the Gateway is behind TLS (Tailscale Serve, HTTPS proxy, etc.).
737-
- `gatewayUrl` is only accepted in a top-level window (not embedded), to prevent clickjacking.
722+
<Accordion title="Origin security notes">
738723
- Public non-loopback Control UI deployments must set `gateway.controlUi.allowedOrigins` explicitly (full origins). Private same-origin LAN/Tailnet loads from loopback, RFC1918/link-local, `.local`, `.ts.net`, or Tailscale CGNAT hosts are accepted without enabling Host-header fallback.
739724
- Gateway startup may seed local origins such as `http://localhost:<port>` and `http://127.0.0.1:<port>` from the effective runtime bind and port, but remote browser origins still need explicit entries.
740725
- Do not use `gateway.controlUi.allowedOrigins: ["*"]` except for tightly controlled local testing; it means allow any browser origin, not "match whatever host I am using."

0 commit comments

Comments
 (0)