diff --git a/companion/codex_display/hook_events.py b/companion/codex_display/hook_events.py index 315cfdc..4a7bcd6 100644 --- a/companion/codex_display/hook_events.py +++ b/companion/codex_display/hook_events.py @@ -59,7 +59,7 @@ def extra_count(self, base_active_paths: Set[str]) -> int: continue identities.add(("path", path)) else: - identities.add(("turn", key)) + identities.add(("session", key[0])) return len(identities) async def process_event(self, event: Dict[str, object]) -> None: diff --git a/companion/tests/test_hook_events.py b/companion/tests/test_hook_events.py index f8a6a37..99f790b 100644 --- a/companion/tests/test_hook_events.py +++ b/companion/tests/test_hook_events.py @@ -64,6 +64,25 @@ async def test_pathless_stop_clears_sidechat_immediately(self): self.assertEqual(self.tracker.extra_count(set()), 0) + async def test_pathless_turns_are_deduplicated_by_session(self): + first = self._event("UserPromptSubmit") + first["transcript_path"] = None + await self.tracker.process_event(first) + + second = self._event("UserPromptSubmit") + second["turn_id"] = "turn-2" + second["transcript_path"] = None + await self.tracker.process_event(second) + + self.assertEqual(self.tracker.extra_count(set()), 1) + + third = self._event("UserPromptSubmit") + third["session_id"] = "session-2" + third["transcript_path"] = None + await self.tracker.process_event(third) + + self.assertEqual(self.tracker.extra_count(set()), 2) + async def test_unconfirmed_submit_expires(self): tracker = HookActivityTracker( self.changed,