Skip to content

fix(remote): a prompt names a conversation, it does not create one - #957

Merged
huichen merged 2 commits into
mainfrom
fix/remote-session-routing
Oct 9, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/remote-session-routing

Conversation

@huichen

@huichen huichen commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

fix(remote): a prompt names a conversation, it does not create one

A follow-up written inside one conversation could appear as a brand new chat.
The host's prepare_remote_prompt treated "no thread owns this session id" as
"make one": it created a chat thread titled from the message, provisioned an
agent session for it, and answered the client with that new session — which the
phone then opened. So a client that named a conversation this desktop does not
have (a row merged in from another desktop, or one deleted since the list was
read) had its text silently re-homed: it landed in a conversation the user was
not looking at, under a title derived from the message, and the conversation
they meant to continue never received it. Nothing failed, so nothing told them.

The refusal now comes before anything is persisted:

  • An empty session id is a client's new-conversation draft and keeps the
    lazy creation (thread born with the first message, real agent session id up
    front, so ack/event subjects/history agree).
  • A non-empty id no thread here owns is refused with a stable code
    (session_not_on_desktop) plus a readable sentence. The phone maps that code
    to "that conversation is not on the connected desktop" instead of a generic
    send failure; other clients keep the sentence.

Mobile side: a merged row from another desktop is opened on the machine that
owns it. The phone holds one active connection, so tapping such a row used to
select a session id against the active desktop — the wrong machine, and (with
the old host behavior) the trigger for the detour above. The row now switches
the active desktop first (the same switch the device picker performs) and then
opens the conversation there; a row of the active desktop, and every row of an
unmerged list, is the plain selection it always was.

Two test fixtures that prompted an invented session id were giving the host
something no client can send — a conversation that was never listed. They now
seed the thread list_sessions would have shown (thread_for_session), which
is also what makes the new contract visible in the suite.

Verified: mobile tsc/eslint clean, 3060 mobile tests pass; desktop cargo fmt --check, clippy (default and --no-default-features, --all-targets)
clean, remote_host::, remote:: and remote_peer:: suites pass. The one
failing desktop test locally,
desktop_settings_refuse_to_guess_sandbox_availability, fails identically with
this change stashed — it asserts the test machine's sandbox probe, not this
code.

docs/internals/desktop/CONNECTION.md records the boundary in its compatibility
list.

@huichen
huichen enabled auto-merge (squash) October 9, 2026 15:25
A follow-up written inside one conversation could appear as a brand new chat.
The host's `prepare_remote_prompt` treated "no thread owns this session id" as
"make one": it created a chat thread titled from the message, provisioned an
agent session for it, and answered the client with that new session — which the
phone then opened. So a client that named a conversation this desktop does not
have (a row merged in from another desktop, or one deleted since the list was
read) had its text silently re-homed: it landed in a conversation the user was
not looking at, under a title derived from the message, and the conversation
they meant to continue never received it. Nothing failed, so nothing told them.

The refusal now comes before anything is persisted:

- An **empty** session id is a client's new-conversation draft and keeps the
  lazy creation (thread born with the first message, real agent session id up
  front, so ack/event subjects/history agree).
- A **non-empty** id no thread here owns is refused with a stable code
  (`session_not_on_desktop`) plus a readable sentence. The phone maps that code
  to "that conversation is not on the connected desktop" instead of a generic
  send failure; other clients keep the sentence.

Mobile side: a merged row from another desktop is opened on the machine that
owns it. The phone holds one active connection, so tapping such a row used to
select a session id against the *active* desktop — the wrong machine, and (with
the old host behavior) the trigger for the detour above. The row now switches
the active desktop first (the same switch the device picker performs) and then
opens the conversation there; a row of the active desktop, and every row of an
unmerged list, is the plain selection it always was.

Two test fixtures that prompted an invented session id were giving the host
something no client can send — a conversation that was never listed. They now
seed the thread `list_sessions` would have shown (`thread_for_session`), which
is also what makes the new contract visible in the suite.

Verified: mobile `tsc`/`eslint` clean, 3060 mobile tests pass; desktop `cargo
fmt --check`, clippy (default and `--no-default-features`, `--all-targets`)
clean, `remote_host::`, `remote::` and `remote_peer::` suites pass. The one
failing desktop test locally,
`desktop_settings_refuse_to_guess_sandbox_availability`, fails identically with
this change stashed — it asserts the test machine's sandbox probe, not this
code.

docs/internals/desktop/CONNECTION.md records the boundary in its compatibility
list.
@huichen
huichen force-pushed the fix/remote-session-routing branch from 3ff7433 to 4132359 Compare October 9, 2026 15:27
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