Skip to content
Open
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/test/threads/workspace-path-claims.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { archiveThread } from "@bb/db";
import { describe, expect, it } from "vitest";
import { unmanagedAttachRefusal } from "../../src/services/threads/workspace-path-claims.js";
import {
Expand Down Expand Up @@ -141,4 +142,39 @@ describe("unmanagedAttachRefusal", () => {
).toMatchObject({ reason: "live-thread" });
});
});

it("allows branch checkout after every thread at the path is archived", async () => {
await withTestHarness(async (harness) => {
const { host } = seedHostSession(harness.deps, {
id: "host-claims-archived",
});
const sharedPath = "/tmp/archived-shared";
const { project } = seedProjectWithSource(harness.deps, {
hostId: host.id,
name: "Archived",
path: sharedPath,
});
const environment = seedEnvironment(harness.deps, {
hostId: host.id,
projectId: project.id,
path: sharedPath,
});
const thread = seedThread(harness.deps, {
projectId: project.id,
environmentId: environment.id,
status: "idle",
});
archiveThread(harness.deps.db, harness.deps.hub, thread.id);

expect(
unmanagedAttachRefusal(harness.deps.db, {
checksOutBranch: true,
dataDir: HOST_DATA_DIR,
hostId: host.id,
path: sharedPath,
projectId: project.id,
}),
).toBeNull();
});
});
});
2 changes: 1 addition & 1 deletion packages/db/src/data/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ export function hasLiveThreadAtHostPath(
and(
eq(environments.hostId, args.hostId),
eq(environments.path, args.path),
nonDeletedThreads(
liveThreads(
inArray(threads.status, [...NON_TERMINAL_THREAD_STATUSES]),
),
),
Expand Down
Loading