Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"dependencies": {
"@effect/platform-node": "catalog:",
"@effect/sql-sqlite-bun": "catalog:",
"@github/copilot": "1.0.2",
"@github/copilot-sdk": "0.1.31-unstable.0",
"@github/copilot": "1.0.7",
"@github/copilot-sdk": "0.1.32",
"@pierre/diffs": "^1.1.0-beta.16",
"effect": "catalog:",
"node-pty": "^1.1.0",
Expand Down
24 changes: 24 additions & 0 deletions apps/web/src/components/ChatView.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EventId, TurnId, type OrchestrationThreadActivity } from "@t3tools/cont
import { describe, expect, it } from "vitest";
import {
deriveVisibleThreadWorkLogEntries,
orderCopilotBuiltInModelOptions,
resolveProviderHealthBannerProvider,
} from "./ChatView.logic";

Expand Down Expand Up @@ -47,6 +48,29 @@ describe("resolveProviderHealthBannerProvider", () => {
});
});

describe("orderCopilotBuiltInModelOptions", () => {
it("reorders runtime copilot models to match the preferred built-in picker order", () => {
expect(
orderCopilotBuiltInModelOptions([
{ slug: "gpt-5.4", name: "GPT-5.4" },
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
{ slug: "gpt-5.4-mini", name: "GPT-5.4 mini" },
{ slug: "gpt-5.2", name: "GPT-5.2" },
]).map((option) => option.slug),
).toEqual(["gpt-5.4", "gpt-5.4-mini", "gpt-5.3-codex", "gpt-5.2"]);
});

it("keeps unknown runtime-only models after the preferred built-in models", () => {
expect(
orderCopilotBuiltInModelOptions([
{ slug: "gpt-5.4", name: "GPT-5.4" },
{ slug: "future-runtime-model", name: "Future Runtime Model" },
{ slug: "gpt-5.4-mini", name: "GPT-5.4 mini" },
]).map((option) => option.slug),
).toEqual(["gpt-5.4", "gpt-5.4-mini", "future-runtime-model"]);
});
});

