Skip to content

The agent that grows with you

feat: organize desktop sessions by gateway and profile

Teknium77a54573433b
diff --git a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx b/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
index 9aa683d5083..408ef457d6e 100644
--- a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
+++ b/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
@@ -187,7 +187,8 @@ export function SidebarFilterMenu({ className }: { className?: string }) {
const foldCollapsed = foldIds.length > 0 && foldIds.every(id => nodeOpen[id] === false)
- const groupingLabel = GROUPINGS.find(option => option.id === grouping)?.label
+ const groupings = GROUPINGS.map(option => option.id === 'profile' ? {...option, label: t.sidebar.gatewayGroups.grouping} : option)
+ const groupingLabel = groupings.find(option => option.id === grouping)?.label
// Two options are conditional: dragging a row is what picks manual, so it
// only appears as a way back out once there's a hand-picked order to leave;
@@ -249,7 +250,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {
onValueChange={value => setSidebarGrouping(value as SidebarGrouping)}
value={grouping}
>
- {GROUPINGS.map(option => (
+ {groupings.map(option => (
<OptionRadio key={option.id} option={option} />
))}
</DropdownMenuRadioGroup>
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-group-model.ts b/apps/desktop/src/app/chat/sidebar/gateway-group-model.ts
new file mode 100644
index 00000000000..9bf36e1df0f
--- /dev/null
+++ b/apps/desktop/src/app/chat/sidebar/gateway-group-model.ts
@@ -0,0 +1,47 @@
+import { useStore } from '@nanostores/react'
+import { useMemo } from 'react'
+
+import type { SessionInfo } from '@/hermes'
+import { resolveProfileColor } from '@/lib/profile-color'
+import { $connectionsRegistry } from '@/store/connection-registry-state'
+import { $profileColors, normalizeProfileKey } from '@/store/profile'
+
+import type { SidebarSessionGroup } from './projects/workspace-groups'
+
+/** Group identity never depends on a mutable label, URL, or the active gateway. */
+export function useGatewaySessionGroups(sessions: SessionInfo[], enabled: boolean) {
+ const registry = useStore($connectionsRegistry)
+ const colors = useStore($profileColors)
+
+ return useMemo<SidebarSessionGroup[] | undefined>(() => {
+ if (!enabled) {
+ return undefined
+ }
+
+ const groups = new Map<string, SidebarSessionGroup>()
+
+ for (const session of sessions) {
+ const profile = normalizeProfileKey(session.profile)
+ const connectionId = session.connection_id || null
+ const id = JSON.stringify([connectionId, profile])
+ const gateway = registry?.connections.find(connection => connection.id === connectionId)
+ const label = connectionId ? `${gateway?.label || connectionId} · ${profile}` : profile
+
+ const group: SidebarSessionGroup = groups.get(id) ?? {
+ id,
+ label,
+ connectionId,
+ profile,
+ mode: 'profile',
+ path: null,
+ color: resolveProfileColor(profile, colors),
+ sessions: []
+ }
+
+ group.sessions.push(session)
+ groups.set(id, group)
+ }
+
+ return [...groups.values()].sort((a, b) => a.label.localeCompare(b.label) || a.id.localeCompare(b.id))
+ }, [sessions, enabled, registry, colors])
+}
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.test.ts b/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.test.ts
new file mode 100644
index 00000000000..5d4acb34593
--- /dev/null
+++ b/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.test.ts
@@ -0,0 +1,33 @@
+// @vitest-environment jsdom
+import { expect, it, vi } from 'vitest'
+
+import {
+ $gatewayGroupAliases,
+ $gatewayGroupCollapsed,
+ $gatewayGroupOrder,
+ renameGatewayGroup,
+ reorderGatewayGroups,
+ toggleGatewayGroup
+} from './gateway-group-preferences'
+
+it('persists identity-scoped edits and reorders newly discovered groups without forgetting hidden groups', async () => {
+ const local = JSON.stringify(['local', 'default'])
+ const remote = JSON.stringify(['remote-1', 'default'])
+ const cloud = JSON.stringify(['cloud-1', 'default'])
+ $gatewayGroupOrder.set([])
+ reorderGatewayGroups([remote, local])
+ expect($gatewayGroupOrder.get()).toEqual([remote, local])
+ renameGatewayGroup(remote, ' Research lab ')
+ toggleGatewayGroup(remote)
+ reorderGatewayGroups([cloud, local])
+ expect($gatewayGroupOrder.get()).toEqual([remote, cloud, local])
+ expect($gatewayGroupAliases.get()).toEqual({ [remote]: 'Research lab' })
+ expect($gatewayGroupCollapsed.get()).toEqual([remote])
+ vi.resetModules()
+ const restored = await import('./gateway-group-preferences')
+ expect(restored.$gatewayGroupOrder.get()).toEqual([remote, cloud, local])
+ expect(restored.$gatewayGroupAliases.get()).toEqual({ [remote]: 'Research lab' })
+ expect(restored.$gatewayGroupCollapsed.get()).toEqual([remote])
+ restored.renameGatewayGroup(remote, ' ')
+ expect(restored.$gatewayGroupAliases.get()).toEqual({})
+})
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.ts b/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.ts
new file mode 100644
index 00000000000..d1b0ba7a829
--- /dev/null
+++ b/apps/desktop/src/app/chat/sidebar/gateway-group-preferences.ts
@@ -0,0 +1,33 @@
+import { Codecs, persistentAtom } from '@/lib/persisted'
+
+import { mergeVisibleReorder } from './order'
+
+const PREFIX = 'hermes.desktop.sidebar.gatewayGroups.v1'
+export const $gatewayGroupAliases = persistentAtom(`${PREFIX}.aliases`, {}, Codecs.stringRecord)
+export const $gatewayGroupOrder = persistentAtom(`${PREFIX}.order`, [], Codecs.stringArray)
+export const $gatewayGroupCollapsed = persistentAtom(`${PREFIX}.collapsed`, [], Codecs.stringArray)
+
+export function renameGatewayGroup(id: string, alias: string) {
+ const aliases = { ...$gatewayGroupAliases.get() }
+ const name = alias.trim()
+
+ if (name) {
+ aliases[id] = name
+ } else {
+ delete aliases[id]
+ }
+
+ $gatewayGroupAliases.set(aliases)
+}
+
+export function reorderGatewayGroups(ids: string[]) {
+ // A filtered-out or temporarily offline section keeps its place.
+ const order = $gatewayGroupOrder.get()
+ const allIds = [...order, ...ids.filter(id => !order.includes(id))]
+ $gatewayGroupOrder.set(mergeVisibleReorder(allIds, ids))
+}
+
+export function toggleGatewayGroup(id: string) {
+ const collapsed = $gatewayGroupCollapsed.get()
+ $gatewayGroupCollapsed.set(collapsed.includes(id) ? collapsed.filter(key => key !== id) : [...collapsed, id])
+}
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx
new file mode 100644
index 00000000000..c53143c270c
--- /dev/null
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx
@@ -0,0 +1,100 @@
+// @vitest-environment jsdom
+import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
+import { MemoryRouter } from 'react-router'
+import { afterEach, expect, it, vi } from 'vitest'
+
+import { SidebarProvider } from '@/components/ui/sidebar'
+import { $connectionsRegistry } from '@/store/connection-registry-state'
+import { $sidebarRowMeta, setSidebarGrouping } from '@/store/layout'
+import { $newChatRoute, $profiles } from '@/store/profile'
+import { $sessionProfilesUsage, $sessions } from '@/store/session'
+import { makeSessionInfo } from '@/test/session-info'
+
+import { ChatSidebar } from './index'
+
+const noop = () => {}
+const resume = vi.fn()
+
+const mount = () =>
+ render(
+ <MemoryRouter>
+ <SidebarProvider>
+ <ChatSidebar
+ currentView="chat"
+ onArchiveSession={noop}
+ onBranchSession={noop}
+ onDeleteSession={noop}
+ onLoadMoreSessions={noop}
+ onManageCronJob={noop}
+ onNavigate={noop}
+ onNewSessionInWorkspace={noop}
+ onNewSessionSplit={noop}
+ onResumeSession={resume}
+ onTriggerCronJob={async () => {}}
+ />
+ </SidebarProvider>
+ </MemoryRouter>
+ )
+
+afterEach(cleanup)
+
+it('keeps equal profile names on separate gateways and routes section creation and row navigation to their owner', () => {
+ mount()
+ act(() => {
+ $connectionsRegistry.set({
+ version: 2,
+ primary: 'local',
+ secureTokenStorage: true,
+ connections: [
+ { id: 'local', label: 'This computer', kind: 'local', tokenSet: false, tokenPreview: null },
+ { id: 'remote-1', label: 'Homelab', kind: 'remote', tokenSet: false, tokenPreview: null },
+ { id: 'cloud-1', label: 'Cloud workspace', kind: 'cloud', tokenSet: false, tokenPreview: null }
+ ]
+ })
+ $profiles.set([
+ { name: 'default', is_default: true },
+ { name: 'work', is_default: false }
+ ] as typeof $profiles.value)
+ setSidebarGrouping('profile')
+ $sidebarRowMeta.set(['cost', 'tokens'])
+ $sessionProfilesUsage.set({ default: { cost_usd: 3, tokens: 100 } })
+ $sessions.set(
+ ['local', 'remote-1', 'cloud-1'].map(connection_id =>
+ makeSessionInfo({
+ id: connection_id,
+ connection_id,
+ profile: 'default',
+ title: `${connection_id} session`,
+ last_active: Date.now() / 1000
+ })
+ )
+ )
+ })
+ act(() =>
+ $sessions.set([
+ ...$sessions.get(),
+ makeSessionInfo({ id: 'legacy', profile: 'default', title: 'Legacy session', last_active: Date.now() / 1000 })
+ ])
+ )
+ expect(screen.getAllByText(/\$3\.00/)).toHaveLength(1)
+ expect(
+ screen
+ .getByText(/\$3\.00/)
+ .closest('[data-gateway-group]')
+ ?.getAttribute('data-gateway-group')
+ ).toBe(JSON.stringify([null, 'default']))
+ expect(screen.getByText('This computer · default')).toBeTruthy()
+ expect(screen.getByText('Homelab · default')).toBeTruthy()
+ expect(screen.getByText('Cloud workspace · default')).toBeTruthy()
+ fireEvent.click(screen.getByRole('button', { name: 'New session in Homelab · default' }))
+ expect($newChatRoute.get()).toMatchObject({ connectionId: 'remote-1', profile: 'default' })
+ fireEvent.click(screen.getByText('cloud-1 session'))
+ expect(resume).toHaveBeenLastCalledWith(
+ 'cloud-1',
+ expect.objectContaining({ connection_id: 'cloud-1', profile: 'default' })
+ )
+ const group = screen.getByText('Homelab · default').closest('[data-gateway-group]')!
+ fireEvent.click(within(group as HTMLElement).getByRole('button', { name: 'Hide Homelab · default sessions' }))
+ expect(screen.queryByText('remote-1 session')).toBeNull()
+ expect(screen.getByText('local session')).toBeTruthy()
+})
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx
new file mode 100644
index 00000000000..07bc128a6a2
--- /dev/null
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx
@@ -0,0 +1,246 @@
+import type { useSensors } from '@dnd-kit/core'
+import { arrayMove } from '@dnd-kit/sortable'
+import { useStore } from '@nanostores/react'
+import type { ReactNode } from 'react'
+import { useState } from 'react'
+
+import { type NewSessionSplitHandler, startNewSessionDrag } from '@/app/chat/new-session-drag'
+import { Button } from '@/components/ui/button'
+import { Codicon } from '@/components/ui/codicon'
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle
+} from '@/components/ui/dialog'
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
+import { Input } from '@/components/ui/input'
+import { ProfileGlyph } from '@/components/ui/profile-glyph'
+import type { SessionInfo } from '@/hermes'
+import { useI18n } from '@/i18n'
+import { useStoreSelector } from '@/lib/use-session-slice'
+import { newSessionInAgent, newSessionInProfile } from '@/store/profile'
+import { $sessionProfilesUsage } from '@/store/session'
+import { $sidebarSessionRankIds } from '@/store/sidebar-sort'
+
+import { SidebarGroupRow, SidebarRowGrab, SidebarRowLink, SidebarRowStack } from './chrome'
+import {
+ $gatewayGroupAliases,
+ $gatewayGroupCollapsed,
+ $gatewayGroupOrder,
+ renameGatewayGroup,
+ reorderGatewayGroups,
+ toggleGatewayGroup
+} from './gateway-group-preferences'
+import { rankSessions } from './order'
+import { SIDEBAR_GROUP_PAGE } from './projects/model'
+import type { SidebarSessionGroup } from './projects/workspace-groups'
+import { WorkspaceAddButton, WorkspaceShowMoreButton } from './projects/workspace-header'
+import { ReorderableList, useSortableBindings } from './reorderable-list'
+
+interface GatewayProfileGroupsProps {
+ groups: SidebarSessionGroup[]
+ renderRows: (sessions: SessionInfo[]) => ReactNode
+ sensors?: ReturnType<typeof useSensors>
+ onNewSessionSplit?: NewSessionSplitHandler
+}
+
+export function GatewayProfileGroups({ groups, renderRows, sensors, onNewSessionSplit }: GatewayProfileGroupsProps) {
+ const order = useStore($gatewayGroupOrder)
+
+ const ordered = [...groups].sort((a, b) => {
+ const left = order.indexOf(a.id)
+ const right = order.indexOf(b.id)
+
+ return (left < 0 ? Infinity : left) - (right < 0 ? Infinity : right) || 0
+ })
+
+ const ids = ordered.map(group => group.id)
+
+ return (
+ <ReorderableList ids={ids} onReorder={reorderGatewayGroups} sensors={sensors}>
+ {ordered.map((group, index) => (
+ <GatewayProfileGroup
+ first={index === 0}
+ group={group}
+ key={group.id}
+ last={index === ordered.length - 1}
+ onMove={direction => reorderGatewayGroups(arrayMove(ids, index, index + direction))}
+ onNewSessionSplit={onNewSessionSplit}
+ renderRows={renderRows}
+ />
+ ))}
+ </ReorderableList>
+ )
+}
+
+interface GatewayProfileGroupProps {
+ group: SidebarSessionGroup
+ renderRows: (sessions: SessionInfo[]) => ReactNode
+ onMove: (direction: 1 | -1) => void
+ onNewSessionSplit?: NewSessionSplitHandler
+ first: boolean
+ last: boolean
+}
+
+function GatewayProfileGroup({ group, renderRows, onMove, first, last, onNewSessionSplit }: GatewayProfileGroupProps) {
+ const { t } = useI18n()
+ const s = t.sidebar
+ const copy = s.gatewayGroups
+ const aliases = useStore($gatewayGroupAliases)
+ const collapsed = useStore($gatewayGroupCollapsed)
+ const rankIds = useStore($sidebarSessionRankIds)
+ // Legacy totals are keyed only by profile. Never attribute those figures to
+ // a registry gateway that happens to expose the same profile name.
+ const usage = useStoreSelector($sessionProfilesUsage, all => (group.connectionId ? undefined : all[group.profile!]))
+ const [renaming, setRenaming] = useState(false)
+ const [draft, setDraft] = useState('')
+ const [visibleCount, setVisibleCount] = useState(SIDEBAR_GROUP_PAGE)
+ const sortable = useSortableBindings(group.id)
+ const label = aliases[group.id] || group.label
+ const open = !collapsed.includes(group.id)
+ const sessions = rankSessions(group.sessions, rankIds)
+ const hiddenCount = Math.max(0, sessions.length - visibleCount)
+ const route = group.connectionId ? { connectionId: group.connectionId, profile: group.profile! } : undefined
+
+ const startSession = () => {
+ if (!open) {
+ toggleGatewayGroup(group.id)
+ }
+
+ const profile = group.profile!
+
+ if (group.connectionId) {
+ newSessionInAgent({ connectionId: group.connectionId, profile })
+ } else {
+ newSessionInProfile(profile)
+ }
+ }
+
+ return (
+ <SidebarRowStack data-gateway-group={group.id} ref={sortable.ref} style={sortable.style}>
+ <SidebarGroupRow
+ actions={
+ <div className="flex items-center">
+ <WorkspaceAddButton
+ label={s.newSessionIn(label)}
+ onClick={startSession}
+ onPointerDown={
+ onNewSessionSplit
+ ? event =>
+ startNewSessionDrag(
+ placement => {
+ if (!open) {
+ toggleGatewayGroup(group.id)
+ }
+
+ onNewSessionSplit(placement.dir, {
+ anchor: placement.anchor,
+ before: placement.before,
+ profile: group.profile,
+ route
+ })
+ },
+ event,
+ { label: s.newSessionIn(label), profile: group.profile, route }
+ )
+ : undefined
+ }
+ />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button aria-label={`${copy.actions}: ${label}`} size="icon-xs" variant="ghost">
+ <Codicon name="ellipsis" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem
+ onSelect={() => {
+ setDraft(aliases[group.id] || '')
+ setRenaming(true)
+ }}
+ >
+ {copy.rename}
+ </DropdownMenuItem>
+ <DropdownMenuItem disabled={!aliases[group.id]} onSelect={() => renameGatewayGroup(group.id, '')}>
+ {copy.resetName}
+ </DropdownMenuItem>
+ <DropdownMenuItem disabled={first} onSelect={() => onMove(-1)}>
+ {copy.moveUp}
+ </DropdownMenuItem>
+ <DropdownMenuItem disabled={last} onSelect={() => onMove(1)}>
+ {copy.moveDown}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ }
+ label={
+ <SidebarRowLink aria-expanded={open} onClick={() => toggleGatewayGroup(group.id)}>
+ {label}
+ </SidebarRowLink>
+ }
+ lead={
+ <SidebarRowGrab
+ ariaLabel={`${copy.reorder}: ${label}`}
+ dragging={sortable.dragging}
+ dragHandleProps={sortable.dragHandleProps}
+ >
+ <ProfileGlyph
+ className="size-full"
+ color={group.color ?? null}
+ isDefault={group.profile === 'default'}
+ name={group.profile!}
+ />
+ </SidebarRowGrab>
+ }
+ toggle={{ ariaLabel: s.projects.toggle(label, !open), onToggle: () => toggleGatewayGroup(group.id), open }}
+ totals={usage ? { costUsd: usage.cost_usd, tokens: usage.tokens } : undefined}
+ />
+ {open && (
+ <>
+ {renderRows(sessions.slice(0, visibleCount))}
+ {hiddenCount > 0 && (
+ <WorkspaceShowMoreButton
+ count={Math.min(SIDEBAR_GROUP_PAGE, hiddenCount)}
+ label={label}
+ onClick={() => setVisibleCount(count => count + SIDEBAR_GROUP_PAGE)}
+ />
+ )}
+ </>
+ )}
+ <Dialog onOpenChange={setRenaming} open={renaming}>
+ <DialogContent>
+ <form
+ onSubmit={event => {
+ event.preventDefault()
+ renameGatewayGroup(group.id, draft)
+ setRenaming(false)
+ }}
+ >
+ <DialogHeader>
+ <DialogTitle>{copy.rename}</DialogTitle>
+ <DialogDescription>{copy.aliasHint}</DialogDescription>
+ </DialogHeader>
+ <Input
+ aria-label={copy.aliasLabel}
+ autoFocus
+ maxLength={120}
+ onChange={event => setDraft(event.target.value)}
+ placeholder={group.label}
+ value={draft}
+ />
+ <DialogFooter>
+ <Button onClick={() => setRenaming(false)} type="button" variant="ghost">
+ {t.common.cancel}
+ </Button>
+ <Button type="submit">{t.common.save}</Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ </SidebarRowStack>
+ )
+}
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index 611a5a4d455..a20b52e7020 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -26,7 +26,6 @@ import { useContributions } from '@/contrib/react/use-contributions'
import { searchSessions, type SessionInfo, type SessionSearchResult } from '@/hermes'
import { useI18n } from '@/i18n'
import { comboTokens } from '@/lib/keybinds/combo'
-import { resolveProfileColor } from '@/lib/profile-color'
import { sessionMatchesSearch } from '@/lib/session-search'
import { normalizeSessionSource, sessionSourceLabel } from '@/lib/session-source'
import { cn } from '@/lib/utils'
@@ -75,7 +74,6 @@ import {
import { notifyError } from '@/store/notifications'
import {
$newChatProfile,
- $profileColors,
$profiles,
$profileScope,
ALL_PROFILES,
@@ -149,6 +147,7 @@ import { type NewSessionSplitHandler, startNewSessionDrag } from '../new-session
import { SidebarSectionAddButton } from './chrome'
import { SidebarCronJobsSection } from './cron-jobs-section'
import { SidebarFilterMenu } from './filter-menu'
+import { useGatewaySessionGroups } from './gateway-group-model'
import { SidebarLoadMoreRow } from './load-more-row'
import { orderByIds, reconcileOrderIds, resolveManualSessionOrderIds, sameIds } from './order'
import { filterSessionsByProfileScope } from './profile-scope'
@@ -168,7 +167,6 @@ import {
sessionMatchesProjectFilter,
sessionRecency as sessionTime,
type SidebarProjectTree,
- type SidebarSessionGroup,
type SidebarWorkspaceTree,
sortProjectsForOverview,
StartWorkButton,
@@ -412,7 +410,6 @@ export function ChatSidebar({
const sessionProfilesTruncated = useStore($sessionProfilesTruncated)
const unreadCount = useStore($unreadFinishedSessionIds).length
const profiles = useStore($profiles)
- const profileColors = useStore($profileColors)
const profileScope = useStore($profileScope)
const activeConnectionId = useStore($activeConnectionId)
@@ -1268,41 +1265,7 @@ export function ChatSidebar({
.sort((a, b) => sessionTime(b.sessions[0]) - sessionTime(a.sessions[0]))
}, [visibleMessagingSessions, messagingPlatformTotals, messagingTruncated, isPinnedSession, messagingProfile])
- // Grouping by profile: one collapsible group per profile, color on the header
- // (not on every row). Default profile floats to the top, the rest alpha.
- // Only reachable while the sidebar is showing every profile — scoped to one,
- // it would draw a single group around the whole list.
- const profileGrouped = showAllProfiles && grouping === 'profile'
-
- const profileGroups = useMemo<SidebarSessionGroup[] | undefined>(() => {
- if (!profileGrouped) {
- return undefined
- }
-
- const groups = new Map<string, SidebarSessionGroup>()
-
- for (const session of agentSessions) {
- const key = normalizeProfileKey(session.profile)
-
- const group = groups.get(key) ?? {
- color: resolveProfileColor(key, profileColors),
- id: key,
- label: key,
- mode: 'profile',
- path: null,
- sessions: []
- }
-
- group.sessions.push(session)
-
- groups.set(key, group)
- }
-
- // default (root) first, then the rest alphabetically.
- return [...groups.values()].sort((a, b) =>
- a.id === 'default' ? -1 : b.id === 'default' ? 1 : a.label.localeCompare(b.label)
- )
- }, [profileGrouped, agentSessions, profileColors])
+ const profileGroups = useGatewaySessionGroups(agentSessions, profileScope === ALL_PROFILES && grouping === 'profile')
// The flat Sessions list always shows ALL recent sessions; Projects is a
// parallel grouped view, not a filter on this one — nothing is hidden here.
diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
index 6a6d8aa8d1d..3f457c885e3 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
@@ -30,6 +30,9 @@ export interface SidebarSessionGroup {
isKanban?: boolean
mode?: 'profile' | 'source' | 'workspace'
sourceId?: string
+ // Exact owner for gateway/profile sidebar sections; absent for workspace lanes.
+ connectionId?: null | string
+ profile?: string
}
/** A repo node: holds its branch/worktree lanes (`repo -> lane -> sessions`). */
diff --git a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx b/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
index 1104a8d2abd..5e1aeb303aa 100644
--- a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
+++ b/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
@@ -30,6 +30,7 @@ import { sessionPinId } from '@/store/session'
import { $sessionDotStateById, hasLiveTurn } from '@/store/session-dot-state'
import { SidebarDateDivider, SidebarSectionMeta } from './chrome'
+import { GatewayProfileGroups } from './gateway-groups'
import { mergeVisibleReorder, orderRowsWithinGroups, reorderableRowIds } from './order'
import {
EnteredProjectContent,
@@ -524,8 +525,9 @@ export function SidebarSessionsSection({
)}
</>
)
+ } else if (groups?.length && groups.every(group => group.mode === 'profile' && group.profile)) {
+ inner = <GatewayProfileGroups groups={groups} onNewSessionSplit={onNewSessionSplit} renderRows={renderRows} sensors={dndSensors} />
} else if (groups?.length) {
- // Profile/source groups never reorder; render them flat with static rows.
inner = groups.map(group => (
<SidebarWorkspaceGroup
group={group}
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index cbb7452a379..1ce7297289a 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -1735,6 +1735,17 @@ export const ar = defineLocale({
missingBody: 'لم يعد هذا الناتج موجودًا في السجل المحلي.'
},
sidebar: {
+ gatewayGroups: {
+ grouping: 'البوابة والملف الشخصي',
+ rename: 'إعادة تسمية المجموعة',
+ aliasLabel: 'اسم العرض',
+ aliasHint: 'يتغير اسم العرض فقط؛ تبقى أسماء البوابة والملف الشخصي دون تغيير.',
+ resetName: 'إعادة تعيين الاسم',
+ moveUp: 'نقل لأعلى',
+ moveDown: 'نقل لأسفل',
+ reorder: 'إعادة ترتيب المجموعة',
+ actions: 'إجراءات المجموعة'
+ },
nav: {
'new-session': 'جلسة جديدة',
skills: 'المهارات',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 2aa581e093f..24e2ebf0d88 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2367,6 +2367,17 @@ export const en: Translations = {
},
sidebar: {
+ gatewayGroups: {
+ grouping: 'Gateway & profile',
+ rename: 'Rename group',
+ aliasLabel: 'Display name',
+ aliasHint: 'Display name only; gateway and profile names stay unchanged.',
+ resetName: 'Reset name',
+ moveUp: 'Move up',
+ moveDown: 'Move down',
+ reorder: 'Reorder group',
+ actions: 'Group actions'
+ },
nav: {
'new-session': 'New session',
skills: 'Capabilities',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 2d59ad16889..38f2611b35b 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2045,6 +2045,17 @@ export const ja = defineLocale({
},
sidebar: {
+ gatewayGroups: {
+ grouping: 'ゲートウェイとプロファイル',
+ rename: 'グループ名を変更',
+ aliasLabel: '表示名',
+ aliasHint: '表示名のみ変更します。ゲートウェイ名とプロファイル名は変わりません。',
+ resetName: '名前をリセット',
+ moveUp: '上に移動',
+ moveDown: '下に移動',
+ reorder: 'グループを並べ替え',
+ actions: 'グループの操作'
+ },
nav: {
'new-session': '新しいセッション',
skills: 'スキルとツール',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 45fc98d7b21..554b148f217 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -2400,6 +2400,17 @@ export const ru = defineLocale({
missingBody: 'Этот артефакт больше нет в локальном реестре.'
},
sidebar: {
+ gatewayGroups: {
+ grouping: 'Шлюз и профиль',
+ rename: 'Переименовать группу',
+ aliasLabel: 'Отображаемое имя',
+ aliasHint: 'Меняется только отображаемое имя; имена шлюза и профиля остаются прежними.',
+ resetName: 'Сбросить имя',
+ moveUp: 'Переместить вверх',
+ moveDown: 'Переместить вниз',
+ reorder: 'Изменить порядок групп',
+ actions: 'Действия с группой'
+ },
nav: {
'new-session': 'Новый сеанс',
skills: 'Возможности',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index b6428083441..2f3e9a51590 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2019,6 +2019,17 @@ export interface Translations {
}
sidebar: {
+ gatewayGroups: {
+ grouping: string
+ rename: string
+ aliasLabel: string
+ aliasHint: string
+ resetName: string
+ moveUp: string
+ moveDown: string
+ reorder: string
+ actions: string
+ }
nav: Record<string, string>
searchAria: string
searchPlaceholder: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 7818f9ba6b4..0b754c5e50b 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -1970,6 +1970,17 @@ export const zhHant = defineLocale({
},
sidebar: {
+ gatewayGroups: {
+ grouping: '閘道與設定檔',
+ rename: '重新命名群組',
+ aliasLabel: '顯示名稱',
+ aliasHint: '僅變更顯示名稱;閘道和設定檔名稱維持不變。',
+ resetName: '重設名稱',
+ moveUp: '上移',
+ moveDown: '下移',
+ reorder: '調整群組順序',
+ actions: '群組動作'
+ },
nav: {
'new-session': '新工作階段',
skills: '技能與工具',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 2298c3a0d67..84283ff0436 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2533,6 +2533,17 @@ export const zh: Translations = {
},
sidebar: {
+ gatewayGroups: {
+ grouping: '网关与配置',
+ rename: '重命名分组',
+ aliasLabel: '显示名称',
+ aliasHint: '仅更改显示名称;网关和配置档名称保持不变。',
+ resetName: '重置名称',
+ moveUp: '上移',
+ moveDown: '下移',
+ reorder: '调整分组顺序',
+ actions: '分组操作'
+ },
nav: {
'new-session': '新建会话',
skills: '技能与工具',