Skip to content

fix: list the remote daemon's models when the active session is remote - #179

Open
shadaj wants to merge 1 commit into
mainfrom
sandbox-de5de0e5-9054-4dce-9542-932d3403b29c
Open

shadaj wants to merge 1 commit into
mainfrom
sandbox-de5de0e5-9054-4dce-9542-932d3403b29c

Conversation

@shadaj

@shadaj shadaj commented Oct 27, 2026

Copy link
Copy Markdown
Member

The model picker (web dropdown and CLI /model) always showed the local
daemon's available_models, even when the loaded session lived on a remote
daemon whose provider/model catalog may differ. Selecting from that list
sent a SwitchModel with a ModelRef the remote might not have.

Root cause was in the daemon: when connecting to a remote it read the
remote's Welcome but kept only sessions, discarding available_models,
and RemoteInfo had no field to carry them to clients.

Protocol / daemon

  • RemoteInfo gains available_models: Vec<ModelInfo> (#[serde(default)],
    wire-compatible with older daemons).
  • remote.rs: store each remote's model list from its Welcome in
    RemoteState, clear it on disconnect, and include it in every RemoteInfo
    emitted via Welcome.remotes / RemotesUpdated.

Web (infinity-web/src/App.tsx, infinity-ui/src/types.ts)

  • Compute currentModels: the active session's remote available_models
    when currentHost is set, otherwise the local list. The dropdown renders
    from currentModels.

CLI (infinity-agent-cli)

  • terminal::run takes the initial remotes from Welcome plus a new
    remotes_updated_rx channel (fed from DaemonMessage::RemotesUpdated in
    daemon_client, mirroring sessions_updated_rx).
  • /model selects the list by the loaded session's ThreadRef.remote. If
    the remote's list is empty (not connected yet) it prints a hint rather than
    opening an empty picker.
  • ModelPickerResult::Selected now carries the chosen ModelInfo, and the
    terminal→client channel carries a ModelRef instead of a usize index
    into a list daemon_client had to mirror. This removes the coupling that
    made per-remote lists impossible.

Tests

  • tui_snapshots.rs: three new tests — remote session lists remote models
    and the switch request carries the remote ModelRef; switching back to a
    local session restores local models; RemotesUpdated refreshes the list.
  • Test harness (tests/common/mod.rs) gains remotes option and
    remotes_updated_tx.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Deploying infinity with  Cloudflare Pages  Cloudflare Pages

Latest commit: 652bbae
Status: ✅  Deploy successful!
Preview URL: https://ffaf2d4d.infinity-dc7.pages.dev
Branch Preview URL: https://sandbox-de5de0e5-9054-4dce-9.infinity-dc7.pages.dev

View logs

The model picker (web dropdown and CLI `/model`) always showed the *local*
daemon's `available_models`, even when the loaded session lived on a remote
daemon whose provider/model catalog may differ. Selecting from that list
sent a `SwitchModel` with a `ModelRef` the remote might not have.

Root cause was in the daemon: when connecting to a remote it read the
remote's `Welcome` but kept only `sessions`, discarding `available_models`,
and `RemoteInfo` had no way to carry them to clients.

## Protocol

* `RemoteInfo.status` is now an enum instead of a string:
  `Connecting | Connected { available_models } | Disconnected { reason }`.
  Connected-without-models / disconnected-with-stale-models are
  unrepresentable. The daemon's private `RemoteStatus` is replaced by this
  shared type.

## Daemon (`remote.rs`)

* Store the remote's model list from its `Welcome` in the `Connected`
  variant; it rides on the existing `Welcome.remotes` / `RemotesUpdated`
  broadcast so clients learn the catalog exactly when the remote becomes
  usable, and lose it on disconnect.

## Web (`infinity-ui`, `infinity-web`)

* `types.ts`: `RemoteStatus` union mirroring the wire shape, plus helpers
  `remoteStatusKind` / `remoteStatusLabel` / `remoteModels` (exported from
  `infinity-ui`).
* `SessionSidebar` / `MigratePicker` use the helpers instead of string
  comparisons.
* `App.tsx`: the model dropdown renders `currentModels` — the active
  session's remote catalog when `currentHost` is set, else the local list.

## CLI (`infinity-agent-cli`)

* `terminal::run` takes the initial `remotes` from `Welcome` plus a new
  `remotes_updated_rx` channel (fed from `RemotesUpdated` in
  `daemon_client`, mirroring `sessions_updated_rx`).
* `/model` picks the list by the loaded session's `ThreadRef.remote`. If
  the remote is not `Connected` it prints why (connecting / disconnected
  reason) rather than opening an empty picker.
* `ModelPickerResult::Selected` carries the chosen `ModelInfo`, and the
  terminal→client channel carries a `ModelRef` instead of a `usize` index
  into a list `daemon_client` had to mirror.

## Tests

* `tui_snapshots.rs`: remote session lists remote models and the switch
  request carries the remote `ModelRef`; switching back to a local session
  restores local models; `RemotesUpdated` (Connecting → Connected) makes the
  remote's models pickable.

BREAKING CHANGE: `RemoteInfo.status` changed from a string to the
`RemoteStatus` enum; `RemoteInfo` no longer has a flat `available_models`.


Co-authored-by: Infinity 🤖 <infinity@hydro.run>
PR: #179
@shadaj
shadaj force-pushed the sandbox-de5de0e5-9054-4dce-9542-932d3403b29c branch from 71c4156 to 652bbae Compare October 27, 2026 20:53
@shadaj
shadaj marked this pull request as ready for review October 27, 2026 20:53
@shadaj
shadaj requested a review from a team October 27, 2026 20:53
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