mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
fix(server): align MCP assignment/day WS payloads with the REST shapes
move_assignment omitted newDayId (moved assignments vanished from
collaborator views), reorder_day_assignments sent assignmentIds where
the client reads orderedIds (reorders emptied the day remotely), and
delete_day sent { id } where the client reads dayId (days never
disappeared). Registry drift findings from the WS contract work.
This commit is contained in:
@@ -137,7 +137,10 @@ export class AssignmentsMcp {
|
||||
if (!this.assignments.getAssignmentForTrip(assignmentId, tripId)) return errorResult('Assignment not found.');
|
||||
if (!this.days.getDay(newDayId, tripId)) return errorResult('Day not found.');
|
||||
const result = this.assignments.moveAssignment(assignmentId, newDayId, orderIndex ?? 0);
|
||||
safeBroadcast(tripId, 'assignment:moved', { assignment: result.assignment, oldDayId: result.oldDayId });
|
||||
// REST parity shape ({ assignment, oldDayId, newDayId }) — the client keys its
|
||||
// per-day assignment map on newDayId, so omitting it filed the moved assignment
|
||||
// under "undefined" on collaborator screens.
|
||||
safeBroadcast(tripId, 'assignment:moved', { assignment: result.assignment, oldDayId: result.oldDayId, newDayId });
|
||||
this.assignments.reconcile(tripId);
|
||||
return ok({ assignment: result.assignment });
|
||||
}
|
||||
@@ -206,7 +209,9 @@ export class AssignmentsMcp {
|
||||
if (!hasTripPermission('day_edit', tripId, ctx.userId)) return permissionDenied();
|
||||
if (!this.days.getDay(dayId, tripId)) return errorResult('Day not found.');
|
||||
this.assignments.reorderAssignments(dayId, assignmentIds);
|
||||
safeBroadcast(tripId, 'assignment:reordered', { dayId, assignmentIds });
|
||||
// REST parity shape ({ dayId, orderedIds }) — the client only reads orderedIds,
|
||||
// so broadcasting the tool-input key name emptied the day for collaborators.
|
||||
safeBroadcast(tripId, 'assignment:reordered', { dayId, orderedIds: assignmentIds });
|
||||
return ok({ success: true, dayId, order: assignmentIds });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,9 @@ export class DaysMcp {
|
||||
if (!hasTripPermission('day_edit', tripId, ctx.userId)) return permissionDenied();
|
||||
if (!this.days.getDay(dayId, tripId)) return { content: [{ type: 'text' as const, text: 'Day not found.' }], isError: true };
|
||||
this.days.remove(dayId);
|
||||
safeBroadcast(tripId, 'day:deleted', { id: dayId });
|
||||
// REST parity shape ({ dayId }) — the client reads payload.dayId, so the { id }
|
||||
// variant never removed the day from collaborator screens.
|
||||
safeBroadcast(tripId, 'day:deleted', { dayId });
|
||||
return ok({ success: true });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user