GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): match subscription accounts across environments by shivamhwp · Pull Request #30362 · pingdotgg/t3code

fix(web): match subscription accounts across environments #30362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shivamhwp wants to merge 13 commits into pingdotgg:main from shivamhwp:issue-watch/30270
+497 −31
Closed

fix(web): match subscription accounts across environments #30362

Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
e0fd933
fix(web): all-environments model settings match one account across in…
shivamhwp Nov 3, 2026
b78c51e
Merge remote-tracking branch 'origin/main' into issue-watch/30270
shivamhwp Nov 7, 2026
9b8e305
fix(web): map the voice cleanup model across environments too, trim r…
shivamhwp Nov 7, 2026
9d48461
Merge remote-tracking branch 'origin/main' into issue-watch/30270
shivamhwp Nov 9, 2026
fd15492
fix(web): scoped model settings refuse conflicting accounts and gener…
shivamhwp Nov 9, 2026
d17cd59
fix(web): reject conflicting accounts across all scoped targets
shivamhwp Nov 9, 2026
ea06907
fix(web): compare text generators before provider identities
shivamhwp Nov 9, 2026
493b3f8
fix(web): scope generator matching to supported model settings
shivamhwp Nov 9, 2026
8901322
Merge remote-tracking branch 'github/main' into issue-watch/30270
maria-rcks Nov 10, 2026
585a695
Merge remote-tracking branch 'origin/main' into issue-watch/30270
juliusmarminge Nov 11, 2026
b045fbb
refactor(web): share the scoped model key guard, drop redundant cases
juliusmarminge Nov 11, 2026
edaf9c0
fix(web): keep a shared instance ID even when environments report oth…
juliusmarminge Nov 11, 2026
aca17ee
Merge remote-tracking branch 'origin/main' into issue-watch/30270
shivamhwp Nov 13, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

73 changes: 73 additions & 0 deletions 73 apps/web/src/components/settings/scopedModelSelection.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import type { ModelSelection, ProviderInstanceId, ServerProvider } from "@t3tools/contracts";
import * as Equal from "effect/Equal";

export const SCOPED_MODEL_SETTING_KEYS = [
"defaultModelSelection",
"fallbackModelSelection",
"textGenerationModelSelection",
"sourceControlWriterModelSelection",
"reviewGuideModelSelection",
"speechPostProcessingModelSelection",
] as const;

const NON_SUBSCRIPTION_CLAUDE_AUTH = new Set(["apiKey", "bedrock", "customEndpoint"]);

/** Only a verified subscription login identifies who pays; names and instance IDs are machine-local. */
function subscriptionAccount(provider: ServerProvider): string | null {
const { driver, auth } = provider;
if (auth.status !== "authenticated" || !auth.type || !auth.email || !auth.workspaceId) {
return null;
}
const subscription =
driver === "codex"
? auth.type === "chatgpt"
: driver === "claudeAgent" && !NON_SUBSCRIPTION_CLAUDE_AUTH.has(auth.type);
return subscription
? JSON.stringify([driver, auth.type, auth.email.toLowerCase(), auth.workspaceId])
: null;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}

/**
* The destination instance for a source instance: the same ID and driver, else the one
* subscription account that matches it uniquely in both environments.
*/
export function resolveScopedModelInstanceId(
instanceId: ProviderInstanceId,
sourceProviders: readonly ServerProvider[],
destinationProviders: readonly ServerProvider[],
): ProviderInstanceId | null {
const source = sourceProviders.find((provider) => provider.instanceId === instanceId);
if (!source) return null;
if (
destinationProviders.some(
(provider) => provider.instanceId === instanceId && provider.driver === source.driver,
)
) {
return instanceId;
}
const account = subscriptionAccount(source);
if (account === null) return null;
const matches = (providers: readonly ServerProvider[]) =>
providers.filter((provider) => subscriptionAccount(provider) === account);
const destination = matches(destinationProviders);
return destination.length === 1 && matches(sourceProviders).length === 1
? destination[0]!.instanceId
: null;
}

