Skip to content

feat(remote): sync the full thread list and projects to devices - #4309

Closed
LHagfoss wants to merge 1 commit into
mainfrom
feat/gateway-sync-full-thread-sidebar-mobile
Closed

LHagfoss wants to merge 1 commit into
mainfrom
feat/gateway-sync-full-thread-sidebar-mobile

Conversation

@LHagfoss

Copy link
Copy Markdown
Owner

What

Lets a paired device (the mobile app) show the same thread list as the desktop sidebar: every project and every saved thread on the host, kept in sync. All changes are additive to protocol v1. New fields are optional and the new operations sit behind new capability flags.

  1. Saved-thread entries carry what the sidebar shows. New optional fields: status, pinned, snoozed_until, harness, model and scheduled_job. project now matches the desktop's grouping: a worktree's repository, then the repo recorded for the folder, then the folder. It is absent for a root folder or RustCode's data folder. workspace still holds the thread's own folder.
    • status values are idle | running | needs_input | stalled | review | done, sent as a plain string. Clients show any unknown value as idle.
    • A settled (done) thread stays done. running and needs_input come from the gateway's live list; the other values come from status.json.
    • snoozed_until is read-only. The engine stores snooze (snooze.json), so the README line saying snooze lives only in the app was out of date and is fixed here.
    • Unread marks, the sidebar's manual order, and folders registered before their first thread live only in the app's localStorage. They are left out and the README says so.
  2. list_projects (capability projects) lists every project that has a saved thread, newest first, max 500, with a truncated flag. Each project has path, name, thread_count, running, needs_input and updated_at. Projects with no open thread are included.
  3. Sync uses subscribe_saved_sessions (capability saved_session_updates). The host pushes saved_sessions_changed frames, each holding whole entries: changed threads, removed thread IDs, changed projects and removed project paths. I chose a push subscription over an updated_since cursor because a cursor can't report deleted threads, and pin, status and snooze changes don't touch the transcript's mtime. While at least one device is subscribed, the gateway rescans about every 5 s. Transcripts are re-read only when history.json, title.txt or workspace.json changed, and the scan stops when the last subscriber leaves. Large diffs are split across frames that each stay under the frame limit.
    • Ordering: the subscription is answered only after a scan made after the request. The client subscribes, waits for saved_sessions_subscribed, then lists. A change that races the listing comes again in a frame, so applying both in arrival order converges.
  4. create_session/create_thread accepts any listed project. Before, path had to be inside home or [remote] roots, so a project at e.g. /Volumes/... was refused. path may now also be exactly a project's path from list_projects. Subfolders of such a project are still refused.

Only threads listed by the session store, with files inside it, are reported (same rule as before). The new code is in remote_gateway/workspace/saved_threads.rs; workspace.rs is at its size cap. There is no Swift client in this repo to update.

Wire examples

A device that asked for thread names in the handshake gets the thread-named form; the committed goldens use v1 names. Both are shown below.

list_saved_threads entry (changed: new optional fields)

{"kind": "response", "protocol_version": 1, "request_id": "req-saved", "result": {"type": "saved_threads", "threads": [
  {"thread_id": "20260714-091502-3fa2c1", "title": "Fix the parser", "project": "/Users/example/projects/parser", "workspace": "/Users/example/worktrees/parser-fix", "updated_at": "2026-07-14T09:40:12Z", "message_count": 42, "state": "saved", "status": "review", "pinned": true, "snoozed_until": "2026-07-15T08:00:00Z", "harness": "codex", "model": "gpt-5.5", "scheduled_job": "nightly-triage"},
  {"thread_id": "5f0c2d9e-7a41-4c1b-9d55-0b6c1f2a3e44", "title": "Refactor the session store", "project": "/Users/example/projects/rustcode", "workspace": "/Users/example/projects/rustcode", "updated_at": "2026-07-14T08:02:55Z", "message_count": 118, "state": "shared", "status": "running", "pinned": false, "harness": "claude-code", "model": "gpt-5.5"},
  {"thread_id": "20260713-171233-9b0e44", "title": "Untitled", "message_count": 3, "state": "open", "open_in": "app", "status": "idle", "pinned": false}
], "next_cursor": "20260713-171233-9b0e44"}}

