Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ breaking changes may land in a minor release.

### Fixed

- Strip leading dashes from task window names. A task id whose last 40 characters
start with `-` was passed to `new-window -n` as an option, so psmux created no window
and the session read as crashed with an empty log (#1061).
- Read BMAD v7's `quick_lenses`/`thorough_lenses` review sets in `validate` and the
run preflight, so a v7 project is no longer required to install the deleted
`bmad-review-adversarial-general` and `bmad-review-edge-case-hunter`. A `workflow.review`
Expand Down
9 changes: 6 additions & 3 deletions src/bmad_loop/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,12 @@ def session_name(run_id: str) -> str:

def task_window_name(task_id: str) -> str:
"""Name of the window a task's agent session runs in, inside the run's
:func:`session_name` session: the task id's last 40 characters. The adapter
names the window with it, and an attach finds the task window by it."""
return task_id[-40:]
:func:`session_name` session: the task id's last 40 characters, leading
dashes stripped. The adapter names the window with it, and an attach finds
the task window by it. A ``-``-leading name reads as an option to
``new-window -n``: psmux then exits 0 with no window and no id, and the
session reads as crashed (#1061)."""
return task_id[-40:].lstrip("-") or task_id


def attach_target_argv(target: str) -> list[str]:
Expand Down
23 changes: 23 additions & 0 deletions tests/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,29 @@ def test_write_pid(tmp_path):
assert float(tokens[1]) > 0


@pytest.mark.parametrize(
"task_id, expected",
[
("3-1-short-key-dev-1", "3-1-short-key-dev-1"),
("x" * 50 + "-dev-1", ("x" * 50 + "-dev-1")[-40:]),
# The 40-char slice starts at a dash: psmux would read it as a flag (#1061).
(
"3-2-aaaaaa-a-bbbbbbbbb-c-dd-eeeeeee-ff-ggggggg-dev-1",
"bbbbbbbbb-c-dd-eeeeeee-ff-ggggggg-dev-1",
),
(
"3-2-aaaaaa-a---bbbbbbb-c-dd-eeeeeee-ff-ggggggg-dev-1",
"bbbbbbb-c-dd-eeeeeee-ff-ggggggg-dev-1",
),
],
)
def test_task_window_name_never_starts_with_a_dash(task_id, expected):
name = runs.task_window_name(task_id)
assert name == expected
assert not name.startswith("-")
assert len(name) <= 40


@pytest.mark.usefixtures("force_tmux_backend") # attach_argv goes through the seam
def test_attach_argv_outside_tmux(monkeypatch):
monkeypatch.delenv("TMUX", raising=False)
Expand Down