export function scopedModelSelectionsEqual(
first: ModelSelection | null,
firstProviders: readonly ServerProvider[],
second: ModelSelection | null,
secondProviders: readonly ServerProvider[],
): boolean {
if (Equal.equals(first, second)) return true;
if (first === null || second === null || first.instanceId === second.instanceId) return false;
return (
resolveScopedModelInstanceId(first.instanceId, firstProviders, secondProviders) ===
second.instanceId &&
resolveScopedModelInstanceId(second.instanceId, secondProviders, firstProviders) ===
first.instanceId &&
Equal.equals({ ...first, instanceId: second.instanceId }, second)
);
}
237 changes: 237 additions & 0 deletions 237 apps/web/src/components/settings/scopedSettings.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
EnvironmentAuthorizationError,
EnvironmentId,
ProjectId,
ProviderDriverKind,
ProviderInstanceId,
type ServerProvider,
type ServerSettings,
} from "@t3tools/contracts";
import { describe, expect, it, vi } from "vite-plus/test";
Expand Down Expand Up @@ -784,3 +786,238 @@ describe("model selection patches at project scope", () => {
).toEqual({ ...saved, options });
});
});

describe("model selections for one account under distinct instance IDs", () => {
const account = (
instanceId: string,
auth: Partial<ServerProvider["auth"]> = {},
driver = "codex",
): ServerProvider => ({
instanceId: ProviderInstanceId.make(instanceId),
driver: ProviderDriverKind.make(driver),
enabled: true,
installed: true,
version: null,
status: "ready",
auth: {
status: "authenticated",
type: driver === "codex" ? "chatgpt" : "max",
email: "[email protected]",
workspaceId: "personal",
...auth,
},
checkedAt: "2026-11-03T00:00:00.000Z",
models: [],
slashCommands: [],
skills: [],
});
const laptopCodex = account("codex_laptop_gmail");
const serverCodex = account("codex_server_gmail", { email: "[email protected]" });
const providers = (laptopProviders: ServerProvider[], serverProviders: ServerProvider[]) =>
new Map([
[laptop.environmentId, laptopProviders],
[server.environmentId, serverProviders],
]);
const matching = providers([laptopCodex], [serverCodex]);
const fromLaptop = (providersByEnvironment: ReturnType<typeof providers>) => ({
sourceEnvironmentId: laptop.environmentId,
providersByEnvironment,
});
const luna = { instanceId: laptopCodex.instanceId, model: "gpt-6-luna" };
const keys = [
"defaultModelSelection",
"fallbackModelSelection",
"textGenerationModelSelection",
"sourceControlWriterModelSelection",
"reviewGuideModelSelection",
"speechPostProcessingModelSelection",
] as const;

it("writes each environment's own instance for every model setting", () => {
const patch = Object.fromEntries(keys.map((key) => [key, luna]));
const plan = planScopedSettingsPatch(all, environments, patch, fromLaptop(matching));
expect(plan.unavailableReason).toBeNull();
expect(plan.serverWrites.map((write) => write.patch)).toEqual([
patch,
Object.fromEntries(keys.map((key) => [key, { ...luna, instanceId: serverCodex.instanceId }])),
]);
const loading = new Map(matching);
loading.delete(server.environmentId);
const pending = planScopedSettingsPatch(all, environments, patch, fromLaptop(loading));
expect(pending.serverWrites).toEqual([]);
expect(pending.unavailableReason).toContain("Server");
});

it("maps project overrides to each member's own instance", () => {
const projectKeys = [
"defaultModelSelection",
"textGenerationModelSelection",
"sourceControlWriterModelSelection",
"reviewGuideModelSelection",
] as const;
const plan = planScopedSettingsPatch(
project,
environments,
Object.fromEntries(projectKeys.map((key) => [key, luna])),
fromLaptop(matching),
);
expect(plan.serverWrites.map((write) => write.patch.projectSettingsOverrides)).toEqual([
{
[projectId]: Object.fromEntries(
projectKeys.map((key) => [key, { ...luna, instanceId: serverCodex.instanceId }]),
),
},
{ [laptopProjectId]: Object.fromEntries(projectKeys.map((key) => [key, luna])) },
]);
});

it("prefers the same instance ID and driver over account matching", () => {
const shared = account("codex_shared");
expect(
planScopedSettingsPatch(
all,
environments,
{ defaultModelSelection: { instanceId: shared.instanceId, model: "gpt-6-luna" } },
fromLaptop(providers([shared, laptopCodex], [serverCodex, shared])),
).serverWrites.map((write) => write.patch.defaultModelSelection?.instanceId),
).toEqual([shared.instanceId, shared.instanceId]);
});

it.each([
[
"an API key account",
[account("codex_laptop_key", { type: "apiKey" })],
[account("codex_server_key", { type: "apiKey" })],
],
[
"a different workspace",
[laptopCodex],
[account("codex_server_gmail", { workspaceId: "team" })],
],
[
"a matching display name with no workspace",
[{ ...account("codex_laptop_gmail", { workspaceId: undefined }), displayName: "Gmail" }],
[{ ...account("codex_server_gmail", { workspaceId: undefined }), displayName: "Gmail" }],
],
[
"an unauthenticated destination",
[laptopCodex],
[account("codex_server_gmail", { status: "unknown" })],
],
[
"two matching destination accounts",
[laptopCodex],
[serverCodex, account("codex_server_other")],
],
["two matching source accounts", [laptopCodex, account("codex_laptop_other")], [serverCodex]],
["missing from the source snapshot", [], [serverCodex]],
[
"the same ID and login on another driver",
[laptopCodex],
[account(laptopCodex.instanceId, { type: "chatgpt" }, "claudeAgent")],
],
])("refuses every write when the account is %s", (_name, laptopProviders, serverProviders) => {
const instanceId = laptopProviders[0]?.instanceId ?? laptopCodex.instanceId;
const plan = planScopedSettingsPatch(
all,
environments,
{ textGenerationModelSelection: { instanceId, model: "gpt-6-luna" } },
fromLaptop(providers(laptopProviders, serverProviders)),
);
expect(plan.serverWrites).toEqual([]);
expect(plan.unavailableReason).toContain("Server");
});

it("keeps a text generator's ID only where it reaches the same API", () => {
const id = ProviderInstanceId.make("openrouter");
const openrouter: ServerSettings["textGenerators"][ProviderInstanceId] = {
kind: "openaiCompatible",
baseUrl: "https://openrouter.ai/api/v1",
apiKey: "",
enabled: true,
};
const withGenerator = (
target: typeof laptop,
config: ServerSettings["textGenerators"][ProviderInstanceId] | undefined,
) =>
config
? environment(target.label, { settings: { textGenerators: { [id]: config } } })
: target;
const selection = { instanceId: id, model: "openai/gpt-6-mini" };
const patch = {
textGenerationModelSelection: selection,
speechPostProcessingModelSelection: selection,
};
// Generators have no provider snapshots to match accounts through.
const plan = (serverGenerator?: typeof openrouter) =>
planScopedSettingsPatch(
all,
[withGenerator(laptop, openrouter), withGenerator(server, serverGenerator)],
patch,
fromLaptop(providers([], [])),
);
expect(plan(openrouter).serverWrites.map((write) => write.patch)).toEqual([patch, patch]);
for (const serverGenerator of [
undefined,
{ ...openrouter, enabled: false },
{ ...openrouter, baseUrl: "https://api.openai.com/v1" },
]) {
expect(plan(serverGenerator).serverWrites).toEqual([]);
expect(plan(serverGenerator).unavailableReason).toContain("Server");
}
});

it("treats the same account and model as one value in either order", () => {
const targets = [
{
environmentId: laptop.environmentId,
settings: {
...DEFAULT_SERVER_SETTINGS,
...Object.fromEntries(keys.map((key) => [key, luna])),
},
},
{
environmentId: server.environmentId,
settings: {
...DEFAULT_SERVER_SETTINGS,
...Object.fromEntries(
keys.map((key) => [key, { ...luna, instanceId: serverCodex.instanceId }]),
),
},
},
];
for (const ordered of [targets, [...targets].reverse()]) {
expect(scopedSettingsAreMixed(ordered, keys, matching)).toBe(false);
expect(
scopedSettingsAreMixed(
ordered,
keys,
providers(
[laptopCodex],
[serverCodex, account(laptopCodex.instanceId, { email: "[email protected]" })],
),
),
).toBe(true);
expect(
scopedSettingsAreMixed(
[
ordered[0]!,
{
...ordered[1]!,
settings: {
...ordered[1]!.settings,
reviewGuideModelSelection: {
...luna,
instanceId: serverCodex.instanceId,
model: "gpt-6-sol",
},
},
},
],
["reviewGuideModelSelection"],
matching,
),
).toBe(true);
}
});
});
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.