(v1: "type": "saved_sessions", "sessions", "session_id".)

list_projects (new)

{"protocol_version": 1, "request_id": "req-projects", "operation": {"type": "list_projects"}}
{"kind": "response", "protocol_version": 1, "request_id": "req-projects", "result": {"type": "projects", "projects": [{"path": "/Users/example/projects/parser", "name": "parser", "thread_count": 12, "running": true, "needs_input": false, "updated_at": "2026-07-14T09:40:12Z"}], "truncated": false}}

subscribe_saved_threads (new)

{"protocol_version": 1, "request_id": "req-saved-sub", "operation": {"type": "subscribe_saved_threads"}}
{"kind": "response", "protocol_version": 1, "request_id": "req-saved-sub", "result": {"type": "saved_threads_subscribed"}}

(v1: subscribe_saved_sessions / saved_sessions_subscribed.)

saved_threads_changed push frame (new)

{
  "kind": "saved_threads_changed",
  "protocol_version": 1,
  "threads": [{"thread_id": "20260714-091502-3fa2c1", "title": "Fix the parser", "project": "/Users/example/projects/parser", "workspace": "/Users/example/worktrees/parser-fix", "updated_at": "2026-07-14T09:40:12Z", "message_count": 42, "state": "saved", "status": "review", "pinned": true, "snoozed_until": "2026-07-15T08:00:00Z", "harness": "codex", "model": "gpt-5.5", "scheduled_job": "nightly-triage"}],
  "removed": ["20260713-171233-9b0e44"],
  "projects": [{"path": "/Users/example/projects/parser", "name": "parser", "thread_count": 12, "running": true, "needs_input": false, "updated_at": "2026-07-14T09:40:12Z"}],
  "removed_projects": ["/Users/example/projects/old"]
}

(v1: "kind": "saved_sessions_changed", "sessions", "session_id".) Empty lists are left out. Each entry replaces the one under its thread_id / path, or is added if new.

Capabilities in the threads/sessions result

"capabilities": [..., "projects", "saved_session_updates"]

create_thread in a listed project outside home (behaviour change, same frames)

{"protocol_version": 1, "request_id": "req-create", "operation": {"type": "create_thread", "path": "/Volumes/work/parser"}}

This is now accepted when /Volumes/work/parser is a path that list_projects returned. Before, it was refused with invalid_request.

Changelog

Paired devices can list every project and saved thread with the desktop sidebar's status, pin, snooze and harness, get pushed updates, and start threads in any listed project.

Testing

  • cargo check --workspace --tests, cargo fmt --all -- --check, scripts/check-comments.py, scripts/check-rust-size.py.
  • Regenerated the schema and goldens with RUSTCODE_UPDATE_REMOTE_PROTOCOL=1 on the remote::contract tests, then reran the contract tests clean.
  • Locally ran remote::, remote_gateway::workspace and remote_gateway::wire_names (178 tests). These include 10 new tests: entry fields and status precedence, past snooze, project grouping and exclusions, the 500-project bound, rescan diffs (pin, rename, delete, add, removed project), splitting large diffs across frames, the subscribe → answer → change frame → stop sequence, and creating a thread in a project outside the roots while refusing its subfolders.
  • Local Clippy stops on existing lints in rustcode-lifecycle/rustcode-loop-detect (a newer local toolchain); CI's Clippy job covers the engine.

Saved-thread entries carry the desktop sidebar's status, pin, snooze, harness, model and scheduled job, and their project is the one the sidebar files them under. list_projects lists every project, subscribe_saved_sessions pushes saved_sessions_changed frames, and create_session accepts any listed project's folder.
@LHagfoss

Copy link
Copy Markdown
Owner Author

Landed on main through #4310, which was built on this branch.

@LHagfoss LHagfoss closed this Nov 24, 2026
@LHagfoss
LHagfoss deleted the feat/gateway-sync-full-thread-sidebar-mobile branch November 24, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant