SIGN IN SIGN UP

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

0 0 73 Python

feat(backend/copilot): keep linked server names fresh from bot gateway events (#13221)

## Why

Linked-server rows in `PlatformLink` were created without capturing the
server's display name (or before the name-capture path existed), so the
Bots settings page renders some servers as raw IDs forever. We don't
want to hit Discord's REST API on every page load just to resolve names.

## What

The bot already has authoritative guild names cached on its gateway
connection. This wires the bot's `on_ready` / `on_guild_join` /
`on_guild_update` events to push the current display name into
`PlatformLink.serverName` via a new internal RPC.

## How

- `db.refresh_server_link_name(platform, server_id, name)` — keyed by
`(platform, platformServerId)`. The where-clause explicitly ORs in
`serverName IS NULL` because in SQL `NULL != 'x'` is `NULL`, not true,
which would silently skip legacy backfills.
- `PlatformLinkingManager.refresh_server_link_name` exposes it as a
cluster-internal RPC.
- `BotBackend.refresh_server_name` is the bot-side wrapper.
- Discord adapter iterates `self._client.guilds` on connect — in-memory
cache only, **no Discord API calls**. Errors are swallowed (refreshing
names is never critical-path). `on_guild_update` covers live renames.

No user-visible change on its own — this is the foundation for the
stacked Bots settings page PR.

## Test plan

- [x] Backend: `poetry run pytest backend/platform_linking/
backend/copilot/bot/` — 190 pass
- [x] Manual: restart bot, watch `serverName` get populated for every
guild the bot can see; rename a server in Discord and watch the DB pick
it up
B
Bently committed
7e2154c31fd511bca2d0bf3ad1d55278fada9183
Parent: 8dc55d9
Committed by GitHub <noreply@github.com> on 5/27/2026, 3:22:43 PM