Skip to content

feat: move threads between environments (draft, not fully tested) - #41771

Draft
jasonLaster wants to merge 6 commits into
pingdotgg:mainfrom
jasonLaster:feat/move-thread-environment
Draft

jasonLaster wants to merge 6 commits into
pingdotgg:mainfrom
jasonLaster:feat/move-thread-environment

Conversation

@jasonLaster

@jasonLaster jasonLaster commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Note

The updated videos and adversarial reruns show a local follow-up based on e438007fed. This draft still points to e438007fed. The failing CI check on that revision is Agent context budget, which needs the maintainer label agent-context-increase.

Problem

A thread is stuck on the environment it started on. To continue work on another machine (laptop to VPS, for example), you start a new thread there and paste context by hand. The original stays active, and its branch doesn't follow.

Demo

Web · Move from Laptop to VPS

Recording; click to open the video

iOS · Move the same thread back to Laptop

Recording; click to open the video

Change

Three server methods, each one service call (ThreadMoveService), which the clients and MCP share:

  • threadMove.export (source; read scope): a bounded snapshot of the thread.
    • User and assistant messages: the first request plus the newest messages within 1 MB (THREAD_MOVE_MAX_HISTORY_BYTES), with a count of what was left behind. For a user-side message that someone other than the user sent, it records who sent it and how.
    • Title, model, modes, and PR links.
    • Git state: branch, tracked remote branch, HEAD, unpushed commits, uncommitted files.
    • It refuses running threads.
  • threadMove.import (target; operate scope): creates the thread through ThreadLaunchService.launch with no first message.
    • Workspace: when the branch is pushed, a new worktree from the remote branch. If the target already has that branch, it reuses or adds a checkout of it. Otherwise it uses the project's default workspace.
    • History is written as run-less items with historyOrigin: "v1_import", so the first turn gets the existing portable handoff, as migrated V1 threads do. Messages keep who sent them, so an agent's message still reads "Agent".
    • If the target can't run the thread's model, it uses the project's default model. Failing that, it uses the same model under another provider instance, then any ready provider, and the notice names the model it switched to. The runtime mode is capped by managed policy, and by the caller's modes for agents.
    • A notice says where the thread came from and what stayed behind.
  • threadMove.complete (source; operate scope): adds a "Moved to …" notice and archives the original. Unarchive reverses it.

Surfaces:

  • client-runtime: createThreadMoveCommands. Its composite move command exports the thread again when Move is pressed, imports it on the target, then completes on the source, and reports when the original could not be archived. It also has helpers for matching the target project by repository, or by a unique title, and for summarizing what happens to the code.
  • Web/desktop: "Move to…" in the sidebar and chat header menus, a command palette action per target, and MoveThreadDialog. The dialog has a project picker and an "Add project to " fallback. It shows warnings about the code and about omitted history.
  • Mobile: "Move to another machine…" in the thread row menu and the command palette, and a ThreadMove sheet.
  • Agents: t3_thread_move (hidden while Linked environments is off) exports here and calls t3_thread_import on the linked environment over its peer link.
    • t3_thread_import is offered only to linked clients (onlyForLinkedClients) and takes the snapshot as JSON text. It goes through startsThreads, so the moved thread carries the link origin and is capped to the link's modes.
    • An agent cannot move the thread it is running in.
  • Docs: a "Move a thread to another machine" section in docs/user/thread-sidebar.md. Translations are included for every web and mobile locale.

Also fixed along the way: a launch with no first message now marks its "agent" setup stage skipped, and clients hide a finished setup whose agent stage was skipped. Before this, a moved thread's setup card showed a "Working for" timer that never stopped. Other setups keep main's behavior.

Scope

A new feature, not a bug fix, requested directly by the branch author.

Verification

The follow-up was tested across two isolated dev environments using Replay. The web and iOS demos show a round trip on the same pushed branch. All 130 focused tests passed. The broader changed-file check passed lint and type checking, and its four Git test failures also reproduced on the original draft head.