describe("deriveVisibleThreadWorkLogEntries", () => {
it("keeps completed tool calls from previous turns visible in the thread timeline", () => {
const activities: OrchestrationThreadActivity[] = [
Expand Down
31 changes: 30 additions & 1 deletion apps/web/src/components/ChatView.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import {
type ProviderKind,
type ThreadId,
} from "@t3tools/contracts";
import { getModelOptions } from "@t3tools/shared/model";
import { type ChatMessage, type Thread } from "../types";
import { randomUUID } from "~/lib/utils";
import { getAppModelOptions } from "../appSettings";
import { getAppModelOptions, type BuiltInAppModelOption } from "../appSettings";
import { type ComposerImageAttachment, type DraftThreadState } from "../composerDraftStore";
import { Schema } from "effect";
import { deriveWorkLogEntries, type WorkLogEntry } from "../session-logic";
Expand Down Expand Up @@ -132,6 +133,34 @@ export function getCustomModelOptionsByProvider(settings: {
};
}

export function orderCopilotBuiltInModelOptions(
runtimeOptions: ReadonlyArray<BuiltInAppModelOption>,
preferredOptions: ReadonlyArray<BuiltInAppModelOption> = getModelOptions("copilot"),
): ReadonlyArray<BuiltInAppModelOption> {
const preferredIndexBySlug = new Map(
preferredOptions.map((option, index) => [option.slug, index] as const),
);

return runtimeOptions
.map((option, runtimeIndex) => ({ option, runtimeIndex }))
.toSorted((left, right) => {
const leftPreferredIndex = preferredIndexBySlug.get(left.option.slug);
const rightPreferredIndex = preferredIndexBySlug.get(right.option.slug);

if (leftPreferredIndex !== undefined && rightPreferredIndex !== undefined) {
return leftPreferredIndex - rightPreferredIndex;
}
if (leftPreferredIndex !== undefined) {
return -1;
}
if (rightPreferredIndex !== undefined) {
return 1;
}
return left.runtimeIndex - right.runtimeIndex;
})
.map(({ option }) => option);
}

export function resolveProviderHealthBannerProvider(input: {
sessionProvider: ProviderKind | null;
selectedProvider: ProviderKind;
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ import {
} from "./chat/MessagesTimeline.logic";
import {
deriveVisibleThreadWorkLogEntries,
orderCopilotBuiltInModelOptions,
resolveProviderHealthBannerProvider,
} from "./ChatView.logic";

Expand Down Expand Up @@ -1401,7 +1402,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
codex: getModelOptions("codex"),
copilot:
copilotProviderModels.length > 0
? copilotProviderModels.map((model) => ({ slug: model.id, name: model.name }))
? orderCopilotBuiltInModelOptions(
copilotProviderModels.map((model) => ({ slug: model.id, name: model.name })),
)
: getModelOptions("copilot"),
}),
[copilotProviderModels],
Expand Down
34 changes: 10 additions & 24 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/contracts/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
],
copilot: [
{ slug: "gpt-5.4", name: "GPT-5.4" },
{ slug: "gpt-5.4-mini", name: "GPT-5.4 mini" },
{ slug: "claude-sonnet-4.6", name: "Claude Sonnet 4.6" },
{ slug: "claude-sonnet-4.5", name: "Claude Sonnet 4.5" },
{ slug: "claude-haiku-4.5", name: "Claude Haiku 4.5" },
Expand All @@ -43,6 +44,7 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
{ slug: "claude-opus-4.5", name: "Claude Opus 4.5" },
{ slug: "claude-sonnet-4", name: "Claude Sonnet 4" },
{ slug: "gemini-3-pro-preview", name: "Gemini 3 Pro (Preview)" },
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
{ slug: "gpt-5.2", name: "GPT-5.2" },
Expand All @@ -52,6 +54,7 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
{ slug: "gpt-5.1", name: "GPT-5.1" },
{ slug: "gpt-5-mini", name: "GPT-5 mini" },
{ slug: "gpt-4.1", name: "GPT-4.1" },
{ slug: "raptor-mini", name: "Raptor mini" },
],
} as const satisfies Record<ProviderKind, readonly ModelOption[]>;
export type ModelOptionsByProvider = typeof MODEL_OPTIONS_BY_PROVIDER;
Expand All @@ -75,6 +78,7 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
copilot: {
"4.1": "gpt-4.1",
"5.4": "gpt-5.4",
"5.4-mini": "gpt-5.4-mini",
"5-mini": "gpt-5-mini",
"5.1": "gpt-5.1",
"5.1-codex": "gpt-5.1-codex",
Expand All @@ -87,6 +91,8 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
sonnet: "claude-sonnet-4.6",
opus: "claude-opus-4.6",
gemini: "gemini-3-pro-preview",
"gemini-3.1": "gemini-3.1-pro",
raptor: "raptor-mini",
},
} as const satisfies Record<ProviderKind, Record<string, ModelSlug>>;

Expand Down
13 changes: 13 additions & 0 deletions packages/shared/src/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ describe("normalizeModelSlug", () => {
expect(normalizeModelSlug("gpt-5.3")).toBe("gpt-5.3-codex");
});

it("maps copilot aliases to canonical slugs", () => {
expect(normalizeModelSlug("5.4-mini", "copilot")).toBe("gpt-5.4-mini");
expect(normalizeModelSlug("gemini-3.1", "copilot")).toBe("gemini-3.1-pro");
expect(normalizeModelSlug("raptor", "copilot")).toBe("raptor-mini");
});

it("returns null for empty or missing values", () => {
expect(normalizeModelSlug("")).toBeNull();
expect(normalizeModelSlug(" ")).toBeNull();
Expand Down Expand Up @@ -50,6 +56,13 @@ describe("resolveModelSlug", () => {
expect(resolveModelSlug(model.slug)).toBe(model.slug);
}
});

it("resolves supported copilot model options", () => {
for (const model of MODEL_OPTIONS_BY_PROVIDER.copilot) {
expect(resolveModelSlug(model.slug, "copilot")).toBe(model.slug);
}
});

it("keeps codex defaults for backward compatibility", () => {
expect(getDefaultModel()).toBe(DEFAULT_MODEL_BY_PROVIDER.codex);
expect(getModelOptions()).toEqual(MODEL_OPTIONS_BY_PROVIDER.codex);
Expand Down
Loading