Repository navigation
Several AI connections at once, one per provider - #2069
Conversation
704a37d to
647e0d2
Compare
davidmckayv
left a comment
There was a problem hiding this comment.
The shape is right: the spec only grows, every write carries an Idempotency-Key, the new extensible enums appear only in answers, the 404 fallback really does draw the old screens, and Reconnect appears only for whoever can fix it. Four things to fix before this goes in, plus two small ones.
Should fix
-
The picker disappears when the default connection can't be read.
model-picker.tsx:169returns before the grouped branch when!catalogue.choosable. With several connections, the top-level fields describe the default. So when the default's Claude sign-in ends but an OpenAI connection still works, the picker is gone. "Choose another model" in the stopped notice (stopped-connection-notice.tsx:16) then clicks a trigger that isn't there and does nothing. The same applies to the no-default case. Fix: whenpickerGroups(catalogue)is non-empty, skip thechoosablegate, or base it on whether any connection is ready. Add a test withchoosable: falseplus connections. -
Change on a non-default row adds a connection instead of changing that one.
ai-connection-list.tsx:349-356(button at :500) opens "Connect another AI" with no provider preset. If the person picks a different provider there, the old row stays and a new one appears. The fix step at :366-373 already presetsprovider: entry.provider; Change should do the same. -
The Disconnect dialog contradicts itself. At
:284and:390, removing the default when two or more others remain but none is ready giveschoosing=false. The dialog then says "Bots can't run until you connect another" while other connections are still listed under it. -
Two existing operations don't say what they do once there are several connections (
model-connections.yaml:447-466, 543-555).deleteAiConnectionstill says "Afterwards the organization has no AI". The new list description says the others stay and the organization is left with no default.replaceAiConnectiondoesn't say what happens when the new provider already has its own connection. Does it replace the default, merge into that provider's connection, or move ids?- The default row's Change still calls
replaceAiConnection(ai-connection-list.tsx:331), so this is a live path. State both rules in those descriptions, and the same for the personal pair.
Small
- A failed Make default leaves the list stale. It invalidates on success only (
mutations.ts:423), so a 409 not-ready leaves the row showing ready. UseonSettled, as remove does. mutations.ts:435says "The server never moves the default by itself". The spec says a removal that leaves exactly one makes it the default.
On the open call (a run refused because its connection stopped): record it as a refused turn. Whether a run is stopped is known before the run is admitted, just like the allowlist, which is recorded. Without a record, after a reload the person's message sits unanswered with no reason, and on Cloud the free run has already been spent. In this PR that only means updating the listRefusedTurns description, which names three codes today, to include the stopped-connection code. RefusedTurn.code is already a plain string.
List, connect, remove and make default the organization's AI connections and a person's own, and sign the organization in to a provider the way a person signs in. The single-connection operations keep their meaning and describe the default connection. The model catalogue lists each connection's models, a model choice names its connection and says when it stopped, and a Bot's default model input can name its source. Every new field is optional, so an older client sends and reads what it did.
AI model, Your AI and Admin, Providers draw one row per connection where the server lists them: the default tagged once there are two, Make default, Change and Disconnect in each row's dialog, and Connect another AI with the shared chooser in a new adding mode. Disconnecting the default asks which connection takes over and makes it the default first. Connections with no default say so. The organization's sign-ins go through its own sign-in operations. Against a server older than the list, or with nothing connected yet, the sections draw the one row they drew before.
… connection With several connections the composer's picker lists each one's models under its name, the default first, and a stopped connection's group says why in place of its models. Picking saves the connection with the model, so the same model on two connections is two choices and changing the default never moves a pick. A pick whose connection is gone shows the default and saves nothing; with no default the picker asks to choose. With one connection it is the picker it was.
After a refused turn the conversation reads its model choice again. When the server says the connection the next run would use is connected but can't run, a notice under the turn gives its sentence, Reconnect into that connection's row in Settings for whoever can fix it, and Choose another model, which opens the composer's picker. The picker's trigger carries a warning mark meanwhile. Nothing reads the refusal's own words, and an older server draws nothing new.
A Bot is shared and each person runs it on their own connections, so its default keeps naming a kind of connection. With several connections it applies on the first ready connection of that kind that lists the model, not only on the one in use, and falls back to the default connection's default otherwise. The Default model section picks from the grouped list and saves the group's kind as the source; with one connection it sends none, as before.
…tays put When an older app disconnects the default and one connection is left, the picker names it so a conversation can still run on it. A pick on a connection that stopped working is shown on that connection, by its id if the connection lists nothing, instead of moving to the default's model.
…efault The sentence after Connect another AI or a row's Change read whether the new connection is the default from the list as it stood, and was wrong with no default or when the default's own provider was connected again. It now follows the server's answer.
A conversation's Reconnect link now says whose connection it is, and only that list in Settings opens its row: on OpenBot Cloud an admin's own connection and the organization's may share an id, and both dialogs used to open. The API says ids are unique within their list only.
In Settings a stopped row's dialog leads with Sign in again or Replace key, which opens the chooser on that provider under a title naming the fix. In the model picker, a stopped connection of the person's own gets a Reconnect link in its group; the organization's waits on an admin.
When the last connection that can run is disconnected, the confirm step uses the sentences the single connection's dialogs always used: a person's runs fall back to the organization's AI, the organization's on OpenBot Cloud leaves only people with their own, otherwise Bots can't run. A person left with no AI where one is required is sent to connect one again.
As agreed for the backend: when a removal leaves exactly one AI connection, the server makes it the default, so disconnecting the default with one other left asks nothing. With more left and none the default, a run with no pick is refused and the conversation's model choice says so (stopped, no-default), and the notice links to choosing a default. Organization sign-ins are offered on OpenBot Cloud and a self-hosted OpenBot; OpenBot Desktop keeps its own plan sign-in.
…rs do Since TrustedRouter, a provider in an answer is AiConnectionProviderAnswer, so a released app doesn't break when one is added. The connection list and the catalogue's connections now use it too, and the app's names accept a provider it doesn't know.
…lt example that can happen Words for three new audit events the backend records: the organization's or a person's default AI changed, and an organization sign-in. The example of connections with no default now shows two left, since one left becomes the default.
… a refused turn is drawn under its message
…nd for connecting another "AI model" leaves Settings → General for Settings → Providers, first under Every Bot. Each connected provider's row leads to its own page (details, Change or Sign in again, Make default, Disconnect with what happens said beside it), and Connect another AI and Change are pages too, not dialogs. Admin → Providers draws the same pages under /admin/providers. A conversation's Reconnect and Choose a default lead there. The one-row screens kept for an older server or an older OpenBot Desktop keep their dialogs.
One button per connection down the popup's left edge, the default first, as T3 Code's picker has its providers. The list shows the chosen connection's models and opens on the one in use; a search looks through every connection, each under its name. A connection that can't run is marked on the rail and says why when chosen. With one connection there is no rail.
…there is no default, and offers the others
…refused Make default reads the list again, and Change keeps to its provider
…tions, and a refused turn can be a stopped AI connection
…y answer now does
647e0d2 to
4a4e47c
Compare
|
Thanks, Dave. All fixed, and the branch is rebased on main again. One thing changed under you since your review: Settings → Providers is now its own screen with a page per provider (and Admin → Providers the same), and the composer's picker has a providers rail once two or more AIs are connected.
Small ones: Make default invalidates on settled (test with a 409), and the comments now say the server moves the default only when a removal leaves exactly one. Your call: Also: main's new rule that every answer declares |
# Conflicts: # app/src/components/bot-profile/default-model.tsx
…oviders after a disconnect - Change and Replace key keep to the connection's own provider: its tile no longer opens the other providers, which connected a second AI instead of changing this one. They open on the connection's own way in, so a key connection asks for the key rather than a plan sign-in. - After Disconnect the page goes back to Providers. The list read after the removal no longer has the connection, so the page left before the mutation's own callback ran and stayed on "isn't connected". - The radios that choose the next default are drawn in the app's colours, as the Bot's default model choice draws them. - Under a refused turn that already says why, the connection notice adds only Reconnect and Choose another model, rather than the same sentence again. - On OpenBot Cloud the organization's several connections say they are for whoever has none of their own: the reader's own Bots may run on their own connections instead.
# Conflicts: # app/src/components/channels/chat-transcript.tsx # app/src/components/settings/ai-connection.tsx
What this changes
Several AI connections at once, one per provider. A person who pays for a Claude plan and a ChatGPT plan, or holds a few keys, keeps all of them connected and picks a model from any of them per conversation, instead of switching one connection that moves every Bot and conversation.
API (
api/openapi/model-connections.yaml,bots.yaml). Only grows; nothing existing changes meaning. Today's single-connection operations describe the default connection.listAiConnections,connectAiConnection,removeAiConnection,makeAiConnectionDefaultunder/ai-connections./people/{personId}/ai-connections.startAiSignIn,getAiSignIn,finishAiSignInunder/ai-connection-sign-ins, as the personal ones, on OpenBot Cloud and a self-hosted OpenBot. OpenBot Desktop running its own OpenBot keeps its own plan sign-in (signInsempty).ModelCatalogue.connections(each connection's models,owner,source,ready,problem),ModelChoice.connectionandstopped,ModelChoiceInput.connection, and a Bot'sdefaultModelinputsource.stoppedchoice (no-default). Ids are unique within their list only.App.
Draft until it has been run against a server that answers the new operations.
Where it runs
Boundary and audit
AI_CONNECTION_STOPPED).API and database
api/and keeps every rule: only new operations and optional fields, new answer enums open (x-extensible-enum, never reachable from a request), no key or address in any answer, and the existing operations keep their meaning so a released app behaves as before. No database change in this repository.Changelog
CHANGELOG.mdunderUnreleased, API.Proof
bun run api:lint,bun test api/(78 pass),bun run format:check,bun run lint,bun run typecheck.OPENBOT_APP_BROWSER=1).