Skip to content

[docs] dialog.set before show() is a silent no-op #58808

Done

Description

@sechlol

Description

Environment


The documented order does nothing

The custom JSX dialog example shows:

context.ui.dialog.set({ size: "large", centered: true })
context.ui.dialog.show(() => (<box>…</box>), onClose)

i.e. set() before show(). On 2.1.4 that ordering is silently ignored: the dialog stays
on the default 60-column preset regardless of size, with no warning.

How it was measured: a throwaway probe plugin auto-opened custom dialogs from setup()
(no input driving) while the TUI ran in a script pty at stty cols 140 rows 40; the raw
transcripts were replayed through a terminal emulator (pyte) and the rendered frames measured
exactly:

set() timing rendered dialog (140-col pty)
before show() — the documented order ignored — always the default 60 cols
synchronously right after show() returns ✅ medium → 60 @ left 40, large → 88 @ left 26, xlarge → 116 @ left 12 (all exactly centered)
80 ms after show() ignored — 60 cols
inside the render thunk ✅ applied (116 @ left 12)
no set() at all 60 cols @ left 40 — centered by default

So set() only takes effect while a dialog is already active/mounting: immediately after
show() returns, or inside the render thunk. Following the docs order cost us a full
debugging cycle before resorting to probing the binary's behavior.

Three adjacent facts the docs don't state

  • Size presets are fixed column widths — medium 60 / large 88 / xlarge 116 — not
    fractions of the terminal. Authors must pick the largest preset that fits
    (ctx.renderer.width) or small terminals overflow (e.g. xlarge on an 80-col terminal).
  • show() dialogs are horizontally centered by default, even without set({ centered }).
  • The host gives the dialog box only a width, never a height (binary inspection; the
    host's own dialogs bound their scrollboxes explicitly, e.g. maxHeight: 20). Custom content
    that needs scrolling must carry its own terminal-derived height bound — worth one sentence
    next to the show() example.

Suggested fix: flip the example to show(...) then set(...) — or make set() before
show() queue its options for the next dialog — and document the preset widths, the default
centering, and the missing height bound.

Plugins

No response

OpenCode version

2.1.4

Steps to reproduce

No response

Screenshot

No response

Operating System

macOS 27.0.1

Terminal

iTerm2

Activity

  1. opencode-agent commented on Oct 24, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I was able to reproduce this on 2.1.4, and it still happens on the latest dev (13a615b90).

    I used a local CLI plugin that opens two dialogs from setup() in a 140-column terminal:

    • Docs order, dialog.set({ size: "xlarge", centered: true }) then dialog.show(...): the dialog stays at the default medium width (60 columns) and isn't vertically centered.
    • Reversed order, show(...) then set(...): the dialog is 116 columns (xlarge) and centered.

    The cause is that show() resets the dialog's size to medium and turns centering off. Anything set before show() is overwritten, which doesn't match the example in the plugin docs.

    Until this is addressed, calling set() right after show() works as a workaround. The recording and screenshots below show both orders, and the script below reproduces it.

    Related: #56145 (closed), about where setSize/setCentered are called in the plugin dialog API.

    recording.mp4

    Screenshot

    Screenshot

    Reproduction script (drive.ts)
    // Repro for anomalyco/opencode#58808: ui.dialog.set() before show() is ignored.
    // The plugin opens an xlarge dialog using the documented order (set, then show),
    // then after 4s the same dialog with the order reversed (show, then set).
    import { Effect } from "effect"
    import { OpenCodeDriver } from "opencode-drive"
    
    const plugin = `import { Plugin } from "@opencode/plugin/tui"
    
    const body = (label: string) => () => (
      <box border width="100%">
        <text>{label}</text>
      </box>
    )
    
    export default Plugin.define({
      id: "repro.dialog-size",
      setup(context) {
        const dialog = context.ui.dialog
        setTimeout(() => {
          // Documented order
          dialog.set({ size: "xlarge", centered: true })
          dialog.show(body("DOCUMENTED ORDER: set(xlarge) then show()"))
        }, 1500)
        setTimeout(() => {
          dialog.clear()
          dialog.show(body("REVERSED ORDER: show() then set(xlarge)"))
          dialog.set({ size: "xlarge", centered: true })
        }, 5500)
      },
    })
    `
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        tui: { recording: true, viewport: { cols: 140, rows: 40 } },
        project: { git: true, files: { ".opencode/plugins/dialog-size/tui.tsx": plugin } },
      },
      ({ ui }) =>
        Effect.gen(function* () {
          // The plugin opens the dialogs on timers from setup(); just watch.
          yield* Effect.sleep(4500)
          yield* ui.screenshot("documented-order") // 60-col dialog, not centered: set() was ignored
          yield* Effect.sleep(4000)
          yield* ui.screenshot("reversed-order") // 116-col xlarge dialog, centered
          yield* Effect.sleep(1000)
        }),
    )

    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.

  2. rebelliard commented on Oct 25, 2026

    @rebelliard

    Opened #58930. It fixes the docs example to call set() after show(), since show() resets size and centering. It also clarifies the Dialog.set JSDoc. No runtime change.

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