Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Linking is two-way, with a permission for each direction: "<A>'s agents can star

With a link allowed, an agent can start a thread on the other computer in that computer's copy of the project, read it and message it, and its reply comes back. A computer you only open from this app (Settings › Connections › Computers you use from here) is not a link: you see its threads here, but agents can't work across. This app's sign-in to it renews whenever they connect and ends after 90 days without one, or when that computer removes it. Fleet's All computers page and its own page then say the sign-in ended and offer to connect again with a new code; its threads stay on it.

To carry on a thread on a linked computer, for example before shutting this one down, click its title at the top of the chat or right-click it in the sidebar (or use the command palette), and pick Move to another computer. The thread goes with its messages and its code changes, including files not yet committed; staged changes arrive unstaged. It lands in a new worktree of that computer's copy of the project; the dialog offers to set the project up there when it's missing. When that computer's permission for this one is Ask first, its user allows the move there. The copy left here stays, read-only, with a link to the new one. With Claude, Codex or Pi, and the same kind of agent picked on the other computer, the agent keeps its full memory: its own session moves too (up to 50 MB) and picks up where it was. Otherwise, or if that session can't be resumed there, the agent gets a summary of the conversation; the dialog and the moved thread's timeline say which. Turns from before the move can't be undone there. A working thread can move too: Move when it's done starts the move once its turn and background work finish, and Stop and move now stops its agent first. While it waits, a notice above the message box says what for, with Cancel, and the thread takes no new messages. An agent can move its own thread with thread_move; it goes when that turn ends. To clear a computer before shutting it down, Move threads (on a computer's page in Fleet, or in the command palette) moves several at once, and quitting the desktop app while threads work offers to move them first, quitting once each has gone. When the other computer asks first, it takes each move's files right away and holds them until its user allows them (all the moves from one computer together, or one at a time), so this computer counts them as sent and can shut down; a move that isn't allowed unfreezes here the next time the two connect. What a thread had going comes along when the other computer runs a current Threadlines, and runs there by itself: a goal that was working carries on, the agent is told its check-backs and sets them again, your queued messages are sent in order, its pull requests come along with auto-fix and auto-merge off (a notice there says what was on, with Turn on), and its plans come along, the waiting one with Implement. Until you send the moved thread a message there, its agent can't use other threads, rooms or schedules. A General Chats thread moves with every file in its folder, up to 100 MB. The dialog says what comes along and what won't work there; the "Moved here" line on the other computer says what arrived and what didn't. If a move doesn't happen, the thread gets back here what the move stopped: its goal and its check-backs, and its queued messages go. A thread in a room, that started other threads, or with a message queued by a scheduled task, another thread or an assistant can't move yet; the dialog says what to finish first.`,
To carry on a thread on a linked computer, for example before shutting this one down, click its title at the top of the chat or right-click it in the sidebar (or use the command palette), and pick Move to another computer. The thread goes with its messages and its code changes, including files not yet committed; staged changes arrive unstaged. It lands in a new worktree of that computer's copy of the project; the dialog offers to set the project up there when it's missing. When that computer's permission for this one is Ask first, its user allows the move there. The copy left here stays, read-only, with a link to the new one. With Claude, Codex or Pi, and the same kind of agent picked on the other computer, the agent keeps its full memory: its own session moves too (up to 50 MB) and picks up where it was. Otherwise, or if that session can't be resumed there, the agent gets a summary of the conversation; the dialog and the moved thread's timeline say which. Turns from before the move can't be undone there. A working thread can move too: Move when it's done starts the move once its turn and background work finish, and Stop and move now stops its agent first. While it waits, a notice above the message box says what for, with Cancel, and the thread takes no new messages. An agent can move its own thread with thread_move; it goes when that turn ends. To clear a computer before shutting it down, Move threads (on a computer's page in Fleet, or in the command palette) moves several at once, and quitting the desktop app while threads work offers to move them first, quitting once each has gone. When the other computer asks first, it takes each move's files right away and holds them until its user allows them (all the moves from one computer together, or one at a time), so this computer counts them as sent and can shut down; a move that isn't allowed unfreezes here the next time the two connect. What a thread had going comes along when the other computer runs a current Threadlines, and runs there by itself: a goal that was working carries on, the agent is told its check-backs and sets them again, your queued messages are sent in order, its pull requests come along with auto-fix and auto-merge off (a notice there says what was on, with Turn on), and its plans come along, the waiting one with Implement. Until you send the moved thread a message there, its agent can't use other threads, rooms or schedules. A General Chats thread moves with every file in its folder, up to 100 MB. The dialog says what comes along and what won't work there; the "Moved here" line on the other computer says what arrived and what didn't. If a move doesn't happen, the thread gets back here what the move stopped: its goal and its check-backs, and its queued messages go. A room moves with its agents: the dialog has a row per agent with the matching agent on the other computer picked (same kind and model, else that kind's default), or Leave out. An agent with no match, or left out, arrives as having left, and both ends say which; each agent that comes keeps its own memory or gets the whole conversation once. Move when it's done waits for the agents' hand-offs and replies to finish, and Stop and move now ends them as Stop does. A thread that started other threads, or with a message queued by a scheduled task, another thread or an assistant can't move yet; the dialog says what to finish first.`,
},
{
id: "devices",
Expand Down
206 changes: 202 additions & 4 deletions apps/server/src/links/LinkMoves.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ProviderInstanceId,
ThreadId,
ThreadMoveId,
ThreadParticipantId,
TurnId,
GENERAL_CHATS_PROJECT_ID,
type OrchestrationCommand,
Expand All @@ -33,10 +34,12 @@ import { ServerEnvironment } from "../environment/Services/ServerEnvironment.ts"
import {
estimateMoveOtherBytes,
inspectMoveCheckout,
type MoveExportInput,
movePayloadPath,
writeMoveExport,
writeScratchExport,
} from "../moves/moveExport.ts";
import { participantSessionKey } from "@threadlines/shared/threadParticipants";
import { OrchestrationEngineService } from "../orchestration/Services/OrchestrationEngine.ts";
import { ProjectionSnapshotQuery } from "../orchestration/Services/ProjectionSnapshotQuery.ts";
import { ProjectionThreadRepository } from "../persistence/Services/ProjectionThreads.ts";
Expand Down Expand Up @@ -204,10 +207,18 @@ function testLayer(
title: "Threadlines",
workspaceRoot: repos.b,
} as never),
// An instance this computer doesn't have ("gone") is refused.
resolveAgentFor: (input) =>
Effect.succeed({
selection: { instanceId: input.agent.instanceId, model: input.agent.model ?? "m" },
} as never),
Effect.succeed(
(input.agent.instanceId === "gone"
? { refused: "Mac mini has no such agent." }
: {
selection: {
instanceId: input.agent.instanceId,
model: input.agent.model ?? "m",
},
}) as never,
),
}),
Layer.mock(OrchestrationEngineService)({
dispatch: (command) =>
Expand Down Expand Up @@ -300,6 +311,9 @@ const pack = (
repos: ReturnType<typeof makeRepos>,
nativeSession?: NativeSessionExport | null,
state?: PeerMoveThreadState,
room?: Pick<MoveExportInput, "room" | "outsideWork"> & {
readonly thread?: OrchestrationThread;
},
) =>
Effect.gen(function* () {
const git = yield* GitVcsDriver.GitVcsDriver;
Expand All @@ -311,7 +325,9 @@ const pack = (
transferId: TRANSFER,
dir,
attachmentsDir: path.join(repos.root, "attachments"),
thread: movingThread(),
thread: room?.thread ?? movingThread(),
room: room?.room,
outsideWork: room?.outsideWork,
projectTitle: "Threadlines",
subdirectory: "",
canonicalKey: "example.com/repo",
Expand Down Expand Up @@ -1342,6 +1358,188 @@ describe("LinkMoves, a General Chats thread", () => {
});
});

describe("LinkMoves, a room (Part 3f, (i))", () => {
const SOL = ThreadParticipantId.make("6f1d7c2a-1b2c-4d3e-8f90-0a1b2c3d4e5f");
const ADA = ThreadParticipantId.make("7a2e8d3b-2c3d-4e4f-9a01-1b2c3d4e5f60");
const at = "2026-10-22T10:00:00.000Z";
/** The moving thread as a room: Sol's reply, and the user's message to it. */
const roomThread = (): OrchestrationThread => {
const thread = movingThread();
return {
...thread,
participants: [],
messages: [
...thread.messages,
{
id: MessageId.make("m3"),
role: "user",
text: "Sol, review it",
participantId: SOL,
turnId: null,
streaming: false,
createdAt: at,
updatedAt: at,
},
{
id: MessageId.make("m4"),
role: "assistant",
text: "Looks right.",
participantId: SOL,
turnId: "turn-2",
agentModels: {
[SOL]: { modelSelection: agent, nameIndex: 1 },
},
streaming: false,
createdAt: at,
updatedAt: at,
},
],
} as unknown as OrchestrationThread;
};
const participant = (id: ThreadParticipantId, handle: string, agentThere?: typeof agent) => ({
id,
handle,
joinedAt: at,
leftAt: null,
source: { driver: "codex", model: "gpt-6.1-sol" },
...(agentThere !== undefined
? { agent: agentThere, seenThroughMessageId: MessageId.make("m4") }
: {}),
});
const outsideWork = [
{
participantId: SOL,
connections: [{ connectionId: "connection-1", name: "Chat" }],
since: at,
version: 1,
},
{
participantId: ADA,
connections: [{ connectionId: "connection-1", name: "Chat" }],
since: at,
version: 1,
},
] as unknown as MoveExportInput["outsideWork"];

it.live(
"lands its agents with fresh ids, each with its own session, fenced; one with no agent here as having left",
() => {
const repos = makeRepos();
const dispatched: OrchestrationCommand[] = [];
const carry: CarryRecord = { home: path.join(repos.root, "claude-b"), adopted: [] };
return Effect.gen(function* () {
const session = yield* exportClaudeNativeSession({
configDir: claudeHomeWithSession(repos.root),
resumeCursor: { resume: SESSION, turnCount: 1 },
});
const { manifest, payload } = yield* pack(repos, null, undefined, {
thread: roomThread(),
room: {
agentRole: "Builder",
participants: [participant(SOL, "Sol", agent), participant(ADA, "Ada")],
sessions: session === null ? [] : [{ participantId: SOL, session }],
},
outsideWork,
});
// The session's files name their agent; the thread's own agent carries none.
const sessionParts = manifest.parts.filter((part) => part.kind === "session");
assert.isAbove(sessionParts.length, 0);
assert(sessionParts.every((part) => part.participantId === SOL));
assert.equal(manifest.session, undefined);
assert.equal(moveManifestRefusal(manifest), null);
assert.equal((yield* deliver(manifest, payload)).status, "committed");

const command = dispatched.find((entry) => entry.type === "thread.import");
assert(command?.type === "thread.import");
const participants = command.participants ?? [];
const sol = participants.find((entry) => entry.handle === "Sol");
const ada = participants.find((entry) => entry.handle === "Ada");
assert(sol !== undefined && ada !== undefined);
// Ids of this computer's own, never the sender's.
assert.notEqual(sol.id, SOL);
assert.notEqual(ada.id, ADA);
assert.deepInclude(sol, {
leftAt: null,
movedIn: true,
nativeSession: "carried",
modelSelection: agent,
});
assert.equal(ada.leftAt, command.createdAt);
assert.equal(ada.movedIn, undefined);
assert.equal(command.agentRole, "Builder");
// Sol's session is bound under its own key here, nothing else is.
assert.deepEqual(
carry.adopted.map((entry) => entry.threadId),
[participantSessionKey(command.threadId, sol.id)],
);
// Its messages name it by its id here.
const reply = command.messages.find((message) => message.text === "Looks right.");
assert.equal(reply?.participantId, sol.id);
// Its carried session saw up to its own reply: named by its id here.
assert.equal(sol.movedSeenThrough, reply?.messageId);
assert.deepEqual(Object.keys(reply?.agentModels ?? {}), [sol.id]);
// Outside work still limits it here; Ada's mark goes with Ada.
assert.deepEqual(
(command.outsideWork ?? []).map((mark) => mark.participantId),
[sol.id],
);
// The "Moved here" line says who came, and who didn't with why.
assert.include(command.arrival?.brought ?? [], "its agents Sol");
assert.include(
command.arrival?.left ?? [],
"Ada didn't come: this computer has no Codex agent.",
);
}).pipe(Effect.provide(testLayer(repos, dispatched, "allowed", () => false, [], carry)));
},
);

it.live(
"refuses a room agent this computer doesn't have, and a part naming no agent of the room",
() => {
const repos = makeRepos();
const dispatched: OrchestrationCommand[] = [];
return Effect.gen(function* () {
const { manifest } = yield* pack(repos, null, undefined, {
thread: roomThread(),
room: {
participants: [
participant(SOL, "Sol", {
instanceId: ProviderInstanceId.make("gone"),
model: "gpt-6.1-sol",
}),
],
sessions: [],
},
});
const moves = yield* LinkMoves;
const state = yield* moves.prepare(link("allowed"), { transferId: TRANSFER, manifest });
assert.equal(state.status, "aborted");
assert.include(state.reason ?? "", "Sol: Mac mini has no such agent.");
assert.equal(
moveManifestRefusal({
...manifest,
thread: {
...manifest.thread,
messages: [
...manifest.thread.messages,
{
messageId: MessageId.make("m-stranger"),
role: "user",
text: "Hi",
turnId: null,
participantId: ADA,
createdAt: at,
},
],
},
}),
"a message names an agent the room doesn't have",
);
}).pipe(Effect.provide(testLayer(repos, dispatched)));
},
);
});

describe("what a move may write here", () => {
it("measures a binary change by the file it makes, delta or literal", () => {
const repos = makeRepos();
Expand Down
Loading
Loading