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: closing a session repeatedly opens an empty "New session" tab #64236
In the TUI (v2.3.0), closing open sessions frequently opens/leaves an empty New session tab active, requiring the user to repeatedly close empty new-session tabs. No empty session rows are persisted in opencode.db (session_v2), so this is client-side TUI tab/route behavior (home / New session slot).
Active plugins: ~/.config/opencode/plugins/alice-and-bot/index.js (verified it does not call TUI tab/route navigation)
Reproduction
Run opencode TUI inside tmux with multiple open session tabs (default horizontal tab strip, cwd scope, ~15 open tabs).
Close open session tabs.
Observe an empty New session tab opening in the tab strip / switching view to an empty session.
Expected Behavior
Closing a session tab when other session tabs remain open should focus an existing neighboring/previous session tab without opening an empty New session tab.
Actual Behavior
Empty New session tabs open repeatedly and have to be manually closed.
Additional Context
Verified against ~/.local/share/opencode/opencode.db (session_v2 table): zero 0-message sessions are created on the server, confirming this is the TUI New session (home route) tab state.
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced this on 2.3.0 in one specific setup: two TUIs open in the same directory. It still happens on the latest dev (e460646).
With the default tabs.scope: "cwd", the tab list is shared by every TUI in that directory. What I did:
In TUI A, create several sessions.
In TUI B (same directory), switch to one of them.
In TUI A, close that same session's tab. B keeps showing the session, but its tab is gone from the strip.
In TUI B, press ctrl+x w. B lands on the empty + New session screen even though 4 session tabs are still open. Closing that empty tab then moves to a real session.
With a single TUI I could not reproduce it: closing tabs with ctrl+x w or by clicking the ✕ always focused a neighbouring tab. If you usually have more than one opencode TUI open in the same project (for example in several tmux panes), this is very likely what you're hitting. If you see it with only one TUI open, please describe the steps.
The recording and screenshots below show TUI B during the reproduction. A simulated model supplied the chat replies, which have no effect on how tabs close. The script below reproduces it.
recording.mp4
Reproduction script (drive.ts)
import{Effect,Stream}from"effect"import{Llm,OpenCodeDriver}from"opencode-drive"constN=5constrow=(f: any,r: number)=>f.lines[r].spans.map((s: any)=>s.text).join("")exportdefaultOpenCodeDriver.use({
...(process.env.OC_DEV ? {opencode: {dev: process.env.OC_DEV}} : {}),tui: {recording: true,keypressOverlay: true},tuiConfig: {tabs: {layout: "horizontal",scope: "cwd"}}asany,project: {git: true,files: {"README.md": "hi\n"}},},(oc)=>Effect.gen(function*(){const{ ui, llm }=ocyield*llm.serve((_req,i)=>Stream.make(Llm.text(`Reply ${i+1}`)))for(leti=1;i<=N;i++){if(i>1){yield*ui.press("x",{ctrl: true})yield*ui.press("n")yield*Effect.sleep(500)}yield*ui.submit(`Task number ${i}`)yield*ui.waitFor(`Task number ${i}`)yield*Effect.sleep(1200)}constb=yield*oc.tuis.launch({recording: true,keypressOverlay: true}asany)yield*Effect.sleep(2500)yield*Effect.log(`B start: [${row(yield*b.ui.capture(),0)}] ${row(yield*b.ui.capture(),3).trim()}`)yield*b.ui.press("x",{ctrl: true})yield*b.ui.press("2")yield*Effect.sleep(1000)yield*Effect.log(`B on 2: [${row(yield*b.ui.capture(),0)}] ${row(yield*b.ui.capture(),3).trim()}`)yield*b.ui.screenshot("B-on-2")// TUI A: switch to the same session (tab 2) and close its tab there.yield*ui.press("x",{ctrl: true})yield*ui.press("2")yield*Effect.sleep(1000)yield*ui.press("x",{ctrl: true})yield*ui.press("w")yield*Effect.sleep(1500)constfa=yield*ui.capture()constfb0=yield*b.ui.capture()yield*Effect.log(`A closed tab 2: A=[${row(fa,0)}] ${row(fa,3).trim()} || B=[${row(fb0,0)}] ${row(fb0,3).trim()}`)yield*ui.screenshot("A-closed-tab-2")yield*b.ui.screenshot("B-after-A-closed-tab-2")// TUI B: close its current tab while 4 other tabs are still open.for(leti=0;i<3;i++){yield*b.ui.press("x",{ctrl: true})yield*b.ui.press("w")yield*Effect.sleep(1500)constfb=yield*b.ui.capture()yield*Effect.log(`B close ${i+1}: B=[${row(fb,0)}] ${row(fb,3).trim()} | ${row(fb,20).trim()}`)yield*b.ui.screenshot(`B-close-${i+1}`)}}),)
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.
The tab strip is shared per cwd, so when another TUI closes the tab, this client's route still points at the session but its tab is gone. Closing it then finds no tab index to move from — closeSessionTab returns no next, and the navigation history has no earlier open tab — so the route falls back to home, which is the empty "New session" screen.
I'll send a fix that picks a remaining tab in that case instead of home.
Activity
opencodejr commentedon Nov 16, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced this on 2.3.0 in one specific setup: two TUIs open in the same directory. It still happens on the latest
dev(e460646).With the default
tabs.scope: "cwd", the tab list is shared by every TUI in that directory. What I did:ctrl+x w. B lands on the empty+ New sessionscreen even though 4 session tabs are still open. Closing that empty tab then moves to a real session.With a single TUI I could not reproduce it: closing tabs with
ctrl+x wor by clicking the ✕ always focused a neighbouring tab. If you usually have more than oneopencodeTUI open in the same project (for example in several tmux panes), this is very likely what you're hitting. If you see it with only one TUI open, please describe the steps.The recording and screenshots below show TUI B during the reproduction. A simulated model supplied the chat replies, which have no effect on how tabs close. The script below reproduces it.
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.ccclucky commentedon Nov 16, 2026
I'll take this one.
The tab strip is shared per
cwd, so when another TUI closes the tab, this client's route still points at the session but its tab is gone. Closing it then finds no tab index to move from —closeSessionTabreturns nonext, and the navigation history has no earlier open tab — so the route falls back tohome, which is the empty "New session" screen.I'll send a fix that picks a remaining tab in that case instead of home.