Skip to content

fix(cli): messages reach the terminal as one line, so a command in one is never split by an inserted newline #1588

Closed

Description

@dan-petty

Friction

A command named in a CLI message reaches the terminal split across two lines, so copying it gives a broken command. Seen at shell start when the keyring prompt was left unanswered:

Keyring password: Keyring left locked; the next terminal you open will ask again, or run `devops
devcontainer unlock-keyring`.

Evidence

  • The source string is one line (MESSAGES.devcontainer.keyring_unlock_skipped, implicit concatenation, no \n), as AGENTS.md's "Line Breaks Belong to Source Files, Not Output" requires.
  • devops_cli.output.console.print sends every step, raw and leveled message (print_info, print_error, print_warning, print_success, print_muted, print_step) to Rich's Console.print with its default soft_wrap=False. Rich then word-wraps at its own width and writes a real newline at a space, here inside the backticked command. A line the terminal wraps copies as one line; Rich's newline does not.
  • tests/test_devcontainer.py::test_an_unanswered_prompt_leaves_the_keyring_for_the_next_terminal collapses the output's whitespace before matching the message, working around the same break.
  • The message also followed the prompt on its line: getpass writes its newline only after an answer, so a timeout, EOF or Ctrl-C leaves the prompt's line open (_unlock_keyring in src/devops_cli/commands/devcontainer.py).

Remedy

Print step, raw and leveled messages with soft_wrap=True, so each reaches the terminal as one line for the terminal to wrap. Tables, panels and Markdown keep Rich's layout. End the prompt's line before the "left locked" message when the prompt is abandoned. Tests: a message wider than the console comes out as one line at every level, an abandoned prompt (timeout, EOF, Ctrl-C) is followed by the message on its own line, and the existing unanswered-prompt test matches the message without collapsing whitespace.

Proposed design

Problem statement

CLI messages that contain commands are split across multiple lines by Rich's word-wrapping, making them hard to copy and execute. Specifically, when a keyring prompt is left unanswered, the follow-up message appears on the next line after the prompt, causing a broken command when copied.

Acceptance criteria

  • Criterion 1: Messages printed with Rich's Console.print have soft_wrap=True so they appear as single lines to the terminal
    Verification: Run a test that prints a long message containing a command and verify it doesn't get split across lines by Rich
  • Criterion 2: The keyring prompt's line is properly ended before the 'left locked' message when the prompt is abandoned
    Verification: Test an abandoned prompt scenario and verify the output shows the prompt on one line, followed by the message on its own line
  • Criterion 3: Existing tests continue to pass without modification
    Verification: Run the existing test suite including test_an_unanswered_prompt_leaves_the_keyring_for_the_next_terminal

Key questions

  • What is the source string for MESSAGES.devcontainer.keyring_unlock_skipped?: The source string is one line (MESSAGES.devcontainer.keyring_unlock_skipped, implicit concatenation, no \n), as AGENTS.md's "Line Breaks Belong to Source Files, Not Output" requires. [sources: src/devops_cli/commands/devcontainer.py:1308]
  • How does devops_cli.output.console.print send messages to Rich?: devops_cli.output.console.print sends every step, raw and leveled message (print_info, print_error, print_warning, print_success, print_muted, print_step) to Rich's Console.print with its default soft_wrap=False. Rich then word-wraps at its own width and writes a real newline at a space, here inside the backticked command. A line the terminal wraps copies as one line; Rich's newline does not. [sources: src/devops_cli/commands/devcontainer.py:1308]
  • What causes a command in a message to be split across lines?: Rich's default soft_wrap=False causes it to word-wrap at its own width and write a real newline at a space, splitting a command that appears on one line in the source. [sources: src/devops_cli/commands/devcontainer.py:1308]
  • What test currently works around this issue?: tests/test_devcontainer.py::test_an_unanswered_prompt_leaves_the_keyring_for_the_next_terminal collapses the output's whitespace before matching the message, working around the same break. [sources: src/devops_cli/commands/devcontainer.py:1308]
  • What is the remedy for this issue?: Print step, raw and leveled messages with soft_wrap=True, so each reaches the terminal as one line for the terminal to wrap. Tables, panels and Markdown keep Rich's layout. End the prompt's line before the "left locked" message when the prompt is abandoned. (proposed) [sources: src/devops_cli/commands/devcontainer.py:1308]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    on Oct 16, 2026
  2. dan-petty commented on Oct 16, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/bug. The candidate fixes a bug where CLI messages are split across lines incorrectly.
    • Priority: P2-Medium. This is a usability issue that affects command copying but does not block functionality or introduce security risks.
    • Value: Medium. Improves user experience by ensuring copied commands work correctly, affecting common CLI usage patterns.
    • Effort: Low. The fix involves changing one parameter ('soft_wrap') in message printing and adjusting prompt handling, which is straightforward.
  3. added a commit that references this issue on Oct 16, 2026
    eacdefa
  4. added this to the v0.2.36 milestone on Oct 16, 2026
  5. dan-petty commented on Oct 16, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 76dd52a (see proposed design in issue body).

  6. dan-petty commented on Oct 16, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1589, merged into release/v0.2.36 as eacdefa.

    Closes #1588

    A command named in a CLI message could reach the terminal split across two lines, so copying it gave a broken command. Seen when the keyring prompt at shell start was left unanswered: "Keyring left locked; ... or run devops" on one line and "devcontainer unlock-keyring." on the next.

    5 file(s) changed.

    How it was verified

    Check runs at a53c465:

    • Audit Defect PR Hardening: skipping
    • Prune PR DevContainer Images: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Changed-Test Independence: pass
    • Analyze (actions): pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Static Analysis: pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • DevContainer Image: skipping

    No task file.

  7. added a commit that references this issue on Oct 17, 2026
    3dd7fa6
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

    source/agenttype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions