opencode icon indicating copy to clipboard operation
opencode copied to clipboard

tui: `tabs.mode: auto` misses Herdr.app / herdr-core panes (no `HERDR_ENV`)

Open nxxxsooo opened this issue 1 week ago • 3 comments

Summary

tabs.mode defaults to auto (#50456), which hides session tabs when HERDR_ENV=1. That covers the herdr TUI (herdr server). It does not cover Herdr's GUI, Herdr.app (dev.herdr.app). The GUI runs panes on herdr-core, and those panes get HC_TERMINAL_ID, HC_SOCKET and HC_SESSION instead. HERDR_ENV is never set. So inside the GUI, OpenCode shows its own tab rail on top of Herdr's tabs.

The same gap applies to the environment-aware defaults built on that check: mouse, and animations in #60111.

Environment

  • opencode version: 2.4.2 (V2 TUI)
  • Client: TUI
  • Model and provider: Not relevant
  • OS: macOS (Darwin 27.2.0, arm64)
  • Terminal: Herdr.app 0.1.18 (herdr-core panes) vs herdr TUI 0.9.5 (TERM_PROGRAM=herdr, HERDR_ENV=1)
  • Shell: zsh
  • Install/channel: latest
  • Active plugins: herdr's own opencode-tui integration and unrelated local plugins. None of them touch tabs.

Reproduction

  1. Install Herdr.app (0.1.18) and open a pane.
  2. Run opencode with no tabs.mode set.
  3. The session tab rail is visible. In a herdr TUI pane (herdr 0.9.5) on the same machine, it is hidden.

Expected Behavior

auto treats herdr-core panes the same way as herdr TUI panes.

Actual Behavior

The tab rail stays on in herdr-core panes, because the resolved check is mode === "on" || (mode === "auto" && HERDR_ENV !== "1") and herdr-core never sets HERDR_ENV.

Additional Context

Suggested fix: resolve "inside herdr" once in a shared helper that checks HERDR_ENV === "1" || !!HC_TERMINAL_ID, and use it for tabs, mouse and animations. Setting HERDR_ENV from herdr-core is not a safe alternative: tools treat HERDR_ENV=1 as meaning the herdr CLI can control the current pane, and that is false under herdr-core.

Related: #65596 (OSC 7501 status in herdr-core). herdr-core also answers the OSC 7501 capability query, which could serve as a terminal-level signal in place of env vars.

Workaround: set "tabs": { "mode": "off" }. That also turns tabs off outside Herdr.

nxxxsooo avatar Nov 26 '26 06:11 nxxxsooo

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.4.2 by imitating the two kinds of pane with environment variables. I didn't have a real Herdr.app.

  • With no tabs config, HC_TERMINAL_ID, HC_SOCKET and HC_SESSION set, and HERDR_ENV unset, the session tab rail is shown after a session is created.
  • With HERDR_ENV=1, the rail is hidden.

The docs describe tabs.mode: auto as hiding tabs inside Herdr. Both config resolvers, the TUI's and the Rust CLI's, only check HERDR_ENV, so herdr-core panes aren't detected. It still happens on the latest dev (44344bd22).

The recording and screenshots below show the herdr-core case (rail shown) and the HERDR_ENV=1 case (rail hidden). The script below reproduces it, using opencode-drive's simulated model for the session.

Related: #60111 (open PR that turns animations off inside herdr; it uses the same kind of check) and #65596 (herdr-core OSC 7501 status).

https://anoma.ly/team/github-bot/media/3efaa0027ff3449ed7e961009ffeae0190ebf10b63643fdeb20e8d784df9ee1c.mp4

Screenshot

Screenshot

Reproduction script (drive.ts)
// Reproduces #66537: tabs.mode "auto" (the default) hides the session tab rail
// when HERDR_ENV=1 (herdr TUI) but not in a Herdr.app / herdr-core pane, which
// sets HC_TERMINAL_ID / HC_SOCKET / HC_SESSION and no HERDR_ENV.
// Set SCENARIO=herdr-tui to run the control case (HERDR_ENV=1).
import { Effect } from "effect"
import { Llm, OpenCodeDriver } from "opencode-drive"

const scenario = process.env.SCENARIO ?? "herdr-core"
const env: Record<string, string> =
  scenario === "herdr-tui"
    ? { HERDR_ENV: "1", TERM_PROGRAM: "herdr" }
    : { HC_TERMINAL_ID: "term-1", HC_SOCKET: "/tmp/hc.sock", HC_SESSION: "sess-1" }
delete process.env.HERDR_ENV

export default OpenCodeDriver.use(
  {
    opencode: { ...(process.env.OC_DEV ? { dev: process.env.OC_DEV } : {}), env },
    tui: { recording: true },
    project: { git: true },
  },
  ({ ui, llm }) =>
    Effect.gen(function* () {
      yield* Effect.log(`scenario=${scenario} env=${JSON.stringify(env)}`)
      yield* llm.queue(Llm.text("Herdr tab test"))
      yield* llm.queue(Llm.text("Hello from the simulated model."))
      yield* ui.submit("hi")
      yield* Effect.sleep("3 seconds")
      yield* ui.screenshot(`tabs-${scenario}`)
      const frame = yield* ui.capture()
      const top = frame.lines[0].spans.map((s) => s.text).join("")
      yield* Effect.log(`top row: ${JSON.stringify(top)}`)
    }),
)

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.

opencodejr[bot] avatar Nov 26 '26 06:11 opencodejr[bot]

Hi! I would like to work on this. I opened PR #66545 with a fix: now tabs.mode: auto also checks HC_TERMINAL_ID, so the tabs are hidden in Herdr.app panes too. I added tests for the TUI and for the Rust CLI. I could not test it with a real Herdr.app, so any feedback is welcome.

Mats2208 avatar Nov 26 '26 15:11 Mats2208

Confirmed on v2.4.3 in a real herdr-core pane (Herdr.app 0.1.18, herdr-core 0.1.22, macOS). With tabs.mode unset, the tab rail is now hidden. Running the same build with the HC_* variables removed brings the rail back, which is expected outside Herdr. I've dropped my tabs.mode: off workaround.

Thanks @neriousy for the fix, and @Mats2208 for the PR.

nxxxsooo avatar Nov 30 '26 02:11 nxxxsooo