Skip to content

feat(remote): let a remote session use the Host's model catalog and context usage - #2379

Open
mybolide wants to merge 6 commits into
vastsa:mainfrom
mybolide:feat/remote-host-model-catalog
Open

mybolide wants to merge 6 commits into
vastsa:mainfrom
mybolide:feat/remote-host-model-catalog

Conversation

@mybolide

@mybolide mybolide commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A remote session runs on the paired Host's providers, but the Composer projected
this Desktop's provider store and transcript onto it: the model menu listed local
models the Host cannot serve, and the context ring stayed empty because a remote
transcript carries usage only on nested tool operations, never the top-level
assistant row.

The Host owns both facts, so RACP now publishes them as read-only operations and
a session reports its own binding.

Split out of #2371 at review request, so the project-group identity fix there can
land with the smallest coherent scope. Nothing in this diff touches the sidebar,
the attach identity path, or host-core persistence.

Protocol (additive)

  • models/list — the Host's own catalog: a flat models[] of
    (providerId, modelId) rows plus the Host's defaults. Two Host providers that
    share a display name stay distinct rows; only public metadata crosses the
    boundary, never an endpoint or credential.
  • session/usage — context occupancy of the newest completed request for
    one session. A turn that called tools issued several requests, and only the
    last one still occupies the model window, so the turn aggregate would
    overstate usage.
  • Session gains optional providerId / modelId / thinkingLevel.
  • A Host without the new operations answers CAPABILITY_UNAVAILABLE and the
    client stays on a read-only model display, so an older Host keeps working.

Implementation

  • packages/shared/src/racp.ts, racp.test.ts, fixtures/racp.schema.json
    — schemas and operation table for both resources and the new session fields;
    packages/racp/src/host-operations.ts carries the typed client interface.
  • crates/host-core/src/sessions/usage.rs — latest_request_usage selects
    the last operation of the newest status = 'completed' turn; rpc/mod.rs
    exposes it as session.turnUsage.
  • apps/pi-host/src/host-operations.ts — publishes only enabled providers
    that have a usable credential, and reports each session's binding.
  • apps/desktop/electron/main/remote/remote-host-models.ts (new) —
    validates both payloads as untrusted input before the renderer sees them: a
    Host is a separate machine and a separate release.
  • apps/desktop/electron/main/remote/backend-router.ts —
    remoteHost/sessionUsage addresses a Host, not a session, so it is
    whitelisted to ROUTE_LOCAL even though its request carries a sessionId;
    routing it as a session channel would hand it to a RemoteBackend that does
    not serve it.
  • apps/desktop/src/lib/remote-host-models.ts (new) — projects the Host
    catalog onto the renderer's provider model without inventing capability or
    reasoning levels the Host did not declare.
  • useRemoteSessionModel.ts (new) — loads catalog and usage per host and
    session, fenced so a switch mid-await cannot paint stale rows;
    Composer.tsx uses the Host catalog in place of the local store and the
    Host's window for the ring.
  • remote-session-safety.ts / remote-ipc-safety.ts — a remote session may
    configure its own model through the Host (sessionConfigure is no longer
    local-only); fastMode stays refused because RACP has no such field.
  • Spec — 03-runtime/19-remote-agent-control-protocol.md §5.8 documents the
    flat catalog and the usage report; §6.2 lists both operations; §5.1 documents
    the new session fields.

Tests

Check Result
pnpm --filter @pi-desktop/shared test 1478 passed
pnpm --filter @pi-desktop/racp test 28 passed
pnpm --filter @pi-desktop/agent-host test 67 passed
node --test on the 7 touched desktop test files 98/98 pass
cargo test -p host-core --locked usage 15 passed
cargo fmt --check -p host-core exit 0
pnpm --filter @pi-desktop/desktop typecheck exit 0
pnpm --filter @pi-desktop/host-runtime test 187 passed, 3 skipped (23 files)
pnpm lint:biome 0 findings (152 files)
pnpm --filter @pi-desktop/docs check:docs 528 pages
pnpm check:pr-base head contains origin/main (7254a0452)

Head af2dfaa06 merges current main (7254a0452); every merge was clean, no
conflicts. An earlier merge (44ab985) resolved three conflicts: the shared
import lists in host-ports.ts and apps/pi-host/src/host-operations.ts, and
useComposerModelMenu.ts, where the menu keeps main's
isImageOnlyChatModel(imageGenerationCandidates, …) guard and still exempts a
Host catalog from this Desktop's local image workflow.
main's newer plugin/mode changes arrived with the merge and are not part of
this diff against main.

The pi-host host-operations.test.ts suite reports 3 failures in this Windows
workspace only, all from POSIX assumptions (workspaceLabel starts with /,
browse roots compared with / separators); the two new model-catalog and usage
cases pass, and the same 3 cases fail unchanged on origin/main.

