diff --git a/apps/server/src/core/ai-chat/ai-chat-run.service.ts b/apps/server/src/core/ai-chat/ai-chat-run.service.ts index d8ddbd65..5d11b202 100644 --- a/apps/server/src/core/ai-chat/ai-chat-run.service.ts +++ b/apps/server/src/core/ai-chat/ai-chat-run.service.ts @@ -378,8 +378,11 @@ export class AiChatRunService implements OnModuleInit { /** * Request an EXPLICIT stop of a run (the user pressed Stop). This is the ONLY * thing that aborts a run — distinct from a browser disconnect, which leaves - * the run going. Records `stop_requested_at` on the row (only while active) and - * aborts the in-process controller if this replica owns the run. Returns true + * the run going. Aborts the in-process controller FIRST (the only thing that + * actually stops the run, if this replica owns it), then makes a best-effort + * attempt to stamp `stop_requested_at` — that audit write stamps only while the + * row is active and may be skipped on a DB error or lost to the finalize race, + * which is acceptable since the row still settles as 'aborted'. Returns true * when a stop took effect (row marked and/or controller aborted), false when * there was nothing active to stop. */