The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): list the active gateway's default in the condensed fleet menu
Brooklyn Nicholsonad798ee92110
diff --git a/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.test.tsx b/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.test.tsxindex cb39d7c0f45..ae1141f4df5 100644--- a/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.test.tsx@@ -44,6 +44,7 @@ vi.mock('@/store/profile', () => ({$showAllProfiles: atom(false),ALL_PROFILES: '__all__',normalizeProfileKey: (name: string) => name,+ prewarmProfilePick: vi.fn(),profileLabel: (profile: { name: string }) => profile.name,refreshActiveProfile: vi.fn().mockResolvedValue(undefined),selectProfile: (name: string) => selectProfile(name),diff --git a/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.tsx b/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.tsxindex 87d7285d261..57857f5af8e 100644--- a/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-dropdown-switcher.tsx@@ -36,6 +36,7 @@ import {$showAllProfiles,ALL_PROFILES,normalizeProfileKey,+ prewarmProfilePick,profileLabel,refreshActiveProfile,selectProfile,@@ -272,7 +273,7 @@ function ProfileItem({label: stringname: string}) {- const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name)+ const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name, prewarmProfilePick)return (<DropdownMenuRadioItemdiff --git a/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx b/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsxindex 4d68a14091e..6fd039f2510 100644--- a/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx@@ -54,6 +54,7 @@ vi.mock('@/store/profile', () => ({$showAllProfiles: atom(false),ALL_PROFILES: '*',normalizeProfileKey: (name: string) => name,+ prewarmProfilePick: vi.fn(),profileLabel: (profile: { display_name?: string; name: string }) =>(profile.display_name ?? '').trim() || profile.name,refreshActiveProfile: vi.fn().mockResolvedValue(undefined),diff --git a/apps/desktop/src/app/chat/sidebar/profile-rail-fleet.test.tsx b/apps/desktop/src/app/chat/sidebar/profile-rail-fleet.test.tsxindex 5eff2d6a3ee..549b22561cf 100644--- a/apps/desktop/src/app/chat/sidebar/profile-rail-fleet.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-rail-fleet.test.tsx@@ -94,6 +94,7 @@ vi.mock('@/store/profile', () => ({$showAllProfiles: atom(false),ALL_PROFILES: '*',normalizeProfileKey: (name: string) => name,+ prewarmProfilePick: vi.fn(),profileLabel: (profile: { display_name?: string; name: string }) =>(profile.display_name ?? '').trim() || profile.name,refreshActiveProfile: vi.fn().mockResolvedValue(undefined),@@ -663,4 +664,32 @@ describe('ProfileRail fleet mode', () => {const gatewayBHome = screen.getByRole('menuitem', { name: 'default · Gateway B' })expect(gatewayBHome.querySelector('.codicon-home')).toBeTruthy()})++ // Regression for #106017 / #131632: the condensed menu listed every at-rest gateway's+ // default but dropped the ACTIVE gateway's own — This device's, in the usual+ // case — leaving it reachable only by hotkey.+ it.each(['local', 'gateway-a'])(+ 'lists the active gateway default in the condensed menu (%s active)',+ async active => {+ armFleet()+ activeConnectionId.set(active)+ profiles.set([+ { display_name: 'Arya', is_default: true, name: 'default' } as { is_default: boolean; name: string },+ ...Array.from({ length: 11 }, (_, index) => ({ is_default: false, name: `p${index + 1}` }))+ ])+ await renderFleet()++ const trigger = screen.getByRole('button', { name: 'Profiles' })+ expect(trigger.textContent).toContain('Arya')++ fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false })++ const home = await screen.findByRole('menuitemradio', { name: 'Arya' })+ expect(home.querySelector('.codicon-home')).toBeTruthy()+ expect(home.getAttribute('aria-checked')).toBe('true')++ fireEvent.click(home)+ expect(selectProfile).toHaveBeenCalledWith('default')+ }+ )})diff --git a/apps/desktop/src/app/chat/sidebar/profile-rail-status.test.tsx b/apps/desktop/src/app/chat/sidebar/profile-rail-status.test.tsxindex 913db7ef9c5..175f1fbbd6d 100644--- a/apps/desktop/src/app/chat/sidebar/profile-rail-status.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-rail-status.test.tsx@@ -66,6 +66,7 @@ vi.mock('@/store/profile', () => ({$showAllProfiles: atom(false),ALL_PROFILES: '*',normalizeProfileKey: (name: string) => name,+ prewarmProfilePick: vi.fn(),profileLabel: (profile: { display_name?: string; name: string }) =>(profile.display_name ?? '').trim() || profile.name,refreshActiveProfile: vi.fn().mockResolvedValue(undefined),diff --git a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsxindex fcba8056790..33ed7848cdc 100644--- a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx@@ -77,6 +77,7 @@ import {$profileScope,ALL_PROFILES,normalizeProfileKey,+ prewarmProfilePick,profileLabel,refreshActiveProfile,selectProfile,@@ -575,11 +576,14 @@ export function ProfileRail() {activeKey={isAll ? null : activeKey}colors={colors}connectionId={namedProfileConnectionId}+ homeConnectionId={activeConnectionId}onCreate={() => setCreateOpen(true)}onImport={() => void runImportProfileFlow()}onSelect={selectProfile}onSelectRest={switchToRest}- profiles={named}+ // Fleet drops the home pill, so the menu is the active default's+ // only door; every at-rest group already lists its own (#106017, #131632).+ profiles={fleet && defaultProfile ? [defaultProfile, ...named] : named}restGroups={restGroups}/></div>@@ -860,13 +864,15 @@ function ImportProfileButton({ label }: { label: string }) {)}-// The condensed rail: every named profile in one compact menu. The trigger-// shows the active profile (tinted initial + name); on default/all scope it-// falls back to the placeholder since the left toggle pill carries that state.+// The condensed rail: the active gateway's profiles in one compact menu. The+// trigger shows the active profile (tinted initial, or home for the default);+// on all scope — or on a default the left toggle pill carries — it falls back+// to the placeholder.function ProfileDropdown({activeKey,colors,connectionId,+ homeConnectionId,onCreate,onImport,onSelect,@@ -877,6 +883,8 @@ function ProfileDropdown({activeKey: null | stringcolors: Record<string, string>connectionId: null | string+ /** The default row's route, like the home pill's: the active connection. */+ homeConnectionId: null | stringonCreate: () => voidonImport: () => voidonSelect: (name: string) => void@@ -908,7 +916,7 @@ function ProfileDropdown({<ProfileGlypharia-hidden="true"color={resolveProfileColor(activeProfile.name, colors)}- isDefault={false}+ isDefault={activeProfile.is_default}name={activeProfile.name}/><span className="truncate">{profileLabel(activeProfile)}</span>@@ -934,8 +942,9 @@ function ProfileDropdown({{profiles.map(profile => (<ProfileDropdownItemcolor={resolveProfileColor(profile.name, colors)}- connectionId={connectionId}+ connectionId={profile.is_default ? homeConnectionId : connectionId}hideStatus={profile.name === value}+ isDefault={profile.is_default}key={profile.name}label={profileLabel(profile)}name={profile.name}@@ -971,6 +980,7 @@ function ProfileDropdownItem({color,connectionId,hideStatus,+ isDefault,label,name}: {@@ -979,12 +989,13 @@ function ProfileDropdownItem({/** The dropdown's own selected row: its sessions are on screen in the* sidebar, so its rollup is suppressed like the active square (#91710). */hideStatus?: boolean+ isDefault: booleanlabel: stringname: string}) {const { t } = useI18n()const p = t.profiles- const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name)+ const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name, prewarmProfilePick)const summary = useProfileStatus(name, connectionId)const statusText = summary && !hideStatus ? profileStatusLabel(p, summary) : null@@ -998,7 +1009,7 @@ function ProfileDropdownItem({value={name}><span className="flex min-w-0 items-center gap-1.5">- <ProfileGlyph aria-hidden="true" color={color} isDefault={false} name={name} />+ <ProfileGlyph aria-hidden="true" color={color} isDefault={isDefault} name={name} /><span className="truncate">{label}</span>{summary && !hideStatus && <ProfileStatusDot summary={summary} />}</span>@@ -1421,7 +1432,7 @@ function ProfileSquare({const suppressClick = useRef(false)// Hovering a square telegraphs the switch — start that profile's backend// spawn now so a cold click doesn't pay the full boot.- const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name)+ const { cancelPrewarm, notePointerMove, startPrewarm } = useProfilePrewarm(name, prewarmProfilePick)// The square carries its profile's session rollup — but never when active:// the workspace is homed there and the sidebar below already shows thatdiff --git a/apps/desktop/src/app/chat/sidebar/use-profile-prewarm.ts b/apps/desktop/src/app/chat/sidebar/use-profile-prewarm.tsindex 71783941c4b..c80b1da68cb 100644--- a/apps/desktop/src/app/chat/sidebar/use-profile-prewarm.ts+++ b/apps/desktop/src/app/chat/sidebar/use-profile-prewarm.ts@@ -9,7 +9,9 @@ export const PREWARM_DWELL_MS = 120/*** pointerenter/pointerleave/pointermove handlers that pre-warm `profile`'s- * pool backend after a short hover dwell (see prewarmProfileBackend).+ * pool backend after a short hover dwell (see prewarmProfileBackend). Rows+ * that pick a profile on the current source pass prewarmProfilePick, so the+ * warm follows the same route as the click.** `pointerenter` alone is not intent: virtualized session lists and running-arc* re-renders fire it when a *stationary* cursor sits over the sidebar and a@@ -17,11 +19,16 @@ export const PREWARM_DWELL_MS = 120* start the dwell only after a real pointermove on that visit, cancel on leave.* Consumers merge these with their own pointer handlers.*/-export function useProfilePrewarm(profile: string | null | undefined) {+export function useProfilePrewarm(+ profile: string | null | undefined,+ warm: (profile: string) => void = prewarmProfileBackend+) {const timer = useRef<null | number>(null)const armed = useRef(false)const profileRef = useRef(profile)profileRef.current = profile+ const warmRef = useRef(warm)+ warmRef.current = warmconst cancelPrewarm = useCallback(() => {armed.current = false@@ -47,7 +54,7 @@ export function useProfilePrewarm(profile: string | null | undefined) {timer.current = window.setTimeout(() => {timer.current = nullarmed.current = false- prewarmProfileBackend(profileRef.current || 'default')+ warmRef.current(profileRef.current || 'default')}, PREWARM_DWELL_MS)}, [])diff --git a/apps/desktop/src/store/profile.test.ts b/apps/desktop/src/store/profile.test.tsindex 003e680967a..0e53d4f4465 100644--- a/apps/desktop/src/store/profile.test.ts+++ b/apps/desktop/src/store/profile.test.ts@@ -7,17 +7,18 @@ import type { ProfileInfo } from '@/types/hermes'// Keep profile.ts's side-effecting imports inert: the gateway socket layer and// the REST query client must not run for real in a unit test.const ensureGatewayForProfile = vi.fn(async (_profile: string) => undefined)-const ensureGatewayForAgent = vi.fn(async () => undefined)+const ensureGatewayForAgent = vi.fn(async (_connectionId: string, _profile: string) => undefined)const openGatewayForProfile = vi.fn(async (_profile: string) => undefined)const openGatewayForAgent = vi.fn(async (_connectionId: null | string, _profile: string) => undefined)const openSecondaryCount = vi.fn(() => 0)+const activeGatewayConnectionId = vi.fn((): null | string => null)const $gateway = atom<unknown>({ id: 'live-socket', connectionState: 'open' })const resetStarmapGraph = vi.fn()vi.mock('@/store/gateway', () => ({$gateway,activeGateway: () => null,- activeGatewayConnectionId: () => null,+ activeGatewayConnectionId,// Activation now verifies the socket's route before publishing the profile.activeGatewayProfileKey: () => ensureGatewayForProfile.mock.lastCall?.[0] ?? $activeGatewayProfile.get(),ensureGatewayForAgent,@@ -47,6 +48,7 @@ const {invalidateProfileListFetches,newSessionInProfile,prewarmProfileBackend,+ prewarmProfilePick,refreshProfiles,selectProfile} = await import('./profile')@@ -248,6 +250,29 @@ describe('prewarmProfileBackend (hover-intent pool spawn)', () => {expect(openGatewayForProfile).not.toHaveBeenCalledWith('warm-lowered-cap')})++ // A hover-warm on a current-source pick must dial the pair the click will:+ // the bare name resolved on the legacy door, so hovering a remote source's+ // `default` spawned This device's default instead (#100098 review).+ it('warms the same (connection, profile) a current-source pick activates', async () => {+ activeGatewayConnectionId.mockReturnValue('gateway')+ $activeGatewayProfile.set('research')+ openGatewayForAgent.mockClear()+ ensureGatewayForAgent.mockClear()++ try {+ prewarmProfilePick('default')+ selectProfile('default')+ await vi.waitFor(() => expect(ensureGatewayForAgent).toHaveBeenCalled())++ expect(openGatewayForProfile).not.toHaveBeenCalled()+ expect(openGatewayForAgent.mock.calls.map(([connection, name]) => [connection, name])).toEqual(+ ensureGatewayForAgent.mock.calls.map(([connection, name]) => [connection, name])+ )+ } finally {+ activeGatewayConnectionId.mockReturnValue(null)+ }+ })})describe('refreshProfiles shared rail list (#49289)', () => {diff --git a/apps/desktop/src/store/profile.ts b/apps/desktop/src/store/profile.tsindex 08b3e98e39f..de81d5e3aac 100644--- a/apps/desktop/src/store/profile.ts+++ b/apps/desktop/src/store/profile.ts@@ -1041,6 +1041,13 @@ function activateOnCurrentSource(target: string): Promise<void> {return connectionId ? ensureGatewayAgent(connectionId, target) : ensureGatewayProfile(target)}+// The hover twin of activateOnCurrentSource: warm the pair the click will dial.+// The bare name resolves on the legacy door, so hovering a remote source's+// `default` warmed This device's instead.+export function prewarmProfilePick(name: string): void {+ prewarmProfileBackend(name, profilePickConnectionId(normalizeProfileKey(name)))+}+// A project id names a row in ONE backend's projects.db. A draft headed for// another profile (or source) must not resolve its cwd from the scope entered on// the current one: the fresh draft runs before the gateway swap refreshes the