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, and the thread can move only back to the computer it came from. If the link it came over can't confirm which computer sent it, it can't move at all until then. 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 moves with them: the dialog lists its threads here, ticked, and one you untick stays here as its own thread, as does one that can't move (the dialog says why). On the other computer the threads that came are still its threads, and its "Moved here" line names the ones that stayed. Threads its agent started on another computer stay there, and the moved thread can't reach them. Moved to the computer one of them is on, its "Moved here" line names that thread, which stays separate. Move when it's done waits for the threads it started to report back, and Stop and move now ends that wait as Stop does. A thread another thread started can move on its own (Move just this thread) or with its whole family. With its whole family, each thread moves with the agent the other computer suggests for it. On its own it stays that thread's thread on the other computer, which can still send to it, read it and stop it; there, like any thread another computer's agent started, its agent never gets other threads, rooms or schedules. A thread another computer's agent started can move only back to that computer, where it is that thread's thread again. A thread with a message queued by a scheduled task, an assistant or a thread outside its family 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, and the thread can move only back to the computer it came from. If the link it came over can't confirm which computer sent it, it can't move at all until then. 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 moves with them: the dialog lists its threads here, ticked, and one you untick stays here as its own thread, as does one that can't move (the dialog says why). On the other computer the threads that came are still its threads, and its "Moved here" line names the ones that stayed. Threads its agent started on another computer stay there, and the moved thread can't reach them. Moved to the computer one of them is on, when that computer runs a current Threadlines, that thread is its thread again there, nested under it, and its "Moved here" line says so; one that started threads of its own, is archived or moving, or has more access than the moved thread gets there stays separate, and the line says why. The thread taken back has no other threads, rooms or schedules, and can move only back to the computer that started it, until you send it a message there; a message in its parent doesn't count. Move when it's done waits for the threads it started to report back, and Stop and move now ends that wait as Stop does. A thread another thread started can move on its own (Move just this thread) or with its whole family. With its whole family, each thread moves with the agent the other computer suggests for it. On its own it stays that thread's thread on the other computer, which can still send to it, read it and stop it; there, like any thread another computer's agent started, its agent never gets other threads, rooms or schedules. A thread another computer's agent started can move only back to that computer, where it is that thread's thread again. A thread with a message queued by a scheduled task, an assistant or a thread outside its family can't move yet; the dialog says what to finish first.`,
},
{
id: "devices",
Expand Down
187 changes: 186 additions & 1 deletion apps/server/src/links/LinkMoves.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ interface CarryRecord {
readonly linkLabel?: string;
/** Threads already here, as their rows read. */
readonly threadsHere?: ReadonlyArray<{ readonly threadId: ThreadId } & Record<string, unknown>>;
/**
* Threads this link gave up (LinkRequests.releaseThread), each with how
* many commands were dispatched by then.
*/
readonly released?: Array<{ readonly threadId: ThreadId; readonly dispatchedBefore: number }>;
}

/** The services LinkMoves leans on, with this computer's git real and the rest faked. */
Expand Down Expand Up @@ -229,6 +234,10 @@ function testLayer(
title: "Threadlines",
workspaceRoot: repos.b,
} as never),
releaseThread: (_deviceId, threadId) =>
Effect.sync(
() => void carry.released?.push({ threadId, dispatchedBefore: dispatched.length }),
),
// An instance this computer doesn't have ("gone") is refused.
resolveAgentFor: (input) =>
Effect.succeed(
Expand Down Expand Up @@ -279,6 +288,23 @@ function testLayer(
// A thread here once its import was dispatched (a family's child reads
// its parent), or one that was here already.
Layer.mock(ProjectionThreadRepository)({
// As the decider would write them: every thread the import asked for.
listAdoptedChildIds: ({ parentThreadId }) =>
Effect.sync(() =>
dispatched.flatMap((command) =>
command.type === "thread.import" && command.threadId === parentThreadId
? (command.adoptsChildren?.children ?? []).map((child) => child.threadId)
: [],
),
),
listAttachedChildIds: ({ parentThreadId }) =>
Effect.succeed(
(carry.threadsHere ?? []).flatMap((row) =>
row.parentThreadId === parentThreadId && row.attachedToParent === 1
? [row.threadId]
: [],
),
),
listIdsByRemoteLink: ({ linkDeviceId }) =>
Effect.succeed(
(carry.threadsHere ?? []).flatMap((row) =>
Expand Down Expand Up @@ -372,7 +398,10 @@ const pack = (
repos: ReturnType<typeof makeRepos>,
nativeSession?: NativeSessionExport | null,
state?: PeerMoveThreadState,
room?: Pick<MoveExportInput, "room" | "outsideWork" | "family" | "linkLineage"> & {
room?: Pick<
MoveExportInput,
"room" | "outsideWork" | "family" | "linkLineage" | "startedThere"
> & {
/** What the move says the computer it leaves calls itself. */
readonly sourceEnvironmentId?: EnvironmentId | undefined;
readonly sourceLabel?: string;
Expand All @@ -394,6 +423,7 @@ const pack = (
dir,
family: room?.family,
linkLineage: room?.linkLineage,
startedThere: room?.startedThere,
attachmentsDir: path.join(repos.root, "attachments"),
thread: room?.thread ?? movingThread(),
room: room?.room,
Expand Down Expand Up @@ -2266,6 +2296,161 @@ describe("a thread moving across its link (Part 3f, (h))", () => {
});
});

describe("a parent taking back the threads it started here (Part 3f, (g))", () => {
/** A thread the link started here for the moving thread (`thread-a` there). */
const startedHere = (threadId: string, title: string, extra: Record<string, unknown> = {}) => ({
threadId: ThreadId.make(threadId),
title,
projectId: ProjectId.make("project-b"),
runtimeMode: "approval-required",
interactionMode: "default",
move: null,
pendingMove: null,
parentThreadId: null,
attachedToParent: 0,
deletedAt: null,
archivedAt: null,
...extra,
remoteOrigin: {
linkDeviceId: "device-windows",
environmentId: WINDOWS,
environmentPinned: true,
environmentLabel: "Windows PC",
threadId: "thread-a",
threadTitle: "Ship it",
},
});
const wrapped = { state: "done", at: "2026-11-17T09:00:00.000Z" } as const;
const startedThere = [
{ threadId: ThreadId.make("thread-both"), override: wrapped },
// On its list there, but not a thread this link started here for it.
{ threadId: ThreadId.make("thread-not-here") },
];
const arriving = (
repos: ReturnType<typeof makeRepos>,
dispatched: OrchestrationCommand[],
carry: Pick<CarryRecord, "released" | "threadsHere">,
linkLineage?: MoveExportInput["linkLineage"],
listed: ReadonlyArray<{ readonly threadId: ThreadId }> = startedThere,
) =>
Effect.gen(function* () {
const packed = yield* pack(repos, null, undefined, {
startedThere: [...listed],
linkLineage,
});
const state = yield* deliver(packed.manifest, packed.payload);
// Asked again (a restart, a lost answer): read from the threads, the same.
const again = yield* (yield* LinkMoves).status(link("allowed"), { transferId: TRANSFER });
return { state, again };
}).pipe(
Effect.provide(
testLayer(repos, dispatched, "allowed", () => false, [], {
home: os.tmpdir(),
adopted: [],
linkLabel: "Windows PC",
pinnedEnvironmentId: WINDOWS,
threadsHere: [
startedHere("thread-both", "Fix tests"),
startedHere("thread-only-here", "Only here"),
],
...carry,
}),
),
);

it.live("only those both its list and this computer's records name, released first", () => {
const repos = makeRepos();
const dispatched: OrchestrationCommand[] = [];
const released: NonNullable<CarryRecord["released"]> = [];
return Effect.gen(function* () {
const { state, again } = yield* arriving(repos, dispatched, { released });
assert.equal(state.status, "committed");
const imported = importOf(dispatched);
assert.deepEqual(imported.adoptsChildren, {
linkDeviceId: "device-windows",
children: [{ threadId: ThreadId.make("thread-both"), override: wrapped }],
});
// Here but not on its list: it stays apart, with today's words.
assert.deepEqual(
(imported.arrival?.left ?? []).filter((sentence) => sentence.includes("this computer")),
[
"Its thread 'Only here' is already on this computer. It stays separate, so this thread can't reach it.",
],
);
// The link let go of it before the import, and again once it landed.
assert.deepEqual(
released.map((entry) => entry.threadId),
["thread-both", "thread-both"],
);
assert.isAtMost(released[0]!.dispatchedBefore, dispatched.indexOf(imported));
assert.isAbove(released[1]!.dispatchedBefore, dispatched.indexOf(imported));
assert.deepEqual(state.adopted, [ThreadId.make("thread-both")]);
assert.deepEqual(again.adopted, [ThreadId.make("thread-both")]);
});
});

it.live("a thread landing under a parent takes none back", () => {
const repos = makeRepos();
const dispatched: OrchestrationCommand[] = [];
const released: NonNullable<CarryRecord["released"]> = [];
return Effect.gen(function* () {
const { state } = yield* arriving(
repos,
dispatched,
{ released },
{ remoteParent: { threadId: ThreadId.make("thread-parent-on-windows"), title: "Ship" } },
);
assert.equal(state.status, "committed");
assert.isUndefined(importOf(dispatched).adoptsChildren);
assert.deepEqual(released, []);
assert.isUndefined(state.adopted);
});
});

it.live("one on its list that can't be taken back keeps its requests, and says why", () => {
const repos = makeRepos();
const dispatched: OrchestrationCommand[] = [];
const released: NonNullable<CarryRecord["released"]> = [];
const listed = ["thread-full-access", "thread-archived", "thread-moving"].map((id) => ({
threadId: ThreadId.make(id),
}));
return Effect.gen(function* () {
const { state } = yield* arriving(
repos,
dispatched,
{
released,
threadsHere: [
// More access than the parent gets here (its modes after the link's cap).
startedHere("thread-full-access", "Full access", { runtimeMode: "full-access" }),
startedHere("thread-archived", "Archived", {
archivedAt: "2026-11-17T10:00:00.000Z",
}),
startedHere("thread-moving", "Moving", { pendingMove: { requestId: "r" } }),
],
},
undefined,
listed,
);
assert.equal(state.status, "committed");
const imported = importOf(dispatched);
assert.isUndefined(imported.adoptsChildren);
// Never released: what its link asked of it still stands.
assert.deepEqual(released, []);
const line = (title: string, why: string) =>
`Its thread '${title}' is already on this computer. It stays separate because ${why}, so this thread can't reach it.`;
assert.includeMembers(
[...(imported.arrival?.left ?? [])],
[
line("Full access", "it has more access than this thread has here"),
line("Archived", "it's archived"),
line("Moving", "it's moving"),
],
);
});
});
});

it("refuses a manifest naming both a parent and a home, itself, or a family too", () => {
const base = {
totalBytes: 0,
Expand Down
Loading
Loading