S7 review: align OAuth UI with S6's actual contract (server-26#225)

- complete: S6 returns streams_stopped, not stopped — the "N radio
  channels were stopped" note never showed.
- start: bot name is nested as bot.name.
- "The bot for a system" with an org-owned preferred bot now sends
  token_id (S6 accepts it today); system_id only for a platform-pinned
  pool bot, which still needs S6 to accept system_id.
- A 404 for one chosen bot no longer hides Connect and the picker
  (the message told the user to try Automatic, but the button was gone).
- Server count uses GET /tokens' per-bot server_cap when present.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Logan Cusano
2026-10-05 02:56:05 -04:00
co-authored by Claude Opus 5.5
parent dd3e5c9655
commit eaa0be07c5
4 changed files with 30 additions and 16 deletions
+17 -9
View File
@@ -28,10 +28,17 @@ const SELECT =
// Option values for the bot picker: "" = let C2 choose, "tok:<id>" = one of
// the org's own bots, "sys:<id>" = whichever bot is preferred for that system.
function startRequest(choice: string): OAuthStartRequest {
function startRequest(choice: string, data: OrgPreferredBots | null): OAuthStartRequest {
const req: OAuthStartRequest = { return_to: "/settings/organization" };
if (choice.startsWith("tok:")) req.token_id = choice.slice(4);
else if (choice.startsWith("sys:")) req.system_id = choice.slice(4);
else if (choice.startsWith("sys:")) {
const id = choice.slice(4);
// The org's own bot preferred for this system: name it by token_id, which
// S6 already accepts. Only a platform-pinned pool bot needs system_id.
const pref = data?.systems.find((s) => s.system_id === id)?.preferred_token_id;
if (pref) req.token_id = pref;
else req.system_id = id;
}
return req;
}
@@ -125,18 +132,19 @@ export function DiscordServersCard({ canEdit, isAdmin }: { canEdit: boolean; isA
setActionError(null);
setJustLinked(null);
try {
const { url } = await startDiscordOAuth(startRequest(choice));
const { url } = await startDiscordOAuth(startRequest(choice, choices));
window.location.assign(url);
// Leave the button in its busy state: the page is navigating to Discord.
} catch (err) {
if (err instanceof OAuthNotConfigured) {
setOauthOff(true);
setShowCode(true);
setActionError(
choice
? "That bot can't connect servers yet. Try Automatic, or link with a code below."
: "Connecting with Discord isn't set up yet. Link with a code below instead.",
);
if (choice) {
// Only this bot is off: keep Connect and the picker so Automatic can be tried.
setActionError("That bot can't connect servers yet. Try Automatic, or link with a code below.");
} else {
setOauthOff(true);
setActionError("Connecting with Discord isn't set up yet. Link with a code below instead.");
}
} else {
setActionError(parseC2Error(err).message);
}