Skip to content

Add word wrapping to the assistant response text box #62046

Open

Description

@pilotwave144

Please add automatic word wrapping to the text box displaying the assistant's responses in the OpenCode interface.

Currently, long lines of text can extend beyond the visible width of the response area instead of wrapping onto subsequent lines. This makes responses difficult to read, particularly when using narrower terminal windows.

The response text should automatically wrap at word boundaries according to the available display width, without requiring horizontal scrolling. This would significantly improve readability and the overall user experience.

Activity

  1. opencodejr commented on Nov 5, 2026

    @opencodejr

    Thanks for the report! In the current v2 TUI, ordinary assistant prose is supposed to wrap at word boundaries already. So we need a few details to work out what's overflowing in your case:

    1. Version: the output of opencode --version.
    2. Interface: are you using the terminal UI (TUI), the desktop app or the web app?
    3. Platform: your OS, how you installed OpenCode, and for the TUI, which terminal emulator you use.
    4. What overflows: is it normal paragraph text, or things like code blocks, tables, or long unbroken strings such as URLs or file paths? If you can share the prompt or response that caused it, please do.
    5. A screenshot of a response running past the visible width, if possible.

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

    I also found these related issues. The list is ordered by likelihood, so please check whether one already covers your problem:

  2. pilotwave144 commented on Nov 5, 2026

    @pilotwave144
    Author

    Thanks for the response. Just to clarify, I'm referring to the Markdown text box used to compose prompts in the OpenCode Desktop application, not code blocks or assistant response rendering.

    Environment:

    • Interface: OpenCode Desktop
    • Version: 2.2.5
    • Operating System: Windows 11

    Requested improvement:

    The Markdown textbox should support automatic word wrapping while typing or pasting longer prompts. Text should wrap at word boundaries according to the available width instead of extending horizontally beyond the visible area.

    Expected behaviour:

    1. Automatically wrap long lines at word boundaries.
    2. Expand the Markdown textbox vertically as additional lines are needed.
    3. Preserve the original Markdown content without inserting newline characters for visual wrapping.
    4. Provide vertical scrolling when the content exceeds the maximum textbox height.

    This would make writing, reviewing and editing longer Markdown prompts considerably more comfortable.

  3. opencodejr commented on Nov 5, 2026

    @opencodejr

    Thanks for clarifying! I couldn't reproduce this here, because our test environment can't run OpenCode Desktop or Windows.

    The prompt composer is meant to work the way you describe already. It wraps at word boundaries, grows taller as you type, adds no real newlines, and scrolls vertically once it reaches its maximum height. In a quick browser test with the same editor styling as 2.2.5, ordinary text wrapped and the box grew, and even a very long URL wrapped instead of running off to the side. So whatever happens in your setup is probably specific to the desktop app's layout or to Windows, and a maintainer with that environment will need to look at it.

    These would help them:

    • A screenshot or short screen recording of a prompt running past the visible width
    • Whether the overflowing text is ordinary words or a long unbroken string (a URL, file path, etc.), and whether you typed it or pasted it
    • Your window size and Windows display scaling, if it's not 100%
    • Whether it also happens in a new session, or after resizing the window
  4. pilotwave144 commented on Nov 5, 2026

    @pilotwave144
    Author

    Markdown code fences should soft-wrap long lines instead of overflowing the message bubble

    Alternates if the tracker wants a feature-request framing: "Add a word-wrap option for code blocks in chat messages" or "Long lines in fenced code blocks are clipped with no scroll affordance."

    Context
    Chat messages are rendered from Markdown. A fenced code block becomes

    …
    , and the browser's default stylesheet applies white-space: pre, which preserves whitespace and forbids wrapping. When any line is wider than the message column, the block overflows horizontally: it grows a scrollbar, or in narrower/nested layouts it is clipped outright with no indication that more content exists.

    This is the wrong default for a chat surface. Code blocks here are overwhelmingly used to display output — logs, stack traces, JSON, diffs pasted from a terminal, AI-generated prose that happens to be fenced — not to edit source files where column alignment carries meaning. The result is that a long line is silently unreadable, and copy-paste users cannot tell whether text is missing. Horizontal scrolling inside a chat bubble is also a genuine accessibility problem: it is hostile to trackpad-less users, awkward with touch, and poorly signalled to screen readers.

    The renderer already wraps ordinary paragraphs and blockquotes correctly, so the capability exists; it is only pre that opts out.

    Steps to reproduce
    Send a message containing a fenced code block whose longest line exceeds the message width.
    Observe that the line extends past the bubble rather than wrapping.
    Minimal payload (250 columns, no spaces beyond the label):

    0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 <- this is 250 columns
    Alternatively, send an ordinary sentence wrapped in fences at 40 columns / 80 columns / 120 columns and resize the window from wide to narrow.

    Actual
    The block does not wrap. Content past the right edge is reachable only by horizontal scrolling, or is clipped entirely. No fade, chevron, or scrollbar may be visible, depending on the client.

    Expected
    Long lines inside a code fence soft-wrap at the container edge, preserving all characters and all real newlines. Copying still yields the original text, because wrapping is a visual operation and does not insert characters.

    Proposed fix
    One rule handles the common and the pathological case:

    pre, pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    }
    pre-wrap preserves whitespace while permitting breaks; overflow-wrap: anywhere covers unbroken tokens such as URLs, hashes, and base64 blobs. If preserving strict column alignment is a hard requirement for some users, keep the default as-is and add a per-message or global "wrap long lines" toggle — but note that the toggle must be discoverable, since the current failure is invisible.

    Acceptance criteria
    A fenced block with a 250-column line wraps inside the bubble at any window width.
    A paragraph containing a 300-character unbroken token wraps.
    Selecting and copying a wrapped block yields the original text with original newlines intact.
    Whitespace and indentation render unchanged.
    Tables and inline code are unaffected unless deliberately included.
    Impact
    Low severity, high frequency: it does not crash anything, but it degrades the primary reading surface of the app, and it shows up constantly because fenced blocks are the default way long machine output is shared. Fixing it is one CSS property.

    Environment
    App / client: ‹fill in›
    Version: ‹fill in›
    OS: ‹fill in›
    Theme/layout: ‹fill in›
    Screenshot: attach the 250-column repro above

    Image
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions