diff --git a/apps/desktop/src/app/chat/index.tsx b/apps/desktop/src/app/chat/index.tsx index f135b0aae959..675d17b4d572 100644 --- a/apps/desktop/src/app/chat/index.tsx +++ b/apps/desktop/src/app/chat/index.tsx @@ -20,12 +20,12 @@ import type { ChatMessage } from '@/lib/chat-messages' import { quickModelOptions, sessionTitle } from '@/lib/chat-runtime' import { useIncrementalExternalStoreRuntime } from '@/lib/incremental-external-store-runtime' import { cn } from '@/lib/utils' +import { migrateSessionDraft } from '@/store/composer' +import { migrateQueuedPrompts } from '@/store/composer-queue' import { $pinnedSessionIds } from '@/store/layout' import { $petActive } from '@/store/pet' import { $petOverlayActive } from '@/store/pet-overlay' import { $gatewaySwapTarget, $profiles } from '@/store/profile' -import { migrateSessionDraft } from '@/store/composer' -import { migrateQueuedPrompts } from '@/store/composer-queue' import { $contextSuggestions, $freshDraftReady, @@ -281,6 +281,7 @@ export function ChatView({ const selectedSessionId = useStore(view.$storedId) const sessions = useStore($sessions) const resumeExhaustedSessionId = useStore($resumeExhaustedSessionId) + // Durable composer/queue scope (lineage root) so auto-compression tip rotation // does not wipe an in-progress draft or orphan /queue entries. const queueSessionKey = useMemo( diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx index 854a0085925d..7eb6e13a82be 100644 --- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx +++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx @@ -5,9 +5,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { getSessionMessages, type SessionInfo } from '@/hermes' import { createClientSessionState } from '@/lib/chat-runtime' +import { clearSessionDraft, stashSessionDraft, takeSessionDraft } from '@/store/composer' import { $activeGatewayProfile, $newChatProfile, ensureGatewayProfile } from '@/store/profile' import { $projectScope, $projectTree, ALL_PROJECTS } from '@/store/projects' -import { clearSessionDraft, stashSessionDraft, takeSessionDraft } from '@/store/composer' import { $activeSessionId, $activeSessionStoredIdRotation, diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts index 2eaa406adf3a..9deb479e7b77 100644 --- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts +++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts @@ -245,6 +245,7 @@ export function useSessionActions({ const nextId = storedIdRotation.nextStoredSessionId const sessions = $sessions.get() const resolvedNext = resolveComposerSessionKey(nextId, sessions) + const durableKey = resolvedNext && resolvedNext !== nextId ? resolvedNext