GeezerVison is showing github.com — fix(opencode): project-defined models appear in that project's picker by juliusmarminge · Pull Request #24585 · pingdotgg/t3code
fix(opencode): project-defined models appear in that project's picker
#24585
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.
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d7fa8ea
test(opencode): project-defined models reach the workspace snapshot (…
juliusmarminge Oct 30, 2026
d29b9e6
fix(opencode): project-defined models appear in that project's picker
juliusmarminge Oct 30, 2026
6d2e28a
fix(opencode): OpenCode 1 projects list their own models too
juliusmarminge Oct 30, 2026
08d8467
fix(opencode): an unreadable project catalog keeps its known models
juliusmarminge Oct 30, 2026
a605290
fix(mobile): new-task and hidden-model pickers use the draft's directory
juliusmarminge Oct 30, 2026
f4feb1c
fix(web): the model picker's open provider tab lists project models
juliusmarminge Oct 30, 2026
ca458db
Merge remote-tracking branch 'origin/main' into fix/issue-24459
juliusmarminge Oct 30, 2026
9cd1814
fix(server): project model discovery retries until it reads, and foll…
juliusmarminge Oct 30, 2026
ed8c778
Merge remote-tracking branch 'origin/main' into fix/issue-24459
juliusmarminge Oct 30, 2026
6ae13e7
fix(server): project models survive machine model changes and load in…
juliusmarminge Oct 30, 2026
f089347
fix(mobile): model picker scans only the provider in view
juliusmarminge Oct 30, 2026
eac44a1
fix(mobile): pulling to refresh the model picker rescans the project'…
juliusmarminge Oct 30, 2026
958a273
test(opencode): unreadable project catalogs stay pending on OpenCode …
juliusmarminge Oct 30, 2026
b91ce46
fix(server): a machine model change rescans every folder catalog
juliusmarminge Oct 30, 2026
fcd760e
Merge remote-tracking branch 'origin/main' into fix/issue-24459
juliusmarminge Nov 11, 2026
10e72ad
test(server): drop registry assertion the merge-snapshot test already…
juliusmarminge Nov 11, 2026
de8689f
Merge remote-tracking branch 'origin/main' into fix/issue-24459
juliusmarminge Nov 11, 2026
0303070
Merge branch 'main' into fix/issue-24459
juliusmarminge Nov 11, 2026
3291c06
Merge remote-tracking branch 'origin/main' into fix/issue-24459
juliusmarminge Nov 11, 2026
bd0f5cd
fix(web): the model picker says it is searching while a project's mod…
juliusmarminge Nov 11, 2026
b46a78c
Merge branch 'main' into fix/issue-24459
juliusmarminge Nov 12, 2026
File filter
Filter by extension
.ts
(6)
.tsx
(1)
All 2 file types selected
Viewed files
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
Hide whitespace
Diff view
Hide whitespace
fix(server): project models survive machine model changes and load in…
… the mobile picker
A machine refresh that changed the machine models dropped every folder's own
model catalog, and a fresh refresh rejected its own folder scan because it
compared against the snapshot from before the machine refresh. Folder catalogs
now stay and are marked pending until the next read settles, and a fresh scan
publishes against the snapshot as the machine refresh left it.
The mobile model picker now keeps the workspace snapshot fresh for the
providers it lists, sharing the composer's refresh atom family, so a project's
OpenCode models appear even when another provider is selected.
The OpenCode catalog loaders are named Effect.fn spans, and the duplicate
workspace snapshot upsert test is folded into the existing one.
Co-Authored-By: Claude Opus 5.5 <[email protected] >
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit 6ae13e79be3c5c1e469ae86b14a4cd0bd2b3aca8
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -6,7 +6,7 @@ import { SheetHeader } from "../../components/ui/SheetHeader";
import { Toolbar } from "../../components/ui/Toolbar";
import * as Dialog from "../../components/ui/Dialog";
import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
import { DEFAULT_SERVER_SETTINGS, ProviderInstanceId } from "@t3tools/contracts";
import {
modelPreferencesMigrationPatch,
resolveModelPreferences,
Expand All
@@ -15,15 +15,14 @@ import type {
EnvironmentId,
ModelSelection,
ProjectId,
ProviderInstanceId,
ProviderOptionDescriptor,
ProviderOptionSelection,
RuntimeMode,
ServerSettings,
ThreadId,
} from "@t3tools/contracts";
import type { LegendListRenderItemProps } from "@legendapp/list/react-native";
import { RegistryContext, useAtomValue } from "@effect/atom-react";
import { RegistryContext, useAtomMount, useAtomValue } from "@effect/atom-react";
import { AnimatedLegendList } from "@legendapp/list/reanimated";
import {
getProviderOptionCurrentLabel,
Expand Down
Expand Up
@@ -92,6 +91,7 @@ import { activeComposerDraftKey, useQueuedRunEdit } from "../../state/queued-run
import { updateThreadDraftModelSelection } from "../../state/use-thread-composer-state";
import { useThreadSelection } from "../../state/use-thread-selection";
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
import { providerWorkspaceSnapshotRefresh } from "../../state/provider-workspace-snapshot-refresh";
import { threadAllowsProviderSwitch } from "../../state/thread-provider-switching";
import { environmentServerConfigsAtom, serverEnvironment } from "../../state/server";
import { mobilePreferencesAtom } from "../../state/preferences";
Expand Down
Expand Up
@@ -637,13 +637,40 @@ function ThreadSettingsSessionProvider(
toggleFavorite,
} satisfies ThreadSettingsSessionValue;
const environmentId = props.environmentId;
const cwd = props.cwd;
const scannedProviderKeys =
providerFilter !== null && providerFilter !== FAVORITES_PROVIDER_FILTER
? [providerFilter]
: providerGroups.map((group) => group.providerKey);
Comment thread
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
🟠 High threads/ThreadSettingsSheet.tsx:645
Workspace discovery skips OpenCode when its machine models are all hidden, so OpenCode's additional project models never appear and its provider filter is unavailable. scannedProviderKeys comes from providerGroups, which omits providers with no visible models; derive scan targets from eligible configured providers instead.
🚀 Reply "fix it for me " or copy this AI Prompt for your agent:
In file @apps/mobile/src/features/threads/ThreadSettingsSheet.tsx around line 645:
Workspace discovery skips OpenCode when its machine models are all hidden, so OpenCode's additional project models never appear and its provider filter is unavailable. `scannedProviderKeys` comes from `providerGroups`, which omits providers with no visible models; derive scan targets from eligible configured providers instead.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
return (
<ThreadSettingsSessionContext.Provider value={value}>
{environmentId && cwd
? scannedProviderKeys.map((providerKey) => (
<ProviderWorkspaceSnapshotScan
key={providerKey}
environmentId={environmentId}
instanceId={ProviderInstanceId.make(providerKey)}
cwd={cwd}
/>
))
: null}
{props.children}
</ThreadSettingsSessionContext.Provider>
);
}
/** A project's own provider config can add models only its workspace scan lists. */
function ProviderWorkspaceSnapshotScan(props: {
readonly environmentId: EnvironmentId;
readonly instanceId: ProviderInstanceId;
readonly cwd: string;
}) {
useAtomMount(providerWorkspaceSnapshotRefresh(props));
return null;
}
function useThreadSettingsSession() {
const value = use(ThreadSettingsSessionContext);
if (!value) {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -42,7 +42,6 @@ import {
scoreQueryMatch,
} from "@t3tools/shared/searchRanking";
import {
createProviderWorkspaceSnapshotRefreshAtomFamily,
dedupeProviderSkillsByName,
getProviderSkillsForSlashMenu,
getProviderSlashCommandsForSlashMenu,
Expand All
@@ -55,7 +54,7 @@ import { Atom } from "effect/reactivity";
import { useEffect, useState } from "react";
import type { ComposerEditorSelection } from "../../components/ComposerEditor";
import { serverEnvironment } from "../../state/server ";
import { providerWorkspaceSnapshotRefresh } from "../../state/provider-workspace-snapshot-refresh ";
import {
useComposerPathSearch,
useComposerPullRequestSearch,
Expand All
@@ -64,11 +63,6 @@ import {
import type { ComposerCommandItem } from "./ComposerCommandPopover";
import { matchesSlashSkillQuery } from "./composerSlashSkillSearch";
const providerWorkspaceSnapshotRefresh = createProviderWorkspaceSnapshotRefreshAtomFamily({
providers: serverEnvironment.providersValueAtom,
refreshProviders: serverEnvironment.refreshProviders,
});
const idleWorkspaceSnapshotRefreshAtom: Atom.Atom<unknown> = Atom.make<void>(undefined).pipe(
Atom.withLabel("mobile:provider-workspace-snapshot-refresh:idle"),
);
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,9 @@
import { createProviderWorkspaceSnapshotRefreshAtomFamily } from "@t3tools/client-runtime/providerSkills";
import { serverEnvironment } from "./server";
/** Shared by the composer and the model picker so one cwd scans once. */
export const providerWorkspaceSnapshotRefresh = createProviderWorkspaceSnapshotRefreshAtomFamily({
providers: serverEnvironment.providersValueAtom,
refreshProviders: serverEnvironment.refreshProviders,
});
Original file line number
Diff line number
Diff line change
Expand Up
@@ -430,54 +430,7 @@ it.layer(
});
describe("ProviderRegistry.layer", () => {
it("keeps a workspace's own models on its wire snapshot until a read replaces them", () => {
const machineModel = {
slug: "opencode/big-pickle",
name: "Big Pickle",
isCustom: false,
capabilities: null,
} satisfies ServerProvider["models"][number];
const projectModel = { ...machineModel, slug: "uni/medium-gpt", name: "Medium GPT" };
const provider = {
instanceId: ProviderInstanceId.make("opencode"),
driver: ProviderDriverKind.make("opencode"),
status: "ready",
enabled: true,
installed: true,
auth: { status: "authenticated" },
checkedAt: "2026-03-25T00:00:00.000Z",
version: "2.0.0",
models: [machineModel],
slashCommands: [],
skills: [],
} satisfies ServerProvider;
const workspaceModels = [machineModel, projectModel];
const result = ProviderRegistry.upsertProviderWorkspaceSnapshot(provider, "/project", {
...provider,
models: workspaceModels,
workspaceModels,
});
assert.strictEqual(result.models, provider.models);
const decoded = decodeServerProvider(encodeServerProvider(result));
assert.deepStrictEqual(decoded.workspaceSnapshots?.[0]?.models, workspaceModels);
const unread = ProviderRegistry.upsertProviderWorkspaceSnapshot(result, "/project", {
...provider,
workspaceModelsPending: true,
});
assert.deepStrictEqual(unread.workspaceSnapshots?.[0]?.models, workspaceModels);
const removed = ProviderRegistry.upsertProviderWorkspaceSnapshot(
unread,
"/project",
provider,
);
assert.strictEqual(removed.workspaceSnapshots?.[0]?.models, undefined);
});
it("drops folder catalogs when a machine refresh changes the machine models", () => {
it("marks folder catalogs pending when a machine refresh changes the machine models", () => {
const machineModel = {
slug: "opencode/big-pickle",
name: "Big Pickle",
Expand Down
Expand Up
@@ -518,8 +471,15 @@ it.layer(
models: [machineModel, addedModel],
});
assert.deepStrictEqual(
changed.workspaceSnapshots?.map((snapshot) => snapshot.cwd),
["/plain"],
changed.workspaceSnapshots?.map(({ cwd, models, modelsPending }) => ({
cwd,
models,
modelsPending,
})),
[
{ cwd: "/project", models: [machineModel, projectModel], modelsPending: true },
{ cwd: "/plain", models: undefined, modelsPending: undefined },
],
);
});
Expand All
@@ -537,11 +497,15 @@ it.layer(
slashCommands: [{ name: "global" }],
skills: [{ name: "global", path: "/global/SKILL.md", enabled: true }],
} satisfies ServerProvider;
const projectModels = [
{ slug: "project-model", name: "Project Model", isCustom: false, capabilities: null },
] satisfies ServerProvider["models"];
const scopedSnapshot = {
...provider,
checkedAt: "2026-03-25T00:01:00.000Z",
slashCommands: [{ name: "project" }],
skills: [{ name: "project", path: "/project/SKILL.md", enabled: true }],
workspaceModels: projectModels,
optionDescriptors: [
{
id: "agent",
Expand Down
Expand Up
@@ -569,13 +533,15 @@ it.layer(
slashCommands: scopedSnapshot.slashCommands,
skills: scopedSnapshot.skills,
optionDescriptors: scopedSnapshot.optionDescriptors,
models: projectModels,
},
]);
const pendingSnapshot = {
...scopedSnapshot,
slashCommands: [COMPACT_SLASH_COMMAND],
slashCommandsPending: true,
workspaceModelsPending: true,
} satisfies ProviderWorkspaceSnapshot;
const partial = ProviderRegistry.upsertProviderWorkspaceSnapshot(
result,
Expand All
@@ -584,6 +550,8 @@ it.layer(
);
assert.deepStrictEqual(partial.workspaceSnapshots?.[0]?.slashCommands, [{ name: "project" }]);
assert.strictEqual(partial.workspaceSnapshots?.[0]?.slashCommandsPending, true);
assert.deepStrictEqual(partial.workspaceSnapshots?.[0]?.models, projectModels);
assert.strictEqual(partial.workspaceSnapshots?.[0]?.modelsPending, true);
const otherProject = ProviderRegistry.upsertProviderWorkspaceSnapshot(
partial,
"/other-project",
Expand All
@@ -601,6 +569,14 @@ it.layer(
{ name: "replacement" },
]);
assert.strictEqual(recovered.workspaceSnapshots?.[0]?.slashCommandsPending, undefined);
assert.deepStrictEqual(recovered.workspaceSnapshots?.[0]?.models, projectModels);
assert.strictEqual(recovered.workspaceSnapshots?.[0]?.modelsPending, undefined);
const withoutModels = ProviderRegistry.upsertProviderWorkspaceSnapshot(
recovered,
"/project",
{ ...scopedSnapshot, workspaceModels: undefined },
);
assert.strictEqual(withoutModels.workspaceSnapshots?.[0]?.models, undefined);
const { optionDescriptors, ...failedSnapshot } = scopedSnapshot;
const firstFailure = ProviderRegistry.upsertProviderWorkspaceSnapshot(
Expand Down
Expand Up
@@ -1632,6 +1608,7 @@ it.layer(
slashCommands: [],
skills: [],
} as const satisfies ServerProvider;
const machineProvider = yield* Ref.make<ServerProvider>(provider);
const scanResult = yield* Ref.make<ProviderWorkspaceSnapshot>({
...provider,
slashCommandsPending: false,
Expand All
@@ -1654,8 +1631,8 @@ it.layer(
packageName: null,
}),
),
getSnapshot: Effect.succeed(provider ),
refresh: Effect.succeed(provider ),
getSnapshot: Ref.get(machineProvider ),
refresh: Ref.get(machineProvider ),
streamChanges: Stream.empty,
applyUsageLimits: () => Effect.void,
},
Expand Down
Expand Up
@@ -1706,6 +1683,27 @@ it.layer(
const recovered = yield* workspaceOf;
assert.deepStrictEqual(recovered?.models, workspaceModels);
assert.strictEqual(recovered?.modelsPending, undefined);
// A fresh refresh whose machine models change still publishes the folder read it ran.
const addedModel = { ...machineModel, slug: "opencode/new", name: "New" };
const nextWorkspaceModels = [machineModel, addedModel, projectModel];
yield* Ref.set(machineProvider, { ...provider, models: [machineModel, addedModel] });
yield* Ref.set(scanResult, {
...provider,
slashCommandsPending: false,
workspaceModels: nextWorkspaceModels,
});
yield* registry.refreshWorkspaceSnapshot({ instanceId, cwd: "/project", fresh: true });
const rescanned = yield* workspaceOf;
assert.deepStrictEqual(rescanned?.models, nextWorkspaceModels);
assert.strictEqual(rescanned?.modelsPending, undefined);
// A machine change alone keeps the folder's models until its next read settles.
yield* Ref.set(machineProvider, provider);
yield* registry.refreshInstance(instanceId);
const stale = yield* workspaceOf;
assert.deepStrictEqual(stale?.models, nextWorkspaceModels);
assert.strictEqual(stale?.modelsPending, true);
}).pipe(Effect.provide(runtimeServices));
}),
);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -283,7 +283,9 @@ export const mergeProviderSnapshot = (
// A folder's own catalog was read against the old machine catalog, so it rescans.
const previousWorkspaceSnapshots = Equal.equals(models, previousProvider.models)
? previousProvider.workspaceSnapshots
: previousProvider.workspaceSnapshots?.filter((snapshot) => snapshot.models === undefined);
: previousProvider.workspaceSnapshots?.map((snapshot) =>
snapshot.models === undefined ? snapshot : { ...snapshot, modelsPending: true },
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
);
return {
...(savedAccount?.status === "ready" ? nextWithoutMessage : nextProvider),
...savedAccount,
Expand Down
Expand Up
@@ -959,17 +961,27 @@ export const layer = Layer.effect(
// Use scan start for TTL, not checkedAt inherited from the machine health check.
const scannedAt = DateTime.formatIso(now);
const instance = yield* instanceRegistry.getInstance(input.instanceId);
if (!instance?.snapshotForCwd) return providers;
const snapshotForCwd = instance?.snapshotForCwd;
if (!instance || !snapshotForCwd) return providers;
const token = yield* Deferred.make<void>();
// A machine refresh can change this cwd's snapshot, so the scan publishes against the result.
const refreshMachineSnapshot = input.fresh
? (instance.invalidateCaches ?? Effect.void).pipe(
Effect.andThen(refreshInstance(input.instanceId)),
Effect.andThen(Ref.get(providersRef)),
Effect.map((current) =>
workspaceSnapshotOf(
current.find((candidate) => candidate.instanceId === input.instanceId),
),
),
)
: Effect.void ;
: Effect.succeed(scannedFrom) ;
const runScan = refreshMachineSnapshot.pipe(
Effect.andThen(instance.snapshotForCwd(input.cwd)),
Effect.flatMap((scanBase) =>
Effect.map(snapshotForCwd(input.cwd), (scopedSnapshot) => ({ scanBase, scopedSnapshot })),
),
// Scans fail on error; returned inventory remains valid even when provider health reports an error.
Effect.flatMap((scopedSnapshot) =>
Effect.flatMap(({ scanBase, scopedSnapshot } ) =>
instanceRegistry.getInstance(input.instanceId).pipe(
Effect.flatMap((currentInstance) => {
if (currentInstance !== instance) return Ref.get(providersRef);
Expand All
@@ -980,7 +992,7 @@ export const layer = Layer.effect(
}
return currentProviders.map((candidate) =>
candidate.instanceId === input.instanceId &&
Equal.equals(workspaceSnapshotOf(candidate), scannedFrom )
Equal.equals(workspaceSnapshotOf(candidate), scanBase )
? upsertProviderWorkspaceSnapshot(candidate, input.cwd, {
...scopedSnapshot,
checkedAt: scannedAt,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -244,11 +244,13 @@ const loadOpenCodeAgents = (client: OpencodeClient) =>
);
/** The providers and agents OpenCode resolves for the client's directory. Fails if either read does. */
export const loadOpenCodeProviderCatalog = (client: OpencodeClient) =>
Effect.all(
{ providerList: loadOpenCodeProviders(client), agents: loadOpenCodeAgents(client) },
{ concurrency: "unbounded" },
);
export const loadOpenCodeProviderCatalog = Effect.fn("OpenCodeRuntime.loadOpenCodeProviderCatalog")(
(client: OpencodeClient) =>
Effect.all(
{ providerList: loadOpenCodeProviders(client), agents: loadOpenCodeAgents(client) },
{ concurrency: "unbounded" },
),
);
export interface ParsedOpenCodeModelSlug {
readonly providerID: string;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -57,5 +57,8 @@ export const loadOpenCode2Catalog = (client: OpenCodeClient, directory: string)
);
/** Missing provider names would relabel every model, so a directory read needs them. */
export const loadOpenCode2DirectoryCatalog = (client: OpenCodeClient, directory: string) =>
readCatalog(client, directory, listProviders(client, directory));
export const loadOpenCode2DirectoryCatalog = Effect.fn(
"OpenCodeRuntime.loadOpenCode2DirectoryCatalog",
)((client: OpenCodeClient, directory: string) =>
readCatalog(client, directory, listProviders(client, directory)),
);
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.