fix(goal): only announce a replaced goal when one was still live
Gate quality finding (Medium): _set read mgr.state.goal regardless of status, so `/goal clear` (or a done goal) followed by `/goal <text>` printed "(replaced the previous goal) was: ..." about a goal that was already gone. Use mgr.has_goal() (active/paused) to decide what counts as replaced.
This commit is contained in:
@@ -147,7 +147,7 @@ def _set(mgr, arg, *, drafting, last_user_message, render, progress):
|
||||
else:
|
||||
headline, contract = goals.parse_contract(arg)
|
||||
contract = contract if not contract.is_empty() else None
|
||||
previous = (mgr.state.goal or "").strip() if mgr.state is not None else ""
|
||||
previous = mgr.state.goal if mgr.has_goal() else ""
|
||||
state = mgr.set(headline or arg, contract=contract)
|
||||
output = render("gateway.goal.set", "⊙ Goal set ({budget}-turn budget): {goal}",
|
||||
budget=state.max_turns, goal=state.goal)
|
||||
|
||||
@@ -145,3 +145,6 @@ def test_double_dash_sets_control_word_goal_and_announces_the_replace():
|
||||
result = _dispatch(mgr, '-- pause the nightly cron')
|
||||
assert goals.load_goal(mgr.session_id).goal == 'pause the nightly cron'
|
||||
assert 'was: original objective' in result.output
|
||||
mgr.clear()
|
||||
fresh = goals.GoalManager(session_id=mgr.session_id) # gateway/TUI reload per command
|
||||
assert 'replaced' not in _dispatch(fresh, 'fresh objective').output
|
||||
|
||||
Reference in New Issue
Block a user