fix(app): release archived chat timelines once nobody shows them

Archiving an agent or its workspace removed it from the active list but left its
transcript in the session store until reload, and so did opening an archived chat
from History and leaving it.

The viewed-timeline owner now owns transcript lifetime: an active agent's
transcript stays resident while hidden, so switching tabs needs no fetch; an
archived agent's transcript stays only while its chat is shown. Late history
pages, live events, and cache reads for a released chat are dropped, and the
chat leaves the opened chats so showing it again catches up afresh. Active-list
reconciliation still keeps the transcript, preserving the History invariant
from #4736.

Refs #6477
This commit is contained in:
Mohamed Boudra
2026-11-26 02:25:15 +01:00
parent e51bb7b8cd
commit 91be92fa69
7 changed files with 449 additions and 18 deletions
+14 -4
View File
@@ -202,10 +202,20 @@ owner wraps cached preparation, network catch-up, accepted timeline application,
behind one interface. React supplies transport and projection operations without selecting a cache
path or issuing a separate persistence notification.
Active-agent list reconciliation does not own transcript lifetime. An archived agent's fresh
history response can arrive before the active-list response that omits it. Clearing history there
would discard accepted rows while the viewed owner still considers them synchronized. Entity
deletion clears the transcript; list membership changes do not.
The viewed-timeline owner also owns how long a transcript stays in memory. An active agent's
transcript stays resident while its chat is hidden, so switching back to it needs no fetch. An
archived agent's transcript stays resident only while its chat is shown, for example when it is
opened from History. When an agent is archived, or the active list drops it because its workspace
was archived, the owner releases the transcript unless the chat is shown. It also releases the
transcript when the chat stops being shown. A released chat leaves the opened chats. When it is
shown again, it reads the replica cache and catches up again. A history page, live event, or cache
read that arrives after the release is dropped.
The active-list reconciliation does not release transcripts itself. An archived agent's fresh
history response can arrive before the active-list response that omits it, while the chat is
open in History. Clearing history there would discard rows the user is reading. Until the active
list first hydrates, no agent is known to be archived, and every transcript stays. Deleting the
agent clears the transcript.
Removing the host from the registry is the destructive boundary: it stops the runtime and clears the
session and host-scoped setup state together.