Skip to content

Commit 953db7a

Browse files
donjor-agent[bot]rsi-pr-agent
authored andcommitted
fix(git): name the thread in checkout move refusals (#1762)
Squashes: - 6b10344 fix(git): name the thread in checkout move refusals (#1762) (#1762) - 88b5270 fixup! fix(git): name the thread in checkout move refusals (#1762) (#1762) Fork-Domain: zmux-estate Fork-Tier: bugfix Fork-Upstreamable: no
1 parent bb196b3 commit 953db7a

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

‎apps/server/src/git/sharedCheckoutGuard.fork.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ describe("sharedCheckoutWsLayerFork", () => {
211211
const log: string[] = [];
212212
const moving = {
213213
...shellThread("root", null, false),
214+
title: "Refusal toast regression",
214215
checkoutMove: { status: "queued" },
215216
} as unknown as OrchestrationV2ThreadShell;
216217
return Effect.gen(function* () {
217218
const threads = yield* ThreadManagement.ThreadManagementService;
218219
const error = yield* threads.dispatch(messageDispatch("root")).pipe(Effect.flip);
219-
expect(String(error.cause)).toContain("has a checkout move in progress");
220+
expect(error.cause).toBe(
221+
'Thread "Refusal toast regression" has a checkout move in progress. Send again when it finishes.',
222+
);
220223
expect(log).toEqual([]);
221224
}).pipe(Effect.provide(makeHarness({ threads: [moving], log })));
222225
});

‎apps/server/src/git/sharedCheckoutGuard.fork.ts‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ const makeTurnStartCheckoutLeaseFork = Effect.gen(function* () {
130130
if (current === null) return yield* dispatch;
131131
// A move waits for the thread to go idle; a new turn would starve it.
132132
if (isCheckoutMoveInFlightFork(current.checkoutMove)) {
133-
return yield* reject(`Thread ${current.id} has a checkout move in progress.`);
133+
return yield* reject(
134+
`Thread "${current.title}" has a checkout move in progress. Send again when it finishes.`,
135+
);
134136
}
135137
const thread = yield* checkoutMoves.recoverRemovedWorktree(current);
136138
const cwd = yield* threadCwd(thread).pipe(Effect.mapError(reject));
@@ -154,17 +156,18 @@ export const sharedCheckoutWsLayerFork = Layer.mergeAll(
154156
const withTurnStartLease = yield* makeTurnStartCheckoutLeaseFork;
155157
return ThreadManagement.ThreadManagementService.of({
156158
...inner,
157-
dispatch: (command) =>
159+
// The wrapped service owns the dispatch span.
160+
dispatch: Effect.fnUntraced(function* (command) {
158161
// Move state is server-resolved; a client may only request a move.
159-
command.type === "thread.metadata.update" && command.checkoutMove !== undefined
160-
? Effect.fail(
161-
new Orchestrator.OrchestratorCommandRejectedError({
162-
commandId: command.commandId,
163-
commandType: command.type,
164-
cause: "Checkout moves are requested through thread.checkoutMove.request.",
165-
}),
166-
)
167-
: withTurnStartLease(inner, command, inner.dispatch(command)),
162+
if (command.type === "thread.metadata.update" && command.checkoutMove !== undefined) {
163+
return yield* new Orchestrator.OrchestratorCommandRejectedError({
164+
commandId: command.commandId,
165+
commandType: command.type,
166+
cause: "Checkout moves are requested through thread.checkoutMove.request.",
167+
});
168+
}
169+
return yield* withTurnStartLease(inner, command, inner.dispatch(command));
170+
}),
168171
});
169172
}),
170173
),
@@ -175,11 +178,15 @@ export const sharedCheckoutWsLayerFork = Layer.mergeAll(
175178
const withBranchGuard = yield* makeSharedCheckoutBranchGuardFork;
176179
return GitWorkflow.GitWorkflowService.of({
177180
...inner,
178-
createRef: (input) =>
179-
input.switchRef === true
181+
// The wrapped service owns the ref spans.
182+
createRef: Effect.fnUntraced(function* (input) {
183+
return yield* input.switchRef === true
180184
? withBranchGuard(input.cwd, inner.createRef(input))
181-
: inner.createRef(input),
182-
switchRef: (input) => withBranchGuard(input.cwd, inner.switchRef(input)),
185+
: inner.createRef(input);
186+
}),
187+
switchRef: Effect.fnUntraced(function* (input) {
188+
return yield* withBranchGuard(input.cwd, inner.switchRef(input));
189+
}),
183190
});
184191
}),
185192
),

0 commit comments

Comments
 (0)