fix(cli): split panel text on newlines before wrapping - #75207
Conversation
|
Thanks for the focused regression fix. Current main still sends the complete approval command through Suggested changes
This is an automated hermes-sweeper review. |
fa9934c to
7a1c8aa
Compare
|
Both points addressed in the amended commit:
|
SummaryFour PRs address #72580 with split-before-wrap changes: #72601 fixes slash confirmation and approval only, #72614 also fixes clarify and adds approval regressions, #73584 changes only approval while mishandling blank lines and bundling unrelated work, and #75207 centralizes all three wrappers while preserving clarify-specific semantics and adding the broadest focused coverage. Related pull requests
Duplicates#72601, #72614, and the relevant approval hunk of #73584 substantially duplicate the split-before-wrap correction in #75207; #75207 subsumes their #72580 work without #73584's blank-line defect or unrelated files. Suggested consolidationKeep #75207 open with a salvage path: retain its shared newline-preserving helpers and focused tests, then add a clarify-panel rendering regression that exercises the panel binding itself. Close #72601 and #73584 as duplicates of #75207; despite #72614's recorded best-fix and keep_open verdicts, close #72614 as a duplicate because #75207 contains the same complete wrapper correction with centralized logic and broader empty-line and clarify-delegation coverage. Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I72580(["issue #72580 (open)"])
subgraph Dup72601 ["PRs duplicating each other"]
P72601["PR #72601 (open)"]
P72614["PR #72614 (open)"]
P73584["PR #73584 (open)"]
P75207["PR #75207 (open)"]
end
P75207 -->|best fix| I72580
class I72580 open
class P72601 open
class P72614 open
class P73584 open
class P75207 open
class P72614 best
class P75207 best
class P75207 target
click I72580 "https://github.com/NousResearch/hermes-agent/issues/72580"
click P72601 "https://github.com/NousResearch/hermes-agent/pull/72601"
click P72614 "https://github.com/NousResearch/hermes-agent/pull/72614"
click P73584 "https://github.com/NousResearch/hermes-agent/pull/73584"
click P75207 "https://github.com/NousResearch/hermes-agent/pull/75207"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 4 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 34 kB of PR diffs, 7 kB of issue/PR text, 3 kB of discussion (5 comments), 7 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
7a1c8aa to
7e62154
Compare
|
Addressed the salvage step from the 2026-08-03 triage: clarify-panel rendering regression that exercises the actual panel binding. The clarify renderer was a
Branch rebased onto latest main (8f27127). 28/28 pass in |
7e62154 to
14f9646
Compare
…72580) textwrap.wrap treats embedded newlines as ordinary whitespace, so a multi-line command pending approval (e.g. a heredoc) collapsed into a few unreadable long lines that pushed the approve/deny choices off-screen. Extract the triplicated _wrap_panel_text (slash-confirm, approval, clarify panels) into one module-level helper that splits on newlines first, then wraps each line individually. The clarify panel keeps its prose-oriented kwargs (break_long_words=False, break_on_hyphens=False) via _wrap_clarify_panel_text. The sudo panel is unaffected (fixed password display).
…visible (NousResearch#72580) Triage salvage step for NousResearch#75207: lift the clarify panel renderer from a run()-scoped closure into an instance method (_get_clarify_display_fragments, mirroring _get_approval_display_fragments) so the actual panel binding is exercisable. Add two rendering regressions through the real renderer: - multiline question keeps one display line per source line and all choices + Other still render (newline-split fix, NousResearch#72580) - tiny terminal drops the question entirely rather than clipping choices
14f9646 to
46c1daa
Compare
46c1daa to
e6985e3
Compare
Bug
When a dangerous command contains embedded newlines (e.g. a
python3 << 'EOF' ... EOFheredoc), the TUI approval panel renders it as a few long lines with literal\ncharacters, making the command unreadable and pushing the approve/deny choices off-screen.Fixes #72580.
Root Cause
_wrap_panel_textincli.py(3 copies: approval panel, sudo panel, clarify panel) calledtextwrap.wrap()directly on the full command string.textwrap.wraptreats\nas ordinary whitespace — it does not split on newlines. A multi-line heredoc script gets collapsed into a handful of long lines with embedded newlines.Fix
_wrap_panel_textincli.pythat splits on\nfirst, then wraps each line individually (preserving empty lines, thewidth>=8floor, andsubsequent_indentsemantics).textwrapkwargs (break_long_words=False, break_on_hyphens=False, default whitespace handling — prose wrapping). It now binds to_wrap_clarify_panel_text, a module-level delegator with those kwargs, so its wrapping behaviour is byte-identical to before; it only gains the newline split.ui-tui/src/components/prompts.tsx:102-104); this fix covers the prompt_toolkit CLI path.No signature changes for callers; the nested call sites are untouched.
Regression Tests
tests/cli/test_wrap_panel_text.py(11 tests): per-source-line preservation for a heredoc, no embedded newlines in output, empty-line preservation, single-line behaviour unchanged, empty input,subsequent_indenton continuations only, the width floor, the no-word-break kwargs — plus 3 rendering-path tests for the clarify delegation (_wrap_clarify_panel_text: multiline question split, prose no-word-break, empty lines). Verified to fail against the pre-fix implementation (3 behaviour failures; the module functions obviously don't exist pre-fix at all).Existing
tests/cli/test_cli_approval_ui.py(15 tests) passes unchanged.Checklist