Skip to content

fix(task): join wrapped command lines in task output header#10387

Merged
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-task-wrapped-command-display
Jun 13, 2026
Merged

fix(task): join wrapped command lines in task output header#10387
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-task-wrapped-command-display

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Problem

When a task''s run script starts with a command wrapped across multiple physical lines with backslash continuations, the task header shows only the first physical line (ending in \) and then glues the task''s extra CLI args onto that dangling backslash. Reported in #10083:

[foo] $ echo long_command \ --extra args

Root cause

exec_script (src/task/task_executor.rs) built the displayed command by taking only the first non-boilerplate physical line via script.lines().find(...). For a backslash-wrapped command that line ends in \, and the header is then formatted as format!("$ {display_script} {args_str}"), gluing the extra CLI args right after the dangling backslash. The existing trunc() only ellipsizes the first line, so it can''t fix this.

Fix

Extract display_first_command(), which:

  • skips leading shebang / blank / set ... boilerplate (same as before), and
  • joins backslash-continued lines into one logical line, so the header shows the full command (still truncated to terminal width by trunc(), and shown in full under CI / task.show_full_cmd).

Execution is unchanged — only the displayed $ ... line is affected.

Literal trailing backslash

A trailing backslash with no following line is treated as literal data (it can''t be a continuation) and is kept verbatim, so e.g. a Windows path echo C:\tmp\ is displayed as-is rather than being altered. Only genuine multi-line continuations are merged. (The remaining ambiguity — a literal \ at the end of a line that is followed by another line — is still treated as a continuation, which is acceptable for a display-only string and noted in the doc comment.)

Testing

  • 8 unit tests for display_first_command (plain, boilerplate-skipping, multi-line join, join after boilerplate, literal trailing \, Windows-path trailing \, all-boilerplate, and a header-with-args case asserting no \ sequence).
  • cargo fmt --all -- --check

Addresses #10083

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved task command header display to correctly handle multi-line commands with continuations and edge cases such as Windows paths and shebangs.
  • Tests

    • Added comprehensive unit tests to validate task header display behavior across various scenarios.

When a task's run script starts with a command wrapped across multiple physical
lines with backslash continuations, the task header showed only the first line
(ending in `\`) and then glued the task's extra CLI args onto that dangling
backslash, e.g. `[foo] $ echo long_command \ --extra args`.

Extract display_first_command(), which skips leading shebang/blank/`set ...`
boilerplate (as before) and additionally joins backslash-continued lines into one
logical line, so the header shows the full command (still truncated to terminal
width by the existing trunc()). A trailing backslash with no following line is
kept as-is, so a literal trailing backslash that is data rather than a
continuation (e.g. a Windows path like `echo C:\tmp\`) is shown verbatim.

Addresses discussion jdx#10083.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c169d79e-d427-4339-aab8-9b50a6aeb788

📥 Commits

Reviewing files that changed from the base of the PR and between cfc245d and f068a50.

📒 Files selected for processing (1)
  • src/task/task_executor.rs

📝 Walkthrough

Walkthrough

This PR refactors the task script header display logic in TaskExecutor by extracting it into a dedicated display_first_command helper that joins backslash-continued lines while skipping boilerplate and preserving literal trailing backslashes, including Windows path cases. The helper replaces inline logic in exec_script and is validated with comprehensive unit tests.

Changes

Task header display formatter

Layer / File(s) Summary
Header display formatter implementation and integration
src/task/task_executor.rs
New display_first_command function finds the first non-boilerplate line (skipping shebang and set forms), joins backslash-continuation lines into a single logical command for display, and preserves trailing literal backslashes including Windows paths. exec_script now computes display_script via this helper instead of inline logic. Unit tests validate formatting for plain commands, boilerplate skipping, continuation joining, literal vs continuation backslashes, Windows paths, and header integrity when extra args are appended.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A formatter hops into view,
With backslash joins and boilerplate skew,
No continuation confusion today,
Headers now shine in a tidy display!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: joining wrapped command lines in the task output header display.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the task header display bug (#10083) where a backslash-continued command showed only its first physical line, causing extra CLI args to be appended after a dangling \. The fix extracts display_first_command(), which skips boilerplate and joins continuation lines into a single logical line before formatting the $ … header.

  • Logic: The new function reuses the exact same boilerplate-skipping predicate as before, then iterates continuation lines via while cmd.trim_end().ends_with('\\'), safely slicing off the trailing \ (ASCII single byte) and space-joining the pieces. A trailing \ with no following line is correctly left intact as literal data.
  • Tests: Eight focused unit tests cover plain commands, boilerplate skipping, multi-line joins, join-after-boilerplate, literal trailing backslash, Windows paths, all-boilerplate input, and the original regression scenario with extra args.
  • Execution: The script executed is completely unaffected; only the displayed $ … line changes.

Confidence Score: 5/5

Safe to merge — only the display string is touched; the script execution path is completely unchanged.

The change is display-only, well-scoped to a single extracted helper, and backed by eight unit tests that cover the original regression, continuation chaining, boilerplate skipping, and edge cases like a trailing backslash with no following line. The byte-slice on the trailing \ is safe because \ is a single ASCII byte. No existing behavior for execution, redaction, or truncation is altered.

No files require special attention.

Important Files Changed

Filename Overview
src/task/task_executor.rs Extracts display_first_command() to join backslash-continued lines before building the task header; 8 unit tests added; execution path is unchanged.

Reviews (1): Last reviewed commit: "fix(task): join wrapped command lines in..." | Re-trigger Greptile

@jdx jdx merged commit 8676789 into jdx:main Jun 13, 2026
33 checks passed
@JamBalaya56562 JamBalaya56562 deleted the fix-task-wrapped-command-display branch June 13, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants