@devries-cameron20 / t3code-1 / commits / 443edd553f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-core): subagent threads no longer inherit the parent's pin (#21271)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

Victor Vogel committed Oct 29, 2026 at 12:52 UTC 443edd553fce0f00de480311583579fcc91c529c
2 files changed +61 -2
apps/server/src/orchestration-v2/SubagentProjection.test.ts
+59 -2
@@ -16,6 +16,7 @@ import {
16 } from "@t3tools/contracts";
17 import * as DateTime from "effect/DateTime";
18 import * as Effect from "effect/Effect";
19 +import * as Layer from "effect/Layer";
20
21 import {
22 makeSubagentChildThread,
@@ -26,7 +27,9 @@ import {
27 endRunlessRootTurns,
28 } from "@t3tools/provider-core/server/subagentProjection";
29
29 -import { emptyProjection } from "./ProjectionStore.ts";
30 +import * as SqlitePersistence from "../persistence/Sqlite.ts";
31 +import * as ProjectionStore from "./ProjectionStore.ts";
32 +import { resolveAutoSettlementAt } from "./ThreadSettlementService.ts";
33
34 const parentThreadId = ThreadId.make("thread:subagent-snoozed-parent");
35 const childThreadId = ThreadId.make("thread:subagent-awake-child");
@@ -117,8 +120,62 @@ it("keeps a subagent child awake when its parent thread is snoozed", () => {
120 });
121 });
122
123 +it.effect.each([
124 + ["sql", ProjectionStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemory))],
125 +] as const)(
126 + "%s: a pinned parent's subagent child is born unpinned and settles once idle",
127 + ([, testLayer]) =>
128 + Effect.gen(function* () {
129 + const store = yield* ProjectionStore.ProjectionStoreV2;
130 + const parentThread = { ...makeParentThread(), pinnedAt: parentCreatedAt, pinOrderKey: "a0" };
131 + const childThread = makeSubagentChildThread({
132 + parentThread,
133 + childThreadId,
134 + parentNodeId: NodeId.make("node:subagent-parent"),
135 + activeProviderThreadId: null,
136 + providerInstanceId: childProviderInstanceId,
137 + modelSelection: childModelSelection,
138 + title: "Child",
139 + now: childCreatedAt,
140 + createdBy: "agent",
141 + creationSource: "provider",
142 + });
143 +
144 + assert.equal(parentThread.pinnedAt, parentCreatedAt);
145 + assert.equal(parentThread.pinOrderKey, "a0");
146 + assert.isNull(childThread.pinnedAt);
147 + assert.isNull(childThread.pinOrderKey);
148 +
149 + for (const thread of [parentThread, childThread]) {
150 + yield* store.apply({
151 + id: EventId.make(`event:${thread.id}`),
152 + type: "thread.created",
153 + threadId: thread.id,
154 + occurredAt: thread.createdAt,
155 + payload: thread,
156 + });
157 + }
158 + const savedParent = yield* store.getThread(parentThreadId);
159 + assert.deepEqual(savedParent.pinnedAt, parentCreatedAt);
160 + assert.equal(savedParent.pinOrderKey, "a0");
161 + const candidates = yield* store.getSettlementCandidates();
162 + assert.deepEqual(
163 + candidates.map((candidate) => candidate.id),
164 + [childThreadId],
165 + );
166 + const settledAt = resolveAutoSettlementAt({
167 + thread: candidates[0]!,
168 + pullRequest: null,
169 + nowMs: DateTime.toEpochMillis(DateTime.add(childCreatedAt, { days: 4 })),
170 + autoSettleAfterDays: 3,
171 + autoSettleOnMerge: false,
172 + });
173 + assert.equal(settledAt && DateTime.formatIso(settledAt), DateTime.formatIso(childCreatedAt));
174 + }).pipe(Effect.provide(testLayer)),
175 +);
176 +
177 function taskFixture() {
121 - const projection = emptyProjection({
178 + const projection = ProjectionStore.emptyProjection({
179 type: "thread.created",
180 id: EventId.make("task-fixture"),
181 threadId: parentThreadId,
packages/provider-core/src/server/subagentProjection.ts
+2
@@ -82,6 +82,8 @@ export function makeSubagentChildThread(input: {
82 settledAt: null,
83 snoozedUntil: null,
84 snoozedAt: null,
85 + pinnedAt: null,
86 + pinOrderKey: null,
87 // A guest link belongs to the thread it was made for.
88 guestShare: null,
89 lastVisitedAt: null,