Skip to content

TUI crash: "State composite separation did not converge" on a composite state diagram #61467

Open

Description

@FAZuH

Description

A fenced mermaid state diagram that the composite layout cannot place throws State composite separation did not converge from packages/merman/src/state/drawing.ts. The error is a plain Error, so the Markdown code block renderer rethrows it and the TUI exits with the crash screen. One message containing the diagram below is enough; reopening the session crashes again immediately.

Stack trace ends in renderCustomNode / createTopLevelCustomRenderer, through gl and tD into pr.

Plugins

None required.

OpenCode version

2.2.5

Steps to reproduce

  1. Send a message containing this fence:
stateDiagram-v2
  direction LR
  state "left" as left {
    done --> [*]
  }
  state "right" as right {
    [*] --> pending
    failed --> [*]
  }
Loading
  1. Reopen the session.

The TUI crashes with State composite separation did not converge instead of rendering the diagram. The failure does not depend on terminal width; it reproduces from 80 to 300 columns. The same content drawn as TB lays out correctly.

Screenshot

N/A

Operating System

Linux

Terminal

tmux

Activity

  1. opencodejr commented on Nov 3, 2026

    @opencodejr
    Contributor

    Thanks for the clear report and the minimal diagram, I was able to reproduce this.

    I had a simulated model reply with your stateDiagram-v2 fence (direction LR, composites left and right). On 2.2.5, the TUI switches to the "OpenCode crashed" screen with State composite separation did not converge as soon as the message renders. The recording and screenshots below show it, and the script below reproduces it.

    It still happens on the latest dev (826381e), run from source. The error is thrown in the state diagram layout (packages/merman/src/state/drawing.ts). The Mermaid Markdown renderer only handles syntax and canvas-size errors, so this one takes down the whole TUI instead of falling back to the plain code block.

    Related: #61468 is an open PR that appears to target this exact error. #48573 and #60341 are other Mermaid rendering crashes with different causes.

    recording.mp4

    Screenshot

    Screenshot

    Reproduction script (drive.ts)
    import { Effect, Stream } from "effect"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    const diagram = [
      "Here is the diagram:",
      "",
      "```mermaid",
      "stateDiagram-v2",
      "  direction LR",
      '  state "left" as left {',
      "    done --> [*]",
      "  }",
      '  state "right" as right {',
      "    [*] --> pending",
      "    failed --> [*]",
      "  }",
      "```",
      "",
    ].join("\n")
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        tui: { recording: true, viewport: { cols: 120, rows: 40 } },
      },
      ({ ui, llm }) =>
        Effect.gen(function* () {
          yield* ui.screenshot("home")
          // Every simulated model request (including the title request on 2.2.5) answers with the diagram
          yield* llm.serve(() => Stream.make(Llm.text(diagram)))
          yield* ui.submit("Draw a state diagram")
          yield* Effect.sleep("6 seconds")
          yield* ui.screenshot("after")
          const frame = yield* ui.capture()
          yield* Effect.log(JSON.stringify(frame).slice(0, 4000))
        }),
    )

    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