Add chat width settings to pane headers (#37753)

* feat: add chat width settings after pane close button

* Translate chat settings label

* Fix chat width options import and verify settings placement
This commit is contained in:
Jinjing
2026-11-03 13:15:19 -08:00
committed by GitHub
parent 7f885c19a6
commit 65687d9ecf
19 changed files with 161 additions and 15 deletions
@@ -19,3 +19,12 @@ export const splitShortcut = defineFixture({
frame.querySelector<HTMLButtonElement>('button[aria-label="Split Chat Right"]')?.focus()
}
})
export const settings = defineFixture({
...splitShortcut,
interact: (frame) => {
frame
.querySelector<HTMLButtonElement>('button[aria-label="Chat settings"]')
?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
}
})
@@ -1,5 +1,6 @@
// @vitest-environment happy-dom
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { getDefaultSettings } from '../../../../shared/constants'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { TooltipProvider } from '@/components/ui/tooltip'
import { useAppStore } from '@/store'
@@ -60,7 +61,8 @@ it('offers chat actions without a duplicate close button and targets Resume at t
const source = renderHeader()
expect(screen.getAllByRole('button').map((button) => button.getAttribute('aria-label'))).toEqual([
'Continue with Terminal Agent',
'Split Chat Right'
'Split Chat Right',
'Chat settings'
])
const folder = useAppStore.getState().folderWorkspaces[0]
act(() => useAppStore.setState({ folderWorkspaces: [{ ...folder, executionHostId: 'ssh:dev' }] }))
@@ -81,6 +83,28 @@ it('offers chat actions without a duplicate close button and targets Resume at t
)
})
it('changes the saved chat width from the standalone chat toolbar', async () => {
const settings = {
...getDefaultSettings('/tmp'),
nativeChatAppearance: { fontSize: 16, width: 'wide' as const }
}
const updateSettings = vi.fn(async (updates) => {
useAppStore.setState({ settings: { ...settings, ...updates } })
})
useAppStore.setState({ settings, updateSettings })
renderHeader()
fireEvent.keyDown(screen.getByRole('button', { name: 'Chat settings' }), { key: 'Enter' })
expect(screen.getByRole('menuitemradio', { name: 'Wide' }).getAttribute('aria-checked')).toBe(
'true'
)
fireEvent.click(screen.getByRole('menuitemradio', { name: 'Full' }))
await waitFor(() =>
expect(updateSettings).toHaveBeenCalledWith({
nativeChatAppearance: { fontSize: 16, width: 'full' }
})
)
})
async function splitTooltipText(): Promise<string | null> {
const trigger = screen.getByRole('button', { name: 'Split Chat Right' })
fireEvent.pointerMove(trigger, { pointerType: 'mouse' })
@@ -10,6 +10,7 @@ import type { NativeChatTabSession } from '../tab-bar/tab-session-history-switch
import { useDocumentDarkTheme } from '@/hooks/use-document-dark-theme'
import { useStructuredChatPaneActions } from './use-structured-chat-pane-actions'
import { NativeChatResumeInCliButton } from './NativeChatResumeInCliButton'
import { NativeChatSettingsButton } from './NativeChatSettingsButton'
import type { NativeChatStructuredViewProps } from './native-chat-view-types'
import type { NativeChatHandOff } from './use-native-chat-hand-off'
@@ -119,6 +120,7 @@ export function NativeChatPaneHeader({
</span>
</TooltipContent>
</Tooltip>
<NativeChatSettingsButton />
</div>
</div>
)
@@ -0,0 +1,27 @@
import { defineFixture } from '../../component-fixtures/component-fixture'
import { NativeChatSettingsButton } from './NativeChatSettingsButton'
import { useAppStore } from '../../store'
export const menu = defineFixture({
width: 320,
render: () => (
<div
className="pane-title-overlay-layer h-48 bg-background p-2"
data-pane-title-surface={
useAppStore.getState().settings?.theme === 'light' ? 'light' : 'dark'
}
style={{ position: 'relative' }}
>
<div className="pane-title-bar" data-active-pane="" data-chromeless="">
<div className="pane-title-actions ml-auto">
<NativeChatSettingsButton />
</div>
</div>
</div>
),
interact: (frame) => {
frame
.querySelector<HTMLButtonElement>('button')
?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
}
})
@@ -0,0 +1,61 @@
import { Settings } from 'lucide-react'
import { useAppStore } from '../../store'
import { translate } from '@/i18n/i18n'
import { Button } from '../ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuTrigger
} from '../ui/dropdown-menu'
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'
import { getChatWidthOptions } from '../settings/appearance/chat/chat-appearance-search'
import { writeNativeChatAppearance } from './native-chat-appearance-write'
export function NativeChatSettingsButton(): React.JSX.Element {
const width = useAppStore((state) => state.settings?.nativeChatAppearance?.width ?? 'comfortable')
const label = translate('components.native-chat.settings', 'Chat settings')
return (
<DropdownMenu>
<Tooltip>
<TooltipTrigger asChild>
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="pane-title"
size="icon-xs"
aria-label={label}
onClick={(event) => event.stopPropagation()}
>
<Settings className="size-3" />
</Button>
</DropdownMenuTrigger>
</TooltipTrigger>
<TooltipContent side="bottom" sideOffset={4}>
{label}
</TooltipContent>
</Tooltip>
<DropdownMenuContent align="end" onClick={(event) => event.stopPropagation()}>
<DropdownMenuLabel>
{translate('settings.appearance.chat.width', 'Width')}
</DropdownMenuLabel>
<DropdownMenuRadioGroup value={width}>
{getChatWidthOptions().map((option) => (
<DropdownMenuRadioItem
key={option.value}
value={option.value}
onSelect={() => {
void writeNativeChatAppearance((current) => ({ ...current, width: option.value }))
}}
>
{option.label}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
)
}
@@ -98,6 +98,8 @@ vi.mock('@/components/ui/dropdown-menu', () => {
return props.children
},
DropdownMenuLabel: Pass,
DropdownMenuRadioGroup: Pass,
DropdownMenuRadioItem: Pass,
DropdownMenuSeparator: () => null,
DropdownMenuShortcut: Pass,
DropdownMenuSub: Pass,
@@ -8,6 +8,7 @@ import { isTerminalLeafId } from '../../../../shared/stable-pane-id'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { ManagedPane, PaneManager } from '@/lib/pane-manager/pane-manager'
import type { PtyTransport } from './pty-transport-types'
import type { AppState } from '../../store/types'
import TerminalPaneHeaderOverlay from './TerminalPaneHeaderOverlay'
import {
encodeWorkspaceFilePaths,
@@ -30,7 +31,7 @@ vi.mock('@/i18n/i18n', () => ({
)
}))
vi.mock('@/store', () => ({
useAppStore: {
useAppStore: Object.assign((selector: (state: Partial<AppState>) => unknown) => selector({}), {
getState: () => ({
settings: { activeRuntimeEnvironmentId: null },
repos: [{ id: 'repo1', connectionId: null, executionHostId: 'local' }],
@@ -39,7 +40,7 @@ vi.mock('@/store', () => ({
folderWorkspaces: [],
sshConnectionStates: new Map()
})
}
})
}))
vi.mock('./terminal-input-activity', () => ({ recordTerminalUserInputForLeaf: vi.fn() }))
vi.mock('./TerminalPaneResumeInChatButton', () => ({
@@ -202,6 +203,7 @@ describe('TerminalPaneHeaderOverlay', () => {
true
)
expect(container.querySelector('button[aria-label="Show chat view"]')).toBeNull()
expect(container.querySelector('button[aria-label="Chat settings"]')).toBeNull()
})
it('keeps Show terminal as the way back from chat view', () => {
@@ -212,6 +214,12 @@ describe('TerminalPaneHeaderOverlay', () => {
})
expect(container.querySelector('button[aria-label="Show terminal"]')).not.toBeNull()
expect(container.querySelectorAll('button[aria-label="Chat settings"]')).toHaveLength(1)
expect(
container.querySelector(
'.pane-title-bar[data-active-pane] button[aria-label="Chat settings"]'
)
).not.toBeNull()
expect(container.textContent).not.toContain('Continue in Chat UI')
})
@@ -11,6 +11,7 @@ import type { PtyTransport } from './pty-transport-types'
import { TerminalPaneHeaderDropSurface } from './TerminalPaneHeaderDropSurface'
import { TerminalPaneResumeInChatButton } from './TerminalPaneResumeInChatButton'
import { makePaneKey } from '../../../../shared/stable-pane-id'
import { NativeChatSettingsButton } from '../native-chat/NativeChatSettingsButton'
export type PaneTitleOverlayRect = {
left: number
@@ -338,6 +339,7 @@ export default function TerminalPaneHeaderOverlay({
</TooltipContent>
</Tooltip>
) : null}
{canShowTerminal && isActivePane ? <NativeChatSettingsButton /> : null}
</div>
</>
)}
+2 -1
View File
@@ -20014,7 +20014,8 @@
"effortPickerFailed": "Die Auswahl des Denkaufwands konnte nicht geöffnet werden.",
"modelApplyFailed": "Modell {{value}} konnte nicht angewendet werden.",
"effortApplyFailed": "Denkaufwand {{value}} konnte nicht angewendet werden."
}
},
"settings": "Chat-Einstellungen"
},
"tab": {
"bar": {
+2 -1
View File
@@ -20425,7 +20425,8 @@
"cancelled": "Orca won't continue this chat automatically.",
"scheduled": "Orca will continue this chat at {{time}}.",
"cancel": "Don't continue"
}
},
"settings": "Chat settings"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19845,7 +19845,8 @@
"cancelled": "Orca no continuará este chat automáticamente.",
"scheduled": "Orca continuará este chat a las {{time}}.",
"cancel": "No continuar"
}
},
"settings": "Configuración del chat"
},
"tab": {
"bar": {
+2 -1
View File
@@ -20065,7 +20065,8 @@
"cancelled": "Orca ne reprendra pas ce chat automatiquement.",
"scheduled": "Orca reprendra ce chat à {{time}}.",
"cancel": "Ne pas reprendre"
}
},
"settings": "Paramètres du chat"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19322,7 +19322,8 @@
"cancelled": "Orca はこのチャットを自動的には続けません。",
"scheduled": "Orca は {{time}} にこのチャットを続けます。",
"cancel": "続けない"
}
},
"settings": "チャット設定"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19311,7 +19311,8 @@
"cancelled": "Orca가 이 채팅을 자동으로 계속하지 않습니다.",
"scheduled": "Orca가 {{time}}에 이 채팅을 계속합니다.",
"cancel": "계속하지 않기"
}
},
"settings": "채팅 설정"
},
"tab": {
"bar": {
+2 -1
View File
@@ -20969,7 +20969,8 @@
"effortPickerFailed": "Não foi possível abrir o seletor de esforço.",
"modelApplyFailed": "Não foi possível aplicar o modelo {{value}}.",
"effortApplyFailed": "Não foi possível aplicar o esforço {{value}}."
}
},
"settings": "Configurações do chat"
},
"tab": {
"bar": {
+2 -1
View File
@@ -20682,7 +20682,8 @@
"effortPickerFailed": "Не удалось открыть меню выбора глубины рассуждений.",
"modelApplyFailed": "Не удалось применить модель {{value}}.",
"effortApplyFailed": "Не удалось применить глубину рассуждений {{value}}."
}
},
"settings": "Настройки чата"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19998,7 +19998,8 @@
"effortPickerFailed": "Çaba seçici açılamadı.",
"modelApplyFailed": "{{value}} modeli uygulanamadı.",
"effortApplyFailed": "Çaba düzeyi {{value}} olarak ayarlanamadı."
}
},
"settings": "Sohbet ayarları"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19707,7 +19707,8 @@
"effortPickerFailed": "無法開啟推理強度選擇器。",
"modelApplyFailed": "無法套用模型 {{value}}。",
"effortApplyFailed": "無法套用推理強度 {{value}}。"
}
},
"settings": "聊天設定"
},
"tab": {
"bar": {
+2 -1
View File
@@ -19277,7 +19277,8 @@
"cancelled": "Orca 不会自动继续此聊天。",
"scheduled": "Orca 将在 {{time}} 继续此聊天。",
"cancel": "不要继续"
}
},
"settings": "聊天设置"
},
"tab": {
"bar": {