New coverage:

  • apps/desktop/test/remote-host-models.test.mjs — the validators reject
    non-catalog shapes, impossible token counts, and impossible context windows;
    the projection keeps the Host's declared thinking ladder and invents neither
    capability nor reasoning levels.
  • apps/desktop/test/remote-backend-router.test.mjs — a host-scoped channel
    stays local even when its request names a remote session id.
  • apps/desktop/test/remote-backend.test.mjs — a session summary carries the
    Host's binding when published, and stays absent instead of inventing a model
    when it is not.
  • packages/shared/src/racp.test.ts — both new resources round-trip through the
    schema, including the flat catalog shape.

Verification on a real paired host

Windows Desktop 0.23.0 against a macOS arm64 Host built from the same
revision, over SSH (first probed on 0.23.0-beta.1, re-checked on the 0.23.0
release with both this branch and #2394 applied). That build carried the
model/usage code paths in this branch unchanged.

  • Context ring: all six Host sessions answered session/usage with ok: true;
    the ring went from 0% to 80%, tooltip
    Remaining context 80%, 802.3K tokens total.
  • Model menu: four Host provider rails, no Recents section, chip
    deepseek-v4.1-flash. Switching a temporary session's model wrote back to the
    Host (385c8e13…|gpt-6-astra|low); the temporary session was deleted
    afterwards and the six existing sessions were untouched.

Not run

  • E2E-231 live paired-host acceptance is not an automated suite; the run above
    was a manual probe on a matching-revision Host.
  • pnpm -r --if-present test: the pi-host suite fails on this Windows host at
    both revisions (config.test.ts expects /data, admin-socket.test.ts needs
    a Unix domain socket, host-operations.test.ts asserts POSIX paths; 17
    failures unchanged by this branch). The two new models/usage cases pass.
  • The desktop suite's 74 Windows failures are the environment's existing
    failures: a baseline worktree at 2b279cf reproduced exactly the same failure
    set (set difference 0).

Compatibility

Additive only. New operations are optional capabilities, the new Session
fields are optional, and no persisted format or database schema changes.

…s usage

A remote session offered no model menu and no context figure, because the
Desktop projected its own provider store and transcript onto a session
that runs on another machine. The Host owns both facts, so RACP now
publishes `models/list` and `session/usage` as read-only operations and
reports each session's provider, model, and thinking level.

The model catalog carries only public metadata, and the Desktop validates
both payloads as untrusted input before the renderer sees them. Context
occupancy is the newest completed request rather than the turn aggregate:
a turn that called tools issued several requests, and only the last one
still occupies the model window.
The catalog section described a nested `providers[].models[]` response
that the Host never returns. The published shape is a flat list of
`(providerId, modelId)` rows plus the Host's defaults, so the spec now
matches the schema in `packages/shared` and the operation the Host
actually serves.
…l-catalog

Keeps the branch on current main (ecb2d98) so the Host model catalog and
usage report can land as a standalone feature. Conflicts were limited to
shared import lists and the composer's image-only guard: the host-ports
module now carries main's multi-line import style plus this branch's
SESSION_THINKING_LEVELS, pi-host re-exports both sides' types, and the
menu keeps main's isImageOnlyChatModel(imageGenerationCandidates, ...)
signature while still exempting a Host catalog from this Desktop's local
image workflow.
@mybolide

Copy link
Copy Markdown
Contributor Author

Merged current main (950200348) into the branch and pushed 01b7eac32; the merge was clean with no conflicts, so the PR is MERGEABLE again and pnpm check:pr-base passes.

Re-ran the verification at this head: host-runtime 187 passed / 3 skipped, shared 1478, agent-host 67, the 7 touched desktop test files 98/98, cargo test -p host-core usage 15/15, cargo fmt --check, desktop tsc, lint:biome, and check:docs all clean. The PR body carries the updated numbers.

@mybolide

Copy link
Copy Markdown
Contributor Author

Merged the latest main (1b0996591, which now includes #2394) into the branch and pushed ff2e257ac; the merge was clean with no conflicts, so pnpm check:pr-base passes again and the PR is no longer behind.

Re-ran the verification at this head:

  • shared 1478, agent-host 67, host-runtime 187 passed / 3 skipped
  • the 7 desktop test files touched here: 98/98
  • desktop tsc --noEmit: exit 0
  • cargo test -p host-core usage: 15 passed; cargo fmt --check: exit 0
  • pnpm lint: 0 findings; docs: 528 pages

The pi-host suite still shows the same Windows-only POSIX failures (config.test.ts/admin-socket.test.ts/host-operations.test.ts); I re-checked a clean worktree at 1b0996591 and it fails the same way there, so those are environmental and unrelated to this diff.

@mybolide

Copy link
Copy Markdown
Contributor Author

Merged the latest main (7254a04, which includes #2530) into the branch and pushed �f2dfaa06; the merge was clean, pnpm check:pr-base passes, and the PR is no longer behind.

Re-ran the verification at this head:

  • shared 1478, the 7 touched desktop test files 98/98
  • desktop tsc --noEmit: exit 0
  • cargo test -p host-core usage: 15 passed; cargo fmt --check: exit 0
  • pnpm lint: 0 findings; build:js and the docs build clean

Separately, I opened #2534 for a sidebar alignment regression that came from #2394: a host project group header was rendered through the generic Button primitive, so btn btn-ghost overrode the title box and pushed the chevron off the rail every local group shares. It is not part of this diff.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant