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
36 changes: 36 additions & 0 deletions apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3087,6 +3087,42 @@ it.live(
);
assert.isFalse(yield* fileSystem.exists(ran));

// A first message sent into an empty thread the link started names no link; the
// thread's own link still decides.
const emptyThreadId = ThreadId.make("thread:limited-empty");
yield* threads.dispatch({
type: "thread.create",
commandId: CommandId.make("launch:limited-empty:create"),
threadId: emptyThreadId,
projectId,
title: "Linked",
modelSelection,
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: null,
createdBy: "agent",
creationSource: "mcp",
linkOrigin: {
sessionId: "mcp-session:linked",
label: "Linked laptop",
access: "auto-accept-edits",
},
});
yield* launches.launch({
...launchInput({
command: "launch:limited-empty",
thread: emptyThreadId,
message: "Start",
workspace: { type: "worktree", baseRef: "main", branch: "feature/limited-empty" },
}),
reuseExistingThread: true,
});
const reused = yield* preparationSettled(emptyThreadId);
assert.equal(reused.runs[0]?.status, "failed");
assert.isNull(reused.thread.worktreePath);
assert.isFalse(yield* fileSystem.exists(ran));

const full = yield* launch("full", "full-access");
assert.equal(full.runs[0]?.status, "starting");
assert.equal(yield* fileSystem.readFileString(ran), "create\n");
Expand Down
11 changes: 10 additions & 1 deletion apps/server/src/orchestration-v2/ThreadLaunchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,17 @@ const make = Effect.gen(function* () {
branch: workspaceStrategy.branch,
}
: workspaceStrategy;
// The thread's link decides, as it does when preparation is retried: a request
// that reuses a thread names none.
const { linkOrigin: _requestLinkOrigin, ...preparation } = input;
yield* schedulePreparation(
{ ...input, workspaceStrategy: preparationStrategy },
{
...preparation,
workspaceStrategy: preparationStrategy,
...(committedThread.linkOrigin === undefined
? {}
: { linkOrigin: committedThread.linkOrigin }),
},
threadId,
runId,
);
Expand Down
5 changes: 3 additions & 2 deletions docs/internals/05_remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ side lists and revokes it in Sharing & access like any other session, and owns i
shared access rules ([`mcp/linkOrigin.ts`](../../apps/server/src/mcp/linkOrigin.ts)). Below full
access, linked work can mutate only threads with the same origin, cannot touch projects, settings,
scheduled tasks, or further links, and skips project setup scripts and worktree layout commands
(a project that declares a layout gives such a thread no worktree). Full-access links are not
fenced because their agents already run as the receiving OS user.
(in a project that declares a layout, a worktree launch or handoff for such a thread fails;
restoring a missing folder brings back plain checkouts). Full-access links are not fenced because
their agents already run as the receiving OS user.
- **Namespace idempotency keys.** All callers on the linking side share one session on the receiving
side, so idempotency keys must be hashed with the caller's namespace before forwarding.
- **Clients read linked threads as standard thread streams.**
Expand Down
Loading