Skip to content

TUI: dialog-prompt.tsx calls textarea.gotoLineEnd during render #56136

Closed as not planned

Description

@Addin

Summary

dialog-prompt.tsx calls textarea.gotoLineEnd() during the render body (onMount), which is a Solid anti-pattern — side effects during render can cause inconsistent layout or re-render loops.

Root cause

packages/tui/src/ui/dialog-prompt.tsx:94-101:

onMount(() => {
  dialog.setSize(props.size ?? "medium")
  setTimeout(() => {
    if (!textarea || textarea.isDestroyed) return
    if (props.busy) return
    textarea.focus()
  }, 1)
  textarea.gotoLineEnd()  // <-- side effect during render
})

Suggested fix

Move textarea.gotoLineEnd() and textarea.focus() into an effect or callback, not the render body. Prefer onMount for one-time setup (as used elsewhere, e.g. dialog-session-list.tsx:194).

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the report, @Addin!

    In the current code, textarea.gotoLineEnd() is already called inside onMount in packages/tui/src/ui/dialog-prompt.tsx. In Solid, onMount runs after the component has rendered and its refs are set, so this isn't a side effect during render. It's also the pattern your suggested fix recommends.

    If you've seen something actually go wrong in the TUI, could you describe it briefly in your own words?

    • Your OpenCode version (opencode --version), OS and terminal
    • Which dialog you opened and how (the steps)
    • What you expected and what happened instead, e.g. the cursor in the wrong place, the input not focused, or flickering or a hang. A screenshot or recording helps.

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.

  2. Addin commented on Oct 16, 2026

    @Addin
    Author

    Thank you for the correction. You're right - looking more carefully at , at line 101 is indeed inside , not directly in the render body. My initial source review was too quick on this one. This is not actually a rendering-during-render violation. I'd like to withdraw this issue (#56136) as it's based on an incorrect reading of the code. The remaining rendering-related issues (#56137-#56145) are separate concerns about / being called during render body rather than , which is a different pattern issue.

  3. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for checking again and following up, @Addin! Since the call is already inside onMount, there's nothing to fix here. You can close this issue yourself, or the bot will close it automatically on 2026-10-19.

    For #56137–#56145: please check those calls the same way, and say whether each one is inside onMount, createEffect or an event handler. It also helps a lot to add any real problem you've seen in the TUI, such as wrong focus or cursor position, flicker, a hang or an error, plus your opencode --version, OS, terminal and the steps that trigger it. Without an observable symptom, a pattern-only report is hard to act on.

  4. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Closing this as not planned, as you asked, @Addin. Like you confirmed, textarea.gotoLineEnd() in dialog-prompt.tsx already runs inside onMount, so there's nothing to fix here. Thanks for following up! If you run into an actual problem in this dialog, such as wrong focus or cursor position, please open a new issue with your version, OS, terminal and steps.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions