Skip to content

The agent that grows with you

fix(desktop): lock the docked composer to the dock by default

Brooklyn Nicholsone928574ab31b
diff --git a/apps/desktop/src/app/chat/composer/floating-surface.test.tsx b/apps/desktop/src/app/chat/composer/floating-surface.test.tsx
index cb4d2137d4d..30e07bffd20 100644
--- a/apps/desktop/src/app/chat/composer/floating-surface.test.tsx
+++ b/apps/desktop/src/app/chat/composer/floating-surface.test.tsx
@@ -1,9 +1,9 @@
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useState } from 'react'
-import { afterEach, expect, it } from 'vitest'
+import { afterEach, beforeEach, expect, it } from 'vitest'
import { PaneGroupContext, PaneVisibleContext } from '@/components/pane-shell/pane-visibility'
-import { $composerPopout, setComposerPoppedOut } from '@/store/composer-popout'
+import { $composerPopout, $composerPopoutGesturesEnabled, setComposerPoppedOut } from '@/store/composer-popout'
import { FloatingComposerSurface } from './floating-surface'
import { claimFloatingComposer, pinFloatingComposerCapture } from './floating-target'
@@ -34,6 +34,9 @@ function Surface({ id, visible = true, groupId = id }: { id: string; visible?: b
)
}
+// Floating is opt-in (the dock lock is the default); these exercise the float.
+beforeEach(() => $composerPopoutGesturesEnabled.set(true))
+
afterEach(async () => {
cleanup()
await act(async () => {})
diff --git a/apps/desktop/src/store/composer-popout-preference.test.ts b/apps/desktop/src/store/composer-popout-preference.test.ts
index c2a866d27d8..5cf11603d23 100644
--- a/apps/desktop/src/store/composer-popout-preference.test.ts
+++ b/apps/desktop/src/store/composer-popout-preference.test.ts
@@ -47,4 +47,33 @@ describe('composer pop-out preference', () => {
position: { bottom: 48, right: 64 }
})
})
+
+ // #101318: drag-to-float was on by default and a short brush undocked it.
+ it('locks a fresh install to the dock', async () => {
+ const store = await loadStore()
+
+ expect(store.$composerPopoutGesturesEnabled.get()).toBe(false)
+ expect(store.$composerPopout.get().poppedOut).toBe(false)
+ })
+
+ it('keeps gestures for a composer that was already floating before the default flipped', async () => {
+ window.localStorage.setItem(
+ ZONES_KEY,
+ JSON.stringify({ main: { poppedOut: true, position: { bottom: 48, right: 64 } } })
+ )
+
+ const store = await loadStore()
+
+ expect(store.$composerPopoutGesturesEnabled.get()).toBe(true)
+ expect(store.$composerPopout.get()).toEqual({ poppedOut: true, position: { bottom: 48, right: 64 } })
+ })
+
+ it('honours a stored choice either way', async () => {
+ window.localStorage.setItem(GESTURES_KEY, 'true')
+ expect((await loadStore()).$composerPopoutGesturesEnabled.get()).toBe(true)
+
+ vi.resetModules()
+ window.localStorage.setItem(GESTURES_KEY, 'false')
+ expect((await loadStore()).$composerPopoutGesturesEnabled.get()).toBe(false)
+ })
})
diff --git a/apps/desktop/src/store/composer-popout.ts b/apps/desktop/src/store/composer-popout.ts
index 23d9053a3e2..befb3f52c80 100644
--- a/apps/desktop/src/store/composer-popout.ts
+++ b/apps/desktop/src/store/composer-popout.ts
@@ -24,7 +24,6 @@ export const POPOUT_WIDTH_REM = 19.5
export const POPOUT_ESTIMATED_HEIGHT = 56
const DEFAULT_POSITION: PopoutPosition = { bottom: 24, right: 24 }
const EDGE_MARGIN = 8
-const gesturesEnabledAtLoad = storedBoolean(POPOUT_GESTURES_ENABLED_STORAGE_KEY, true)
const isPosition = (value: unknown): value is PopoutPosition => {
const position = value as Partial<PopoutPosition> | null
@@ -46,11 +45,12 @@ function isState(value: unknown): value is ComposerPopoutState {
return typeof state?.poppedOut === 'boolean' && isPosition(state.position)
}
-function load(): ComposerPopoutState {
+/** The persisted placement, before the gesture preference gates it. */
+function loadSaved(): ComposerPopoutState {
const saved = readState(POPOUT_STORAGE_KEY)
if (isState(saved)) {
- return { ...saved, poppedOut: gesturesEnabledAtLoad && saved.poppedOut }
+ return saved
}
// Upgrade existing floats without resurrecting a stale singleton preference
@@ -62,7 +62,7 @@ function load(): ComposerPopoutState {
const state = states.find(zone => zone.poppedOut) ?? states[0]
return {
- poppedOut: gesturesEnabledAtLoad && Boolean(state?.poppedOut),
+ poppedOut: Boolean(state?.poppedOut),
position: state?.position ?? DEFAULT_POSITION
}
}
@@ -70,13 +70,24 @@ function load(): ComposerPopoutState {
const position = readState(LEGACY_POSITION_KEY)
return {
- poppedOut: gesturesEnabledAtLoad && storedBoolean(LEGACY_ENABLED_KEY, false),
+ poppedOut: storedBoolean(LEGACY_ENABLED_KEY, false),
position: isPosition(position) ? position : DEFAULT_POSITION
}
}
+const saved = loadSaved()
+
+// Locked to the dock by default: a short upward brush on the docked composer
+// used to peel it into a float nobody asked for (#101318). A composer that is
+// already floating from before the default flipped keeps its gestures — that
+// user chose the float, and docking it on update would read as a regression.
+const gesturesEnabledAtLoad = storedBoolean(POPOUT_GESTURES_ENABLED_STORAGE_KEY, saved.poppedOut)
+
/** One floating placement per window; drafts and runtimes remain session-owned. */
-export const $composerPopout = atom<ComposerPopoutState>(load())
+export const $composerPopout = atom<ComposerPopoutState>({
+ ...saved,
+ poppedOut: gesturesEnabledAtLoad && saved.poppedOut
+})
export const $composerPopoutGesturesEnabled = atom(gesturesEnabledAtLoad)
const persist = () => persistString(POPOUT_STORAGE_KEY, JSON.stringify($composerPopout.get()))