Skip to content

The agent that grows with you

fix(review): route Desktop voice/display config writes and the approval-mode RPCs by profile; remount the terminal-backend panel per scope

teknium196ae4ee44a68
diff --git a/apps/desktop/src/app/capabilities/toolsets/toolset-detail.tsx b/apps/desktop/src/app/capabilities/toolsets/toolset-detail.tsx
index dca646aa4fc..c3193f19c3d 100644
--- a/apps/desktop/src/app/capabilities/toolsets/toolset-detail.tsx
+++ b/apps/desktop/src/app/capabilities/toolsets/toolset-detail.tsx
@@ -78,7 +78,7 @@ export function ToolsetDetail({
generic Settings → Config editor. */}
{toolset.name === 'browser' && <BrowserRealProfilePanel profile={profile} />}
{toolset.name === 'terminal' && (
- <TerminalBackendPanel onConfiguredChange={onConfiguredChange} profile={profile} />
+ <TerminalBackendPanel key={profileScopeKey(profile)} onConfiguredChange={onConfiguredChange} profile={profile} />
)}
<ToolsetConfigPanel
key={`${toolset.name}:${profileScopeKey(profile)}`}
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
index 65820c0c031..7e8f019c187 100644
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
@@ -1,5 +1,5 @@
import { useStore } from '@nanostores/react'
-import { useMemo } from 'react'
+import { useCallback, useMemo } from 'react'
import { useNavigate } from 'react-router'
import { ConnectionSwitcher } from '@/app/chat/sidebar/connection-switcher'
@@ -36,9 +36,11 @@ import { cacheHitLabel, contextBarLabel, LiveDuration, tokensPerSecondLabel, usa
import { useStoreSelector } from '@/lib/use-session-slice'
import { cn } from '@/lib/utils'
import { resolveVersionStatus } from '@/lib/version-status'
+import type { ApprovalModeRequester } from '@/store/approval-mode'
import { copyFilePath, revealFile, shouldOfferLocalReveal } from '@/store/file-actions'
import { $freeTierStatus, FREE_TIER_MODEL } from '@/store/free-tier'
import { openFreeTierSignIn } from '@/store/free-tier-sign-in'
+import { requestGatewayForProfile } from '@/store/gateway'
import { revealFileInTree } from '@/store/layout'
import { $onboardingGate, guidedOnboardingActive } from '@/store/onboarding-gate'
import { $activeGatewayProfile } from '@/store/profile'
@@ -334,7 +336,15 @@ export function useStatusbarItems({
const cacheHit = cacheHitLabel(currentUsage)
const tokensPerSecond = tokensPerSecondLabel(currentUsage)
- const approvalModeItem = useApprovalModeStatusbarItem(activeGatewayProfile, requestGateway)
+ // Dial the viewed profile directly: the ambient `requestGateway` is the
+ // session-routed dispatcher, which re-scopes `params.profile` to the FOCUSED
+ // session's owner — a profile other than the one this menu shows.
+ const requestApprovalModeGateway = useCallback<ApprovalModeRequester>(
+ (method, params) => requestGatewayForProfile(activeGatewayProfile, method, params),
+ [activeGatewayProfile]
+ )
+
+ const approvalModeItem = useApprovalModeStatusbarItem(activeGatewayProfile, requestApprovalModeGateway)
const systemResourcesItem = useSystemResourcesStatusbarItem()
const gatewayMenuContent = useMemo(
diff --git a/apps/desktop/src/store/display-toggles.test.ts b/apps/desktop/src/store/display-toggles.test.ts
index d20a6710ef8..e40b3cb3018 100644
--- a/apps/desktop/src/store/display-toggles.test.ts
+++ b/apps/desktop/src/store/display-toggles.test.ts
@@ -2,11 +2,14 @@ import { atom } from 'nanostores'
import { beforeEach, describe, expect, it, vi } from 'vitest'
const $gateway = atom<unknown>(null)
-const request = vi.fn(async (_method: string, _params?: Record<string, unknown>) => undefined)
+const request = vi.fn(async (_profile: string, _method: string, _params?: Record<string, unknown>) => undefined)
+// The viewed profile is not the launch profile: an unscoped write would land in
+// the wrong config.yaml (#125969 class), so every push must be routed by profile.
vi.mock('@/store/gateway', () => ({
$gateway,
- activeGateway: () => ({ request })
+ activeGatewayProfileKey: () => 'work',
+ requestGatewayForProfile: request
}))
const { mirrorDisplayToggle } = await import('./display-toggles')
@@ -17,7 +20,8 @@ const $enabled = atom(true)
mirrorDisplayToggle('display.test_toggle', STORAGE_KEY, $enabled)
-const sets = () => request.mock.calls.filter(([method]) => method === 'config.set').map(([, params]) => params)
+const sets = () =>
+ request.mock.calls.filter(([, method]) => method === 'config.set').map(([profile, , params]) => ({ ...params, profile }))
beforeEach(() => {
localStorage.clear()
@@ -30,7 +34,7 @@ describe('display toggle mirror', () => {
it('sends the user answer to the gateway when it changes', () => {
$enabled.set(false)
- expect(sets()).toEqual([{ key: 'display.test_toggle', value: 'false' }])
+ expect(sets()).toEqual([{ key: 'display.test_toggle', profile: 'work', value: 'false' }])
})
it('re-sends a touched setting to a gateway that has never seen it', () => {
@@ -40,7 +44,7 @@ describe('display toggle mirror', () => {
$gateway.set({})
- expect(sets()).toEqual([{ key: 'display.test_toggle', value: 'false' }])
+ expect(sets()).toEqual([{ key: 'display.test_toggle', profile: 'work', value: 'false' }])
})
it('leaves an untouched setting alone, so a hand-edited config.yaml wins', () => {
diff --git a/apps/desktop/src/store/display-toggles.ts b/apps/desktop/src/store/display-toggles.ts
index 011fc52c5d5..f0dc7b80d37 100644
--- a/apps/desktop/src/store/display-toggles.ts
+++ b/apps/desktop/src/store/display-toggles.ts
@@ -25,7 +25,7 @@
import type { ReadableAtom } from 'nanostores'
import { readKey } from '@/lib/storage'
-import { $gateway, activeGateway } from '@/store/gateway'
+import { $gateway, activeGatewayProfileKey, requestGatewayForProfile } from '@/store/gateway'
interface Mirror {
configKey: string
@@ -36,9 +36,13 @@ interface Mirror {
const mirrors: Mirror[] = []
function push(mirror: Mirror): void {
- void activeGateway()
- ?.request('config.set', { key: mirror.configKey, value: mirror.read() ? 'true' : 'false' })
- .catch(() => {
+ // Routed by profile: `config.set` is `@_profile_scoped`, and on the
+ // shared-primary route an unscoped write edits the LAUNCH profile's
+ // config.yaml instead of the viewed one (#125969 class).
+ void requestGatewayForProfile(activeGatewayProfileKey(), 'config.set', {
+ key: mirror.configKey,
+ value: mirror.read() ? 'true' : 'false'
+ }).catch(() => {
// Not connected, or a gateway too old to know the key. The next toggle
// and the next connection both try again.
})
diff --git a/apps/desktop/src/store/voice-live.test.ts b/apps/desktop/src/store/voice-live.test.ts
new file mode 100644
index 00000000000..1fb5ee66be2
--- /dev/null
+++ b/apps/desktop/src/store/voice-live.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it, vi } from 'vitest'
+
+const request = vi.fn(async (_profile: string, _method: string, _params?: Record<string, unknown>) => undefined)
+
+vi.mock('@/store/gateway', () => ({
+ activeGatewayProfileKey: () => 'work',
+ requestGatewayForProfile: request
+}))
+
+vi.mock('@/lib/voice-live', () => ({
+ fetchVoiceLiveStatus: async () => null
+}))
+
+const { setVoiceChatMode } = await import('./voice-live')
+
+describe('setVoiceChatMode', () => {
+ it('routes the write through the viewed profile, not the bare active socket', async () => {
+ await setVoiceChatMode('gpt-live')
+
+ // `config.set` is profile-scoped on the backend: an unscoped write on the
+ // shared-primary route edits the LAUNCH profile's config.yaml (#125969 class).
+ expect(request).toHaveBeenCalledWith('work', 'config.set', { key: 'voice.voice_chat_mode', value: 'gpt-live' })
+ })
+})
diff --git a/apps/desktop/src/store/voice-live.ts b/apps/desktop/src/store/voice-live.ts
index 3de58e374de..fc62c1ea7ca 100644
--- a/apps/desktop/src/store/voice-live.ts
+++ b/apps/desktop/src/store/voice-live.ts
@@ -1,7 +1,7 @@
import { atom } from 'nanostores'
import { fetchVoiceLiveStatus, type VoiceLiveStatus } from '@/lib/voice-live'
-import { activeGateway } from '@/store/gateway'
+import { activeGatewayProfileKey, requestGatewayForProfile } from '@/store/gateway'
/**
* `voice.voice_chat_mode` as the backend resolves it, plus whether GPT-Live can
@@ -41,15 +41,13 @@ export function selectedVoiceChatMode(status: null | VoiceLiveStatus = $voiceLiv
* the app is talking to) and re-read the resolved status, so the menu shows
* what the backend will actually mount next. Takes effect on the NEXT
* conversation; an active one keeps its engine.
+ *
+ * Routed by profile, not by socket: `config.set` is `@_profile_scoped`, so on
+ * the shared-primary route an unscoped write lands in the LAUNCH profile's
+ * config.yaml, not the viewed one (#125969 class).
*/
export async function setVoiceChatMode(mode: 'chained' | 'gpt-live'): Promise<null | VoiceLiveStatus> {
- const gateway = activeGateway()
-
- if (!gateway) {
- throw new Error('gateway not connected')
- }
-
- await gateway.request('config.set', { key: 'voice.voice_chat_mode', value: mode })
+ await requestGatewayForProfile(activeGatewayProfileKey(), 'config.set', { key: 'voice.voice_chat_mode', value: mode })
return refreshVoiceLiveStatus()
}