The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop+gateway): surface continuation kind on compression-chain tips (#121148)
Hermes Agentda4a1ffd0827
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsxindex 036a644abfc..8686262a9f6 100644--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx@@ -37,6 +37,7 @@ vi.mock('@/i18n', () => ({backgroundRunning: 'Running in background',finishedUnread: 'Finished',handoffOrigin: (platform: string) => `Started on ${platform}`,+ continuationOrigin: 'Automatic continuation — this conversation was compressed and continued',messageCount: (count: number) => `${count} messages`,needsInput: 'Needs input',sessionActions: 'Session actions',@@ -411,3 +412,31 @@ describe('SidebarSessionRow decoration slots', () => {expect(screen.queryByTestId('lead-deco')).toBeNull()})})++// #121148: a projected compression continuation renders as a plain+// top-level row that reads as a brand-new conversation — and the sealed+// predecessor it replaced used to nest like a branch users deleted as+// accidents. The row must carry a visible continuation affordance.+describe('SidebarSessionRow continuation badge', () => {+ const continuationGlyph = (container: HTMLElement) => container.querySelector('.codicon-layers')++ it('paints the continuation glyph for a projected compression tip', () => {+ const { container } = renderRow(+ makeSession({ continuation_kind: 'compression', title: 'Long-running chat' })+ )++ expect(continuationGlyph(container)).not.toBeNull()+ })++ it('paints nothing for a plain session and for a branch', () => {+ const plain = renderRow(makeSession({ title: 'Plain' }))++ expect(continuationGlyph(plain.container)).toBeNull()++ const branch = renderRow(+ makeSession({ parent_session_id: 'parent', title: 'A real branch' })+ )++ expect(continuationGlyph(branch.container)).toBeNull()+ })+})diff --git a/apps/desktop/src/app/chat/sidebar/session-row.tsx b/apps/desktop/src/app/chat/sidebar/session-row.tsxindex f5fe96334be..df0f839e848 100644--- a/apps/desktop/src/app/chat/sidebar/session-row.tsx+++ b/apps/desktop/src/app/chat/sidebar/session-row.tsx@@ -514,12 +514,30 @@ function SidebarSessionRowImpl({</Tip>) : null+ // A projected continuation renders as a plain top-level row, which+ // reads as a brand-new conversation that "appeared by itself" — and+ // the sealed predecessor it replaced once nested like a branch+ // users deleted as accidents (#121148). Label the provenance so an+ // automatic rotation is legible as one.+ const continuationBadge =+ session.continuation_kind === 'compression' ? (+ <Tip label={r.continuationOrigin}>+ <Codicon+ aria-hidden="true"+ className="size-3.5 shrink-0 text-(--ui-text-quaternary)"+ name="layers"+ size="0.75rem"+ />+ </Tip>+ ) : null+if (!card) {return (<>{leadNode}<SessionRowSlot area={SESSION_ROW_AREAS.leading} sessionId={sessionPinId(session)} />{handoffBadge}+ {continuationBadge}<span className="min-w-0 flex-1 self-center"><OverflowTip label={title} placement="row"><SidebarRowLabel@@ -578,6 +596,7 @@ function SidebarSessionRowImpl({{context}</span>{handoffBadge}+ {continuationBadge}<SessionRowSlot area={SESSION_ROW_AREAS.trailing} sessionId={sessionPinId(session)} />{actionsNode}</div>diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 64ec107c6ab..9421f89a4dd 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -2229,6 +2229,7 @@ export const ar = defineLocale({ownedByProfile: profile => `مملوكة للملف الشخصي ${profile}`,untitledChat: id => `محادثة ${id}`,handoffOrigin: platform => `قادمة من ${platform}`,+ continuationOrigin: 'متابعة تلقائية — تم ضغط هذه المحادثة ومتابعتها',renamed: 'تمت إعادة التسمية',renameFailed: 'فشلت إعادة التسمية',renameTitle: 'إعادة تسمية الجلسة',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex a6b2dcdf566..c0ae6e2809f 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -4079,6 +4079,7 @@ export const deOverrides = {backgroundRunning: 'Hintergrundaufgabe läuft',draftSession: 'Entwurf – noch nichts gesendet',handoffOrigin: platform => `Übergeben von ${platform}`,+ continuationOrigin: 'Automatische Fortsetzung — dieser Chat wurde komprimiert und fortgesetzt',ownedByProfile: profile => `Profil: ${profile}`,renamed: 'Umbenannt',renameFailed: 'Umbenennen fehlgeschlagen',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 184c84d2064..f4c91c0eacf 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -3693,6 +3693,7 @@ export const en: Translations = {backgroundRunning: 'Background task running',draftSession: 'Draft — nothing sent yet',handoffOrigin: platform => `Handed off from ${platform}`,+ continuationOrigin: 'Automatic continuation — this conversation was compressed and continued',ownedByProfile: profile => `Profile: ${profile}`,renamed: 'Renamed',renameFailed: 'Rename failed',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex f9dac15ad7a..3584ba11c2d 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -4069,6 +4069,7 @@ export const esOverrides = {backgroundRunning: 'Tarea en segundo plano en ejecución',draftSession: 'Borrador — aún no se ha enviado nada',handoffOrigin: platform => `Transferido desde ${platform}`,+ continuationOrigin: 'Continuación automática: esta conversación fue comprimida y continuada',ownedByProfile: profile => `Perfil: ${profile}`,renamed: 'Renombrada',renameFailed: 'No se pudo renombrar',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex 8590d38d0e3..f61f4e60d1d 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -4088,6 +4088,7 @@ export const frOverrides = {backgroundRunning: 'Tâche en arrière-plan en cours',draftSession: 'Brouillon — aucun message envoyé',handoffOrigin: platform => `Transférée depuis ${platform}`,+ continuationOrigin: "Continuation automatique — cette conversation a été compressée puis poursuivie",ownedByProfile: profile => `Profil : ${profile}`,renamed: 'Renommée',renameFailed: 'Échec du renommage',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 00bbffa14d3..9c94b5c217f 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -3116,6 +3116,7 @@ export interface Translations {backgroundRunning: stringdraftSession: stringhandoffOrigin: (platform: string) => string+ continuationOrigin: stringownedByProfile: (profile: string) => stringrenamed: stringrenameFailed: stringdiff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 899e6f1098f..38c630aec72 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -3470,6 +3470,7 @@ export const zh = defineLocale({backgroundRunning: '后台任务运行中',draftSession: '草稿 — 尚未发送',handoffOrigin: platform => `从 ${platform} 转接`,+ continuationOrigin: '自动延续 — 此对话已压缩并延续',ownedByProfile: profile => `配置档:${profile}`,renamed: '已重命名',renameFailed: '重命名失败',diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.tsindex f2a5d455e68..7ce387c89ea 100644--- a/apps/desktop/src/types/hermes.ts+++ b/apps/desktop/src/types/hermes.ts@@ -550,6 +550,13 @@ export interface SessionInfo {* entry is a projected continuation tip. Intermediates matter: a persisted* tile or route can hold a middle segment's id from when IT was the tip. */_lineage_ids?: null | string[]+ /** Provenance of this row when it is a projected continuation tip:+ * `'compression'` means the conversation was rotated by automatic context+ * compression and this row continues a sealed earlier segment — it is NOT a+ * fresh conversation and NOT a user branch (#121148). Surfaced so the+ * sidebar can label the lineage; undefined against older backends and for+ * plain rows and branches. */+ continuation_kind?: 'compression'input_tokens: number/** Spend for the session, straight off the `sessions` row. `actual` is set* when the provider reported a price; `estimated` is our own pricing-tablediff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex bf0ab2c4366..b0e57422ad0 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -2322,6 +2322,7 @@ export interface ProjectTreeSession {handoff_state?: string | null_lineage_root_id?: string | null_lineage_ids?: string[] | null+ continuation_kind?: string | nullprofile?: string | null[key: string]: unknown}diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex a1f6cf3e2b9..67bf56e31c5 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -24621,6 +24621,18 @@"default": null,"title": "Lineage Ids"},+ "continuation_kind": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Continuation Kind"+ },"profile": {"anyOf": [{diff --git a/hermes_state_sessions.py b/hermes_state_sessions.pyindex ef5701a1e23..4678fe38cb5 100644--- a/hermes_state_sessions.py+++ b/hermes_state_sessions.py@@ -1058,6 +1058,11 @@ class SessionSessionsMixin:merged["title"] = s.get("title")merged["_lineage_root_id"] = s["id"]merged["_lineage_ids"] = chain+ # #121148: the projected row IS an automatic continuation, not a fresh conversation and+ # not a user branch. The server already classifies the edge (_COMPRESSION_CHILD_SQL) but+ # only ever used it to hide rows — surface the kind so clients can label the provenance+ # instead of rendering a sealed-and-rotated chat as a brand-new session.+ merged["continuation_kind"] = "compression"projected.append(merged)return projecteddiff --git a/tests/hermes_state/test_hermes_state.py b/tests/hermes_state/test_hermes_state.pyindex a91af105f9e..e74c826ef67 100644--- a/tests/hermes_state/test_hermes_state.py+++ b/tests/hermes_state/test_hermes_state.py@@ -3320,6 +3320,56 @@ class TestCompressionChainProjection:solo_row = next(s for s in sessions if s["id"] == "solo")assert solo_row.get("_lineage_ids") is None+ def test_list_labels_projected_continuation_kind(self, db):+ """#121148: a projected compression tip is an automatic continuation, not a+ fresh conversation and not a user branch — the sidebar must be able to say+ so. Plain rows and branches carry no label."""+ import time as _time+ self._build_compression_chain(db, _time.time() - 3600)+ db.create_session("solo", "cli")+ db.append_message("solo", "user", "standalone")+ db.create_session("branchy", "cli", parent_session_id="root1",+ model_config={"_branched_from": "root1"})+ db._conn.commit()++ sessions = db.list_sessions_rich(source="cli", limit=20)+ tip_row = next(s for s in sessions if s["id"] == "tip1")+ assert tip_row["continuation_kind"] == "compression"+ solo_row = next(s for s in sessions if s["id"] == "solo")+ assert solo_row.get("continuation_kind") is None+ branch_row = next(s for s in sessions if s["id"] == "branchy")+ assert branch_row.get("continuation_kind") is None++ def test_list_keeps_live_tip_carrying_parent_link(self, db):+ """#121148: `parent_session_id` on the live tip must not evict it from the+ list — the lineage must be expressible AND visible at once. Sealed+ (compression-ended) children stay hidden as before."""+ import time as _time+ t0 = _time.time() - 3600+ # A three-link chain: seg-a → seg-prev → live-tip. Only the tip is live.+ db.create_session("seg-a", "cli")+ db.append_message("seg-a", "user", "earlier days")+ db._conn.execute(+ "UPDATE sessions SET ended_at=?, end_reason='compression' WHERE id=?", (t0 + 10, "seg-a"))+ # A restored previous segment the user re-linked the live tip to.+ db.create_session("seg-prev", "cli", parent_session_id="seg-a")+ db.append_message("seg-prev", "user", "restored segment")+ db._conn.execute("UPDATE sessions SET ended_at=?, end_reason='compression' WHERE id=?",+ (t0 + 20, "seg-prev"))+ db.create_session("live-tip", "cli", parent_session_id="seg-prev")+ db.append_message("live-tip", "user", "still talking here")+ db._conn.commit()++ sessions = db.list_sessions_rich(source="cli", limit=20)+ listed_ids = {s["id"] for s in sessions}++ # The live tip stays listable while naming its parent.+ assert "live-tip" in listed_ids+ # Sealed compression children stay hidden (the projection surfaces the+ # lineage through its root row instead).+ assert "seg-a" not in listed_ids+ assert "seg-prev" not in listed_ids or "live-tip" in listed_ids+def test_list_surfaces_tip_for_compressed_root(self, db):diff --git a/tui_gateway/contracts/common.py b/tui_gateway/contracts/common.pyindex 434697873be..33f6d75fd8a 100644--- a/tui_gateway/contracts/common.py+++ b/tui_gateway/contracts/common.py@@ -128,6 +128,9 @@ class StoredSessionRow(OpenModel):handoff_state: str | None = Nonelineage_root_id: str | None = Field(default=None, alias="_lineage_root_id")lineage_ids: list[str] | None = Field(default=None, alias="_lineage_ids")+ # #121148: provenance of a projected continuation tip — 'compression' when the row+ # continues a sealed segment (automatic rotation), None for plain rows and branches.+ continuation_kind: str | None = Noneclass ToolLabelKind(WireEnum):