-
Notifications
You must be signed in to change notification settings - Fork 36
fix: prevent auto-closing failed issues and preserve em-dash content #2112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,10 +80,23 @@ parse_task_line() { | |
| local task_id | ||
| task_id=$(echo "$line" | grep -oE 't[0-9]+(\.[0-9]+)*' | head -1 || echo "") | ||
|
|
||
| # Extract description (between task ID and first metadata field) | ||
| # Extract FULL description (everything after task ID, including em-dash content) | ||
| # We'll clean out metadata fields separately, but preserve the full text | ||
| local full_text | ||
| full_text=$(echo "$line" | sed -E 's/^[[:space:]]*- \[.\] t[0-9]+(\.[0-9]+)* //' || echo "") | ||
|
|
||
| # Extract description by removing all metadata fields but keeping em-dash content | ||
| # Strategy: remove tags, estimate, and key:value pairs, but preserve text after em dash | ||
| local description | ||
| description=$(echo "$line" | sed -E 's/^[[:space:]]*- \[.\] t[0-9]+(\.[0-9]+)* //' | | ||
| sed -E 's/ (#[a-z]|~[0-9]|→ |logged:|started:|completed:|ref:|actual:|blocked-by:|blocks:|assignee:|verified:).*//' || | ||
| description=$(echo "$full_text" | | ||
| sed -E 's/ #[a-z][a-z0-9-]*//g' | # Remove tags | ||
| sed -E 's/ ~[0-9]+[hmd]( \(ai:[^)]+\))?//g' | # Remove estimate | ||
| sed -E 's/ (logged|started|completed|actual|verified):[^ ]+//g' | # Remove date fields | ||
| sed -E 's/ (assignee|blocked-by|blocks|model|category):[^ ]+//g' | # Remove other metadata | ||
| sed -E 's/ ref:GH#[0-9]+//g' | # Remove GH ref | ||
| sed -E 's/ pr:#[0-9]+//g' | # Remove PR ref | ||
| sed -E 's/ → \[todo\/PLANS\.md#[^]]+\]//g' | # Remove plan link | ||
| sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//' || # Trim whitespace | ||
| echo "") | ||
|
Comment on lines
+83
to
100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The sanitization pipeline removes 🛠️ Proposed fix — add `ref:todo/tasks/` pattern to the pipeline sed -E 's/ ref:GH#[0-9]+//g' | # Remove GH ref
sed -E 's/ pr:#[0-9]+//g' | # Remove PR ref
+ sed -E 's/ ref:todo\/tasks\/[^ ]+//g' | # Remove task file ref
sed -E 's/ → \[todo\/PLANS\.md#[^]]+\]//g' | # Remove plan link🤖 Prompt for AI Agents |
||
|
|
||
| # Extract tags | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -457,13 +457,14 @@ sync_issue_status_label() { | |||||||||||||||
| if [[ -n "$fail_error" && "$fail_error" != "null" ]]; then | ||||||||||||||||
| fail_comment="Task $task_id failed (was: $old_state). Error: $fail_error" | ||||||||||||||||
| fi | ||||||||||||||||
| # Close with failure comment but don't add status:done | ||||||||||||||||
| gh issue close "$issue_number" --repo "$repo_slug" \ | ||||||||||||||||
| --comment "$fail_comment" 2>/dev/null || true | ||||||||||||||||
| # DO NOT auto-close failed tasks - they need human review | ||||||||||||||||
| # Add needs-review label and post failure comment, but keep issue OPEN | ||||||||||||||||
| gh issue comment "$issue_number" --repo "$repo_slug" \ | ||||||||||||||||
| --body "$fail_comment" 2>/dev/null || true | ||||||||||||||||
|
Comment on lines
+462
to
+463
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
References
|
||||||||||||||||
| gh issue edit "$issue_number" --repo "$repo_slug" \ | ||||||||||||||||
| "${remove_args[@]}" 2>/dev/null || true | ||||||||||||||||
| log_verbose "sync_issue_status_label: closed #$issue_number as failed ($task_id)" | ||||||||||||||||
| return 0 | ||||||||||||||||
| --add-label "needs-review" "${remove_args[@]}" 2>/dev/null || true | ||||||||||||||||
|
Comment on lines
464
to
+465
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comment, using
Suggested change
References
|
||||||||||||||||
| log_verbose "sync_issue_status_label: flagged #$issue_number for review ($task_id failed)" | ||||||||||||||||
| # Don't return here - let the non-terminal state logic handle label updates | ||||||||||||||||
| ;; | ||||||||||||||||
|
Comment on lines
+460
to
468
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
GitHub CLI's The established in-file pattern ( 🛠️ Proposed fixIn gh label create "status:done" --repo "$repo_slug" --color "6F42C1" --description "Task is complete" --force 2>/dev/null || true
+ gh label create "needs-review" --repo "$repo_slug" --color "E4E669" --description "Failed task needs human review" --force 2>/dev/null || true
return 0In -ALL_STATUS_LABELS="status:available,status:queued,status:claimed,status:in-review,status:blocked,status:verify-failed,status:needs-testing,status:done"
+ALL_STATUS_LABELS="status:available,status:queued,status:claimed,status:in-review,status:blocked,status:verify-failed,status:needs-testing,status:done,needs-review"🤖 Prompt for AI Agents
Comment on lines
+467
to
468
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Misleading fall-through comment — non-terminal label logic is a no-op for The comment says "let the non-terminal state logic handle label updates", but ✏️ Proposed fix- # Don't return here - let the non-terminal state logic handle label updates
+ # Return early — failed is a terminal state; label and comment already applied above.
+ return 0Or, if intentional fall-through is desired for future flexibility, correct the comment: - # Don't return here - let the non-terminal state logic handle label updates
+ # Fall through intentionally (new_label is empty for failed; no further label is applied)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| blocked) | ||||||||||||||||
| # Read the error/blocked reason from DB | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chaining multiple
sedcommands via pipes can be inefficient as each one starts a new process. You can consolidate these into a singlesedcall using the-eoption for each expression. This improves both performance and readability.References