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 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.`,
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 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. 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 moves only with that thread for now. 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
42 changes: 39 additions & 3 deletions apps/server/src/links/LinkMoveRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ import * as SqlSchema from "effect/sql/SqlSchema";
* Where a move stands here, as recorded. `awaiting_approval` with
* `stagedApproval` takes its bytes while it waits; the asking computer reads
* it as `receiving`, then `staged_awaiting_approval` once every byte is here.
* `waiting_for_family`: a family member's import waits, every byte staged,
* for another member (its parent to commit, or the folder it shares to be
* made; docs/design/fleet.md, Part 3f, review change 2); it holds no slot in
* flight, and the asking computer reads it as `importing`.
*/
export const LinkMoveStatus = Schema.Literals([
"awaiting_approval",
"receiving",
"importing",
"waiting_for_family",
"committed",
"aborted",
]);
Expand Down Expand Up @@ -78,6 +83,13 @@ export const LinkMoveRow = Schema.Struct({
abortCode: Schema.NullOr(PeerMoveAbortCode),
/** An aborted move's clean-up is done. Null on an aborted row: still owed. */
cleanedAt: Schema.NullOr(IsoDateTime),
/**
* A family member's (docs/design/fleet.md, Part 3f, (g)): the family's key
* here, from the link and the family's id. Null: it moves on its own.
*/
familyKey: Schema.NullOr(Schema.String),
/** The thread's id on the computer it left, so another member's import can find this one. */
sourceThreadId: Schema.NullOr(Schema.String),
createdAt: IsoDateTime,
updatedAt: IsoDateTime,
});
Expand Down Expand Up @@ -105,9 +117,15 @@ export interface LinkMoveRepositoryShape {
readonly stagedApproval: boolean;
readonly manifest: PeerMoveManifest;
readonly threadId: ThreadId;
readonly familyKey?: string | undefined;
readonly reason?: string;
readonly now: string;
}) => Effect.Effect<LinkMoveRow, LinkMoveRepositoryError>;
/** A family's member, by its thread's id there: the newest such move. */
readonly findFamilyMember: (
familyKey: string,
sourceThreadId: string,
) => Effect.Effect<Option.Option<LinkMoveRow>, LinkMoveRepositoryError>;
readonly get: (
linkDeviceId: string,
transferId: string,
Expand Down Expand Up @@ -186,6 +204,8 @@ const make = Effect.gen(function* () {
reason AS "reason",
abort_code AS "abortCode",
cleaned_at AS "cleanedAt",
family_id AS "familyKey",
source_thread_id AS "sourceThreadId",
created_at AS "createdAt",
updated_at AS "updatedAt"
FROM link_moves
Expand All @@ -211,17 +231,33 @@ const make = Effect.gen(function* () {
const get: LinkMoveRepositoryShape["get"] = (linkDeviceId, transferId) =>
findOne({ linkDeviceId, transferId }).pipe(wrap("get"));

const findMember = SqlSchema.findOneOption({
Request: Schema.Struct({ familyKey: Schema.String, sourceThreadId: Schema.String }),
Result: LinkMoveDbRow,
execute: ({ familyKey, sourceThreadId }) =>
sql.unsafe(
`${select} WHERE family_id = ? AND source_thread_id = ? ORDER BY created_at DESC, transfer_id DESC LIMIT 1`,
[familyKey, sourceThreadId],
),
});

const findFamilyMember: LinkMoveRepositoryShape["findFamilyMember"] = (
familyKey,
sourceThreadId,
) => findMember({ familyKey, sourceThreadId }).pipe(wrap("findFamilyMember"));

const insert: LinkMoveRepositoryShape["insert"] = (input) =>
Effect.gen(function* () {
const manifest = yield* encodeManifest(input.manifest);
yield* sql`
INSERT INTO link_moves (
link_device_id, transfer_id, transfer_key, status, staged_approval, manifest_json,
bytes_received, thread_id, reason, created_at, updated_at
bytes_received, thread_id, reason, family_id, source_thread_id, created_at, updated_at
) VALUES (
${input.linkDeviceId}, ${input.transferId}, ${input.transferKey}, ${input.status},
${input.stagedApproval ? 1 : 0}, ${manifest}, 0, ${input.threadId},
${input.reason ?? null}, ${input.now}, ${input.now}
${input.reason ?? null}, ${input.familyKey ?? null}, ${input.manifest.source.threadId},
${input.now}, ${input.now}
)
ON CONFLICT(link_device_id, transfer_id) DO NOTHING
`;
Expand Down Expand Up @@ -307,7 +343,7 @@ const make = Effect.gen(function* () {
markArrived,
listUnarrived,
insert,

findFamilyMember,
get,
listOpen,
listCleanupOwed,
Expand Down
Loading
Loading