Skip to content
Merged
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
17 changes: 16 additions & 1 deletion apps/server/src/mcp/toolkits/pullRequests/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
}),
Layer.mock(Orchestrator.OrchestratorV2)({
getThreadShell: (id) =>
Effect.succeed(id === THREAD_ID && thread ? v2PullRequestThread(thread) : null),
Effect.succeed(id === thread?.id ? v2PullRequestThread(thread) : null),
dispatch,
}),
Layer.succeed(SecureRandom.SecureRandom, testCrypto),
Expand Down Expand Up @@ -237,6 +237,21 @@ describe("pull request toolkit handlers", () => {
}),
);

it.effect("points a bare thread uuid at the mcp: thread it belongs to", () =>
Effect.gen(function* () {
const bareId = ThreadId.make("5d0b4a3e-8c1f-4a52-9d37-2f6c7e1b9a04");
const harness = yield* makeHarness({
thread: { ...makeThread([]), id: ThreadId.make(`mcp:${bareId}`) },
});
const error = yield* harness
.call("link_pull_request", { threadId: bareId, number: 123 })
.pipe(Effect.flip);
expect(error.message).toBe(`Thread ${bareId} was not found. Did you mean \`mcp:${bareId}\`?`);
expect(error).toMatchObject({ _tag: "OrchestratorMcpFailure", code: "thread_not_found" });
expect(yield* Ref.get(harness.commands)).toEqual([]);
}),
);

it.effect("links by URL with source agent on the token's thread", () =>
Effect.gen(function* () {
const harness = yield* makeHarness();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/mcp/toolkits/pullRequests/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "../../../sourceControl/threadPullRequests.ts";
import * as McpInvocationContext from "../../McpInvocationContext.ts";
import * as McpToolAccess from "../../McpToolAccess.ts";
import { threadNotFound } from "../../threadAccess.ts";
import {
type ListThreadPullRequestsResult,
PullRequestLinkFailedError,
Expand All @@ -40,7 +41,6 @@ import {
type PullRequestTargetInput,
PullRequestWatchFailedError,
PullRequestWatchFromSubagentError,
PullRequestThreadNotFoundError,
PullRequestThreadRequiredError,
PullRequestGuideFailedError,
PullRequestProjectNotFoundError,
Expand Down Expand Up @@ -226,7 +226,7 @@ const make = Effect.gen(function* () {
Effect.mapError((cause) => new Failure({ cause })),
);
if (Option.isNone(thread) || thread.value.deletedAt !== null) {
return yield* new PullRequestThreadNotFoundError({ threadId });
return yield* threadNotFound(engine, threadId, `Thread ${threadId} was not found.`);
}
return thread.value;
});
Expand Down
10 changes: 0 additions & 10 deletions apps/server/src/mcp/toolkits/pullRequests/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ export class PullRequestThreadRequiredError extends Schema.TaggedError<PullReque
}
}

export class PullRequestThreadNotFoundError extends Schema.TaggedError<PullRequestThreadNotFoundError>()(
"PullRequestThreadNotFoundError",
{ threadId: Schema.String },
) {
override get message(): string {
return `Thread ${this.threadId} was not found.`;
}
}

export class PullRequestLinkFailedError extends Schema.TaggedError<PullRequestLinkFailedError>()(
"PullRequestLinkFailedError",
{ cause: Schema.Defect() },
Expand Down Expand Up @@ -193,7 +184,6 @@ export const PullRequestToolError = Schema.Union([
PullRequestHostRequiredError,
PullRequestUrlUnavailableError,
PullRequestThreadRequiredError,
PullRequestThreadNotFoundError,
PullRequestLinkFailedError,
PullRequestUnlinkFailedError,
PullRequestListFailedError,
Expand Down
Loading