Skip to content

fix(cli): print user and server text as-is instead of as Rich markup - #2520

Merged
Pangjiping merged 1 commit into
opensandbox-group:mainfrom
acodercat:fix/cli-escape-rich-markup
Nov 2, 2026
Merged

Pangjiping merged 1 commit into
opensandbox-group:mainfrom
acodercat:fix/cli-escape-rich-markup

Conversation

@acodercat

Copy link
Copy Markdown
Contributor

OutputFormatter builds Rich markup strings around the text it prints: f" [bold {style}]{icon} {msg}[/]" for messages, and the same for error-panel lines, success-panel values and spinner text. Panel content and plain table cells are passed as str, which Rich also parses as markup. So any path, file name, log line or server error that contains something like a tag is rendered wrong.

On current main:

  • osb file write sb1 '/tmp/notes[draft].txt' -c x writes the file and then prints Written: /tmp/notes.txt. The file rm table drops [draft] the same way.
  • With a [/] in the path, the file is written, then printing raises MarkupError and the command exits 1, so a successful write is reported as a failure.
  • A server error such as file not found: /data/[old]/x.txt is shown as /data//x.txt.
  • osb command logs output with brackets is mangled inside its panel.

There is one more, related problem. handle_errors passes its own [dim]Type: ...[/] markup to error_panel, and with --no-color that markup is printed literally: ERROR [RuntimeError]: boom [dim]Type: RuntimeError[/].

Summary

  • OutputFormatter treats every text it is given as plain text:
    • Messages, error-panel lines, success-panel keys and values, and spinner text are escaped with rich.markup.escape before they go into the formatter's own styling.
    • Panel content and plain table cells are rendered as Text. Status, ID and dim cells already were.
  • handle_errors passes plain text (<message>\n\nType: <qualname>) instead of markup. The type line loses its dim style, but it now shows correctly with and without color.

Testing

  • Not run (explain why)

  • Unit tests

  • Integration tests

  • e2e / manual verification

  • New TestTextIsNotMarkup in tests/test_output.py: messages, error panel, success panel, panel and table cells must print /tmp/notes[draft]/a[/]b unchanged. All five tests fail on current main.

  • New TestHandleErrors in tests/test_utils.py, with and without color: an unexpected error must print its message unchanged and no [dim]. Both cases fail on current main.

  • The full CLI suite passes (337 passed). ruff is clean, and pyright reports no new errors in the changed files.

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

OutputFormatter interpolated messages, panel lines, success-panel values,
spinner text, panel content and table cells into Rich markup. Text that
looks like a tag was swallowed or broke rendering: `osb file write
'/tmp/notes[draft].txt'` printed `Written: /tmp/notes.txt`, an error
about `/data/[old]/x` lost the `[old]`, and a `[/]` in a path raised
MarkupError after the command had already succeeded.

Escape that text in the formatter, and render panel content and table
cells as Text. handle_errors passed its own `[dim]` markup to
error_panel, which no-color output printed literally; it now passes
plain text.
@github-actions github-actions Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 31, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T08:50:16.539349Z 1b26693 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Pangjiping Pangjiping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Pangjiping
Pangjiping merged commit 2e6d093 into opensandbox-group:main Nov 2, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants