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 drops provider grouping when the session location differs from the default location #62105
When the TUI opens a session whose directory is not the client's default location, /models shows one flat list without provider groups, Favorites or Recent, and its action reads "View all integrations" as if nothing were connected. The integrations dialog in the same session shows the providers as connected.
useConnected() in packages/tui/src/component/use-connected.tsx calls data.location.integration.list() without a location, so it reads the default location's store. LocationProvider only syncs the active location, so when the two differ that store stays empty and useConnected() returns false. The model dialog and the integrations dialog already pass the active location (location.ref); useConnected() doesn't.
I hit it with --server against a remote service: the client's cwd doesn't exist on the server, so the default location falls back to the server's cwd while the session lives in a project directory. The same happens locally with -s <session> for a session in another directory.
Plugins
None needed to reproduce.
OpenCode version
2.2.1 (still present on dev)
Steps to reproduce
Connect any provider, e.g. Anthropic.
Start the service from one directory (cd ~ && opencode service start).
Create a session in a different directory via POST /api/session with {"location":{"directory":"/path/to/project"}}.
From a directory that isn't that project (or from another machine with --server), run opencode -s <session-id>.
Open /models: flat list, "View all integrations". Open the integrations dialog: providers show as connected.
Screenshot
Not attached; /models renders a single flat list with "View all integrations" as its action.
Operating System
Linux (NixOS / Ubuntu)
Terminal
Reproduces independent of terminal (state bug, not rendering).
Thanks for the precise steps and root-cause analysis. I could reproduce this on 2.2.1.
What I did:
Connected a provider (the test harness's simulated provider, connected with an API key).
Created a session through POST /api/session with location.directory set to a directory other than the TUI's cwd.
Opened it with --server <url> -s <session id> from the original directory.
Opened /models.
The result was one flat list with no provider header, no Favorite action and "View all integrations" as the action. A TUI whose session is in its own directory, on the same service, shows the provider group, "Connect an integration" and "Favorite". The first screenshot below shows that baseline, the second shows the problem, and the recording and script below cover the whole run.
It still happens on the latest dev (187486e), where useConnected() still calls data.location.integration.list() without the active location.
Related:
tui: /model search no longer matches provider names #60851: same root cause; it showed up as searching by provider name in /models no longer matching. It was closed because it couldn't be reproduced, and your steps show the trigger.
// Repro for #62105: /models loses provider groups when the TUI opens a session// whose directory differs from the TUI's default location.// Drive launches OpenCode through a small wrapper that appends `-s <session>` to the// second TUI, i.e. `opencode -s <id>` run from a directory other than the session's.// OC_DEV=/path/to/checkout runs the CLI from source instead of `opencode2` on PATH.import{Effect}from"effect"import{OpenCodeDriver}from"opencode-drive"import{mkdirSync,writeFileSync,rmSync,readFileSync,readdirSync}from"node:fs"import{join}from"node:path"constSESS="/tmp/opencode/repro-session"constOTHER="/tmp/opencode/otherproj"constWRAPPER="/tmp/opencode/opencode-wrapper.sh"constREAL=process.env.OC_DEV
? `${process.execPath} --conditions=browser --preload=${process.env.OC_DEV}/packages/tui/node_modules/@opentui/solid/scripts/preload.js ${process.env.OC_DEV}/packages/cli/src/index.ts`
: "opencode2"mkdirSync("/tmp/opencode",{recursive: true})writeFileSync(WRAPPER,`#!/bin/shcase " $* " in *" --server "*) if [ -s ${SESS} ]; then exec ${REAL} "$@" -s "$(cat ${SESS})"; fi ;;esacexec ${REAL} "$@"`,{mode: 0o755},)rmSync(SESS,{force: true})exportdefaultOpenCodeDriver.use({opencode: {command: [WRAPPER]},project: {git: true,files: {"README.md": "project\n"}},},({ tuis, artifacts,ui: primary})=>Effect.gen(function*(){mkdirSync(OTHER,{recursive: true})// service endpoint registered by the isolated OpenCode serviceconstdir=join(artifacts,"home/.local/state/opencode")constreg=JSON.parse(readFileSync(join(dir,readdirSync(dir).find((f)=>/^service.*\.json$/.test(f))!),"utf8"))constapi=(path: string,init: RequestInit={})=>Effect.promise(async()=>{constres=awaitfetch(newURL(path,reg.url),{
...init,headers: {"content-type": "application/json","x-opencode-directory": encodeURIComponent(join(artifacts,"files")),
...(reg.password ? {authorization: "Basic "+btoa(`${reg.username??"opencode"}:${reg.password}`)} : {}),},})consttext=awaitres.text()return{status: res.status, text }})yield*Effect.log(JSON.stringify(reg))constints=yield*api("/api/integration")yield*Effect.log(ints.status+" "+JSON.stringify(JSON.parse(ints.text).data.map((i: any)=>[i.id,i.connections.length,i.methods.map((m: any)=>m.type).join("/")])))if(process.env.SKIP)return// 1. connect a provider with a (fake) API keyyield*Effect.log(JSON.stringify(yield*api(`/api/integration/${process.env.INTEGRATION??"simulation"}/connect/key`,{method: "POST",body: JSON.stringify({key: "sk-fake"})})))// baseline: the primary TUI (session in its own default location) shows grouped /modelsyield*Effect.sleep(1500)yield*primary.type("/models")yield*Effect.sleep(800)yield*primary.enter()yield*Effect.sleep(2500)yield*primary.screenshot("baseline-models-default-location")yield*primary.press("escape")// 2. create a session in a different directoryconstcreated=yield*api("/api/session",{method: "POST",body: JSON.stringify({location: {directory: OTHER}})})yield*Effect.log(created.text)constsession=JSON.parse(created.text).datawriteFileSync(SESS,session.id)yield*Effect.log(`session ${session.id} in ${OTHER}`)// 3. open a TUI on that session (`opencode -s <id>` from the project dir)constt=yield*tuis.launch({recording: true,keypressOverlay: true})constui=t.uiyield*Effect.sleep(3000)yield*t.recording!.mark("TUI opened with -s <session in another directory>")yield*ui.screenshot("session")// 4. /modelsyield*t.recording!.mark("/models")yield*ui.type("/models")yield*Effect.sleep(800)yield*ui.enter()yield*Effect.sleep(2500)yield*ui.screenshot("models")yield*ui.press("escape")yield*Effect.sleep(800)// 5. integrations dialog for comparisonyield*t.recording!.mark("integrations dialog")yield*ui.type("/connect")yield*Effect.sleep(800)yield*ui.enter()yield*Effect.sleep(2500)yield*ui.screenshot("integrations")yield*ui.press("escape")yield*Effect.sleep(500)}),)
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.
Activity
opencodejr commentedon Nov 5, 2026
Thanks for the precise steps and root-cause analysis. I could reproduce this on 2.2.1.
What I did:
POST /api/sessionwithlocation.directoryset to a directory other than the TUI's cwd.--server <url> -s <session id>from the original directory./models.The result was one flat list with no provider header, no Favorite action and "View all integrations" as the action. A TUI whose session is in its own directory, on the same service, shows the provider group, "Connect an integration" and "Favorite". The first screenshot below shows that baseline, the second shows the problem, and the recording and script below cover the whole run.
It still happens on the latest
dev(187486e), whereuseConnected()still callsdata.location.integration.list()without the active location.Related:
/modelsno longer matching. It was closed because it couldn't be reproduced, and your steps show the trigger.useConnected()read the current location.recording.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.