diff --git a/server/src/nest/assistant/assistant-undo.helpers.ts b/server/src/nest/assistant/assistant-undo.helpers.ts index 266d3b8f6..ecaf06ce3 100644 --- a/server/src/nest/assistant/assistant-undo.helpers.ts +++ b/server/src/nest/assistant/assistant-undo.helpers.ts @@ -72,6 +72,9 @@ const CHECKS: Readonly>> = { ), }; +/** The call a check reads when its caller has none: no arguments, no held card. */ +const NO_CALL: UndoCall = { args: {}, preview: null }; + /** * True when the change `toolName` made (its stored `result`) is still as it * left it. `call` is what the answer may not name (the day a vacation toggle @@ -81,7 +84,7 @@ export function unchangedSinceApplied( toolName: string, result: unknown, snapshot: TripSnapshot, - call: UndoCall = { args: {}, preview: null }, + call: UndoCall = NO_CALL, ): boolean { const check = CHECKS[toolName]; return !!check && check(recordOf(result), { ...snapshot, reads: snapshot.reads ?? new Map() }, call); diff --git a/server/src/nest/assistant/tool-call-preview.helpers.ts b/server/src/nest/assistant/tool-call-preview.helpers.ts index f37c01648..b134ea08f 100644 --- a/server/src/nest/assistant/tool-call-preview.helpers.ts +++ b/server/src/nest/assistant/tool-call-preview.helpers.ts @@ -379,6 +379,9 @@ function bookedDay(result: unknown): number | null { return reservation && typeof reservation === 'object' ? id(reservation as Args, 'day_id') : null; } +/** Where a change came from when its caller does not say: no held card, no trip. */ +const NOT_FROM: AppliedFrom = { preview: null, tripId: null }; + /** * The receipt of an applied change: what it touched (the created row from its * answer, the changed one from its arguments), the day "Show on map" goes to @@ -393,7 +396,7 @@ export function appliedChange( result: unknown, dayId: number | null, undoUntil: string | null, - from: AppliedFrom = { preview: null, tripId: null }, + from: AppliedFrom = NOT_FROM, ): AssistantApplied | null { // A tool without a card of its own touched something the client has no view for. const runs = writeToolOf(toolName, args);