Skip to content

tui: "Jump to latest" pill stays visible after collapsing tool calls #66799

Description

@jmmon

Description

After a turn with several commands/tool calls, the collapsed activity summary (e.g. "+ 4 commands, 1 thought") can be expanded to make the transcript taller than the viewport. Scroll to the bottom, then to the top, then click the summary again to collapse it: the whole transcript now fits on screen, but the "Jump to latest ↓" pill stays visible even though nothing is below the viewport. Guess: the away-from-bottom state is only recomputed on scroll events, so a collapse that shrinks the content height never clears it.

Plugins

none

OpenCode version

v2.4.2

Steps to reproduce

  1. In a session, send a prompt that runs four shell commands each printing 60 lines (e.g. seq 60 four times), so the turn produces a collapsed activity summary.
  2. Click the collapsed summary row ("+ 4 commands, 1 thought") to expand it, and expand the command outputs so the transcript is clearly taller than the viewport.
  3. Scroll to the bottom.
  4. Scroll to the top.
  5. Click the summary row again to collapse it.
  6. Observe: the entire transcript is visible on screen, but "Jump to latest ↓" is still shown at the bottom right.

Reproduces 3/3 headlessly with this script (private headless TUI driver with a simulated model, shared as evidence — steps 1–6 above stand on their own):

Reproduction script (drive-collapse.ts)
// Repro: stale "Jump to latest" pill after collapsing the activity group.
// Steps (from jmmon, 2026-11-26): prompt with many commands/tool calls ->
// expand the group (content must exceed viewport) -> scroll bottom -> scroll
// top -> collapse. Pill should disappear when the collapsed transcript fits the
// viewport; suspected stale (awayFromBottom only recomputes on scroll events).
import { Effect } from "effect"
import { Llm, OpenCodeDriver } from "opencode-drive"

const out = (n: number) =>
  Array.from({ length: 60 }, (_, i) => `${n}-out-${String(i + 1).padStart(2, "0")}: command output line`).join("\n")

const cmds = ["cmd-alpha", "cmd-bravo", "cmd-charlie", "cmddelta"]

