Skip to content

tui: collapsed reasoning title ignores thinkingOpacity (hardcoded 0.6 alpha) #51134

Open

Description

@Duo-Huang

Description

The collapsed reasoning title (+ Thought …) in the v2 TUI is hard to read on transparent terminal backgrounds, and it cannot be fixed via theme config.

Root cause: SessionReasoningGroupView in packages/tui/src/routes/session/index.tsx hardcodes alpha 0.6 for the title whenever it is neither hovered nor expanded:

color={
  !props.completed
    ? theme.text.base
    : hover() || expanded()
      ? theme.text.feedback.warning.base
      : RGBA.fromValues(
          theme.text.feedback.warning.base.r,
          theme.text.feedback.warning.base.g,
          theme.text.feedback.warning.base.b,
          0.6, // <-- never reads theme.thinkingOpacity
        )
}

The theme's thinkingOpacity value is parsed (defaults to 0.6) but nothing on this code path reads it, so setting thinkingOpacity in a custom theme has no effect on the collapsed title. Suggested fix: use theme.thinkingOpacity (falling back to 0.6) instead of the literal.

Plugins

@plannotator/opencode

OpenCode version

v2.0.14

Steps to reproduce

  1. Use a theme with a transparent background.
  2. Let a reasoning block stay collapsed (don't hover or expand it).
  3. The + Thought … header always renders at 0.6 alpha, regardless of thinkingOpacity in the theme.

Screenshot and/or share link

(transparent-background TUI: collapsed header visibly dimmer than the hovered/expanded state on the same wallpaper)

Operating System

macOS 26.6.2

Terminal

iTerm2 3.7.0 (window transparency + blur)

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I can confirm this, both on v2.0.14 and on the latest dev (fa1260d6).

    To check, I used a custom theme based on opencode with background: "none", thinkingOpacity: 1.0 and a bright green warning colour. When a reasoning block finishes and collapses, the + Thought … header is drawn at 0.6 alpha (#00ff00 shows as rgb(0,153,0)). It only reaches full colour while hovered, and it dims again once the mouse leaves. With thinkingOpacity: 1.0 it should stay at full colour. The recording and screenshots below show this, and the script below reproduces it.

    As you found, the alpha is hardcoded to 0.6 in the collapsed reasoning row (now in packages/tui/src/routes/session/group-view.tsx), and the same literal is in ReasoningHeader in message-parts.tsx. The theme's thinkingOpacity is parsed but never used there.

    recording.mp4

    Screenshot

    Screenshot

    Reproduction script (drive.ts)
    // Repro for #51134: collapsed "+ Thought" header ignores theme.thinkingOpacity.
    // Custom theme = built-in "opencode" theme with background "none", warning "#00ff00" and thinkingOpacity: 1.0.
    // Expected: collapsed header colour == hovered colour (alpha 1.0). Actual: collapsed is drawn at 0.6 alpha.
    import { Effect, Stream } from "effect"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    const theme: any = {"defs": {"darkStep1": "#0a0a0a", "darkStep2": "#141414", "darkStep3": "#1e1e1e", "darkStep4": "#282828", "darkStep5": "#323232", "darkStep6": "#3c3c3c", "darkStep7": "#484848", "darkStep8": "#606060", "darkStep9": "#fab283", "darkStep10": "#ffc09f", "darkStep11": "#808080", "darkStep12": "#eeeeee", "darkSecondary": "#5c9cf5", "darkAccent": "#9d7cd8", "darkRed": "#e06c75", "darkOrange": "#f5a742", "darkGreen": "#7fd88f", "darkCyan": "#56b6c2", "darkYellow": "#e5c07b", "lightStep1": "#ffffff", "lightStep2": "#fafafa", "lightStep3": "#f5f5f5", "lightStep4": "#ebebeb", "lightStep5": "#e1e1e1", "lightStep6": "#d4d4d4", "lightStep7": "#b8b8b8", "lightStep8": "#a0a0a0", "lightStep9": "#3b7dd8", "lightStep10": "#2968c3", "lightStep11": "#8a8a8a", "lightStep12": "#1a1a1a", "lightSecondary": "#7b5bb6", "lightAccent": "#d68c27", "lightRed": "#d1383d", "lightOrange": "#d68c27", "lightGreen": "#3d9a57", "lightCyan": "#318795", "lightYellow": "#b0851f"}, "theme": {"primary": {"dark": "darkStep9", "light": "lightStep9"}, "secondary": {"dark": "darkSecondary", "light": "lightSecondary"}, "accent": {"dark": "darkAccent", "light": "lightAccent"}, "error": {"dark": "darkRed", "light": "lightRed"}, "warning": {"dark": "darkOrange", "light": "lightOrange"}, "success": {"dark": "darkGreen", "light": "lightGreen"}, "info": {"dark": "darkCyan", "light": "lightCyan"}, "text": {"dark": "darkStep12", "light": "lightStep12"}, "textMuted": {"dark": "darkStep11", "light": "lightStep11"}, "background": "none", "backgroundPanel": {"dark": "darkStep2", "light": "lightStep2"}, "backgroundElement": {"dark": "darkStep3", "light": "lightStep3"}, "border": {"dark": "darkStep7", "light": "lightStep7"}, "borderActive": {"dark": "darkStep8", "light": "lightStep8"}, "borderSubtle": {"dark": "darkStep6", "light": "lightStep6"}, "diffAdded": {"dark": "#4fd6be", "light": "#1e725c"}, "diffRemoved": {"dark": "#c53b53", "light": "#c53b53"}, "diffContext": {"dark": "#828bb8", "light": "#7086b5"}, "diffHunkHeader": {"dark": "#828bb8", "light": "#7086b5"}, "diffHighlightAdded": {"dark": "#b8db87", "light": "#4db380"}, "diffHighlightRemoved": {"dark": "#e26a75", "light": "#f52a65"}, "diffAddedBg": {"dark": "#20303b", "light": "#d5e5d5"}, "diffRemovedBg": {"dark": "#37222c", "light": "#f7d8db"}, "diffContextBg": {"dark": "darkStep2", "light": "lightStep2"}, "diffLineNumber": {"dark": "#8f8f8f", "light": "#595959"}, "diffAddedLineNumberBg": {"dark": "#1b2b34", "light": "#c5d5c5"}, "diffRemovedLineNumberBg": {"dark": "#2d1f26", "light": "#e7c8cb"}, "markdownText": {"dark": "darkStep12", "light": "lightStep12"}, "markdownHeading": {"dark": "darkAccent", "light": "lightAccent"}, "markdownLink": {"dark": "darkStep9", "light": "lightStep9"}, "markdownLinkText": {"dark": "darkCyan", "light": "lightCyan"}, "markdownCode": {"dark": "darkGreen", "light": "lightGreen"}, "markdownBlockQuote": {"dark": "darkYellow", "light": "lightYellow"}, "markdownEmph": {"dark": "darkYellow", "light": "lightYellow"}, "markdownStrong": {"dark": "darkOrange", "light": "lightOrange"}, "markdownHorizontalRule": {"dark": "darkStep11", "light": "lightStep11"}, "markdownListItem": {"dark": "darkStep9", "light": "lightStep9"}, "markdownListEnumeration": {"dark": "darkCyan", "light": "lightCyan"}, "markdownImage": {"dark": "darkStep9", "light": "lightStep9"}, "markdownImageText": {"dark": "darkCyan", "light": "lightCyan"}, "markdownCodeBlock": {"dark": "darkStep12", "light": "lightStep12"}, "syntaxComment": {"dark": "darkStep11", "light": "lightStep11"}, "syntaxKeyword": {"dark": "darkAccent", "light": "lightAccent"}, "syntaxFunction": {"dark": "darkStep9", "light": "lightStep9"}, "syntaxVariable": {"dark": "darkRed", "light": "lightRed"}, "syntaxString": {"dark": "darkGreen", "light": "lightGreen"}, "syntaxNumber": {"dark": "darkOrange", "light": "lightOrange"}, "syntaxType": {"dark": "darkYellow", "light": "lightYellow"}, "syntaxOperator": {"dark": "darkCyan", "light": "lightCyan"}, "syntaxPunctuation": {"dark": "darkStep12", "light": "lightStep12"}, "thinkingOpacity": 1.0}}
    
    // Make the warning colour distinctive (#00ff00) so it is obvious the custom theme is in use.
    theme.theme.warning = "#00ff00"
    
    const hex = (c: any) => JSON.stringify(c)
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        tui: { recording: true, pointerOverlay: true },
        tuiConfig: { theme: { name: "opaque-thoughts", mode: "dark" } },
        project: { git: true, files: { ".opencode/themes/opaque-thoughts.json": JSON.stringify(theme, null, 2) } },
      },
      ({ ui, llm }) =>
        Effect.gen(function* () {
          // Answer every model request (including any title request) with reasoning + text.
          yield* llm.serve(() => Stream.make(Llm.reasoning("Let me think about the answer carefully."), Llm.text("The answer is 42.")))
          yield* ui.submit("What is the answer?")
          const find = Effect.gen(function* () {
            const frame = yield* ui.capture()
            for (let y = 0; y < frame.lines.length; y++) {
              let x = 0
              for (const span of frame.lines[y]!.spans) {
                if (span.text.includes("Thought")) return { y, x, fg: span.fg, text: span.text }
                x += span.width
              }
            }
            return undefined
          })
          // Poll the captured frame (rather than ui.waitFor) until the collapsed reasoning header appears.
          let collapsed = yield* find
          for (let i = 0; i < 120 && !collapsed; i++) {
            yield* Effect.sleep("500 millis")
            collapsed = yield* find
          }
          yield* Effect.sleep("1 second")
          collapsed = yield* find
          yield* Effect.log(`collapsed Thought fg: ${hex(collapsed?.fg)} span=${JSON.stringify(collapsed?.text)}`)
          yield* ui.screenshot("collapsed")
          if (collapsed) {
            yield* ui.mouse({ action: "move", x: collapsed.x + 4, y: collapsed.y })
            yield* Effect.sleep("500 millis")
            const hovered = yield* find
            yield* Effect.log(`hovered Thought fg: ${hex(hovered?.fg)}`)
            yield* ui.screenshot("hovered")
            yield* ui.mouse({ action: "move", x: 0, y: 0 })
            yield* Effect.sleep("500 millis")
            const after = yield* find
            yield* Effect.log(`collapsed again fg: ${hex(after?.fg)}`)
            yield* ui.screenshot("collapsed-again")
            yield* Effect.log(
              JSON.stringify(collapsed.fg) === JSON.stringify(hovered?.fg)
                ? "OK: collapsed header honours thinkingOpacity 1.0"
                : "BUG: collapsed header is dimmed although theme sets thinkingOpacity: 1.0",
            )
          }
        }),
    )

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions