Skip to content

feat(cloud): move a chat between your Mac and the cloud with its memory - #167

Merged
andrewcai8 merged 5 commits into
mainfrom
feat/move-chat-cloud
Oct 5, 2026
Merged

andrewcai8 merged 5 commits into
mainfrom
feat/move-chat-cloud

Conversation

@andrewcai8

@andrewcai8 andrewcai8 commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Moving a chat to the cloud used to mean pasting a summary into a new cloud chat. The agent lost its memory and had to rebuild context, and it got some of it wrong. scripts/cloud/move-chat.ts moves the chat 1:1. The box continues the same native Claude session, and the chat's history shows up in T3.

Design

to-cloud --thread <local thread id> --message-file <first message>:

  1. Reads the chat from the local desktop app's database (read-only). This gives its Claude session id, worktree, account and model selection. It refuses a chat that is still running.
  2. Snapshots the worktree with a throwaway index: HEAD plus tracked edits and untracked files, minus ignored ones. It pushes the snapshot to handoff/move-<thread>-<commit>. The worktree, its index and its branch are left alone.
  3. Provisions an E2B box on the manager through environmentControl.provision, pinned to the same account and checked out at that branch. The chat's thread id is the one the box's importer will give the session.
  4. Writes the session transcript to the box with each record's cwd rebased onto the box workspace. The box then runs its own agentSessions.scan and agentSessions.import. That creates the thread bound to the native session and shows the last 200 messages.
  5. Sends a short header turn ("Moved from the Mac: continues local thread ..."). It detaches that provider session and puts the moved transcript in place. Then it sends the first message, which opens with --resume <session id>.
  6. Follows that turn and prints the reply.

--include <path> copies local-only files such as .env into the box workspace. They go through the E2B API and never touch git. The total is capped by --include-cap-mb.

to-local --sandbox <id> --worktree <dir> --claude-config-dir <dir> reverses it. It snapshots the box workspace to handoff/move-back-*, using the box server's git environment. It writes the box's session into the local Claude config dir with cwd rebased, keeping a backup of any existing file. Then it fetches the branch and prints the claude --resume command. The local app is V1 and has no import, so the CLI is how you continue there.

Re-running to-cloud for the same thread picks up where it stopped. The request id, command ids and message ids are kept in ~/.t3/move-chat/<thread>.json. The transcript is only swapped in once.

What it reuses from upstream

  • AgentSessionScanner and AgentSessionImporter (agentSessions.scan and agentSessions.import) build the thread, its visible history and its native thread binding.
  • provider-session.detach closes the header turn's CLI process. The next turn reopens it with resume, because a provider turn now exists.
  • The manager's provision and attach RPCs, and the cloud smoke's pairing flow. Its RPC helpers move to scripts/cloud/t3Rpc.ts, and the smoke now uses them too.

Why the header turn

Today the V2 Claude adapter opens an imported thread's first turn with sessionId rather than resume. It only resumes once a provider turn exists. Claude refuses a --session-id that already has a transcript ("Session ID ... is already in use"). I checked this with the CLI. So the header turn creates a throwaway session under that id, the detach ends it, and the real history replaces it. A one-line adapter change would remove the header turn (resume when the provider thread came from an import). Boxes only pick that up after a host deploy, so it is left as a follow-up.

Verified

The local "proactivity" chat moved to a new E2B box. The first cloud turn ran claude ... --resume=b3bc7fd7-... and completed. Its reply named the mind-trigger-consent branch, /tmp/measure/snapshots and pingdotgg#6499–pingdotgg#6629. All three appear in the local session and not in the earlier summary handoff. to-local was run against the same box with a temporary config dir. It pushed the workspace snapshot and wrote a 6123-line transcript whose cwd fields point back at the Mac worktree.

vp test run cloud/moveChat.test.ts cloud/turnProgress.test.ts passes. That covers Claude's project directory names, the cwd rewrite, GitHub remote parsing, and the snapshot (edits, deletions, untracked files, no ignored files, checkout untouched).

Limits

  • Claude only. Codex keeps its sessions in dated rollout files and the importer already reads them, but this tool does not move them yet.
  • Local side reads the V1 desktop database (state.sqlite).
  • E2B only.
  • Tool-result sidecar files and subagent transcripts stay behind. The conversation itself does not need them.
  • Paths inside old messages still name the Mac. The first message should tell the agent where it is now.
  • Paths longer than 200 characters are refused, because Claude shortens those directory names with a hash.

Ran with Claude Opus 5.5 (1M context) in Claude Code.

🤖 Generated with Claude Code

Carrying outside files (second commit). A moved agent also depends on files it used outside its checkout: design notes, measurement data, env files, and the repo's Claude auto-memory. to-cloud now finds them from the chat's own record (main and subagent transcripts plus saved tool outputs), skips git repos (reported with their remote), tool-config dot-dirs and anything over the caps, fills the budget smallest first, and extracts them on the box at the same absolute paths (the Mac home is linked to /home/user). carry --sandbox <id> --thread <id> [--dry-run] does the same for an already-moved chat. Used on 2026-10-05 to restore two chats on andrew.megpt.app (85 and 8 paths carried).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 4.9 KiB −40 B (−0.8%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB −40 B (−3.3%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.8 KiB −41 B (−0.2%) 29.3 KiB ✅
Codex Live turn messages 2 1 −1 (−50.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 03a1ec0 · PR result: 8d68b70 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@github-actions github-actions Bot added size:XXL and removed size:XL labels Oct 5, 2026
andrewcai8 and others added 2 commits October 5, 2026 17:33
scripts/cloud/move-chat.ts moves a local Claude chat to an E2B box on the
manager, carrying the checkout exactly as it is on disk and the agent's
native Claude session, so the box continues the same conversation. The box
imports the session with its own agent session importer, which also shows
the history in T3. to-local pulls the box's session and workspace back.

The cloud smoke now shares its RPC and pairing helpers with it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A moved agent lost every note, data dir and env file it had written or read
outside its checkout. move-chat now finds those paths in the whole session
record (main and subagent transcripts, tool inputs and outputs), carries the
ones that are not code or tool config to the same absolute paths on the box
within per-item and total caps, merges the repo's Claude memory, and tells the
agent what came along and what did not. `carry` does the same for a box that
was already moved; `--dry-run` prints the manifest only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@andrewcai8
andrewcai8 force-pushed the feat/move-chat-cloud branch from d91d9c1 to 0e19f6b Compare October 5, 2026 16:33
andrewcai8 and others added 3 commits October 5, 2026 17:36
…g URL never prints its token

A finished or failed move's state is set aside, so a later move of the same chat no longer
replays the old request and message ids against the old box.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…fect diagnostics

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@andrewcai8
andrewcai8 merged commit dee321e into main Oct 5, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant