Skip to content

TUI: question/ask prompt renders one word per line when model emits carriage returns #36040

Closed as not planned

Description

@qingshanyuluo

Summary

When the agent uses the interactive question/ask tool, some model providers emit carriage-return (\r) characters inside the question header, question body, and option label/description. The TUI's opentui renderer treats a bare \r as a hard line break, so the prompt renders with nearly every word on its own line.

What happens

The question and its options become almost unreadable — each word (or CJK segment) wraps to a separate line, e.g.:

定位
换行
问题

TUI
里我输入
/粘贴的文字

instead of:

定位换行问题
TUI 里我输入/粘贴的文字

Root cause

Question strings flow from the model tool call through Question.ask (packages/opencode/src/question/index.ts), which publishes the question.asked event consumed by every render surface:

  • TUI: packages/tui/src/context/sync.tsx → packages/tui/src/routes/session/question.tsx
  • CLI footer: packages/opencode/src/cli/cmd/run/session-data.ts → packages/opencode/src/cli/cmd/run/footer.question.tsx
  • Web: packages/app/src/pages/session/composer/session-question-dock.tsx
  • Scrollback: packages/opencode/src/cli/cmd/run/scrollback.writer.tsx

There is no \r normalization anywhere in this chain. Notably, the user's own prompt textarea already normalizes CRLF (packages/tui/src/component/prompt/index.tsx), but question content coming from the model was never sanitized. The opentui text buffer receives the raw bytes and each \r-separated token wraps to its own line.

Expected

\r characters from model-provided question text should be normalized before the data is stored/broadcast, so the prompt renders normally. Intentional newlines in the multi-line question body should be preserved.

Environment

  • Reproducible across models that emit \r in tool-call string output.
  • Affects the TUI most visibly (opentui hard-breaks on \r).

A fix PR follows.

Activity

  1. github-actions commented on Sep 8, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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