Skip to content

feat(mobile): show agents on relayed servers in Home's agent lists - #47032

Closed
BTForIT wants to merge 2 commits into
stablyai:mainfrom
BTForIT:mobile-home-relayed-server-agents
Closed

BTForIT wants to merge 2 commits into
stablyai:mainfrom
BTForIT:mobile-home-relayed-server-agents

Conversation

@BTForIT

@BTForIT BTForIT commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Refs #43353. This fixes the Agents list half; the desktop card's worktree count isn't changed here.

Home's Feed, Active agents and Agents badge list a paired desktop's own agents, but not agents on servers the desktop relays to. An agent on a relayed server that's waiting on the user only shows up if the user happens to open that server's workspace list.

What changes:

  • The desktop already keeps one change watch per paired server (paired-server-rows-watch.ts). That watch now also passes on the server's worktreeRowsChanged and agentListChanged notices through a small listener hook (PairedServerAgentRowsChanges). No new subscription is opened.
  • RelayHostRowsAnnouncer turns those notices into one relayHostRowsChanged event per server for phones. Bursts are merged: 500 ms after the last notice, at most every 2 s. A server is announced only while a phone connection that read its rows stays open.
  • The phone re-reads a desktop's relayed rows only on that event or on relayHostsChanged, with delta reads where the desktop supports them. Nothing new polls.
  • New capability mobile.relay-host-rows-changed-event.v1. Older desktops and phones behave as before.
  • A server reached through two desktops, or also paired directly, is listed once. The direct pairing wins; otherwise it's the first desktop in Home's order.
  • Relayed rows show the server's name and have no read or clear actions, since the desktop doesn't own those agents' read state. Tapping one opens it on the server.
  • The rows producer's options type moves to paired-server-rows-state.ts to keep the producer under the line limit.

One question for you: the rows watch only runs with ORCA_SIDEBAR_INPUTS=main, so I put the capability behind that switch too, and released builds don't change. If you'd rather ship this before that switch is on, the first commit (d51f6b0) has the same feature with its own watch in the announcer. I left it out because it would be a second subscription doing what the rows watch does. Happy to go either way.

Cost: nothing while servers are idle. Each change costs one event of about 60 bytes, then one hosts list and one delta read per relayed server, at most one read every 3 s. Polling every 3 s like the workspace list would cost 20 requests a minute per server while Home is open.

How to reproduce on main:

  1. Pair a desktop with a remote server, so the server's workspaces appear under the desktop on mobile.
  2. Pair a phone to the desktop.
  3. Start an agent on the server and let it reach a permission prompt.
  4. Open Home on the phone. Feed, Active agents and the Agents badge don't include the agent. Open the server's workspace list and it's there.

Tests:

  • mobile-relay-host-rows-announcer.test.ts: bursts merged into one event, unread servers ignored, a server announced until the last reading connection closes, nothing after dispose.
  • home-relayed-server-agents.test.ts: each server listed once, and no read or clear actions on relayed rows.
  • Both fail on main and pass on this branch. Desktop and mobile typecheck, oxlint and oxfmt pass on the changed files. The one lint error left (a cast at src/main/runtime/rpc/core.ts:301) is already on main.
  • Not yet tried on a real phone.

BTForIT and others added 2 commits November 22, 2026 17:27
A phone paired to a desktop sees the agents running on that desktop, but
not the ones running on servers the desktop relays to. Those agents only
show when the user opens the server's workspace list. Home's Feed, Active
agents and the Agents badge miss them.

The desktop now passes a relayed server's own row-change notices
(worktreeRowsChanged, agentListChanged) on to phones as one small
relayHostRowsChanged event per server, coalesced at 500 ms / 2 s. It
watches a server only while a phone connection that read the server's
rows stays open. Phones re-read a desktop's relayed server rows only on
that event or on relayHostsChanged. Nothing new polls.

- New capability mobile.relay-host-rows-changed-event.v1; a phone without
  it, or a desktop without it, behaves as before.
- A server reached through two desktops, or also paired directly, lists
  once (directly paired wins, otherwise the first desktop in Home order).