export default OpenCodeDriver.use(
  {
    tools: ["shell"],
    tui: { recording: true, viewport: { cols: 120, rows: 36 } },
  },
  ({ ui, llm, tools }) =>
    Effect.gen(function* () {
      const shells = yield* tools.control("shell")
      yield* llm.queue(
        Llm.reasoning("Planning the four commands carefully so the thought row is realistic and long enough."),
        Llm.toolCall({ index: 0, id: "call_a", name: "shell", input: { command: cmds[0] } }),
        Llm.toolCall({ index: 1, id: "call_b", name: "shell", input: { command: cmds[1] } }),
        Llm.finish("tool-calls"),
      )
      yield* llm.queue(
        Llm.toolCall({ index: 0, id: "call_c", name: "shell", input: { command: cmds[2] } }),
        Llm.toolCall({ index: 1, id: "call_d", name: "shell", input: { command: cmds[3] } }),
        Llm.finish("tool-calls"),
      )
      yield* llm.queue(Llm.text("FINAL-ANSWER done"))
      yield* ui.submit("Run four long commands")

      for (const [id, n] of [["call_a", 1], ["call_b", 2], ["call_c", 3], ["call_d", 4]] as const) {
        const call = yield* shells.take(id)
        yield* call.succeed({ output: out(n), exit: 0 })
      }
      yield* ui.waitFor("FINAL-ANSWER")
      yield* Effect.sleep(500)
      yield* ui.screenshot("01-collapsed")
      yield* Effect.log(`baseline (collapsed, fits): pill visible=${yield* ui.matches("Jump to latest")}`)

      const lineWith = Effect.fn("lineWith")(function* (needle: string) {
        const frame = yield* ui.capture()
        return frame.lines.findIndex((line) => line.spans.some((s) => s.text.includes(needle)))
      })
      const click = Effect.fn("click")(function* (y: number) {
        yield* ui.mouse({ action: "move", x: 40, y })
        yield* ui.mouse({ action: "down", x: 40, y })
        yield* ui.mouse({ action: "up", x: 40, y })
        yield* Effect.sleep(300)
      })

      // Expand the activity group. Match "N commands" so the user prompt
      // ("Run four long commands") is not mistaken for the summary row.
      const sumY = yield* lineWith("4 commands")
      yield* Effect.log(`activity summary row at y=${sumY}`)
      yield* click(sumY)
      yield* ui.screenshot("02-group-expanded")

      // Expand each shell output so the transcript far exceeds the viewport.
      for (const cmd of cmds) {
        const y = yield* lineWith(cmd)
        if (y >= 0) yield* click(y)
      }
      yield* Effect.sleep(300)
      yield* ui.screenshot("03-tools-expanded")

      // Scroll to bottom, then to top.
      for (let i = 0; i < 60; i++) yield* ui.mouse({ action: "scroll", x: 60, y: 18, direction: "down" })
      yield* Effect.sleep(400)
      yield* Effect.log(`at bottom: FINAL-ANSWER visible=${yield* ui.matches("FINAL-ANSWER")}`)
      for (let i = 0; i < 80; i++) yield* ui.mouse({ action: "scroll", x: 60, y: 18, direction: "up" })
      yield* Effect.sleep(1500)
      yield* ui.screenshot("04-scrolled-top-expanded")

      // Collapse the group again. The scroll animation keeps settling for a
      // second after the wheel stops, so wait for a stable row position and
      // verify the click actually toggled (a stray hit on the user message
      // opens Message Actions instead).
      let sumY2 = -1
      for (let i = 0; i < 6; i++) {
        const y = yield* lineWith("commands,")
        yield* Effect.sleep(400)
        const y2 = yield* lineWith("commands,")
        if (y === y2 && y >= 0) {
          sumY2 = y
          break
        }
      }
      yield* Effect.log(`collapsing at y=${sumY2}`)
      yield* click(sumY2)
      if (yield* ui.matches("Search actions")) {
        yield* Effect.log("click hit the message box; escaping and retrying")
        yield* ui.press("escape")
        yield* Effect.sleep(400)
        yield* click(yield* lineWith("commands,"))
      }
      yield* Effect.sleep(500)
      yield* ui.screenshot("05-after-collapse")

      const fits = yield* ui.matches("FINAL-ANSWER")
      const pill = yield* ui.matches("Jump to latest")
      yield* Effect.log(`after collapse: whole transcript visible=${fits}, pill visible=${pill}`)
      if (fits && pill) yield* Effect.log("STALE PILL REPRODUCED")
    }),
)

Screenshot

N/A — the script above reproduces deterministically; its final frame shows the entire transcript fitting on screen with "Jump to latest ↓" still displayed.

Operating System

Omarchy (Arch Linux)

Terminal

Foot

