The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 11:30 UTC
fix(server): settle inactive threads with open PRs (#9610)
Guillermo Casanova committed
Sep 4, 2026 at 12:44 UTC
d536b0580d044967dc644498d8c5a6e96464f767
4 files changed
+23
-10
apps/server/src/orchestration/ThreadSettlementPolicy.test.ts
+2
-2
@@ -95,8 +95,8 @@ describe("resolveAutoSettlementAt", () => {
95
expect(decide(makeThread({ latestUserMessageAt: "2026-08-25T12:00:00.000Z" }))).toBe(false);
96
});
97
98
- it("keeps open pull requests active", () => {
99
- expect(decide(makeThread(), { state: "open", updatedAt: NOW })).toBe(false);
98
+ it("settles inactive threads with open pull requests", () => {
99
+ expect(decide(makeThread(), { state: "open", updatedAt: NOW })).toBe(true);
100
});
101
102
it("settles closed requests and honors the merge setting", () => {
apps/server/src/orchestration/ThreadSettlementPolicy.ts
-1
@@ -81,7 +81,6 @@ export function resolveAutoSettlementAt(input: {
81
if (pullRequestSettles(thread, pullRequest, input.autoSettleOnMerge)) {
82
return activityAt ?? thread.createdAt;
83
}
84
- if (pullRequest.state === "open") return null;
84
}
85
if (input.autoSettleAfterDays === null || activityAt === null) return null;
86
return Date.parse(activityAt) < Date.parse(input.now) - input.autoSettleAfterDays * DAY_MS
apps/server/src/orchestration/ThreadSettlementReactor.test.ts
+17
-3
@@ -408,6 +408,7 @@ describe("ThreadSettlementReactor", () => {
408
const fixture = yield* makeHarness({
409
snapshot: makeSnapshot([
410
makeThread("merged-in-app", {
411
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
412
linkedPullRequest: {
413
projectId: PROJECT_ID,
414
repository: "owner/repository",
@@ -415,7 +416,10 @@ describe("ThreadSettlementReactor", () => {
416
url: "https://example.test/owner/repository/pull/42",
417
},
418
}),
418
- makeThread("slow-periodic-lookup", { branch: "another-feature" }),
419
+ makeThread("slow-periodic-lookup", {
420
+ branch: "another-feature",
421
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
422
+ }),
423
]),
424
branchPullRequest: () =>
425
Ref.updateAndGet(branchLookupCount, (count) => count + 1).pipe(
@@ -460,7 +464,12 @@ describe("ThreadSettlementReactor", () => {
464
const state = yield* Ref.make<"open" | "merged">("open");
465
const mergedThreadSettled = yield* Deferred.make<void>();
466
const fixture = yield* makeHarness({
463
- snapshot: makeSnapshot([makeThread("branch-thread", { branch: "saved-feature" })]),
467
+ snapshot: makeSnapshot([
468
+ makeThread("branch-thread", {
469
+ branch: "saved-feature",
470
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
471
+ }),
472
+ ]),
473
branchPullRequest: () =>
474
Ref.get(state).pipe(
475
Effect.map((pullRequestState) => ({ state: pullRequestState, updatedAt: NOW })),
@@ -500,6 +509,7 @@ describe("ThreadSettlementReactor", () => {
509
const fixture = yield* makeHarness({
510
snapshot: makeSnapshot([
511
makeThread("merged-in-app", {
512
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
513
linkedPullRequest: {
514
projectId: PROJECT_ID,
515
repository: "owner/repository",
@@ -508,6 +518,7 @@ describe("ThreadSettlementReactor", () => {
518
},
519
}),
520
makeThread("unrelated-linked", {
521
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
522
linkedPullRequest: {
523
projectId: PROJECT_ID,
524
repository: "owner/repository",
@@ -683,7 +694,10 @@ describe("ThreadSettlementReactor", () => {
694
const fixture = yield* makeHarness({
695
snapshot: makeSnapshot(
696
[
686
- makeThread("missing-own-project", { linkedPullRequest }),
697
+ makeThread("missing-own-project", {
698
+ latestUserMessageAt: "2026-08-27T00:00:00.000Z",
699
+ linkedPullRequest,
700
+ }),
701
makeThread("missing-branch-project", { branch: "saved-feature" }),
702
],
703
[makeProject(LINKED_PROJECT_ID, "/workspace/linked")],
docs/user/thread-sidebar.md
+4
-4
@@ -13,10 +13,10 @@ request merges if **Auto-settle merged threads** is enabled.
13
Each server stores its own copy of the automatic settlement settings and checks them even when no
14
web, desktop, or mobile client is connected. By default, it settles threads after three days without
15
activity and when their pull request merges. An eligible idle thread also settles when its pull
16
-request closes. An open pull request blocks inactivity settlement. Active work, pending input, and
17
-live background work keep the thread active. T3 Code settles from a closed or merged pull request
18
-only when its timestamp is not older than the user's latest activity. If that timestamp is not
19
-available, the inactivity rule still applies. A manual un-settle also keeps the thread active.
16
+request closes. An open pull request does not block inactivity settlement. Active work, pending
17
+input, and live background work keep the thread active. T3 Code settles from a closed or merged
18
+pull request only when its timestamp is not older than the user's latest activity. If that timestamp
19
+is not available, the inactivity rule still applies. A manual un-settle also keeps the thread active.
20
21
**Settled** lists threads by when their work finished, newest first. A thread you settle yourself
22
sorts by the moment you settled it. A thread that settled on its own sorts by its last message or