Skip to content

tui: sidebar missing when viewing a subagent session — no context usage or cost for that session #48548

Closed as not planned

Description

@Ploppy3

Summary

When navigating into a subagent (child) session in the opencode2 TUI, the session sidebar is not rendered. Since the Context section lives in the sidebar, there is no way to see the subagent session's own context usage (tokens / percentage) or cost while viewing it. The sidebar only appears for the root session.

Reproduction

  1. In opencode2, run a prompt that spawns a subagent (e.g. the task tool).
  2. Navigate into the child session: down (session.child.first) to open the subagent picker, or right (session.child.next) to go to the next child session.
  3. Observe that the sidebar is missing while viewing the subagent session.
  4. session.sidebar.toggle (<leader>b) does not bring it back in the child session.

Expected Behavior

The sidebar should be available in subagent session views as well, with the Context section showing that session's token usage and cost.

Actual Behavior

The sidebar is absent for child/subagent sessions, so context usage and cost for that specific session cannot be inspected anywhere in the TUI.

Impact

For subagent-heavy workflows, per-subagent context pressure and spend are invisible in the TUI. The parent session's sidebar does not compensate for this (see also #45417 for subagent cost not being aggregated).

Environment

  • opencode2 v0.0.0-beta-19425
  • Linux x86_64
  • npm install (@opencode/cli)

Activity

  1. JLegends commented on Sep 17, 2026

    @JLegends

    Confirming. The two issues compound: there is no sidebar while you are in the child session, and the root session's sidebar excludes everything the child spent (#45417, #47822). So for a fan-out there is no place in the TUI that shows the child's spend.

    Partial workaround until the sidebar renders for child sessions: a root-sidebar plugin that aggregates descendants. api.client.session.children({ path: { sessionID } }) returns each child's cost and tokens, so you can render "subagents: $X" next to the root Context block. It does not give you the per-child context pressure you are after, but it stops the spend from being invisible.

    Building that now on macOS v1.18.31, will link it here once it works.

  2. VladSmr commented on Oct 2, 2026

    @VladSmr

    The native sidebar skips subagent sessions, so I built /context-breakdown: it
    lists every child session with its own ctx, % and per-category breakdown
    (system, schemas, user/assistant, reasoning, tool args, residual), alongside
    the main session.

    opencode-context-indicator — still in a testing stage; with your help and
    feedback we can make it better together. Dual V1 + V2, tested against 2.0.21+,
    everything local.

    https://github.com/VladSmr/opencode-context-indicator
    npm: opencode-context-indicator

  3. Ploppy3 commented on Oct 5, 2026

    @Ploppy3
    Author

    Still valid on v2.0.23 (v2 tip fad352c): session-frame.tsx still returns sidebarVisible = false for any session with a parentID, before the manual toggle is considered — so the sidebar (and context/cost) remains unavailable in subagent sessions.

  4. saneksa commented on Oct 27, 2026

    @saneksa

    Opened #59573 for this. The sidebar check in session-frame.tsx returned false for any session with a parentID before looking at the setting or the toggle. The PR removes that check, so subagent sessions get the sidebar and its Context block like the root session.

  5. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed report. I tried to reproduce this with a simulated model on the latest release (2.2.0; the beta you're on wouldn't start in our test harness). The subagent ran and the root session showed its sidebar, but my automated run never managed to open the child session (the subagent picker didn't select it), so I couldn't watch the sidebar there myself. That's a gap in my test run, not evidence that the problem doesn't happen.

    The code backs up your report: the TUI's session frame hides the sidebar for any session that has a parent session, and that check runs before both the auto setting and the manual toggle. So in a subagent session the sidebar can't appear, and <leader>b has no visible effect there. Related:

    A maintainer will need to confirm by opening a child session by hand. If you can, it would help to know whether you opened the subagent through the picker (down) or with right, and how wide your terminal was.

  6. sebastianlungu commented on Oct 30, 2026

    @sebastianlungu

    still broken on 2.2.4. open a subagent and there's no context %, no token count, no cost for that session, and ctrl+x b doesn't help because parentID sessions never render the sidebar. the parent's numbers aren't a substitute.

    #59573 removes exactly that check and has been open since oct 27 — can someone prio it? and fwiw the original report (#38495) got closed as not planned instead of fixed, which is why this keeps coming back.

  7. opencodejr commented on Oct 31, 2026

    @opencodejr

    Closing this for now, since we haven't heard back. We asked how you opened the subagent session (the down picker or right) and how wide your terminal was, because our automated run never got into the child session and couldn't confirm the missing sidebar directly.

    We didn't rule the problem out. The TUI code does hide the sidebar for any session that has a parent session, and open PR #59573 changes exactly that. Related: #45417 (subagent cost not added to the parent session) and #50795 (a subagent session hides the effective model in the footer).

    If this still happens on a current v2 release, please comment with those details and we can reopen it. Thanks for the clear report.

  8. Alek2077 commented on Nov 3, 2026

    @Alek2077

    Still reproducible on OpenCode 2.2.5 (Linux x86_64, WSL2), so adding current evidence rather than opening a duplicate.

    Repro:

    1. Open a root session using a model that reports usage (for example opencode-go/deepseek-v4.1-flash).
    2. Confirm the root session shows the right-side Context block (Context — 120,282 tokens — 60% used on a 200k model).
    3. Dispatch a subagent and open the child session (down → subagent picker → Enter, or right).
    4. The child session shows the composer (Subagents / Shell / Terminals) but no sidebar and no Context block. session.sidebar.toggle (ctrl+x b) does nothing.

    Source on 2.2.5: packages/tui/src/component/session-frame.tsx returns false from sidebarVisible for any session with a parentID, before the session.sidebar setting or manual toggle is considered. The child route also replaces the prompt with the composer, so the prompt-footer context meter is not mounted either.

    For the child session, the data is present: the last assistant message reports input 382, cache.read 99,328, output 103, reasoning 356 (about 100,169 context tokens on a 200k model), but there is no UI surface that shows it.

    Expected: the child session shows the same right-side Context block as the root session.

    Actual: no context usage or cost is visible for the child session.

    This is the same root cause as #59573; please consider reopening or tracking this until that lands. No new feature request needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions