@devries-cameron20 / t3code Mirror · read-only / commits / 675d2bd3b2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 22:15 UTC

fix(server): closed PR watches end even when the activity read fails (#27953)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 11, 2026 at 12:00 UTC 675d2bd3b23f315cbfa03d687df788b68b11a157
2 files changed +76 -4
apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
+7 -4
@@ -308,7 +308,7 @@ export const make = Effect.gen(function* () {
308
309 const giveUp = (target: WatchTarget) =>
310 record(target, null, {
311 - text: `T3 Code stopped watching pull request #${target.link.number} (${target.link.url}) because it failed to read it from the host ${READ_FAILURE_LIMIT} times in a row. Check it yourself, and call watch_pull_request to watch it again.`,
311 + text: `T3 Code stopped watching pull request #${target.link.number} (${target.link.url}) because it failed to read it from the host ${READ_FAILURE_LIMIT} times in a row. Check it yourself, and call watch_pull_request only if it is still open.`,
312 notification: {
313 source: { kind: "monitor" },
314 outcome: "failed",
@@ -501,11 +501,14 @@ export const make = Effect.gen(function* () {
501 { concurrency: 2 },
502 );
503 // Activity failures must not cancel or hide a permanent detail failure.
504 + // Activity is irrelevant once the pull request is closed or merged, so it cannot block ending.
505 const read = Exit.isFailure(detailRead)
506 ? Exit.failCause(detailRead.cause)
506 - : Exit.isFailure(activityRead)
507 - ? Exit.failCause(activityRead.cause)
508 - : Exit.succeed([detailRead.value, activityRead.value] as const);
507 + : detailRead.value.state !== "open"
508 + ? Exit.succeed([detailRead.value, Option.none<PullRequestActivity>()] as const)
509 + : Exit.isFailure(activityRead)
510 + ? Exit.failCause(activityRead.cause)
511 + : Exit.succeed([detailRead.value, activityRead.value] as const);
512 if (Exit.isFailure(read)) {
513 if (Cause.hasInterruptsOnly(read.cause)) return yield* Effect.failCause(read.cause);
514 lastReads.delete(group.key);
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+69
@@ -3663,6 +3663,75 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3663 }),
3664 );
3665
3666 + it.effect("ends a watch on a closed pull request whose activity cannot be read", () =>
3667 + Effect.gen(function* () {
3668 + const orchestrator = yield* Orchestrator.OrchestratorV2;
3669 + const threadId = ThreadId.make("runtime-pull-request-watch-closed-unreadable");
3670 + const projectId = ProjectId.make("pr-watch-closed-unreadable-project");
3671 + yield* seedProject({
3672 + projectId,
3673 + title: "Watch closed unreadable",
3674 + workspaceRoot: "/workspace/watch-closed-unreadable",
3675 + defaultModelSelection: null,
3676 + createdAt: "2026-10-01T00:00:00.000Z",
3677 + });
3678 + yield* orchestrator.dispatch({
3679 + type: "thread.create",
3680 + createdBy: "user",
3681 + creationSource: "web",
3682 + commandId: CommandId.make("pr-watch-closed-unreadable-create"),
3683 + threadId,
3684 + projectId,
3685 + title: "Watch closed unreadable",
3686 + modelSelection,
3687 + runtimeMode: "full-access",
3688 + interactionMode: "default",
3689 + branch: null,
3690 + worktreePath: null,
3691 + });
3692 + yield* orchestrator.dispatch({
3693 + type: "thread.pull-request.watch",
3694 + commandId: CommandId.make("pr-watch-closed-unreadable-start"),
3695 + threadId,
3696 + host: "github.com",
3697 + repository: "pingdotgg/t3code",
3698 + number: 8,
3699 + watching: true,
3700 + link: { url: "https://github.com/pingdotgg/t3code/pull/8", source: "agent" },
3701 + });
3702 + const reactor = yield* PullRequestWatchReactor.make.pipe(
3703 + Effect.provide(
3704 + Layer.mergeAll(
3705 + NodeServices.layer,
3706 + NodeCrypto.layer,
3707 + Layer.mock(PullRequestService.PullRequestService)({
3708 + watchFingerprint: () => Effect.succeed(null),
3709 + detail: () =>
3710 + Effect.succeed({
3711 + ...watchedPullRequestDetail({
3712 + projectId,
3713 + number: 8,
3714 + at: "2026-10-02T12:00:00.000Z",
3715 + }),
3716 + state: "closed" as const,
3717 + }),
3718 + activity: () => Effect.die("host unreachable"),
3719 + }),
3720 + ),
3721 + ),
3722 + );
3723 + yield* reactor.sweep;
3724 +
3725 + const thread = yield* orchestrator.getThreadShell(threadId);
3726 + assert.isUndefined(thread?.pullRequests?.[0]?.watch);
3727 + const { messages } = yield* orchestrator.getThreadRecords(threadId, ["messages"]);
3728 + assert.deepEqual(
3729 + messages.flatMap((message) => message.notification?.summary ?? []),
3730 + ["#8: closed, stopped watching"],
3731 + );
3732 + }),
3733 + );
3734 +
3735 it.effect("wakes once for a state it reported, across a restart and a new watch", () =>
3736 Effect.gen(function* () {
3737 const orchestrator = yield* Orchestrator.OrchestratorV2;