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 @@ -144,7 +144,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, pull request auto-fix and auto-merge keep watching from there (switched off, with why, when its branch had to be renamed there), and its plans come along, the waiting one with Implement. 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 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.`,
},
{
id: "devices",
Expand Down
22 changes: 21 additions & 1 deletion apps/server/src/links/LinkMoves.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,21 @@ describe("LinkMoves, what a thread had going (Part 3e)", () => {
const command = importOf(dispatched);
// Working, it is picked up here, with its budget as it was.
assert.deepInclude(command.goal, { status: "active", tokenBudget: 5_000, tokensUsed: 1_200 });
// The pull request comes along with its switch off: only the user here
// turns it on, from the offer the thread keeps.
assert.deepEqual(command.pullRequests, {
autoFix: false,
autoMerge: null,
linked: [
{
number: 212,
url: "https://example.com/repo/pull/212",
autoFix: false,
autoMerge: null,
},
],
});
assert.deepEqual(command.movedFrom.pullRequestSwitches, {
autoFix: true,
autoMerge: null,
linked: [
Expand All @@ -1067,12 +1081,16 @@ describe("LinkMoves, what a thread had going (Part 3e)", () => {
assert.include(message, "Look at CI on #212");
assert.deepEqual(command.arrival?.brought, [
"its goal",
"auto-fix for #212",
"pull request #212",
"1 queued message",
"its plan",
]);
assert.include(command.arrival?.left.join("\n"), "can't set them");
assert.include(command.arrival?.left.join("\n"), "3 older plans stayed on Windows PC.");
assert.include(
command.arrival?.left.join("\n"),
"Auto-fix was on for this thread's pull request and #212 on Windows PC. It's off here until you turn it on.",
);
// One send: the arrival message, by the move's own command id.
assert.deepEqual(
sends(dispatched).map((entry) =>
Expand Down Expand Up @@ -1180,6 +1198,8 @@ describe("LinkMoves, what a thread had going (Part 3e)", () => {
command.arrival?.left.join("\n"),
"Auto-fix is off here: this computer already has a branch named `feature/move-me`, so pushes from this thread wouldn't reach pull request #212.",
);
// Turning it on wouldn't reach the pull request: nothing is offered.
assert.isUndefined(command.movedFrom.pullRequestSwitches);
}).pipe(
Effect.provide(
testLayer(repos, dispatched, "allowed", () => false, [], {
Expand Down
65 changes: 40 additions & 25 deletions apps/server/src/links/LinkMoves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
type ProviderInstanceId,
type ProviderInteractionMode,
type PullRequestMergeMethod,
type ThreadMovedFrom,
type RuntimeMode,
PEER_MOVE_CHUNK_MAX_BYTES,
PEER_MOVE_STATE_MAX_BYTES,
Expand Down Expand Up @@ -88,6 +89,10 @@ import { ServerConfig } from "../config.ts";
import { ServerEnvironment } from "../environment/Services/ServerEnvironment.ts";
import { receivedPathRefusal, writeReceivedFile } from "../fs/receivedFiles.ts";
import { ProjectSetupScriptRunner } from "../project/Services/ProjectSetupScriptRunner.ts";
import {
movedPullRequestSwitchesWords,
pullRequestSwitchesWords,
} from "@threadlines/shared/threadMoveProjection";
import { arrivalMessageText } from "../moves/arrivalMessage.ts";
import { MOVE_MAX_BYTES } from "../moves/moveExport.ts";
import { derivedUuid } from "../orchestration/childRequestIds.ts";
Expand Down Expand Up @@ -1829,7 +1834,7 @@ const make = Effect.gen(function* () {
? device.value.label
: row.manifest.source.environmentLabel;
const scratch = isScratchMoveManifest(row.manifest);
const state = yield* importedState({
const { pullRequestSwitches, ...state } = yield* importedState({
row,
root: land.root,
instanceId: agent.selection.instanceId,
Expand Down Expand Up @@ -1857,6 +1862,7 @@ const make = Effect.gen(function* () {
label: fromLabel,
threadId: row.manifest.source.threadId,
movedAt: now,
...(pullRequestSwitches !== undefined ? { pullRequestSwitches } : {}),
},
messages,
activities,
Expand Down Expand Up @@ -1901,7 +1907,7 @@ const make = Effect.gen(function* () {
Effect.gen(function* () {
const { row, now } = input;
const state = row.manifest.thread.state;
if (state === undefined) return {};
if (state === undefined) return { pullRequestSwitches: undefined };
const key = row.transferKey;
const capabilities = yield* providers
.getCapabilities(input.instanceId)
Expand Down Expand Up @@ -1969,7 +1975,11 @@ const make = Effect.gen(function* () {
}
}

// (c) Pull request switches.
// (c) Pull requests: the links come along, every switch off. A switch
// acts with this computer's GitHub sign-in, so only the user here turns
// one on; the "Moved here" line and the thread's notice offer what was
// on there (movedFrom.pullRequestSwitches).
let pullRequestSwitches: ThreadMovedFrom["pullRequestSwitches"];
let pullRequests:
| {
readonly autoFix: boolean;
Expand All @@ -1996,33 +2006,37 @@ const make = Effect.gen(function* () {
: untracked
? `Auto-fix is off here: this thread's branch couldn't track ${moved?.upstreamBranch ?? "its branch"} on this computer, so it can't tell what isn't pushed yet.`
: null;
const linked = carriedSwitches.linked.map((entry) => ({
number: entry.number,
url: entry.url,
autoFix: off === null && entry.autoFix,
autoMerge: off === null ? entry.autoMerge : null,
}));
pullRequests = {
autoFix: off === null && carriedSwitches.autoFix,
autoMerge: off === null ? carriedSwitches.autoMerge : null,
linked,
autoFix: false,
autoMerge: null,
linked: carriedSwitches.linked.map((entry) => ({
number: entry.number,
url: entry.url,
autoFix: false,
autoMerge: null,
})),
};
if (numbers.length > 0) brought.push(which);
const wasOn = movedPullRequestSwitchesWords(carriedSwitches, input.fromLabel);
if (off !== null) {
left.push(off);
} else {
if (pullRequestSwitchesWords(carriedSwitches) !== null) left.push(off);
} else if (wasOn !== null) {
pullRequestSwitches = {
autoFix: carriedSwitches.autoFix,
autoMerge: carriedSwitches.autoMerge,
linked: carriedSwitches.linked
.filter((entry) => entry.autoFix || entry.autoMerge !== null)
.map((entry) => ({
number: entry.number,
url: entry.url,
autoFix: entry.autoFix,
autoMerge: entry.autoMerge,
})),
};
left.push(wasOn);
const ready = yield* gitHubReadiness(input.root);
const fixing =
carriedSwitches.autoFix || carriedSwitches.linked.some((entry) => entry.autoFix);
const merging =
carriedSwitches.autoMerge !== null ||
carriedSwitches.linked.some((entry) => entry.autoMerge !== null);
const switches =
fixing && merging ? "auto-fix and auto-merge" : fixing ? "auto-fix" : "auto-merge";
brought.push(`${switches} for ${which.replace(/^pull request /u, "")}`);
if (ready.gitHubReady === false) {
left.push(
"Auto-fix came along, but GitHub isn't signed in on this computer. Sign in and it starts.",
);
left.push("GitHub isn't signed in on this computer. Sign in before you turn them on.");
}
}
}
Expand Down Expand Up @@ -2098,6 +2112,7 @@ const make = Effect.gen(function* () {
...(pullRequests !== undefined ? { pullRequests } : {}),
...(queuedFollowUps.length > 0 ? { queuedFollowUps } : {}),
...(proposedPlans.length > 0 ? { proposedPlans } : {}),
...(pullRequestSwitches !== undefined ? { pullRequestSwitches } : {}),
arrival: {
...(text !== null ? { message: { messageId: arrivalMessageId(row), text } } : {}),
brought,
Expand Down
20 changes: 16 additions & 4 deletions apps/server/src/mcp/scheduleToolHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as Effect from "effect/Effect";
import * as Result from "effect/Result";

import { derivedUuid } from "../orchestration/childRequestIds.ts";
import { isLinkFenced, linkFenceRefusal } from "../orchestration/linkFence.ts";
import {
providerModelReasoning,
reasoningLevel,
Expand Down Expand Up @@ -135,8 +136,13 @@ export function makeScheduleToolHandlers(deps: ScheduleToolDeps) {
return { refusal: { outcome: "refused" as const, detail: GONE } };
}
// The fence: its runtime has no Threadlines tools; this guards a stale credential.
if ((thread.remoteOrigin ?? null) !== null) {
return { refusal: { outcome: "not_allowed" as const, detail: REMOTE_ORIGIN_REFUSAL } };
if (isLinkFenced(thread)) {
return {
refusal: {
outcome: "not_allowed" as const,
detail: linkFenceRefusal(thread, "schedule tools"),
},
};
}
return { mode, thread, service };
});
Expand Down Expand Up @@ -372,8 +378,14 @@ export function makeScheduleToolHandlers(deps: ScheduleToolDeps) {
return { outcome: "not_a_run" as const, detail: NO_SCHEDULES };
}
const thread = yield* deps.readThread(scope.threadId);
if (thread === undefined || (thread.remoteOrigin ?? null) !== null) {
return { outcome: "not_allowed" as const, detail: REMOTE_ORIGIN_REFUSAL };
if (thread === undefined || isLinkFenced(thread)) {
return {
outcome: "not_allowed" as const,
detail:
thread === undefined
? REMOTE_ORIGIN_REFUSAL
: linkFenceRefusal(thread, "schedule tools"),
};
}
const latched = yield* latchCallerTurn(deps.readThread, scope);
if ("gone" in latched) return { outcome: "not_a_run" as const, detail: GONE };
Expand Down
31 changes: 31 additions & 0 deletions apps/server/src/mcp/threadToolHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,37 @@ describe("thread tools across linked computers", () => {
expect(tools.dispatched).toEqual([]);
}),
);

it.effect(
"gives a thread that moved here no thread tools until the user here takes it over",
() =>
Effect.gen(function* () {
const movedFrom = {
environmentId: EnvironmentId.make("env-windows"),
label: "Windows PC",
threadId: ThreadId.make("windows-thread"),
movedAt: "2026-01-01T00:00:00.000Z",
};
const fenced = yield* makeTools({
links: fakeLinks(),
caller: makeThread({ movedFrom: { ...movedFrom, fenced: true } }),
});
const read = yield* fenced.handlers.thread_read(mainCaller(), { threadId: CHILD });
const listed = yield* fenced.handlers.thread_list(mainCaller(), { scope: "project" });
expect(read.outcome).toBe("not_allowed");
expect(read.detail).toContain("moved here from Windows PC");
expect(listed.outcome).toBe("not_allowed");
// Once it has: the same thread reads as any other.
const lifted = yield* makeTools({
links: fakeLinks(),
caller: makeThread({ movedFrom }),
others: [makeChild()],
});
expect(
(yield* lifted.handlers.thread_read(mainCaller(), { threadId: CHILD })).outcome,
).toBe("ok");
}),
);
});

describe("thread_move", () => {
Expand Down
18 changes: 14 additions & 4 deletions apps/server/src/mcp/threadToolHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";

import { childRequestCommandId, derivedUuid } from "../orchestration/childRequestIds.ts";
import { isLinkFenced, linkFenceRefusal } from "../orchestration/linkFence.ts";
import {
checkoutMoveRefusal,
childHasLiveWork,
Expand Down Expand Up @@ -479,11 +480,20 @@ export function makeThreadToolHandlers(deps: ThreadToolDeps) {
if (thread === undefined) {
return { refusal: { outcome: "refused" as const, detail: GONE } };
}
// A thread another computer's agent started here never gets these
// A thread another computer's agent started here never gets these, nor
// one that moved here until the user here takes it over
// (docs/design/fleet.md, "Fence"); its runtime has no thread tools, so
// this only guards a stale credential.
if ((thread.remoteOrigin ?? null) !== null) {
return { refusal: { outcome: "not_allowed" as const, detail: REMOTE_ORIGIN_REFUSAL } };
// this guards a stale credential, and a runtime from before the move.
if (isLinkFenced(thread)) {
return {
refusal: {
outcome: "not_allowed" as const,
detail:
(thread.remoteOrigin ?? null) !== null
? REMOTE_ORIGIN_REFUSAL
: linkFenceRefusal(thread, "thread tools"),
},
};
}
return { mode, thread };
});
Expand Down
Loading
Loading