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
33 changes: 33 additions & 0 deletions src/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,39 @@ describe("Discord controller flows", () => {
);
});

it("rejects resume when the thread worktree path no longer exists on disk", async () => {
const { controller, clientMock } = await createControllerHarness();
const missingWorktreePath = "/tmp/worktrees/bold-bartik/repo-name";
clientMock.listThreads.mockResolvedValue([
{
threadId: "thread-stale",
title: "Stale Worktree Thread",
projectKey: missingWorktreePath,
createdAt: Date.now() - 60_000,
updatedAt: Date.now() - 30_000,
},
]);
clientMock.readThreadState.mockResolvedValue({
threadId: "thread-stale",
threadName: "Stale Worktree Thread",
model: "openai/gpt-5.4",
cwd: missingWorktreePath,
serviceTier: "default",
});

const reply = await controller.handleCommand(
"cas_resume",
buildTelegramCommandContext({
args: "thread-stale",
commandBody: "/cas_resume thread-stale",
}),
);

expect(reply.text).toContain("Cannot resume");
expect(reply.text).toContain(missingWorktreePath);
expect(reply.text).toContain("no longer exists on disk");
});

it("sends Discord model pickers directly instead of returning Telegram buttons", async () => {
const { controller, sendComponentMessage } = await createControllerHarness();
await (controller as any).store.upsertBinding({
Expand Down
8 changes: 7 additions & 1 deletion src/controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execFile } from "node:child_process";
import { promises as fs } from "node:fs";
import { existsSync, promises as fs } from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -3228,6 +3228,12 @@ export class CodexPluginController {
message: "This action can only bind from a live command or interactive context.",
};
}
if (params.workspaceDir && this.isWorktreePath(params.workspaceDir) && !existsSync(params.workspaceDir)) {
return {
status: "error",
message: `Cannot resume: workspace path no longer exists on disk.\n\`${params.workspaceDir}\`\n\nThe worktree may have been removed. Check your local paths or start a new session.`,
};
}
const approval = await requestBinding({
summary: `Bind this conversation to Codex thread ${params.threadTitle?.trim() || params.threadId}.`,
});
Expand Down