Activity

  1. added
    area/tui
    type/bug
    version/v2
    on Nov 27, 2026
  2. opencodejr commented on Nov 27, 2026

    @opencodejr
    Contributor

    Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.

    Thanks for the clear steps and the script. I reproduced this on v2.4.2, and it still happens on the latest dev (8db8c7f).

    I used a simulated model and intercepted shell calls that each return 60 lines. Steps: expand the activity summary and the command outputs, scroll to the bottom, then to the top, then click the summary to collapse it. Afterwards the whole transcript (prompt, summary, final answer) is on screen, but Jump to latest ↓ is still shown at the bottom right. The recording and the screenshot below show it, and the script below reproduces it.

    One difference from your run: in my runs only two of the queued shell calls ran, so the summary row read "+ 2 commands" instead of "+ 4 commands, 1 thought". The pill still stuck after collapsing.

    Your guess fits what I see in the code, though I haven't confirmed it. The TUI only recomputes whether the view is away from the bottom when the scrollbar reports a change. A collapse that shrinks the content while the view is already at the top may never trigger that.

    https://anoma.ly/team/github-bot/media/8bb2e7d15934bcf816755295d26453e38b0c3ea0375eec95ae73cf0ba58febaf.mp4

    Screenshot

    Reproduction script (drive.ts)
    // Repro for anomalyco/opencode#66799: stale "Jump to latest" pill after collapsing the activity group.
    import { Effect } from "effect"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    const out = (n: number) =>
      Array.from({ length: 60 }, (_, i) => `${n}-out-${String(i + 1).padStart(2, "0")}: command output line`).join("\n")
    const cmds = ["cmd-alpha", "cmd-bravo", "cmd-charlie", "cmddelta"]
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        tools: ["shell"],
        tui: { recording: true, viewport: { cols: 120, rows: 36 } },
      },
      ({ ui, llm, tools }) =>
        Effect.gen(function* () {
          const shells = yield* tools.control("shell")
          yield* llm.title(() => Effect.succeed("Four long commands"))
          yield* llm.queue(
            Llm.reasoning("Planning the four commands carefully so the thought row is realistic and long enough."),
            Llm.toolCall({ index: 0, id: "call_a", name: "shell", input: { command: cmds[0] } }),
            Llm.toolCall({ index: 1, id: "call_b", name: "shell", input: { command: cmds[1] } }),
            Llm.finish("tool-calls"),
          )
          yield* llm.queue(
            Llm.toolCall({ index: 0, id: "call_c", name: "shell", input: { command: cmds[2] } }),
            Llm.toolCall({ index: 1, id: "call_d", name: "shell", input: { command: cmds[3] } }),
            Llm.finish("tool-calls"),
          )
          yield* llm.queue(Llm.text("FINAL-ANSWER done"))
          yield* ui.submit("Run four long commands")
          for (const [id, n] of [["call_1", 1], ["call_2", 2]] as const) {
            yield* Effect.log(`waiting for ${id}`)
            const call = yield* shells.take().pipe(Effect.timeout("20 seconds"))
            yield* call.succeed({ output: out(n), exit: 0 })
            yield* Effect.log(`completed ${id} (${JSON.stringify(call.input)})`)
          }
          yield* Effect.log("waiting for final")
          yield* ui.waitFor("FINAL-ANSWER")
          yield* Effect.sleep(500)
          yield* ui.screenshot("01-collapsed")
          yield* Effect.log(`baseline: pill visible=${yield* ui.matches("Jump to latest")}`)
    
          const lineWith = Effect.fn("lineWith")(function* (needle: string) {
            const frame = yield* ui.capture()
            return frame.lines.findIndex((line) => {
              const text = line.spans.map((s) => s.text).join("")
              return text.includes(needle) && !text.includes("Run four")
            })
          })
          const click = Effect.fn("click")(function* (y: number) {
            yield* ui.mouse({ action: "move", x: 40, y })
            yield* ui.mouse({ action: "down", x: 40, y })
            yield* ui.mouse({ action: "up", x: 40, y })
            yield* Effect.sleep(300)
          })
    
          const sumY = yield* lineWith(" commands")
          yield* Effect.log(`summary row y=${sumY}`)
          yield* click(sumY)
          yield* ui.screenshot("02-group-expanded")
          for (const cmd of cmds) {
            const y = yield* lineWith(cmd)
            if (y >= 0) yield* click(y)
          }
          yield* Effect.sleep(300)
          yield* ui.screenshot("03-tools-expanded")
    
          for (let i = 0; i < 60; i++) yield* ui.mouse({ action: "scroll", x: 60, y: 18, direction: "down" })
          yield* Effect.sleep(400)
          for (let i = 0; i < 80; i++) yield* ui.mouse({ action: "scroll", x: 60, y: 18, direction: "up" })
          yield* Effect.sleep(1500)
          yield* ui.screenshot("04-scrolled-top")
    
          let sumY2 = -1
          for (let i = 0; i < 6; i++) {
            const y = yield* lineWith(" commands")
            yield* Effect.sleep(400)
            const y2 = yield* lineWith(" commands")
            if (y === y2 && y >= 0) { sumY2 = y; break }
          }
          yield* Effect.log(`collapsing at y=${sumY2}`)
          yield* click(sumY2)
          if (yield* ui.matches("Search actions")) {
            yield* ui.press("escape")
            yield* Effect.sleep(400)
            yield* click(yield* lineWith(" commands"))
          }
          yield* Effect.sleep(1500)
          yield* ui.screenshot("05-after-collapse")
          const fits = yield* ui.matches("FINAL-ANSWER")
          const pill = yield* ui.matches("Jump to latest")
          const frame = yield* ui.capture()
          yield* Effect.log("FRAME:\n" + frame.lines.map((l) => l.spans.map((s) => s.text).join("")).join("\n"))
          yield* Effect.log(`after collapse: whole transcript visible=${fits}, pill visible=${pill}`)
          if (fits && pill) yield* Effect.log("STALE PILL REPRODUCED")
        }),
    )

    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.

  3. added
    status/repro-simulated
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tuiplatform/linuxstatus/repro-simulatedtype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions