Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Merge pull request #7510 from atomantic/claim/issue-7501

[._.]/4a41377523aa
diff --cc server/lib/aiToolkit/internal/providerModes.js
index baff0e2b21,c580cc1ecf..fa8da745f4
--- a/server/lib/aiToolkit/internal/providerModes.js
+++ b/server/lib/aiToolkit/internal/providerModes.js
@@@ -13,28 -13,29 +13,48 @@@ const MODE_KEY_DEFAULTS = { endpoint: '
* this list, or it mints a pair this function then refuses to group — the exact
* failure a dual-mode create exists to prevent. `command` is checked separately
* (it has no empty-value default).
+ *
+ * DERIVED from `MODE_KEY_DEFAULTS` rather than restated, because the pairing
+ * test and `sharedModeUpdates`' fan-out list are one list seen from two sides:
+ * a key that says "these two describe the same connection" but is NOT fanned
+ * out when it changes splits the card on the very edit that changed it, and
+ * leaves the mode the editor did not open pointed at the old backend. Adding a
+ * key to the defaults above therefore opts it into both.
*/
-export const MODE_GROUPED_KEYS = Object.freeze(['endpoint', 'apiKey', 'envVars', 'credentialBootstrap']);
+export const MODE_GROUPED_KEYS = Object.freeze(Object.keys(MODE_KEY_DEFAULTS));
+
+/** True when a record NAMES a connection-identity value rather than leaving it at the empty default. */
+function namesModeValue(provider, key) {
+ if (key === 'credentialBootstrap') return hasCredentialBootstrap(provider);
+ const value = provider?.[key];
+ if (typeof value === 'string') return value.length > 0;
+ if (value && typeof value === 'object') return Object.keys(value).length > 0;
+ return false;
+}
+
+/** A fanned-out value must not ALIAS one object across two stored records. */
+const detachModeValue = value => (value && typeof value === 'object' ? structuredClone(value) : value);
+ /**
+ * Fields belonging to the CLI mode ALONE, which must not ride the shared body
+ * to the TUI sibling {@link expandModePair} mints beside it.
+ *
+ * `headlessArgs` is the non-interactive argv — a flag list handed to a program
+ * being driven without a terminal, meaningless to a PTY launch, and already
+ * declared mode-specific by `PROVIDER_MODE_OVERRIDE_KEYS`.
+ *
+ * Deliberately NOT here: `textTransport` and its consents. A record ADVERTISING
+ * the Codex app-server transport is not a record permitted to use it — the two
+ * explicit consents are, and they are never fanned out (see
+ * `sharedModeUpdates`). The shipped Codex pair declares the transport on BOTH
+ * modes, so dropping it would make a hand-minted pair differ from the seeded
+ * one for the same program.
+ *
+ * Every key here must stay clear of {@link MODE_GROUPED_KEYS} — dropping one of
+ * those would mint a pair `providerModeGroups` then refuses to group.
+ */
+ export const CLI_ONLY_KEYS = Object.freeze(['headlessArgs']);
+
export function providerModeGroups(providers) {
const byId = new Map(providers.map(provider => [provider.id, provider]));
const paired = new Set();