Skip to content

fix(runs): strip leading dashes from task window names (#1061) - #1062

Open
RECOHA wants to merge 1 commit into
bmad-code-org:mainfrom
RECOHA:fix/1061-dash-leading-window-name
Open

RECOHA wants to merge 1 commit into
bmad-code-org:mainfrom
RECOHA:fix/1061-dash-leading-window-name

Conversation

@RECOHA

@RECOHA RECOHA commented Nov 23, 2026 •

Copy link
Copy Markdown

Closes #1061.

Problem

runs.task_window_name returns task_id[-40:]. When that slice starts with -, new-window -n <name> reads the name as an option: psmux exits 0, prints nothing for -P -F, and creates no window. The empty window id then reads as a crashed session ("no work produced: dev session crashed", empty log). It is deterministic per story key, so the same story fails on every retry.

Fix

Strip leading dashes in task_window_name (falling back to the full id if nothing is left). The adapter (new-window -n) and the TUI attach (window lookup by name) both go through this function, so they stay in step.

Tests

  • New test_task_window_name_never_starts_with_a_dash in tests/test_runs.py: two cases fail without the fix, all pass with it.
  • On Windows 11, tests/test_runs.py, test_generic_tmux.py, test_tui_launch.py, test_psmux_backend.py and test_multiplexer.py show the same 4 failures with and without this change (test_delete_run_refuses_a_redirected_run_dir[*], test_archive_run_refuses_a_redirected_runs_dir: redirected-dir setup on this machine). No new failures. ruff and black are clean on the touched files; pyright error count on them is unchanged.
  • Applied the same one-line change to an installed 0.13.2: the story that failed launched normally.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Task window names no longer begin with a dash after truncation, preventing some tasks from failing to create a window.

…#1061)

A task id whose last 40 characters start with `-` was passed to
`new-window -n` as an option: psmux exits 0 with no window and no id,
and the session reads as crashed with an empty log. Strip the leading
dashes in `task_window_name`, so the adapter and attach stay in step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The task window name function now strips leading dashes from the task ID’s final 40 characters. If the result is empty, it returns the full task ID. Parameterized tests cover the name length and dash handling.

Changes

Task window name handling

Layer / File(s) Summary
Sanitize and validate task window names
src/bmad_loop/runs.py, tests/test_runs.py, CHANGELOG.md
The function strips leading dashes from the final 40 characters and falls back to the full task ID if the result is empty. Tests check short and long IDs, leading dashes, and the 40-character limit. The changelog records the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: pbean, dracic

Merge Risk: Minimal · up to 5e1f3

This fixes task windows whose names began with a dash being parsed as options, which left no window and made the session look crashed. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: leading dashes are stripped from task window names in the runs module. It matches the changeset summary, which describes stripping leading dashes in task_window_name w…
Linked Issues check Passed Issue #1061 requires that task_window_name strip leading dashes, with a full-ID fallback when nothing remains, so the new-window -n adapter and TUI attach agree. The reviewed diff (merge base 8224…
Out of Scope Changes check Passed The changes are limited to three areas. src/bmad_loop/runs.py contains the required fix. tests/test_runs.py contains the regression test for that fix. CHANGELOG.md adds a Fixed entry that descri…
Full details: Title check

Explanation

The title names the main change: leading dashes are stripped from task window names in the runs module. It matches the changeset summary, which describes stripping leading dashes in task_window_name with a full-ID fallback. The title is specific and follows the conventional commit style. The #1061 reference is an issue number, and the objectives cite PR #1062, so the number does not match the PR objectives. This does not affect the content match.

Full details: Linked Issues check

Explanation

Issue #1061 requires that task_window_name strip leading dashes, with a full-ID fallback when nothing remains, so the new-window -n adapter and TUI attach agree. The reviewed diff (merge base 8224d53 to head 5e1f362) changes src/bmad_loop/runs.py so task_window_name returns task_id[-40:].lstrip("-") or the full task_id when that result is empty. The issue states that GenericAdapter and attach both use this function, so the single change covers both paths. The new test_task_window_name_never_starts_with_a_dash in tests/test_runs.py covers the leading-dash case and the length bound. The PR description reports that the test fails without the fix and passes with it. The evidence comes from the summary and the PR description. I did not inspect the test file or the call sites directly. The issue requests no other coding change.

Full details: Out of Scope Changes check

Explanation

The changes are limited to three areas. src/bmad_loop/runs.py contains the required fix. tests/test_runs.py contains the regression test for that fix. CHANGELOG.md adds a Fixed entry that describes the same change. Each change connects directly to #1061. The PR makes no psmux backend or unrelated adapter changes, which the issue excludes. The four Windows redirected-directory test failures are reported as present with and without the change, so they are not caused by this PR.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the window name,
And trims the dashes from its frame.
Forty chars fit neat and right,
Tests keep the edge cases in sight.
The window opens; logs stay bright.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 639cd539-ed86-4543-9c5d-00d032246eff
Commits

Reviewing files that changed from the base of the PR and between 8224d53 and 5e1f362.

Files selected for processing: 3

  • CHANGELOG.md
  • src/bmad_loop/runs.py
  • tests/test_runs.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

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.

psmux: task window name starting with '-' creates no window; session reads as crashed

1 participant