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
24 changes: 16 additions & 8 deletions companion/codex_display/hook_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,23 @@ async def process_event(self, event: Dict[str, object]) -> None:
)
else:
existing = self._turns.get(key)
self._turns[key] = PendingTurn(
turn_id=turn_id,
transcript_path=path or (
existing.transcript_path if existing is not None else None
),
phase="pending_stop",
created_at=existing.created_at if existing is not None else now,
counted=existing.counted if existing is not None else False,
resolved_path = path or (
existing.transcript_path if existing is not None else None
)
if resolved_path is None:
self._turns.pop(key, None)
else:
self._turns[key] = PendingTurn(
turn_id=turn_id,
transcript_path=resolved_path,
phase="pending_stop",
created_at=(
existing.created_at if existing is not None else now
),
counted=(
existing.counted if existing is not None else False
),
)
await self._on_change()

async def reconcile(self, now: Optional[float] = None) -> None:
Expand Down
12 changes: 12 additions & 0 deletions companion/tests/test_hook_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ async def test_stop_waits_for_matching_task_complete(self):
await self.tracker.reconcile()
self.assertEqual(self.tracker.extra_count(set()), 0)

async def test_pathless_stop_clears_sidechat_immediately(self):
submit = self._event("UserPromptSubmit")
submit["transcript_path"] = None
await self.tracker.process_event(submit)
self.assertEqual(self.tracker.extra_count(set()), 1)

stop = self._event("Stop")
stop["transcript_path"] = None
await self.tracker.process_event(stop)

self.assertEqual(self.tracker.extra_count(set()), 0)

async def test_unconfirmed_submit_expires(self):
tracker = HookActivityTracker(
self.changed,
Expand Down