@@ -202,7 +202,8 @@ def test_name_cycle_uses_cycle_value_not_flag_token(self) -> None:
202202
203203 self .assertEqual (code , 0 )
204204 session = stdout .getvalue ().strip ()
205- self .assertIn (f"sa-{ project_slug (str (self .root ))} -{ project_hash (str (self .root ))} -" , session )
205+ self .assertIn (f"sa-{ project_slug (str (self .root ))} -" , session )
206+ self .assertNotIn (f"sa-{ project_slug (str (self .root ))} -{ project_hash (str (self .root ))} -" , session )
206207 self .assertTrue (session .endswith ("-review-r2" ), session )
207208 self .assertNotIn ("-r--cycle" , session )
208209
@@ -239,6 +240,27 @@ def test_project_only_session_filter_uses_slug_and_hash(self) -> None:
239240 self .assertEqual (code , 0 )
240241 self .assertEqual (sessions , [own ])
241242
243+ def test_project_only_session_filter_keeps_current_project_legacy_sessions_with_artifacts (self ) -> None :
244+ own = f"sa-{ project_slug (str (self .root ))} -{ project_hash (str (self .root ))} -260521-101010-e5-s5-3-review"
245+ legacy_own = f"sa-{ project_slug (str (self .root ))} -260521-101012-e5-s5-3-review"
246+ legacy_other = f"sa-{ project_slug (str (self .root ))} -260521-101013-e5-s5-4-review"
247+ legacy_state = Path (tempfile .gettempdir ()) / f".sa-{ project_hash (str (self .root ))} -session-{ legacy_own } -state.json"
248+ legacy_state .write_text ("{}" , encoding = "utf-8" )
249+ output = "\n " .join ([own , legacy_own , legacy_other ])
250+
251+ try :
252+ with (
253+ mock .patch .dict (os .environ , {"PROJECT_ROOT" : str (self .root )}),
254+ mock .patch ("story_automator.core.tmux_runtime.command_exists" , return_value = True ),
255+ mock .patch ("story_automator.core.tmux_runtime.run_cmd" , return_value = (output , 0 )),
256+ ):
257+ sessions , code = tmux_list_sessions (project_only = True )
258+ finally :
259+ legacy_state .unlink (missing_ok = True )
260+
261+ self .assertEqual (code , 0 )
262+ self .assertEqual (sessions , [own , legacy_own ])
263+
242264 def test_kill_all_defaults_to_all_automator_sessions (self ) -> None :
243265 with (
244266 mock .patch ("story_automator.commands.tmux.tmux_list_sessions" , return_value = (["sa-one" ], 0 )) as list_sessions ,
@@ -273,11 +295,12 @@ def test_kill_all_all_projects_opt_in(self) -> None:
273295 self .assertEqual (code , 0 )
274296 list_sessions .assert_called_once_with (False )
275297
276- def test_generate_session_name_includes_project_hash (self ) -> None :
298+ def test_generate_session_name_preserves_legacy_public_shape (self ) -> None :
277299 with mock .patch .dict (os .environ , {"PROJECT_ROOT" : str (self .root )}):
278300 session = generate_session_name ("dev" , "2" , "2.4" )
279301
280- self .assertIn (f"sa-{ project_slug (str (self .root ))} -{ project_hash (str (self .root ))} -" , session )
302+ self .assertIn (f"sa-{ project_slug (str (self .root ))} -" , session )
303+ self .assertNotIn (f"sa-{ project_slug (str (self .root ))} -{ project_hash (str (self .root ))} -" , session )
281304 self .assertTrue (session .endswith ("-e2-s2-4-dev" ), session )
282305
283306
0 commit comments