You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tui: /models shows only "Free models" on 2.4.1 with connected integrations and a paid model active #66112
Still reproduces on 2.4.1, which includes the #65793 fix. Unlike #65802 / #65812, the providers here are connected through /connect with credentials, not declared only in config, so this case should already be covered by #65793.
On 2.4.1 the /models dialog still opens the "Free models" page ("Connect a provider for access to more models") even though:
the active session model is a paid model (opencode/gemini-4-hydrogen),
the providers are connected via /connect (opencode oauth "Personal" + API key; deepseek key; siliconflow-cn key),
the server returns the full catalog for the same location.
F2 (model.cycle_recent) and the current session model work, so only the dialog is gated.
Same location (~/Documents/test-b, the "Directory listing" session in the screenshot), server data:
In 2.4.1 the dialog chooses between the normal picker and the free-models fallback with the connected-provider check (hasConnectedProvider / useConnected, changed in #65793). That check should be true when any integration has a connection, or when a non-opencode provider in the provider list has a non-deprecated model. Both hold here, yet the dialog still takes the free-models branch, so the check appears to run against empty lists in the TUI even though the same server returns them.
Still reproduces after closing and reopening /models; the screenshot was taken after a fresh TUI start on 2.4.1.
OpenCode version
2.4.1
Steps to reproduce
Connect providers via /connect (opencode account + API key, deepseek key, siliconflow key).
Use a session in a directory where those providers resolve.
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I could reproduce this on 2.4.1, and it still happens on the latest dev (4bb997e).
What I did, using a test driver with a simulated provider declared in config in place of your /connect integrations (I have no real provider accounts here):
Started the TUI in a project root. /models showed the normal picker with the provider's model.
Created a session whose directory is a sub-folder of that project (packages/b).
Started the TUI from the project root directly into that session (--session <id>) and ran /models.
The dialog opened on Free models · Connect a provider for access to more models ("No items available"). At the same moment the server listed the provider and its model for that directory, and for the launch directory too. The recording and screenshots below show it, and the script below reproduces it.
This matches your guess that the lists the dialog checks are not scoped to the session's directory: the check for whether a provider is connected reads the lists of the directory the TUI was started in, which are not loaded when the TUI opens straight into a session elsewhere. This is my reading of the code, not a confirmed fix. As a possible workaround, starting opencode in the session's own directory should give the normal picker, since that was the case that worked here. I've passed the details to the maintainers.
This is a different cause from the config-only provider case in #60587, which #65793 fixed.
// Repro for anomalyco/opencode#66112: /models opens the "Free models" page when the TUI starts// directly in a session whose directory differs from the directory the TUI was launched in.//// The wrapper written below runs `opencode` (or the checkout in $OC_DEV) and appends// `--session <id>` to TUIs launched after the id file is written, like `opencode -s <id>`.import{writeFileSync,rmSync,mkdirSync,chmodSync}from"node:fs"import{Effect}from"effect"import{OpenCodeDriver}from"opencode-drive"constSID_FILE="/tmp/opencode/tmp/repro-sid"constWRAPPER="/tmp/opencode/tmp/oc-wrapper.sh"mkdirSync("/tmp/opencode/tmp",{recursive: true})rmSync(SID_FILE,{force: true})writeFileSync(WRAPPER,"#!/bin/sh\n# Launch opencode; TUIs started with --server get `--session <id>` appended once the id file exists.\nSID_FILE=/tmp/opencode/tmp/repro-sid\nif [ -n \"$OC_DEV\" ]; then\n set -- bun --conditions=browser --preload=\"$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js\" \"$OC_DEV/packages/cli/src/index.ts\" \"$@\"\nelse\n set -- opencode \"$@\"\nfi\ncase \" $* \" in\n *\" --server \"*) if [ -s \"$SID_FILE\" ]; then set -- \"$@\" --session \"$(cat \"$SID_FILE\")\"; fi ;;\nesac\nexec \"$@\"\n")chmodSync(WRAPPER,0o755)exportdefaultOpenCodeDriver.use({opencode: {command: [WRAPPER],env: process.env.OC_DEV ? {OC_DEV: process.env.OC_DEV} : {},},project: {git: true,files: {"README.md": "project A\n","packages/b/README.md": "sub-folder B\n"}},tui: {viewport: {cols: 120,rows: 36}},},({ ui, opencode, tuis })=>Effect.gen(function*(){// 1. Primary TUI, launched in project A: /models lists the connected (config) provider.yield*Effect.sleep(3000)yield*ui.submit("/models")yield*Effect.sleep(1500)yield*ui.screenshot("A-models-in-launch-dir")yield*ui.press("escape")// 2. A session that lives in another directory: the sub-folder packages/b of the same project.constmodelsA: any=yield*((opencodeasany).model.list({})asEffect.Effect<any>)constOTHER_DIR=`${modelsA.location.directory}/packages/b`constsession: any=yield*((opencodeasany).session.create({location: {directory: OTHER_DIR}})asEffect.Effect<any>)yield*Effect.log(`session ${session.id} in ${JSON.stringify(session.location)}`)writeFileSync(SID_FILE,session.id)yield*Effect.log(`server models for launch dir: ${JSON.stringify((modelsA.data??[]).map((m: any)=>`${m.providerID}/${m.id}`))}`)// 3. A TUI started from project A with `--session <id>` (like `opencode -s <id>`), then /models.constsecond=yield*tuis.launch("resumed",{recording: true,viewport: {cols: 120,rows: 36}})yield*Effect.sleep(4000)yield*second.ui.screenshot("B-session-home")yield*second.ui.submit("/models")yield*Effect.sleep(2000)yield*second.ui.screenshot("B-models-in-session")// The server lists a provider and a non-free model for the session's directory.constmodelsB2: any=yield*((opencodeasany).model.list({location: {directory: OTHER_DIR}})asEffect.Effect<any>)yield*Effect.log(`server models for ${OTHER_DIR} while /models is open: ${JSON.stringify((modelsB2.data??[]).map((m: any)=>`${m.providerID}/${m.id}`))}`)constprovidersB: any=yield*((opencodeasany).provider.list({location: {directory: OTHER_DIR}})asEffect.Effect<any>)yield*Effect.log(`server providers for ${OTHER_DIR}: ${JSON.stringify((providersB.data??[]).map((p: any)=>p.id))}`)yield*Effect.sleep(1000)}),)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
Thanks for the reproduction and the workaround. If the direction is confirmed (scope the connected check to the session location), I'd like to take this and open a PR against dev with a regression test for the parent-directory -> subfolder-session case.
Confirming the same failure on 2.4.1 (macOS 26, arm64, Ghostty), with som additional data points.
First: it reproduces when the TUI's launch directory is the session directory, so starting opencode in the session's own directory did not help here — though every failing observation was a session resumed with -s <id> --standalone, not a fresh one.
Second: the setup is one config-declared openai-compatible provider in the native V2 shape (providers block, settings.apiKey: "{env:...}".
Server data: GET /api/model returns the provider's models with enabled: true, status: "active", GET /api/provider lists the provider with activation: "enabled", and opencode models lists everything. opencode run -m provider/model works.
Two details:
The full list only ever appears immediately after /connect — in dialog-model.tsx that flow re-opens the dialog via onConnected={(providerID) => dialog.replace(() => <DialogModel providerID={providerID} />)}, so the dialog renders with an explicit providerID and the useConnected() gate is never consulted. Reopening /models without that prop recomputes the gate and shows the Free models page again. So "connect, then it works" is the bypass, not the check passing.
In v2.4.1 and current dev, useConnected() (packages/tui/src/component/use-connected.tsx) calls data.location.integration.list(), data.location.provider.list() and data.location.model.list() with no location argument, while the dialogs read the provider and model lists scoped to the session (data.location.{provider,model}.list(location.ref)). Per @opencode/client/solid/data.ts, a no-argument list() keys on the default location, so the gate and the dialogs only read the same entries when the session's ref matches the launch-directory default — the Free page rendering from the scoped list while the gate fails shows the two diverge in this session. That is the same reading as above, at the level of specific calls.
experimental: { "new-designs": false } restores the full dialog as a workaround.
Another case of the same cause, on 2.4.1 (Linux): a remote TUI, opencode --server <url> --session <id>, connected to a service on another machine.
In this setup the suggested workaround (start the TUI in the session's own directory) is not possible, because that directory only exists on the server host. So every remote session hits the "Free models" page, while a TUI on the server host itself shows the normal picker for the same session.
What I see in the 2.4.1 client:
The default location is the client's local process.cwd().
When the session location differs, the location provider syncs only the session location (S = same ? undefined : y → location.sync(S)), so lists for the default location are never loaded.
The connected check used by /models (nq({ integrations: location.integration.list(), providers: location.provider.list(), models: location.model.list() })) reads the default location with no ref, so it sees empty lists. Meanwhile the free-models list itself reads location.model.list(ref) for the session, which is why paid models with zero cost (subscriptions) still appear on that page.
Server side is fine. For the session directory, GET /api/integration?location[directory]=… shows 10 connected integrations and /api/provider returns 10 providers. For a client cwd that doesn't exist on the server, the same calls return 404 LocationNotFoundError.
Verified on the remote host, same session and same binary:
client cwd /tmp: "Free models"
client cwd = an empty local directory with the same path as the session's server directory: normal picker
That empty mirror directory is the workaround we use until the check is scoped to the session location (ref), as proposed above.
Activity
opencodejr commentedon Nov 24, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I could reproduce this on 2.4.1, and it still happens on the latest
dev(4bb997e).What I did, using a test driver with a simulated provider declared in config in place of your
/connectintegrations (I have no real provider accounts here):/modelsshowed the normal picker with the provider's model.packages/b).--session <id>) and ran/models.The dialog opened on Free models · Connect a provider for access to more models ("No items available"). At the same moment the server listed the provider and its model for that directory, and for the launch directory too. The recording and screenshots below show it, and the script below reproduces it.
This matches your guess that the lists the dialog checks are not scoped to the session's directory: the check for whether a provider is connected reads the lists of the directory the TUI was started in, which are not loaded when the TUI opens straight into a session elsewhere. This is my reading of the code, not a confirmed fix. As a possible workaround, starting
opencodein the session's own directory should give the normal picker, since that was the case that worked here. I've passed the details to the maintainers.This is a different cause from the config-only provider case in #60587, which #65793 fixed.
https://anoma.ly/team/github-bot/media/9b36b024e59fe035bb2f6464298a0aee8e0304e61548a5735195e8ba039e9a80.mp4
Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.rplague commentedon Nov 24, 2026
Thanks for the reproduction and the workaround. If the direction is confirmed (scope the connected check to the session location), I'd like to take this and open a PR against dev with a regression test for the parent-directory -> subfolder-session case.
ned9 commentedon Nov 24, 2026
Confirming the same failure on 2.4.1 (macOS 26, arm64, Ghostty), with som additional data points.
First: it reproduces when the TUI's launch directory is the session directory, so starting opencode in the session's own directory did not help here — though every failing observation was a session resumed with
-s <id> --standalone, not a fresh one.Second: the setup is one config-declared openai-compatible provider in the native V2 shape (
providersblock,settings.apiKey: "{env:...}".Server data:
GET /api/modelreturns the provider's models withenabled: true, status: "active",GET /api/providerlists the provider withactivation: "enabled", andopencode modelslists everything.opencode run -m provider/modelworks.Two details:
The full list only ever appears immediately after
/connect— indialog-model.tsxthat flow re-opens the dialog viaonConnected={(providerID) => dialog.replace(() => <DialogModel providerID={providerID} />)}, so the dialog renders with an explicitproviderIDand theuseConnected()gate is never consulted. Reopening/modelswithout that prop recomputes the gate and shows the Free models page again. So "connect, then it works" is the bypass, not the check passing.In v2.4.1 and current
dev,useConnected()(packages/tui/src/component/use-connected.tsx) callsdata.location.integration.list(),data.location.provider.list()anddata.location.model.list()with no location argument, while the dialogs read the provider and model lists scoped to the session (data.location.{provider,model}.list(location.ref)). Per@opencode/client/solid/data.ts, a no-argumentlist()keys on the default location, so the gate and the dialogs only read the same entries when the session's ref matches the launch-directory default — the Free page rendering from the scoped list while the gate fails shows the two diverge in this session. That is the same reading as above, at the level of specific calls.experimental: { "new-designs": false }restores the full dialog as a workaround.alessai commentedon Nov 25, 2026
Another case of the same cause, on 2.4.1 (Linux): a remote TUI,
opencode --server <url> --session <id>, connected to a service on another machine.In this setup the suggested workaround (start the TUI in the session's own directory) is not possible, because that directory only exists on the server host. So every remote session hits the "Free models" page, while a TUI on the server host itself shows the normal picker for the same session.
What I see in the 2.4.1 client:
process.cwd().S = same ? undefined : y→location.sync(S)), so lists for the default location are never loaded./models(nq({ integrations: location.integration.list(), providers: location.provider.list(), models: location.model.list() })) reads the default location with no ref, so it sees empty lists. Meanwhile the free-models list itself readslocation.model.list(ref)for the session, which is why paid models with zero cost (subscriptions) still appear on that page.Server side is fine. For the session directory,
GET /api/integration?location[directory]=…shows 10 connected integrations and/api/providerreturns 10 providers. For a client cwd that doesn't exist on the server, the same calls return404 LocationNotFoundError.Verified on the remote host, same session and same binary:
/tmp: "Free models"That empty mirror directory is the workaround we use until the check is scoped to the session location (
ref), as proposed above.