Skip to content

Commit 1f55acf

Browse files
fix(client-runtime): refresh settled counts when threads move project (#36543)
Co-authored-by: Julius Marminge <[email protected]>
1 parent a3477a5 commit 1f55acf

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/client-runtime/src/state/olderSettledThreads.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ describe("olderSettledCountKey", () => {
9393
expect(key([...base, row("woken", { createdDay: 5 })])).not.toBe(start);
9494
// A local row that turns older (a backdated auto-settle).
9595
expect(key([base[0]!, row("open", { createdDay: 60, settledDay: 20 })])).not.toBe(start);
96+
// An older row that moves to another project.
97+
expect(key([{ ...base[0]!, projectId: ProjectId.make("project-b") }, base[1]!])).not.toBe(
98+
start,
99+
);
96100
});
97101

98102
it("stays put for new threads and subagents", () => {

‎packages/client-runtime/src/state/olderSettledThreads.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ export function sortOlderSettledScopes(
8080

8181
/**
8282
* Changes whenever the older count can: any removal (by largest sequence, so a repeat counts), an
83-
* older row that arrives or changes, or an old row arriving outside the set (unsettled). Threads
84-
* created after the cut never enter it, as threads settle after creation. Archived-thread events
85-
* arrive as removals too, each costing one count read.
83+
* older row that arrives, changes or moves project, or an old row arriving outside the set
84+
* (unsettled). Threads created after the cut never enter it, as threads settle after creation.
85+
* Archived-thread events arrive as removals too, each costing one count read.
8686
*/
8787
export function olderSettledCountKey(
8888
threads: ReadonlyArray<OrchestrationV2ThreadShell>,
@@ -96,7 +96,7 @@ export function olderSettledCountKey(
9696
if (!isListedThreadLineage(thread.lineage)) continue;
9797
const older = isOlderSettledThreadShell(thread, beforeMs);
9898
if (older || DateTime.toEpochMillis(thread.createdAt) < beforeMs) {
99-
rows.push(`${thread.id}:${older ? 1 : 0}`);
99+
rows.push(`${thread.id}:${thread.projectId}:${older ? 1 : 0}`);
100100
}
101101
}
102102
return `${lastRemoval}|${rows.sort().join(",")}`;

0 commit comments

Comments
 (0)