The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep no-op tail re-records as LRU touches
teknium1c3d2e108f1d2
diff --git a/apps/desktop/src/store/transcript-tail.test.ts b/apps/desktop/src/store/transcript-tail.test.tsindex cd33cbb72d6..0aafeb279c1 100644--- a/apps/desktop/src/store/transcript-tail.test.ts+++ b/apps/desktop/src/store/transcript-tail.test.ts@@ -1,6 +1,6 @@import { beforeEach, describe, expect, it } from 'vitest'-import { $transcriptTailBySessionId, recordTranscriptTail } from './transcript-tail'+import { $transcriptTailBySessionId, clearTranscriptTailPaging, recordTranscriptTail } from './transcript-tail'const page = (count: number, limit = 10) => ({messages: Array.from({ length: count }, (_, i) => ({ id: `m${i}` })),@@ -16,9 +16,11 @@ describe('recordTranscriptTail no-op suppression', () => {recordTranscriptTail('s1', page(5))let notifications = 0+const unsub = $transcriptTailBySessionId.subscribe(() => {notifications += 1})+notifications = 0recordTranscriptTail('s1', page(5))@@ -31,9 +33,11 @@ describe('recordTranscriptTail no-op suppression', () => {recordTranscriptTail('s1', page(5))let notifications = 0+const unsub = $transcriptTailBySessionId.subscribe(() => {notifications += 1})+notifications = 0recordTranscriptTail('s1', page(7))@@ -41,4 +45,20 @@ describe('recordTranscriptTail no-op suppression', () => {expect(notifications).toBe(1)})++ it('keeps a no-op re-recorded entry at the MRU end so it survives the next eviction', () => {+ clearTranscriptTailPaging()+ recordTranscriptTail('active', page(5))++ for (let i = 0; i < 255; i += 1) {+ recordTranscriptTail(`other-${i}`, page(5))+ }++ // Identical re-record: no publish, but it must still count as recent use.+ recordTranscriptTail('active', page(5))+ recordTranscriptTail('newcomer', page(5))++ expect($transcriptTailBySessionId.get().active).toBeDefined()+ expect($transcriptTailBySessionId.get()['other-0']).toBeUndefined()+ })})diff --git a/apps/desktop/src/store/transcript-tail.ts b/apps/desktop/src/store/transcript-tail.tsindex 84ef8adf5e4..74c8394f62b 100644--- a/apps/desktop/src/store/transcript-tail.ts+++ b/apps/desktop/src/store/transcript-tail.ts@@ -110,11 +110,17 @@ function sameTailState(a: TranscriptTailState, b: TranscriptTailState): booleanfunction setTranscriptTailEntry(key: string, state: TranscriptTailState): void {const current = $transcriptTailBySessionId.get()+// Heartbeats re-record identical entries; a needless .set() re-renders the// whole chat tree through the tail atom (#113842).if (key in current && sameTailState(current[key], state)) {+ // Still a use of the entry: bump it to the MRU end so the constantly+ // re-read active session is not the next eviction candidate.+ transcriptTailOrder = [...transcriptTailOrder.filter(candidate => candidate !== key), key]+return}+const existing = new Set(Object.keys(current))transcriptTailOrder = transcriptTailOrder.filter(candidate => candidate !== key && existing.has(candidate))transcriptTailOrder.push(key)