Adversarial scenarios and rerun results
Scenario Result How it was checked
Held messages after stopping a turn Export and completion both refuse the move while messages are queued. The original stays active and the queue is preserved. Server regression test
Two clients move the same thread to the same destination Both requests resolve to one imported thread. Concurrent import regression test
Pushed branch moves there and back The target tracks the remote branch and the return move keeps the branch. Web and iOS round trip
Target is killed during Git checkout No destination thread is published while checkout is pending. The source stays active. Retrying after restart replaces the incomplete checkout, and the first Replay turn runs in the recovered worktree. Forced restart of the target dev server, plus Git recovery regression test
Same project title, different repositories The unrelated repository is no longer preselected. Shared client regression test
Last turn was reverted before moving The source move notice is visible after unarchiving. Server regression test
Image-only message History contains a readable placeholder. Both move dialogs say that attachments stay in the original thread. History regression test and web/iOS dialog inspection
Earlier verification and recording

Recording; click to open the video

At e438007, rebased onto main d73e41a:

  • CI: all 8 required checks pass, including the full web, server and mobile test suites.

  • Locally: vp run check:changed against main passes. That covers format, lint, knip, the server GraphQL check, typecheck of 43 packages, tests next to the changes, and the React compiler check. vp run i18n:check passes too.

  • ThreadMoveService.test.ts runs a whole move against a real in-memory orchestrator:

    • import writes the history in order as run-less imported items with the arrival notice, and keeps who sent each message;
    • export of the moved thread returns the same messages;
    • completion archives the thread once, with a "Moved to" notice.

    The test fails when the import's history write is broken.

  • ThreadLaunchService.test.ts: a worktree launch with no first message finishes with the agent stage skipped and no runs.

  • The rebase conflicts were only in the translation catalogs (resolved as main's entries plus this branch's new keys) and in agentContextBudget.json. That file is re-measured at 62543 bytes: main's 61709, plus this PR's 834.

Manual QA with two dev environments ("Laptop" and "VPS") and demo data, before the rebase:

  • The first run moved a thread with its conversation, its pushed branch fix/flaky-login checked out in a new VPS worktree, its model and both notices. It found the bugs fixed in the follow-up commit: typecheck errors, an unwanted worktree when the env mode was unset, a dead end with no usable model, the never-ending timer, a stale uncommitted-file warning, notice wording after Unarchive, and no project pre-selected without a repository identity.
  • The second run found that an agent's message arrived as "Sent by T3 Code", since fixed. The earlier recording above shows the fixed flow: the moved thread keeps the "Agent" label, the original is archived, and Unarchive then a second move reuse the existing VPS checkout.

Not run: the move-thread-to-linked-machine eval case, and the mobile sheet on a device. Lint, typecheck and the React compiler check did cover the mobile sheet's latest change.

Known gaps:

  • No capability flag, so against an older server the action shows and then fails with an RPC error.
  • On mobile, Android can dismiss the sheet mid-move. The move still finishes, but nothing navigates.
  • Expanding the move notice shows blank space, and the notice uses warning styling.
  • The dialog says the branch will be "checked out from its remote" even when the target already has a checkout of it.

Model and harness: Claude Opus 5.5 in Claude Code, running in T3 Code. The web and mobile UI were written by delegated Claude Opus 5.5 child threads.

Follow-up fixes and demo verification by GPT-6.2 Sol in Codex, running in T3 Code.

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Nov 24, 2026
@jasonLaster jasonLaster changed the title feat: move threads between environments (untested) feat: move threads between environments (draft, not fully tested) Nov 24, 2026
@jasonLaster
jasonLaster force-pushed the feat/move-thread-environment branch from 9d23c39 to e0b8e2c Compare November 24, 2026 06:14
louisefindlay23 pushed a commit to louisefindlay23/t3code that referenced this pull request Nov 27, 2026
Threads were stuck on the machine they started on. This carries the
upstream draft pingdotgg#41771 into the fork build: a "Move to…"
menu on web and desktop and a "Move to another machine…" action on
mobile export the thread, import it into the same project on the target
(or add the project there first), and archive the original.

On top of that draft, moving first commits any uncommitted files on the
thread's branch and pushes the branch through a new threadMove.prepare
call, so the target receives the work. If the push fails the move stops
and the original thread is left as it was. Merging into main also keeps
the fork's "Move to project" menu next to the new one.

Co-Authored-By: Jason Laster <254562+jasonLaster@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
louisefindlay23 added a commit to louisefindlay23/t3code that referenced this pull request Nov 27, 2026
…#69)

Threads were stuck on the machine they started on. This carries the
upstream draft pingdotgg#41771 into the fork build: a "Move to…"
menu on web and desktop and a "Move to another machine…" action on
mobile export the thread, import it into the same project on the target
(or add the project there first), and archive the original.

