The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): let each chat hide its composer status stack
brooklyn!accb82032cfe
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex f5eafb4e15d..e85dc93f426 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -154,6 +154,8 @@ fill/shadow), `ghost`, `floating` (a control loose from any surface — opaquepopover fill + `shadow-md`, hover lifts the glyph only), `link`, `text`(boxless quiet inline — "Cancel", "Clear"), `textStrong` (bold underlinedinline affordance — "Change", "Open logs").+`grip` is the quiet, fill-free drawer handle; pair it with size `grip` for a+48×16 hit area around a small horizontal ridge.**Sizes:** `default`, `xs`, `sm`, `lg`, `inline` (flush, zero box — for buttonsthat sit inside a heading/sentence; replaces `h-auto px-0 py-0`), `micro`@@ -346,6 +348,10 @@ so glass and message-bubble transparency do not reveal scrolling text.pause/resume preserve the user's disclosure choice. Error banners meet thestack's top edge without a blank padding strip. File and preview links remainvisible at the bottom of the stack, below the queue and all status groups.+ A centered ridge on the composer's top edge hides/reveals the entire stack,+ including the git row, with a short downward/upward drawer slide. Its choice+ persists per conversation and owner, not globally. Hidden sections stay+ mounted but inert so their disclosure choices survive; reduced motion is instant.- Popping out a composer makes it the window's only visible composer. It keepsits viewport placement while hover or keyboard focus selects a chat pane;moving back into the editor retains that recipient. Drafts, attachments anddiff --git a/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.test.tsxnew file mode 100644index 00000000000..f414f7af507--- /dev/null+++ b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.test.tsx@@ -0,0 +1,31 @@+import { act, renderHook } from '@testing-library/react'+import { beforeEach, expect, it, vi } from 'vitest'++import { $collapsedStatusDrawers } from '@/store/composer-status-drawer'++import { useStatusDrawer } from './use-status-drawer'++vi.mock('@/store/session-states', () => ({+ knownOwnerForSession: () => ({ connectionId: 'local', profile: 'default', targetProfile: 'default' })+}))++beforeEach(() => $collapsedStatusDrawers.set([]))++it('keeps stored conversations independent from drafts and other conversations', () => {+ const { result, rerender } = renderHook(({ sessionKey }) => useStatusDrawer(sessionKey), {+ initialProps: { sessionKey: null as string | null }+ })++ act(() => result.current.toggle())+ expect(result.current.collapsed).toBe(true)++ rerender({ sessionKey: 'existing-a' })+ expect(result.current.collapsed).toBe(false)+ act(() => result.current.toggle())+ rerender({ sessionKey: 'existing-b' })+ expect(result.current.collapsed).toBe(false)+ rerender({ sessionKey: 'existing-a' })+ expect(result.current.collapsed).toBe(true)+ rerender({ sessionKey: null })+ expect(result.current.collapsed).toBe(false)+})diff --git a/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.ts b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.tsnew file mode 100644index 00000000000..27985d62214--- /dev/null+++ b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.ts@@ -0,0 +1,50 @@+import { useStore } from '@nanostores/react'+import { useState } from 'react'++import { useStoreSelector } from '@/lib/use-session-slice'+import { $collapsedStatusDrawers, setStatusDrawerCollapsed, statusDrawerKey } from '@/store/composer-status-drawer'+import { $activeConnectionId } from '@/store/connections'+import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile'+import { isSessionOwnerRoute } from '@/store/session-request-router'+import { knownOwnerForSession } from '@/store/session-states'++import { useComposerScope } from '../scope'++export function useStatusDrawer(sessionKey: string | null) {+ const scope = useComposerScope()+ const activeProfile = useStore($activeGatewayProfile)+ const activeConnection = useStore($activeConnectionId)+ const owner = knownOwnerForSession(sessionKey)+ const route = isSessionOwnerRoute(owner) ? owner : null++ const profile = normalizeProfileKey(+ route?.profile ?? (typeof owner === 'string' ? owner : scope.profile ?? activeProfile)+ )++ const targetProfile = normalizeProfileKey(route?.targetProfile ?? profile)+ const connectionId = route ? route.connectionId ?? null : owner ? null : scope.connectionId ?? activeConnection+ const ownerKey = JSON.stringify([connectionId, profile, targetProfile])+ const key = sessionKey ? statusDrawerKey({ connectionId, profile, targetProfile, sessionId: sessionKey }) : null+ const saved = useStoreSelector($collapsedStatusDrawers, keys => key !== null && keys.includes(key))+ const draftKey = key ?? ownerKey+ const [draft, setDraft] = useState({ key: draftKey, collapsed: false })++ // Unsaved drafts have no durable preference. Never carry their choice into+ // a stored conversation selected from the sidebar or a subsequent new chat.+ if (draft.key !== draftKey) {+ setDraft({ key: draftKey, collapsed: false })+ }++ const collapsed = key ? saved : draft.key === draftKey && draft.collapsed++ return {+ collapsed,+ toggle: () => {+ if (key) {+ setStatusDrawerCollapsed(key, !collapsed)+ } else {+ setDraft({ key: draftKey, collapsed: !collapsed })+ }+ }+ }+}diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsxindex 249f8e5f721..9d2a953f1df 100644--- a/apps/desktop/src/app/chat/composer/index.tsx+++ b/apps/desktop/src/app/chat/composer/index.tsx@@ -1,6 +1,15 @@import { ComposerPrimitive } from '@assistant-ui/react'import { useStore } from '@nanostores/react'-import { type ClipboardEvent, type FormEvent, type KeyboardEvent, useCallback, useEffect, useMemo, useRef } from 'react'+import {+ type ClipboardEvent,+ type FormEvent,+ type KeyboardEvent,+ useCallback,+ useEffect,+ useId,+ useMemo,+ useRef+} from 'react'import { useTourMarker } from '@/app/chat/tour-marker'import { useHudComposerDrag } from '@/app/hud/composer-drag'@@ -66,6 +75,7 @@ import { useComposerVoice } from './hooks/use-composer-voice'import { useEmojiCompletions } from './hooks/use-emoji-completions'import { useComposerMicroActions } from './hooks/use-micro-actions'import { useSlashCompletions } from './hooks/use-slash-completions'+import { useStatusDrawer } from './hooks/use-status-drawer'import { useSessionStatusPresence } from './hooks/use-status-presence'import { shouldConvertPasteToAttachment } from './large-paste'import { ActionBadges } from './micro-actions'@@ -84,6 +94,7 @@ import {import { useComposerScope, useComposerSurfaceId } from './scope'import { ComposerStatusStack } from './status-stack'import { CodingStatusRow } from './status-stack/coding-row'+import { StatusDrawerContent, StatusDrawerToggle } from './status-stack/drawer'import { SuggestionPills } from './suggestion-pills'import { extractClipboardImageBlobs, openDirectiveScope } from './text-utils'import { ComposerTriggerPopover } from './trigger-popover'@@ -193,6 +204,9 @@ export function ChatBar({// undelivered behind the blocked tool batch). Drives the button affordance.const blockingPrompt = useStore(useMemo(() => sessionBlockingPrompt(sessionId ?? null), [sessionId]))const activeQueueSessionKey = queueSessionKey || sessionId || null+ const { collapsed: statusDrawerCollapsed, toggle: toggleStatusDrawer } = useStatusDrawer(activeQueueSessionKey)+ const statusDrawerId = useId()+ const codingDrawerId = useId()// Status items (subagents, background processes) are keyed by the RUNTIME// session id — gateway events and process.list both speak that id. Only the@@ -1298,37 +1312,39 @@ export function ChatBar({queue). An in-flow dock child: the dock is bottom-anchored, so itgrows upward over the thread and the dock's own measurement coversit. Collapses to nothing when every status is empty. */}- <ComposerStatusStack- onSubmit={onSubmit}- queue={- activeQueueSessionKey && queuedPrompts.length > 0 ? (- <QueuePanel- busy={busy}- editingId={queueEdit?.entryId ?? null}- entries={queuedPrompts}- onDelete={id => {- if (removeQueuedPrompt(activeQueueSessionKey, id) && queueEdit?.entryId === id) {- exitQueuedEdit('cancel')- }- }}- onEdit={beginQueuedEdit}- onResume={() => {- unparkQueuedPrompts(activeQueueSessionKey)-- // Idle → kick the head immediately; busy → the settle drain- // takes over now that the park is lifted.- if (!busy) {- void drainNextQueued()- }- }}- onSendNow={id => void sendQueuedNow(id)}- onSteerNow={id => void steerQueuedNow(id)}- parked={queueParked}- />- ) : null- }- sessionId={statusSessionId}- />+ <StatusDrawerContent collapsed={statusDrawerCollapsed} id={statusDrawerId}>+ <ComposerStatusStack+ onSubmit={onSubmit}+ queue={+ activeQueueSessionKey && queuedPrompts.length > 0 ? (+ <QueuePanel+ busy={busy}+ editingId={queueEdit?.entryId ?? null}+ entries={queuedPrompts}+ onDelete={id => {+ if (removeQueuedPrompt(activeQueueSessionKey, id) && queueEdit?.entryId === id) {+ exitQueuedEdit('cancel')+ }+ }}+ onEdit={beginQueuedEdit}+ onResume={() => {+ unparkQueuedPrompts(activeQueueSessionKey)++ // Idle → kick the head immediately; busy → the settle drain+ // takes over now that the park is lifted.+ if (!busy) {+ void drainNextQueued()+ }+ }}+ onSendNow={id => void sendQueuedNow(id)}+ onSteerNow={id => void steerQueuedNow(id)}+ parked={queueParked}+ />+ ) : null+ }+ sessionId={statusSessionId}+ />+ </StatusDrawerContent><ComposerPrimitive.RootclassName={cn('group/composer relative w-full overflow-visible rounded-2xl',@@ -1344,7 +1360,7 @@ export function ChatBar({data-hud-grabbing={hudGrabbing ? '' : undefined}data-popped-out={poppedOut ? '' : undefined}data-slot="composer-root"- data-status-stack={statusStackVisible ? '' : undefined}+ data-status-stack={statusStackVisible && !statusDrawerCollapsed ? '' : undefined}data-thread-scrolled-up={scrolledUp ? '' : undefined}data-tip-region=""data-tour={composerTourMarker}@@ -1398,6 +1414,13 @@ export function ChatBar({/>)}<div className="relative w-full rounded-[inherit]">+ {!hudMode && !guidedChat && (+ <StatusDrawerToggle+ collapsed={statusDrawerCollapsed}+ controls={`${statusDrawerId} ${codingDrawerId}`}+ onToggle={toggleStatusDrawer}+ />+ )}{hudMode && busy && <span aria-hidden className="arc-border arc-composer" />}<divclassName={cn(@@ -1416,21 +1439,23 @@ export function ChatBar({><div aria-hidden className={composerInputBacking} />{!guidedChat && (- <CodingStatusRow- onBranchOff={handleBranchOff}- onConvertBranch={handleConvertBranch}- onListBranches={handleListBranches}- // A tile's rail reviews ITS worktree: pin the pane's scope to- // this surface's cwd. Main keeps the classic follow-the-- // active-session scope (null).- onOpen={() => toggleReview(scope.target === 'main' ? null : (cwd ?? null), scope.target)}- onOpenWorktree={openInWorktree}- onSwitchBranch={handleSwitchBranch}- // Blank in a bot chat: the row hides itself without a repo,- // and stops probing git / GitHub for a surface that has no- // branch to show. Cheaper than a second composer.- repoPath={botChat ? undefined : cwd}- />+ <StatusDrawerContent collapsed={statusDrawerCollapsed} id={codingDrawerId}>+ <CodingStatusRow+ onBranchOff={handleBranchOff}+ onConvertBranch={handleConvertBranch}+ onListBranches={handleListBranches}+ // A tile's rail reviews ITS worktree: pin the pane's scope to+ // this surface's cwd. Main keeps the classic follow-the-+ // active-session scope (null).+ onOpen={() => toggleReview(scope.target === 'main' ? null : (cwd ?? null), scope.target)}+ onOpenWorktree={openInWorktree}+ onSwitchBranch={handleSwitchBranch}+ // Blank in a bot chat: the row hides itself without a repo,+ // and stops probing git / GitHub for a surface that has no+ // branch to show. Cheaper than a second composer.+ repoPath={botChat ? undefined : cwd}+ />+ </StatusDrawerContent>)}<divclassName={cn(diff --git a/apps/desktop/src/app/chat/composer/status-stack/drawer.css b/apps/desktop/src/app/chat/composer/status-stack/drawer.cssnew file mode 100644index 00000000000..dc81dbd9625--- /dev/null+++ b/apps/desktop/src/app/chat/composer/status-stack/drawer.css@@ -0,0 +1,51 @@+.status-drawer {+ display: grid;+ grid-template-rows: 1fr;+ /* Quick lift, then a soft landing. Closing is deliberately shorter. */+ transition: grid-template-rows 260ms cubic-bezier(0.16, 1, 0.3, 1);+}++.status-drawer-clip {+ min-height: 0;+ overflow: hidden;+}++.status-drawer-content {+ /* The bottom-anchored dock already slides this content as the row opens.+ Another translate doubles its travel and hides the first half of arrival. */+ visibility: visible;+ transition: visibility 0s;+}++.status-drawer[data-collapsed] {+ grid-template-rows: 0fr;+ transition: grid-template-rows 150ms cubic-bezier(0.4, 0, 0.2, 1);+}++.status-drawer[data-collapsed] .status-drawer-content {+ visibility: hidden;+ transition: visibility 0s 150ms;+}++.status-drawer-toggle {+ opacity: 0.35;+ transition: opacity 120ms ease-out, color 120ms ease-out;+}++.status-drawer-toggle:is(:hover, :focus-visible) {+ opacity: 1;+}++/* Hidden content stays mounted, keeping the grip available to reopen it. */+[data-slot='composer-dock']:not(:has([data-slot='composer-status-stack'], .coding-status-bar)) .status-drawer-toggle {+ display: none;+}++@media (prefers-reduced-motion: reduce) {+ .status-drawer,+ .status-drawer[data-collapsed],+ .status-drawer-content,+ .status-drawer[data-collapsed] .status-drawer-content {+ transition: none;+ }+}diff --git a/apps/desktop/src/app/chat/composer/status-stack/drawer.tsx b/apps/desktop/src/app/chat/composer/status-stack/drawer.tsxnew file mode 100644index 00000000000..8fd9807f3b8--- /dev/null+++ b/apps/desktop/src/app/chat/composer/status-stack/drawer.tsx@@ -0,0 +1,59 @@+import './drawer.css'++import type { ReactNode } from 'react'++import { Button } from '@/components/ui/button'+import { Tip } from '@/components/ui/tooltip'+import { useI18n } from '@/i18n'++interface StatusDrawerContentProps {+ children: ReactNode+ collapsed: boolean+ id: string+}++/** Keep the live sections mounted: hiding the drawer must not reset their disclosures. */+export function StatusDrawerContent({ children, collapsed, id }: StatusDrawerContentProps) {+ return (+ <div+ aria-hidden={collapsed || undefined}+ className="status-drawer"+ data-collapsed={collapsed ? '' : undefined}+ id={id}+ inert={collapsed}+ >+ <div className="status-drawer-clip">+ <div className="status-drawer-content">{children}</div>+ </div>+ </div>+ )+}++interface StatusDrawerToggleProps {+ collapsed: boolean+ controls: string+ onToggle: () => void+}++export function StatusDrawerToggle({ collapsed, controls, onToggle }: StatusDrawerToggleProps) {+ const { t } = useI18n()+ const label = collapsed ? t.statusStack.showStack : t.statusStack.hideStack++ return (+ <Tip label={label}>+ <Button+ aria-controls={controls}+ aria-expanded={!collapsed}+ aria-label={label}+ className="status-drawer-toggle absolute -top-2 left-1/2 z-10 -translate-x-1/2"+ data-slot="status-drawer-toggle"+ onClick={onToggle}+ size="grip"+ type="button"+ variant="grip"+ >+ <span aria-hidden className="h-0.75 w-7 rounded-full bg-current" />+ </Button>+ </Tip>+ )+}diff --git a/apps/desktop/src/components/ui/button.tsx b/apps/desktop/src/components/ui/button.tsxindex fdbb64b8c0d..97fe05a7403 100644--- a/apps/desktop/src/components/ui/button.tsx+++ b/apps/desktop/src/components/ui/button.tsx@@ -26,6 +26,7 @@ const buttonVariants = cva(secondary:'bg-(--ui-bg-quaternary) text-(--ui-text-primary) hover:bg-(--chrome-action-hover) hover:text-(--ui-text-primary)',ghost: 'text-(--ui-text-secondary) hover:bg-(--chrome-action-hover) hover:text-(--ui-text-primary)',+ grip: 'bg-transparent text-(--ui-text-tertiary) transition-colors hover:text-(--ui-text-secondary) focus-visible:text-(--ui-text-primary)',// A control floating free of any surface (fan-menu discs, detached// chips): the menu/popover treatment — opaque popover fill + the// shared `shadow-md` ring-and-drop. Hover only lifts the glyph; a fill@@ -55,6 +56,7 @@ const buttonVariants = cva('icon-xs': "size-6 rounded-[4px] [&_svg:not([class*='size-'])]:size-3",'icon-sm': 'size-8 rounded-[4px]','icon-lg': 'size-10 rounded-[4px]',+ grip: 'h-4 w-12 rounded-full p-0','icon-titlebar':'titlebar-icon-button h-(--titlebar-control-height) w-(--titlebar-control-size) rounded-[4px] [&_svg:not([class*="size-"])]:size-(--titlebar-icon-size)'}diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 90cf9b6a45f..3187d4cd011 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -2234,6 +2234,8 @@ export const ar = defineLocale({}},statusStack: {+ hideStack: 'إخفاء لوحة الحالة',+ showStack: 'إظهار لوحة الحالة',agents: 'الوكلاء',background: count => `${count} في الخلفية`,goalActive: 'الهدف نشط',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 0fb6235fa90..3221852be72 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -3175,6 +3175,8 @@ export const en: Translations = {},statusStack: {+ hideStack: 'Hide status stack',+ showStack: 'Show status stack',agents: 'Agents',background: count => `${count} Background`,goalActive: 'Goal active',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 80bd2549d73..0e51f012c39 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -2604,6 +2604,8 @@ export const ja = defineLocale({},statusStack: {+ hideStack: 'ステータススタックを隠す',+ showStack: 'ステータススタックを表示',agents: 'エージェント',background: count => `バックグラウンド ${count} 件`,goalActive: '目標進行中',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex e4806d00fdf..d72e2dca58e 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -2919,6 +2919,8 @@ export const ru = defineLocale({}},statusStack: {+ hideStack: 'Скрыть панель состояния',+ showStack: 'Показать панель состояния',agents: 'Агенты',background: count => `${count} ${RU_NOUN(count, 'фоновая задача', 'фоновые задачи', 'фоновых задач')}`,goalActive: 'Цель активна',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 4e87fd8e84f..798229d1a11 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -2677,6 +2677,8 @@ export interface Translations {}statusStack: {+ hideStack: string+ showStack: stringagents: stringbackground: (count: number) => stringgoalActive: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex e303a84e7e6..5a8c53d41d6 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -2589,6 +2589,8 @@ export const zhHant = defineLocale({},statusStack: {+ hideStack: '隱藏狀態面板',+ showStack: '顯示狀態面板',agents: '代理',background: count => `${count} 個背景任務`,goalActive: '目標進行中',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex dcc22d4b01e..5316dec4bbf 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -3315,6 +3315,8 @@ export const zh = defineLocale({},statusStack: {+ hideStack: '隐藏状态面板',+ showStack: '显示状态面板',agents: '代理',background: count => `${count} 个后台任务`,goalActive: '目标进行中',diff --git a/apps/desktop/src/store/composer-status-drawer.test.ts b/apps/desktop/src/store/composer-status-drawer.test.tsnew file mode 100644index 00000000000..b7e06906732--- /dev/null+++ b/apps/desktop/src/store/composer-status-drawer.test.ts@@ -0,0 +1,42 @@+import { beforeEach, expect, it, vi } from 'vitest'++beforeEach(() => {+ window.localStorage.clear()+ vi.resetModules()+})++it('restores the hidden choice without sharing it with another session or owner', async () => {+ const store = await import('./composer-status-drawer')+ const scope = { connectionId: 'local', profile: 'default', targetProfile: 'default', sessionId: 'chat-a' }+ const key = store.statusDrawerKey(scope)+ const otherSession = store.statusDrawerKey({ ...scope, sessionId: 'chat-b' })+ const otherProfile = store.statusDrawerKey({ ...scope, profile: 'coder', targetProfile: 'coder' })+ const otherConnection = store.statusDrawerKey({ ...scope, connectionId: 'remote' })++ store.setStatusDrawerCollapsed(key, true)+ store.setStatusDrawerCollapsed(otherSession, true)+ store.setStatusDrawerCollapsed(otherSession, false)+ vi.resetModules()++ const restored = await import('./composer-status-drawer')+ expect(restored.$collapsedStatusDrawers.get()).toEqual([key])+ expect(restored.$collapsedStatusDrawers.get()).not.toContain(otherProfile)+ expect(restored.$collapsedStatusDrawers.get()).not.toContain(otherConnection)+})++it('follows local profile renames and scopes profile removal to the exact owner', async () => {+ const store = await import('./composer-status-drawer')+ const scope = { connectionId: 'local', profile: 'coder', targetProfile: 'coder', sessionId: 'chat' }+ const local = store.statusDrawerKey(scope)+ const remote = store.statusDrawerKey({ ...scope, connectionId: 'remote' })+ const renamed = store.statusDrawerKey({ ...scope, profile: 'work', targetProfile: 'work' })++ store.setStatusDrawerCollapsed(local, true)+ store.setStatusDrawerCollapsed(remote, true)+ store.migrateStatusDrawersForProfile('coder', 'work')+ expect(store.$collapsedStatusDrawers.get()).toEqual([renamed, remote])+ store.dropStatusDrawersForProfile('work')+ expect(store.$collapsedStatusDrawers.get()).toEqual([remote])+ store.dropStatusDrawersForProfile('coder', { connectionId: 'remote', profile: 'coder', targetProfile: 'coder' })+ expect(store.$collapsedStatusDrawers.get()).toEqual([])+})diff --git a/apps/desktop/src/store/composer-status-drawer.ts b/apps/desktop/src/store/composer-status-drawer.tsnew file mode 100644index 00000000000..22c6035dd04--- /dev/null+++ b/apps/desktop/src/store/composer-status-drawer.ts@@ -0,0 +1,100 @@+import { Codecs, persistentAtom } from '@/lib/persisted'++interface StatusDrawerScope {+ connectionId: string | null+ profile: string+ targetProfile: string+ sessionId: string+}++const MAX_SAVED_DRAWERS = 512++function decodeScope(key: string): StatusDrawerScope | null {+ try {+ const value: unknown = JSON.parse(key)++ if (+ !Array.isArray(value) ||+ value.length !== 4 ||+ (value[0] !== null && typeof value[0] !== 'string') ||+ !value.slice(1).every(part => typeof part === 'string' && part.length > 0)+ ) {+ return null+ }++ const [connectionId, profile, targetProfile, sessionId] = value as [string | null, string, string, string]++ return { connectionId, profile, targetProfile, sessionId }+ } catch {+ return null+ }+}++export function statusDrawerKey(scope: StatusDrawerScope): string {+ return JSON.stringify([scope.connectionId, scope.profile, scope.targetProfile, scope.sessionId])+}++/** Only hidden drawers need an entry; new conversations keep the existing open default. */+export const $collapsedStatusDrawers = persistentAtom<string[]>(+ 'hermes.desktop.collapsedStatusDrawers.v1',+ [],+ Codecs.json(value =>+ Array.isArray(value)+ ? [...new Set(value.filter((key): key is string => typeof key === 'string' && decodeScope(key) !== null))].slice(+ -MAX_SAVED_DRAWERS+ )+ : []+ )+)++export function setStatusDrawerCollapsed(key: string, collapsed: boolean): void {+ const next = $collapsedStatusDrawers.get().filter(saved => saved !== key)++ if (collapsed) {+ next.push(key)+ }++ $collapsedStatusDrawers.set(next.slice(-MAX_SAVED_DRAWERS))+}++export function migrateStatusDrawersForProfile(from: string, to: string): void {+ const renamed = $collapsedStatusDrawers.get().map(key => {+ const scope = decodeScope(key)++ if (!scope || (scope.connectionId !== null && scope.connectionId !== 'local')) {+ return key+ }++ return statusDrawerKey({+ ...scope,+ profile: scope.profile === from ? to : scope.profile,+ targetProfile: scope.targetProfile === from ? to : scope.targetProfile+ })+ })++ $collapsedStatusDrawers.set([...new Set(renamed)])+}++export function dropStatusDrawersForProfile(+ profile: string,+ route?: { connectionId?: string; profile?: string; targetProfile?: string }+): void {+ $collapsedStatusDrawers.set(+ $collapsedStatusDrawers.get().filter(key => {+ const scope = decodeScope(key)++ if (!scope) {+ return false+ }++ const matches = route+ ? scope.profile === route.profile?.trim() &&+ (!route.targetProfile || scope.targetProfile === route.targetProfile.trim()) &&+ (!route.connectionId || scope.connectionId === route.connectionId.trim())+ : (scope.connectionId === null || scope.connectionId === 'local') &&+ (scope.profile === profile || scope.targetProfile === profile)++ return !matches+ })+ )+}diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.tsindex 95e56af19db..ad815c6b809 100644--- a/apps/desktop/src/store/session-states.ts+++ b/apps/desktop/src/store/session-states.ts@@ -36,6 +36,7 @@ import { stableArray } from '@/lib/stable-array'import { readJson, writeJson } from '@/lib/storage'import type { SessionInfo } from '@/types/hermes'+import { dropStatusDrawersForProfile, migrateStatusDrawersForProfile } from './composer-status-drawer'import { dropPreviewTabsForProfile, migratePreviewTabsForProfile, setPreviewScope } from './preview'import { dropPreviewArtifactsForProfile, migratePreviewArtifactsForProfile } from './preview-status'import { $activeGatewayProfile, normalizeProfileKey } from './profile'@@ -2080,6 +2081,7 @@ export function dropTilesForProfile(const name = normalizeProfileKey(profile)dropPreviewArtifactsForProfile(name, route)+ dropStatusDrawersForProfile(name, route)// Route fields go through the SAME canonicalization as `name` below — a// source-scoped delete must not be defeated by stray whitespace around a// profile name that a non-route delete trims away.@@ -2222,6 +2224,7 @@ export function migrateTilesForProfile(oldProfile: string, newProfile: string):migrateRememberedNavigationForProfile(from, to)migrateSessionOwnerHintsForProfile(from, to)migratePreviewArtifactsForProfile(from, to)+ migrateStatusDrawersForProfile(from, to)// Sibling family: the rail's profile-keyed buckets move with the rename, or// the renamed profile opens with an empty rail and the old name keeps them.migratePreviewTabsForProfile(from, to)