Skip to content

Commit 0163ac7

Browse files
committed
fix: close acknowledgement lifecycle race gaps
1 parent 1d9e301 commit 0163ac7

6 files changed

Lines changed: 110 additions & 9 deletions

File tree

‎apps/web/src/app/(sandbox)/task/[taskId]/sidebar-actions/OverflowMenu.client.test.tsx‎

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/web/src/app/(sandbox)/task/[taskId]/sidebar-actions/OverflowMenu.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ function OverflowMenuBase({
141141

142142
const handleMarkDone = async () => {
143143
try {
144-
await acknowledgeResolution.mutateAsync({ taskId });
145-
toast.success('Task marked done.');
144+
const { changed } = await acknowledgeResolution.mutateAsync({ taskId });
145+
if (changed) {
146+
toast.success('Task marked done.');
147+
} else {
148+
toast.error('Task status changed before it could be marked done.');
149+
}
146150
} catch (error) {
147151
toast.error(
148152
error instanceof Error ? error.message : 'Failed to mark task done.',

‎apps/web/src/components/tasks/TaskBoard.client.test.tsx‎

Lines changed: 36 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/web/src/components/tasks/TaskBoard.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ function MarkDoneButton({ taskId }: { taskId: string }) {
6767

6868
const handleMarkDone = async () => {
6969
try {
70-
await acknowledgeResolution.mutateAsync({ taskId });
71-
toast.success('Task marked done.');
70+
const { changed } = await acknowledgeResolution.mutateAsync({ taskId });
71+
if (changed) {
72+
toast.success('Task marked done.');
73+
} else {
74+
toast.error('Task status changed before it could be marked done.');
75+
}
7276
} catch (error) {
7377
toast.error(
7478
error instanceof Error ? error.message : 'Failed to mark task done.',

‎apps/web/src/trpc/commands/sandbox-session/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import {
2727
and,
2828
compareAndSetTrustedRunActingUser,
29+
clearTaskResolution,
2930
db,
3031
environments,
3132
eq,
@@ -306,6 +307,8 @@ export async function sendSandboxPromptCommand(
306307
let discordReplyQuoteId: string | null = null;
307308

308309
try {
310+
await clearTaskResolution(parsed.taskId);
311+
309312
// The actor switch must land before the prompt reaches the sandbox so the
310313
// worker's sender-vs-acting-user guard passes (critical for runs that
311314
// start without an acting user, e.g. automation-started tasks).

‎apps/web/src/trpc/commands/sandbox-session/send-prompt.test.ts‎

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)