On top of that draft, moving first commits any uncommitted files on the
thread's branch and pushes the branch through a new threadMove.prepare
call, so the target receives the work. If the push fails the move stops
and the original thread is left as it was. Merging into main also keeps
the fork's "Move to project" menu next to the new one.

Co-authored-by: x <x@x>
Co-authored-by: Jason Laster <254562+jasonLaster@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@jasonLaster
jasonLaster force-pushed the feat/move-thread-environment branch 2 times, most recently from 46ae8c1 to 494b747 Compare November 27, 2026 17:44
jasonLaster and others added 6 commits November 28, 2026 06:03
UNTESTED: written on a host too small to typecheck, lint, or run the app.
Only the new pure-logic unit tests were run (server ThreadMoveService.test.ts,
client-runtime threadMove.test.ts). No typecheck, lint, web/mobile tests,
eval run, or real move between two environments has been done. Committed
with --no-verify: the pre-commit lint and knip hooks crash for lack of memory
on this host.

A thread's conversation can now move to another environment the client is
connected to, or, for agents, to a linked environment:

- threadMove.export (source): bounded snapshot of user/assistant messages
  (first request + newest within 1 MB), model, modes, PR links, and git state.
  Refuses running threads.
- threadMove.import (target): launches a thread in the chosen project on the
  source's pushed branch (reusing a checkout there when one exists), else the
  project's default workspace; writes the history as run-less imported items
  so the first turn gets the portable handoff; adds a notice of what stayed
  behind.
- threadMove.complete (source): notes where the thread went and archives it.
- Web/desktop: Move to… in the sidebar and chat header menus, command palette,
  and a dialog. Mobile: thread row menu, command palette, and a sheet.
- Agents: t3_thread_move, forwarding to a linked-only t3_thread_import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he service in toolkit tests

Found by the first typecheck run (on another machine). Still untested
overall: no full typecheck or lint has passed yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first real run (on a laptop) moved a thread successfully but found:

- Typecheck errors: test layers past the 20-argument pipe limit, missing
  ThreadMoveService mocks in ws/AgentContextBudget/core tests, a vitest
  import, and the move command's Effect.fn form.
- A project with no explicit env mode got a worktree: settings now resolve
  through t3.json and the built-in defaults.
- A target with neither the thread's provider nor a project default model
  dead-ended the dialog: fall back to the same model under another instance,
  then any ready provider.
- A moved thread's setup card kept a "Working for" timer running: a launch
  with no first message no longer tracks an agent stage, and a finished
  setup without one is hidden.
- The dialog's git warning came from the snapshot taken when it opened: the
  move now exports again when Move is pressed.
- The source notice said the thread "stays archived", wrong after Unarchive.
- Projects without a repository identity were never pre-selected: fall back
  to the single same-titled project.

t3_thread_import now takes the snapshot as JSON text, which keeps the tool
list growth to 834 bytes; agentContextBudget.json is updated.

Still not fully verified: no complete typecheck or lint has passed yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd-to-end test

Manual QA between two dev environments found that a moved message an agent
wrote showed as "Sent by T3 Code": the import stamped every message as sent
by the server. The move now carries each user-side message's createdBy and
creationSource, so it keeps its "Agent" label. The arrival notice also says
when the target had to switch models.

- ThreadMoveService.test.ts: an end-to-end move against a real in-memory
  orchestrator (import writes run-less imported history and the notice,
  export round-trips the messages, completion archives once), plus the
  fallback-model fixture fix that blocked the server typecheck.
- Mobile ThreadMoveSheet: export the thread without a setState-in-effect
  helper, which lint rejected.
- useThreadActionMenu.test.ts: stub the move dialog and state the menu now
  imports, which crashed the suite at load.
- moveArrivalNotice is no longer exported (knip).

vp run check:changed passes against main's merge base (format, lint, knip,
typecheck of 43 packages, 31 test files, react compiler), and so does
vp run i18n:check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The earlier fix hid any finished worktree setup that had no agent stage.
On main, a finished setup with no stages must stay visible until a run
starts, and the mobile worktree-setup-state test failed in CI. Launches
with no first message, such as a moved thread, now keep the agent stage
and mark it skipped, and the client hides only a finished setup whose
agent stage was skipped. Everything else keeps main's rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep only main's i18n keys plus the ones thread moves add, and measure
the tool-list budget again against current main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). 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