Skip to content

ui: put remote server pairing behind an experimental setting - #43

Closed
allozaur wants to merge 73 commits into
allozaur/feat/serversfrom
allozaur/feat/experimental-remote-pairing
Closed

allozaur wants to merge 73 commits into
allozaur/feat/serversfrom
allozaur/feat/experimental-remote-pairing

Conversation

@allozaur

@allozaur allozaur commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Overview

Pairing a remote server over WebRTC becomes an opt-in Experimental setting, off by default, that names its known security gap, so the tunnel can ship while the stronger handshake is designed. Servers added by URL work either way.

Additional information

A layer of the work-in-progress stack on the fork, based on allozaur/feat/servers (#35).

Cause

The client sends {type: 'auth', pass} to whichever peer answered its offer on the public WebTorrent tracker, and the room code it rendezvous on is visible to anyone watching that tracker. Whoever answers first can collect the pass code and then pose as either side.

What changed
  • New setting in Settings → General, "Enable remote server pairing", off by default, with the flask icon of the other experimental settings. Its help text says it is experimental, and an amber note under it names the gap and the planned fix: a mutual challenge-response where both sides prove they know the code without sending it.
  • Settings fields can carry a note, a caveat shown under the help text.
  • remoteAccessStore.isEnabled gates the transport at its one choke point: while it is off no tunnel opens, and turning it off closes the ones already open.
  • With the setting off, the servers form offers URLs only, the empty state and page copy speak of URLs, and the local card hides its Pair button. It still shows the host's access code and QR code, since the host was started with --connect on purpose. A saved remote server stays listed, so it can be edited or forgotten.
  • With the setting on, the Remote server tab carries the flask icon, and the remote form shows an Experimental notice about the gap.
Follow-up: mutual authentication

The planned fix keys an HMAC-SHA256 challenge-response on the pass code. Both sides send a fresh nonce, the host proves first, and both proofs cover the DTLS certificate fingerprints of the two SDPs, which ties them to this very connection and defeats a relay in the middle. The access code and QR code stay as they are, so scanning still connects in one step. Old peers are refused rather than downgraded. It needs a matching change in ggml-org/llama-connect, so it lands separately.

Testing
  • npm run check, lint and the unit suite pass. A new unit test covers the default, the experimental flag and note, and that no tunnel opens while the setting is off.
  • Checked in the dev server: the setting and its note in Settings, and the Servers page and form with the setting off and on.

Requirements

@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 39b0d62 to 3a734ad Compare November 9, 2026 11:29
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch from 1495208 to 4106fe5 Compare November 9, 2026 11:31
@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 3a734ad to 7fbabe8 Compare November 9, 2026 11:56
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch from 4106fe5 to ecbc54d Compare November 9, 2026 12:00
@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 7fbabe8 to e7a2c6b Compare November 9, 2026 12:44
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch 3 times, most recently from e336891 to 8e232e4 Compare November 9, 2026 15:06
@allozaur
allozaur force-pushed the allozaur/feat/servers branch 2 times, most recently from 8be6ea1 to 6a2834b Compare November 9, 2026 15:24
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch from 8e232e4 to 8ff3bc3 Compare November 9, 2026 15:24
@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 6a2834b to c4d1026 Compare November 9, 2026 16:03
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch 2 times, most recently from 932b062 to f9f546b Compare November 9, 2026 16:26
A project's folder shows the same row as a chat's working directory change.
Master draws that row inline in ChatMessageCwdChange; move it into its own
component so both use it.

Assisted-by: Claude (Opus 5.5 Medium)
The projects work as it stood before groups split out of it, kept on top
of groups until it is reworked into its own PR. Not for review.

Projects live in their own IndexedDB table (schema version 3) with a name,
a goal, instructions, context items, a working directory and a hidden
flag, and are configured in one dialog. A new chat in a project starts
from its instructions and context and in its folder. Every visible project
is a sidebar section beside the groups. A chat's menus and the chat form
add it to a project, and a chip under the chat form shows it. Tabs and
pinned chats lead with their project's name, the search dialog lists
projects, and the agent can read and edit them.

A chat in a project shows in the project's section, not its group's.

Assisted-by: Claude (Opus 5.5 Medium)
A Projects action under Search opens a page of project cards, newest
first, with the ones hidden from the sidebar apart below. A card opens the
project dialog, and its right-click menu and "more actions" dropdown edit,
hide or delete the project; New project creates one.

Assisted-by: Claude (Opus 5.5 Medium)
A project is no longer a section of its own: it is a row with its chats
under it, and sits in Pinned, a group or Ungrouped like a chat, moved
there from its menu or by dragging it. A chat dropped on a project joins
it; a chat moved to a group leaves its project. Folding a project
replaces hiding it, so the hidden flag is gone.

Assisted-by: Claude (Opus 5.5 Medium)
The instructions no longer sit under a "You are working in the project"
preamble and an "Instructions for this project:" heading: they go into
the system prompt exactly as the user wrote them. The context list, when
there is one, follows with its own label.

Assisted-by: Claude (Opus 5.5 Medium)
A pinned project's card shows a dimmed pin in its bottom right corner.

Assisted-by: Claude (Opus 5.5 Medium)
The Projects page splits into "Your projects" and "Archived" tabs. Archiving
a project, from its sidebar row or its card, takes it and its chats off the
sidebar and out of the project pickers; restoring it from its card brings
them back where they were.

Assisted-by: Claude (Opus 5.5 Medium)
A project opens on its own page in the chat layout: a breadcrumb with pin, archive, delete and export actions, an editable title, Instructions and Context cards, the project's recent chats and the chat form, all in the chat column. A chat sent from there starts in the project, in the project's working directory. Context takes uploaded files and files or MCP resources picked through the @ picker.

Assisted by: Claude (Opus 5.5 Medium)
Chats opened from a project page live under #/projects/<id>/chat/<cid>, and #/projects/<id>/chat/new starts a chat inside the project. There the tab bar leads with the project breadcrumb and shows only the project's chats, linked inside the project; + opens a new-chat tab of the project. Closing tabs, cycling them and the close shortcut stay within the view. Opening a chat from the sidebar keeps the regular view.

Assisted by: Claude (Opus 5.5 Medium)
The pin and the project menu move from the top corner to the title row,
next to what they act on, and the top bar keeps only the breadcrumb.
The goal is edited in place under the title, like the name, with a
placeholder while it is empty. A details line under it shows the chat
count, when the project was last updated and its working directory.

Assisted by: Claude (Opus 5.5 Medium)
Going back to a project from one of its chats keeps the project's tab
bar, with none of the tabs active and the breadcrumb naming the project
as the current page. The page's own breadcrumb returns once the last
tab closes.

Assisted by: Claude (Opus 5.5 Medium)
A conversation has one home: its project's view when it is in a
project, the regular view otherwise. The sidebar, the search dialog,
the conversation shortcuts, forks and the search page link there
directly, and the chat layout redirects any other way in (an old link,
the back button, a chat moved in or out of a project while open)
without a history entry of its own.

Project chats stay in their project's tab strip, out of the regular
one, so they no longer carry the project name as a prefix there.

Assisted by: Claude (Opus 5.5 Medium)
The card on the Projects page and the + of a project's sidebar row go to
the project's page, where its new chats start, and the row's menu gains
Open project. A chat outside any project no longer shows the project
chip left over from the last project page.

Assisted-by: Claude (Opus 5.5 Medium)
…on phones

Assisted-by: Claude (Opus 5.5 Medium)
… project

Assisted-by: Claude (Opus 5.5 Medium)
allozaur and others added 26 commits November 9, 2026 17:34
The models store derives its list from the backends now, so the drawer
test seeds the active models instead of assigning the derived list, and
runs inside the tooltip provider the app shell supplies.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
The active backend of an external provider has no /props, so its role
degrades to MODEL while the selector still has a list to show. The
trigger opened the manager instead of the list.

Gate the trigger on the selectable list instead of the router role.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
A compat backend serves the selection itself and reports no load state,
so the selected model sat inside its provider section, possibly cut off
by the display cap. Give it a leading section of its own, in the
selector list and the manager table, the way loaded models lead the
llama-compat ones.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
A remote provider serves its own template and reports no /props, so the
section would never show one.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
The pane passed no canToggleLoad, so the load button defaulted to
visible for models of backends that cannot load or unload.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
The status cell branched on the active backend's role, so rows collapsed
to the served-by placeholder once a provider was the selected backend,
and the state lookup resolved the backend by raw-name first match, which
a same-named provider catalog entry shadowed: loading a loaded local
model then failed with 'model is already running'.

Branch the cell per row instead, resolve the state from the local feed
first and the backends' own listings after, and start the local feed
while a remote backend is active: the feed reports the local server's
models, so the local server's role decides.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
Drop the OpenAI-compatible backend dialect from the providers work: every
backend now speaks the llama.cpp API, so there is nothing to negotiate.

Goes with it: the protocol enum and its capability and wire-quirk tables,
the adapter registry (it had a single implementation, and both protocols
resolved to it), the chat and models path overrides, the endpoint probe
that classified a URL as llama or OpenAI, and the hosted-provider presets
with their recommendation block. ChatService now builds llama.cpp requests
directly and decodes its stream through chat-wire, keeping the timings the
server reports instead of the wall-clock fallback a foreign endpoint needs.

The gates that read those capabilities collapse to their llama.cpp branch:
load, unload, slots, props, the resumable-stream endpoints and pre-encode
are simply available. A row of another server loads through that server,
and the switch that keeps local server state now keys on the built-in
backend rather than on a protocol.
A remote llama.cpp server is one the UI reaches over a WebRTC data channel
instead of a base URL. It stays a provider: it is listed, named, enabled and
disabled, and its models appear in the selector like everyone else's.

What changes is where a provider's requests are addressed. A remote provider
has no URL of its own, so it is given a synthetic origin whose host carries its
id (`https://<id>.remote.llamacpp.invalid`, the suffix being reserved so the
host can never resolve). Every service already builds its URLs through `apiUrl`,
so nothing in the services had to learn about tunnels: `getBackendBaseUrl` hands
back the synthetic origin, and a fetch wrapper installed in `hydrateStores`
routes a request by that host instead of by the page origin.

Routing on the address is what makes this safe to run next to other providers.
The first remote-access build tunneled everything aimed at the page origin, so
one tunnel was the most it could hold, and a remote provider with a URL of its
own would have slipped past it. Now a request aimed at a tunnel origin with no
live tunnel is refused out loud, and because the origin cannot resolve, a call
site that ever bypasses the resolver dies in the browser rather than reaching
the server that happens to serve this UI. A request queued while the handshake
ran is refused the same way if the channel died underneath it.

Tunnels open lazily: only the provider the app opens with is handshaked during
startup, the rest when one of their models is picked or Connect is hit on their
card. A provider that is disabled or removed loses its data channel, and its
code - which is a credential - is dropped with it.

Three things this forces into the open, all of them pinned to the built-in
provider back when no second provider could exist:

- `validateApiKey` probed the active provider with the key of the local one, so
  a remote provider answering 401 raised the API key splash over a credential
  belonging to another machine.
- `streamTool` ran tools on the local server while the model asking for one
  could be anywhere. A tool now runs where its tokens are generated.
- settings export scrubbed `apiKey` and MCP headers but exported the provider
  list whole, keys included. Remote providers now leave the export entirely:
  without their code they name nothing, and with it they are a key.

The tunnel itself comes from ggml-org#24577 (ngxson), with the base-path stripping
dropped: a request already carries the path the host's server serves.

Co-Authored-By: ngxson <ngxson@gmail.com>
The providers view gains the second kind of provider. A remote one shows its
code masked with a reveal, reports the tunnel and the server behind it as two
things that can fail - Connecting, N models, Disconnected, or Not connected
with a Connect button - and forgets its code when it is deleted.

Pairing is a code, and 40 characters of near-nonsense is a poor thing to type on
a phone, so a browser that ships a native BarcodeDetector gets a Scan button
that reads the QR code llama-server prints with --connect. No dependency, no
camera unless the user asks, and everywhere the detector is missing the field is
simply filled by hand.

Pairing saves the provider and then opens its tunnel, because the tunnel belongs
to the provider and has to be able to find it. A failed handshake therefore
leaves the provider in place with a retry on its card rather than rolling the
pair back: the code the user pasted is worth keeping.

With no local server and no provider the view says so plainly - this page has no
server of its own - and offers the code first, which is the state a build served
from the network opens in. That replaces the blocking splash of the first remote
build: the app boots, the built-in provider is dropped once its probe fails, and
what is left is an empty provider list that knows what to ask for.
The addressing rules are the cheap part to check and the expensive part to get
wrong: a provider id that stops round-tripping through its host, a code alphabet
that quietly accepts a pasted `I`, or a stored list that lets a URL provider
claim the tunnel host all mean a request goes somewhere it should not.

The client test drives the installed transport itself and asserts the part that
matters most - a refused request left nothing on the server serving the UI - and
the unit test pins the shapes the transport reads: codes, origins, and the
provider list that decides what may be routed at all.
The provider and backend vocabulary is retired across the data layer, the
stores, the components and the tests: the list, the view and the noun are
servers.

Assisted-by: DeepSeek-V4.1-Flash
A local card shows the host side of a server started with --connect, the
status words name the state instead of hiding it in a tooltip, a stalled
handshake can be dropped, and the access code can be copied off the card.

Assisted-by: DeepSeek-V4.1-Flash
A backgrounded tab on iOS or Android loses its peer connection, which leaves
the card on a failure the user can only clear by hand. Coming back now asks
for the channels that were already wanted, once the network has settled.

Assisted-by: DeepSeek-V4.1-Flash
The code a host prints can be scanned off the screen by the phone that pairs
with it, and the settings export says it carries access codes.

Assisted-by: DeepSeek-V4.1-Flash
The models dialog stays desktop-only, so a phone had no way into its server
list; the sidebar now carries a Servers entry that opens the list on its own.

Assisted-by: DeepSeek-V4.1-Flash
The add and pair form becomes a bottom sheet on a phone: its actions stay in
thumb reach and its fields scroll under them, while a desktop keeps the
dialog.

Assisted-by: DeepSeek-V4.1-Flash
The card's state table, the tunnel recovery and a handshake the user gives up
on, the QR round trip through the browser's own detector, and the phone's way
into the servers dialog.

Assisted-by: DeepSeek-V4.1-Flash
The parser dropped apiKey, so a key typed in the add or edit form was written
to the settings and never seen again: every request went out without it and a
key-protected server answered 401. A paired server keeps its key too, which
is what makes --connect together with --api-key possible.

Assisted-by: DeepSeek-V4.1-Flash
The UI drives llama.cpp servers only: it loads and unloads models, reads the
router feed and its chat template. /props is asked once the URL settles, and a
definite answer that it is something else blocks saving the server. An
endpoint that does not answer, or guards /props with a key, stays unknown, so
a working server behind a reverse proxy is never locked out.

Assisted-by: DeepSeek-V4.1-Flash
The chat banner is the surface left when nothing can serve a request, and it
stopped at a retry that cannot succeed. It now carries the door to the servers
dialog, where a server is paired.

Assisted-by: DeepSeek-V4.1-Flash
A load on a server behind a tunnel was a spinner with no progress, since the
feed was pinned to the local origin. The active server's own feed is read at
its origin while it is reachable, and an operation that waits on a load keeps
its polling as the fallback, so a feed that stops or never starts cannot hang
a row.

Assisted-by: DeepSeek-V4.1-Flash
The sidebar entry test renders the footer items through onAction, the way
the stack's SidebarNavigationActions takes them, and the files the replay
touched get their import order, class member order and formatting back.

Assisted-by: Claude (Opus 5.5 Medium)
On a phone the sidebar and the chat's no-server banner open #/servers, with the menu key and a
title like the Settings and MCP pages.

Assisted-by: Claude (Opus 5.5 Medium)
The CORS proxy, its auth header, streamed tool calls and the API key check
followed the active server, so with a remote server active, MCP traffic went
through someone else's machine and streamed tools ran where the tool list did
not come from. Pin them to the local server, like the tool list.

Hidden models: read ids saved before server-qualified ids as the local
server's, and check the active server's raw ids against qualified ones, so
hidden models stay hidden and out of the automatic pick. A conversation's
model now stays on the active server when that server has it too.

Assisted-by: Claude (Opus 5.5 Medium)
…l the design system lands

Assisted-by: Claude (Opus 5.5 Medium)
Pairing over WebRTC still sends the pass code to whichever peer answers on
the public tracker, so it ships off by default as an Experimental setting
that names that gap and the planned mutual challenge-response. While it is
off the servers form offers URLs only and no tunnel opens; turning it off
closes the ones already open.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 16c93c9 to 3187ad3 Compare November 9, 2026 16:35
@allozaur
allozaur force-pushed the allozaur/feat/experimental-remote-pairing branch from f9f546b to 2362865 Compare November 9, 2026 16:35
@allozaur
allozaur force-pushed the allozaur/feat/servers branch from 3187ad3 to a48d5fe Compare November 10, 2026 09:16
@allozaur allozaur closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant