Files
cobble/src/bots-queue/push-workspace-removed.ts
T
tben 139b3e443d Give the coordinator working crew management tools
- Resolve the crew and workspaces fresh inside each tool run, so a bot or
  workspace created earlier in the same reply is usable: create_bot,
  assign_computer, add_bot_to_workspace, delegate_task and
  set_bot_workspace_instructions.
- Add coordinator-only update_bot, find_bot, find_workspace, delete_bot,
  delete_workspace and remove_bot_from_workspace tools.
- Push server:workspace-removed when a workspace is deleted, and
  workspace_ids on server:bot-updated so a workspace's crew drops a bot
  that was taken out of it.
2026-10-19 20:34:51 +01:00

29 lines
841 B
TypeScript

import { sendToUser } from "@/src/websocket/(functions)/send-to-user";
type Params = {
workspace_id: number | string;
/**
* Everyone who saw the workspace, read before its row was deleted:
* afterwards its links are gone with it, so its audience can't be
* worked out any more.
*/
user_ids: number[];
};
/**
* Pushes `server:workspace-removed` to everyone who could see a workspace
* that was deleted, so its rail row goes at once and nothing opens a dead
* workspace.
*/
export default function pushWorkspaceRemoved({ workspace_id, user_ids }: Params) {
for (const user_id of user_ids) {
sendToUser({
user_id,
data: {
event: "server:workspace-removed",
data: { workspace_id: Number(workspace_id) },
},
});
}
}