mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
Show a shimmering "Summarizing thread" label during auto-compaction, skip the post-turn hydrate when compaction fired so the live transcript does not collapse to the stored summary-only session.
38 lines
1,006 B
TypeScript
38 lines
1,006 B
TypeScript
import { atom, computed } from 'nanostores'
|
|
|
|
import { $activeSessionId } from './session'
|
|
|
|
// Per-session flag while auto-compaction runs mid-turn. Without it the
|
|
// transcript looks like it reset; per-session so a background chat can't
|
|
// clobber the foreground view.
|
|
const keyFor = (sessionId: string | null | undefined): string => sessionId ?? ''
|
|
|
|
export const $compactingSessions = atom<Record<string, true>>({})
|
|
|
|
export const $compactionActive = computed(
|
|
[$compactingSessions, $activeSessionId],
|
|
(sessions, activeId) => keyFor(activeId) in sessions
|
|
)
|
|
|
|
export function setSessionCompacting(sessionId: string | null | undefined, active: boolean): void {
|
|
const key = keyFor(sessionId)
|
|
const sessions = $compactingSessions.get()
|
|
|
|
if (active) {
|
|
if (key in sessions) {
|
|
return
|
|
}
|
|
|
|
$compactingSessions.set({ ...sessions, [key]: true })
|
|
|
|
return
|
|
}
|
|
|
|
if (!(key in sessions)) {
|
|
return
|
|
}
|
|
|
|
const next = { ...sessions }
|
|
delete next[key]
|
|
$compactingSessions.set(next)
|
|
}
|