- Relayed rows show the server's name, offer no read or clear actions
  (the desktop does not own those agents' read state), and open on the
  server.

Tests: mobile-relay-host-rows-announcer.test.ts (coalescing, one watch
per server held until the last reading connection closes) and
home-relayed-server-agents.test.ts (per-server dedupe, read and clear
actions withheld). Both fail on main and pass here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ired-server rows watch

The previous commit opened a second client-event subscription to each
relayed server just to hear its row changes. The desktop already keeps
one watch per paired server in contact (paired-server-rows-watch), so
the row notices now come from that watch through a small listener hook,
PairedServerAgentRowsChanges, and the announcer opens no watch of its
own.

- The watch passes worktreeRowsChanged and agentListChanged to
  PairedServerAgentRowsChanges, which the producer exposes as
  agentRowsChanged.
- RelayHostRowsAnnouncer only listens to it. It keeps the 500 ms / 2 s
  merging and announces a server only while a phone connection that read
  its rows stays open.
- That watch exists only in builds with ORCA_SIDEBAR_INPUTS=main, so
  mobile.relay-host-rows-changed-event.v1 moves to the dark-switch
  capabilities. Other builds don't advertise it, and their phones read
  nothing new.
- The producer's options type moves to paired-server-rows-state.ts so the
  producer stays under the line limit.

Tests: mobile-relay-host-rows-announcer.test.ts now drives the hook
directly. Both new tests fail on main and pass here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Mobile Home now includes agents from eligible relayed servers in desktop worktree data. The merge excludes archived worktrees and duplicate server installations, and adds execution-host metadata to included agents. Row keys and entry lookup distinguish execution hosts. Relayed rows do not expose desktop unread and clear actions, and session opening passes the execution-host ID when present. Runtime row-change announcements are tracked for phones that read server workspaces and trigger Home queries to refresh.

Merge Risk: Low · up to ceb66

Home's Feed, Active agents and badge now include agents from relayed servers. After a server reconnects, those agents can stay stale until the next row notice or a focus refetch. Duplicate or stale rows are also possible in narrow cases. The behavior is gated to builds where the sidebar-inputs switch is on, so exposure is limited. These issues are worth addressing but are unlikely to cause serious harm.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description follows the repository template closely. It has the What Changed, Why, Testing, Performance, and Risk content, and it states a specific reproduction path and test coverage. It has a cl… Add an ELI5 summary. Link a real issue with 'Fixes #' or explain why one is not applicable. Add BEFORE and AFTER visual proof for the mobile Home UI change, or add a justified N/A. Set the Risk level to Low, Medium, or High, and state how t…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the primary change: agents on relayed servers are now shown in Home's agent lists on mobile. The changeset adds relayed server agents to Home's agent rows, and the title is specific an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the primary change: agents on relayed servers are now shown in Home's agent lists on mobile. The changeset adds relayed server agents to Home's agent rows, and the title is specific and concise. It is a conventional feat(mobile) title and follows the expected style.

Full details: Description check

Explanation

The description follows the repository template closely. It has the What Changed, Why, Testing, Performance, and Risk content, and it states a specific reproduction path and test coverage. It has a clear mechanism, justified tradeoffs, and a performance line. The ELI5 section, the Linked Issue section, the Visual Proof section, and the Risk level are missing or incomplete. The Linked Issue refers to #43353 only as 'Refs', and the template requires 'Fixes #' with an actual issue. The Visual Proof section has no before and after attachments, and the 'Not yet tried on a real phone' note does not replace it. The Risk section lacks a level and a revert plan. The Testing checkboxes are unchecked, and the Performance line is filled in with a numeric cost rather than the one-line 'None, because' form. The description is mostly complete, but the required sections need attention.

Resolution

Add an ELI5 summary. Link a real issue with 'Fixes #' or explain why one is not applicable. Add BEFORE and AFTER visual proof for the mobile Home UI change, or add a justified N/A. Set the Risk level to Low, Medium, or High, and state how to back out the change. Complete the Testing checkboxes that apply. Finish the Performance sentence with the 'None, because' form or state the trade-off in one line. Fill in the Review and Notes sections if they apply.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 306f9a8e-775c-45cc-a4ca-00cd52a3eebc
Commits

Reviewing files that changed from the base of the PR and between 1a99e6c and ceb66a8.

Files selected for processing: 25

  • mobile/src/agents/MobileAgentListRows.tsx
  • mobile/src/agents/agent-list-rows.ts
  • mobile/src/agents/use-agent-list-row-actions.tsx
  • mobile/src/home/use-home-server-agents.ts
  • mobile/src/home/use-mobile-home-data.ts
  • mobile/src/host-screen/catalog/host-list-queries.ts
  • mobile/src/worktree/catalog/home-host-worktree-fetch.ts
  • mobile/src/worktree/catalog/home-relayed-server-agents.test.ts
  • mobile/src/worktree/catalog/home-worktree-info.ts
  • src/main/ipc/runtime-environments/mobile-relay/runtime-environment-change-events.ts
  • src/main/ipc/runtime-environments/mobile-relay/runtime-environment-mobile-relay-hosts.ts
  • src/main/runtime/construction/dark-switch-runtime-capabilities.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-rows-announcer.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-rows-announcer.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/methods/pairing/mobile-relay-hosts.ts
  • src/main/runtime/rpc/server/runtime-rpc-pairing.ts
  • src/main/runtime/sidebar-inputs/workspace-rows/paired-server-rows-producer.ts
  • src/main/runtime/sidebar-inputs/workspace-rows/paired-server-rows-state.ts
  • src/main/runtime/sidebar-inputs/workspace-rows/paired-server-rows-watch.ts
  • src/shared/remote-runtime/relay/mobile-desktop-relay-contract.ts
  • src/shared/remote-runtime/session-graph/runtime-client-events.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

const stateWord = needsYou ? agentStateLabel(row.dotState) : ''
const place = [
props.footer === 'agent' ? formatAgentTypeLabel(agent.agentType) : row.entry.workspaceName,
row.entry.executionHost?.label,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Keep the server name visible when the footer truncates.

If the workspace name fills the available width, the single-line footer truncates the server label. Users then cannot see which server owns the agent. Reserve space for the server label or render it separately.

? await readHostServerWorkspaces(
client,
capabilities.includes(MOBILE_RELAY_HOST_WORKTREE_DELTAS_RUNTIME_CAPABILITY),
previous?.servers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Do not admit agent rows read before the latest connect as live.

After a reconnect, homeServerAgentsQuery refetches with the previous connection's servers as previous. If the status read succeeds and a server's row read fails, the retained rows are returned as a successful result. That result has a dataUpdatedAt after the connect, so isLive admits it. Those agents then reach Feed, Active agents and the badge as live. useHomeServerAgents states that a relayed server's agents show only from a read on the current connection, so this violates that contract.

The whole previous value is also returned when fetchServerWorkspaces returns null, through held in readHostServerWorkspaces.

Rows read before the latest connect must not reach the agent results as live. Choose how to enforce this. The options include not forwarding previous across connections or dropping prior-connection rows on a successful read. The choice must keep the workspace list's per-server retention unchanged, because applyServerWorkspaces depends on it.

continue
}
const relayed = servers.hosts.flatMap((server) => {
if (server.installationId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Relayed servers without installationId can be listed twice.

installationId is optional on the relay host contract and on the phone parser. The desktop emits it only when it is set. When a relayed server has no installationId, the deduplication branch at home-worktree-info.ts:102 does not run. The same server reached through two desktops is then listed twice, and Home counts its agents twice. The PR requires a server reached through multiple desktops to be listed once.

Define the identity for such a server before its rows are merged. Either derive a stable identity that both desktops report, or exclude relayed rows that lack one. Apply that rule before deduplication and direct-pairing precedence run.

Comment on lines +27 to +31
runtime.registerSubscriptionCleanup(
`relay-host-rows:${connectionId}:${params.hostId}`,
release,
connectionId
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Stability & Availability · Quick win

Release the relay-host reader at once when its connection has already closed.

worktrees awaits server sync and host lookup before it calls rowsAnnouncer.hold. If the phone disconnects during those awaits, its subscriptions are cleaned up first. The late onClose registration then has no later cleanup to release it. The closed connection stays in the announcer's reader set, and row changes for that server keep being announced.

Check ctx.signal in onClose. If the signal is already aborted, call release() now and skip the registration. Otherwise register the cleanup as before.

Suggested fix

           onClose: (release: () => void) =>
-              runtime.registerSubscriptionCleanup(
-                `relay-host-rows:${connectionId}:${params.hostId}`,
-                release,
-                connectionId
-              )
+            {
+              // The connection may have closed while worktrees awaited; release now instead of registering.
+              if (ctx.signal?.aborted) {
+                release()
+                return
+              }
+              runtime.registerSubscriptionCleanup(
+                `relay-host-rows:${connectionId}:${params.hostId}`,
+                release,
+                connectionId
+              )
+            }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
runtime.registerSubscriptionCleanup(
`relay-host-rows:${connectionId}:${params.hostId}`,
release,
connectionId
)
onClose: (release: () => void) => {
// The connection may have closed while worktrees awaited; release now instead of registering.
if (ctx.signal?.aborted) {
release()
return
}
runtime.registerSubscriptionCleanup(
`relay-host-rows:${connectionId}:${params.hostId}`,
release,
connectionId
)
}

Comment on lines +59 to +63
onRowsChanged: () => {
if (current()) {
owner.agentRowsChanged.emit(entry.environmentId)
}
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Announce agent rows when a server event replay arrives.

A replay can stand for missed agent-row notices. The subscription maps it to reposChanged, which refreshes the server's rows but never reaches onRowsChanged. Home keeps stale agent rows until another agent notice, a host-list change, or a focus refetch.

Call onRowsChanged for replay responses as well. Keep onChange for every non-agent change.

Suggested fix

           const change = isRuntimeSubscriptionReplayResponse(response)
             ? 'reposChanged'
             : serverClientEventChange(response.result)
-          if (change === 'agentRows') {
-            callbacks.onRowsChanged?.()
-          } else if (change) {
-            callbacks.onChange({ catalog: change !== 'worktreesChanged' })
-          }
+          // A replay may stand for missed agent-row notices, so it also re-announces rows.
+          if (change === 'agentRows' || isRuntimeSubscriptionReplayResponse(response)) {
+            callbacks.onRowsChanged?.()
+          }
+          if (change && change !== 'agentRows') {
+            callbacks.onChange({ catalog: change !== 'worktreesChanged' })
+          }

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this! Your change was carried forward in #49357, which keeps your commits and has now merged. It works in released builds and only reads a server when that server reports a change. Closing this one in favour of it.

@nwparker nwparker closed this Nov 26, 2026
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.

2 participants