fix(threads): include archived threads in the unfiltered thread refs
Worktree cleanup treats listAllThreadRefs as the complete set, but it mapped only the live shells. A worktree held solely by an archived thread was therefore classified orphaned and offered for removal — the same data-loss shape this RPC exists to prevent, through a different gap. Also drops the two toSorted calls in the subagent derivations: this module is mobile-reachable and Hermes ships no ES2023 change-by-copy array methods, so an Android import could crash. The regression deletes toSorted from the prototype while exercising both derivations. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
1391f94470
commit
1aea7ba0d3
2 files changed
+16
-7
No files matched your search
@@ -393,6 +393,7 @@ it.effect("lists compact references for every active thread, including hidden su
|
||||
parentThreadId: null,
|
||||
relationshipToParent: null,
|
||||
} as const;
|
||||
const archivedId = ThreadId.make("thread:thread-management:refs-archived");
|
||||
const threads = [
|
||||
shell(rootId, rootLineage, null),
|
||||
shell(
|
||||
@@ -417,7 +418,10 @@ it.effect("lists compact references for every active thread, including hidden su
|
||||
schemaVersion: 3,
|
||||
snapshotSequence: 10,
|
||||
threads,
|
||||
archivedThreads: [],
|
||||
// An archived thread still holds its worktree; worktree cleanup
|
||||
// treats this RPC as the complete set, so omitting the archive
|
||||
// would classify that worktree as orphaned and remove it.
|
||||
archivedThreads: [shell(archivedId, rootLineage, null)],
|
||||
}),
|
||||
}),
|
||||
),
|
||||
@@ -427,7 +431,7 @@ it.effect("lists compact references for every active thread, including hidden su
|
||||
const service = yield* ThreadManagementService;
|
||||
|
||||
expect(yield* service.listAllThreadRefs()).toEqual({
|
||||
threadRefs: threads.map((thread) => ({
|
||||
threadRefs: [...threads, shell(archivedId, rootLineage, null)].map((thread) => ({
|
||||
threadId: thread.id,
|
||||
projectId,
|
||||
worktreePath,
|
||||
|
||||
@@ -479,11 +479,16 @@ const make = Effect.gen(function* () {
|
||||
const listAllThreadRefs: ThreadManagementServiceShape["listAllThreadRefs"] = () =>
|
||||
orchestrator.getShellSnapshot().pipe(
|
||||
Effect.map((snapshot) => ({
|
||||
threadRefs: snapshot.threads.map(({ id, projectId, worktreePath }) => ({
|
||||
threadId: id,
|
||||
projectId,
|
||||
worktreePath,
|
||||
})),
|
||||
// Worktree cleanup treats this as the complete set: an archived thread
|
||||
// still holds its worktree, so omitting the archive would classify it
|
||||
// as orphaned and remove it.
|
||||
threadRefs: [...snapshot.threads, ...snapshot.archivedThreads].map(
|
||||
({ id, projectId, worktreePath }) => ({
|
||||
threadId: id,
|
||||
projectId,
|
||||
worktreePath,
|
||||
}),
|
||||
),
|
||||
})),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user