Skip to content
Merged
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
28 changes: 18 additions & 10 deletions src/mapify_cli/recitation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,23 @@ def update_subtask_status(
"'python -m mapify_cli.recitation_manager create <task_id> <goal> <subtasks_json>'"
)

for subtask in plan.subtasks:
if subtask.id == subtask_id:
subtask.status = status
if status == 'in_progress':
plan.current_subtask_id = subtask_id
subtask.iterations += 1
if error:
subtask.errors.append(error)
break
# Find the target subtask up front so we can validate and log reliably
target_subtask = next(
(subtask for subtask in plan.subtasks if subtask.id == subtask_id),
None
)

if target_subtask is None:
raise ValueError(
f"Subtask with id {subtask_id} was not found in the current plan"
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message format is inconsistent with the test expectation. The test expects the pattern 'Subtask with id 999' but the message includes 'was not found in the current plan' which may not match. Consider simplifying to match the test pattern exactly, or update the test to match the full message.

Suggested change
f"Subtask with id {subtask_id} was not found in the current plan"
f"Subtask with id {subtask_id}"

Copilot uses AI. Check for mistakes.
)

target_subtask.status = status
if status == 'in_progress':
plan.current_subtask_id = subtask_id
target_subtask.iterations += 1
if error:
target_subtask.errors.append(error)

plan.updated_at = datetime.now().isoformat()

Expand All @@ -175,7 +183,7 @@ def update_subtask_status(
"subtask_id": subtask_id,
"status": status,
"error": error,
"iterations": subtask.iterations if subtask else None
"iterations": target_subtask.iterations
}
)

Expand Down
8 changes: 3 additions & 5 deletions tests/test_recitation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,9 @@ def test_update_nonexistent_subtask(self, manager, sample_subtasks):
"""Test updating a subtask that doesn't exist"""
manager.create_plan('test', 'Test', sample_subtasks)

# Should not raise error, but also shouldn't update anything
plan = manager.update_subtask_status(999, 'completed')

# No subtask should be completed
assert all(st.status == 'pending' for st in plan.subtasks)
# Should raise an error when subtask ID is not found
with pytest.raises(ValueError, match="Subtask with id 999"):
manager.update_subtask_status(999, 'completed')

def test_long_error_message(self, manager, sample_subtasks):
"""Test that long error messages are truncated in markdown"""
Expand Down