fix(task): join wrapped command lines in task output header#10387
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors the task script header display logic in ChangesTask header display formatter
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Greptile SummaryThis 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
Confidence Score: 5/5Safe 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 No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(task): join wrapped command lines in..." | Re-trigger Greptile |
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:Root cause
exec_script(src/task/task_executor.rs) built the displayed command by taking only the first non-boilerplate physical line viascript.lines().find(...). For a backslash-wrapped command that line ends in\, and the header is then formatted asformat!("$ {display_script} {args_str}"), gluing the extra CLI args right after the dangling backslash. The existingtrunc()only ellipsizes the first line, so it can''t fix this.Fix
Extract
display_first_command(), which:set ...boilerplate (same as before), andtrunc(), 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
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
Tests