Show a newly created bot in the rail at once
The rail was built from page props and only knew bots it already had, so a bot the coordinator created did not appear until a reload. create_bot and add_bot_to_workspace now push server:bot-created (BotCreatedData) to everyone who sees the bot: its rail row, the workspaces it is in, and whether it belongs in that user's own chat list. useLiveBots inserts it, after the pinned coordinator outside a workspace and only when the open workspace is one it joined. liveRelay pushes created bots too, so a bot added by another process still shows.
This commit is contained in:
@@ -3,6 +3,7 @@ import { AppData } from "@/src/data/app-data";
|
||||
import { logError } from "@/src/functions/backend/logger";
|
||||
import grabConnectedUserIds from "@/src/websocket/(functions)/grab-connected-user-ids";
|
||||
import relayChangedBots from "./relay-changed-bots";
|
||||
import relayCreatedBots from "./relay-created-bots";
|
||||
import relayNewBotMessages from "./relay-new-bot-messages";
|
||||
import relayNewJobUpdates from "./relay-new-job-updates";
|
||||
import type { LiveRelayCursor } from "./types";
|
||||
@@ -50,7 +51,10 @@ export default async function liveRelay() {
|
||||
* Overlap one interval, so a change written in the same
|
||||
* millisecond as the last look isn't missed.
|
||||
*/
|
||||
await relayChangedBots({ since: cursor.bots_at - AppData.LiveRelayPollMs, users });
|
||||
const bots_since = cursor.bots_at - AppData.LiveRelayPollMs;
|
||||
|
||||
await relayCreatedBots({ since: bots_since, users });
|
||||
await relayChangedBots({ since: bots_since, users });
|
||||
cursor.bots_at = now;
|
||||
} catch (error) {
|
||||
await logError({ title: `Live relay failed`, error }).catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user