The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): add reasoning level up/down keybind actions
Brooklyn Nicholson2ffa4977baf9
diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex f53700a4b63..c9037cc495a 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -1070,6 +1070,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {useKeybinds({archiveSelectedSession,openNewSessionTab,+ requestGateway,startFreshSession: startFreshSessionDraft,toggleCommandCenter,toggleSelectedPindiff --git a/apps/desktop/src/app/hooks/use-keybinds-tab-slot.test.ts b/apps/desktop/src/app/hooks/use-keybinds-tab-slot.test.tsindex c3eb2628ab5..66d7ae5032c 100644--- a/apps/desktop/src/app/hooks/use-keybinds-tab-slot.test.ts+++ b/apps/desktop/src/app/hooks/use-keybinds-tab-slot.test.ts@@ -63,6 +63,7 @@ beforeEach(() => {useKeybinds({archiveSelectedSession: () => undefined,openNewSessionTab: () => undefined,+ requestGateway: <T,>() => Promise.resolve(undefined as T),startFreshSession: () => undefined,toggleCommandCenter: () => undefined,toggleSelectedPin: () => undefineddiff --git a/apps/desktop/src/app/hooks/use-keybinds.ts b/apps/desktop/src/app/hooks/use-keybinds.tsindex 07929a53645..2e224b90865 100644--- a/apps/desktop/src/app/hooks/use-keybinds.ts+++ b/apps/desktop/src/app/hooks/use-keybinds.ts@@ -16,6 +16,7 @@ import {} from '@/components/pane-shell/tree/store'import { setWorkspaceScope } from '@/components/pane-shell/workspace-scope'import { onReleaseTypingFocus } from '@/components/ui/keyboard-first'+import { translateNow } from '@/i18n/runtime'import { findBarClaimsCombo } from '@/lib/find-in-page'import {contributedKeybindHandler,@@ -27,6 +28,7 @@ import {import { handleApprovalKey, releaseApprovalKey } from '@/lib/keybinds/approval-keys'import { actionAllowedInInput, comboFromEvent, isEditableTarget } from '@/lib/keybinds/combo'import { composerFocusKeysAllowed, isComposerFocusSoftCombo, typeToFocusChar } from '@/lib/keybinds/composer-focus-keys'+import { stepReasoningEffort, writeSessionReasoningEffort } from '@/lib/reasoning-step'import { openWorktreeDialog } from '@/store/coding-status'import { $commandPaletteOpen, openCommandPalettePage, toggleCommandPalette } from '@/store/command-palette'import {@@ -46,6 +48,7 @@ import {togglePanesFlipped,toggleSidebarOpen} from '@/store/layout'+import { notifyError } from '@/store/notifications'import { openBrowserTab } from '@/store/preview'import {$newChatProfile,@@ -58,7 +61,15 @@ import {import { toggleProfileRailVisible } from '@/store/profile-rail-prefs'import { openFolderAsProject } from '@/store/projects'import { toggleReview } from '@/store/review'-import { $selectedStoredSessionId, setModelPickerOpen } from '@/store/session'+import {+ $activeSessionId,+ $currentReasoningEffort,+ $defaultReasoningEffort,+ $selectedStoredSessionId,+ markComposerSelectionManual,+ setCurrentReasoningEffort,+ setModelPickerOpen+} from '@/store/session'import { $focusedStoredSessionId, reopenLastClosedTile } from '@/store/session-states'import {$switcherOpen,@@ -100,6 +111,8 @@ import {} from '../routes'export interface KeybindRuntimeDeps {+ /** Gateway RPC requester for session-scoped model controls (reasoning). */+ requestGateway: <T>(method: string, params?: Record<string, unknown>) => Promise<T>/** Open/close the command center overlay (sessions / system / usage). */toggleCommandCenter: () => void/** Drop to a fresh new-session draft. */@@ -211,6 +224,51 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {setTerminalTakeover(false)}+ // Reasoning level up/down (#71627): step the ACTIVE session one notch+ // through off → minimal → … → xhigh (clamped; max/ultra stay behind the+ // menu). Optimistic store write with rollback, and a monotonic sequence so+ // a slow earlier response can't revert a newer press.+ const reasoningRequestSeqRef = useRef(0)++ const stepSessionReasoning = (direction: 1 | -1) => {+ const sessionId = $activeSessionId.get()++ // No live session: the draft's pick still steps (it ships on the next+ // session.create); no `config.set` — without a session the RPC falls+ // back to the persistent profile config and would rewrite the default.+ const rollback = $currentReasoningEffort.get()+ const fallback = $defaultReasoningEffort.get() || undefined+ const next = stepReasoningEffort(rollback, direction, fallback)++ if (next === rollback.trim().toLowerCase()) {+ return+ }++ markComposerSelectionManual()+ setCurrentReasoningEffort(next)++ if (!sessionId) {+ return+ }++ const requestSeq = reasoningRequestSeqRef.current + 1++ reasoningRequestSeqRef.current = requestSeq++ void writeSessionReasoningEffort(deps.requestGateway, sessionId, next)+ .then(value => {+ if (reasoningRequestSeqRef.current === requestSeq) {+ setCurrentReasoningEffort(value)+ }+ })+ .catch(error => {+ if (reasoningRequestSeqRef.current === requestSeq) {+ setCurrentReasoningEffort(rollback)+ notifyError(error, translateNow('shell.modelOptions.updateFailed'))+ }+ })+ }+handlersRef.current = {'keybinds.openPanel': () => navigate(`${SETTINGS_ROUTE}?tab=keybinds`),@@ -224,6 +282,8 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {},'composer.voice': requestVoiceToggle,'composer.dictate': requestComposerDictation,+ 'composer.reasoningUp': () => stepSessionReasoning(1),+ 'composer.reasoningDown': () => stepSessionReasoning(-1),// On the Settings overlay, ⌘K scopes to settings search; the second press// (or Esc) still closes as usual via toggle.diff --git a/apps/desktop/src/app/right-sidebar/terminal/reveal-focus.test.ts b/apps/desktop/src/app/right-sidebar/terminal/reveal-focus.test.tsindex 3674e267e65..8dc324520f7 100644--- a/apps/desktop/src/app/right-sidebar/terminal/reveal-focus.test.ts+++ b/apps/desktop/src/app/right-sidebar/terminal/reveal-focus.test.ts@@ -76,6 +76,7 @@ beforeEach(() => {unmountKeybinds = renderHook(() =>useKeybinds({+ requestGateway: vi.fn(),archiveSelectedSession: () => undefined,openNewSessionTab: () => undefined,startFreshSession: () => undefined,diff --git a/apps/desktop/src/components/find-bar.test.tsx b/apps/desktop/src/components/find-bar.test.tsxindex 4f70f8357a8..ab14fdbb5f6 100644--- a/apps/desktop/src/components/find-bar.test.tsx+++ b/apps/desktop/src/components/find-bar.test.tsx@@ -916,6 +916,7 @@ function KeybindHarness({ deps }: { deps: KeybindRuntimeDeps }) {describe('view.findInPage keybind gate', () => {function renderKeybinds(pathname: string) {const deps: KeybindRuntimeDeps = {+ requestGateway: vi.fn(),toggleCommandCenter: vi.fn(),startFreshSession: vi.fn(),openNewSessionTab: vi.fn(),diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 808507e2313..96a9c3b2175 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -385,6 +385,8 @@ export const ar = defineLocale({'composer.modelPicker': 'فتح منتقي النموذج','composer.voice': 'بدء / إيقاف المحادثة الصوتية','composer.dictate': 'بدء / إيقاف الإملاء',+ 'composer.reasoningUp': 'رفع مستوى التفكير',+ 'composer.reasoningDown': 'خفض مستوى التفكير','view.toggleSidebar': 'تبديل الشريط الجانبي للجلسات','view.toggleRightSidebar': 'تبديل متصفح الملفات','view.toggleReview': 'تبديل لوحة المراجعة',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex a8742a4e4de..307db9b3f2b 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -685,6 +685,8 @@ export const deOverrides = {'composer.focus': 'Composer fokussieren','composer.modelPicker': 'Modellauswahl öffnen','composer.voice': 'Sprachkonversation starten / stoppen',+ 'composer.reasoningUp': 'Reasoning-Stufe erhöhen',+ 'composer.reasoningDown': 'Reasoning-Stufe senken','view.toggleSidebar': 'Session-Sidebar umschalten','view.cycleSidebarGrouping': 'Session-Gruppierung wechseln','view.toggleRightSidebar': 'Dateibrowser umschalten',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex a49c5bced16..dd74deb158f 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -745,6 +745,8 @@ export const en: Translations = {'composer.modelPicker': 'Open model picker','composer.voice': 'Start / stop voice conversation','composer.dictate': 'Start / stop dictation',+ 'composer.reasoningUp': 'Reasoning level up',+ 'composer.reasoningDown': 'Reasoning level down','view.toggleSidebar': 'Toggle sessions sidebar','view.cycleSidebarGrouping': 'Cycle session grouping','view.toggleRightSidebar': 'Toggle file browser',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex ab39affbb24..04e03529abb 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -685,6 +685,8 @@ export const esOverrides = {'composer.focus': 'Enfocar compositor','composer.modelPicker': 'Abrir selector de modelo','composer.voice': 'Iniciar / detener conversación por voz',+ 'composer.reasoningUp': 'Subir nivel de razonamiento',+ 'composer.reasoningDown': 'Bajar nivel de razonamiento','view.toggleSidebar': 'Alternar barra lateral de sesiones','view.cycleSidebarGrouping': 'Cambiar la agrupación de sesiones','view.toggleRightSidebar': 'Alternar explorador de archivos',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex ef17b0d73dd..4ab29df2a89 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -684,6 +684,8 @@ export const frOverrides = {'composer.focus': 'Mettre le focus sur le compositeur','composer.modelPicker': 'Ouvrir le sélecteur de modèle','composer.voice': 'Démarrer / arrêter la conversation vocale',+ 'composer.reasoningUp': 'Augmenter le niveau de raisonnement',+ 'composer.reasoningDown': 'Réduire le niveau de raisonnement','view.toggleSidebar': 'Basculer la barre latérale des sessions','view.cycleSidebarGrouping': 'Changer le regroupement des sessions','view.toggleRightSidebar': "Basculer l'explorateur de fichiers",diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 84d0f9b7f5d..7acf3103f4f 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -402,6 +402,8 @@ export const ru = defineLocale({'composer.modelPicker': 'Открыть выбор модели','composer.voice': 'Начать / остановить голосовой диалог','composer.dictate': 'Начать / остановить диктовку',+ 'composer.reasoningUp': 'Повысить уровень размышлений',+ 'composer.reasoningDown': 'Понизить уровень размышлений','view.toggleSidebar': 'Показать / скрыть панель сеансов','view.toggleRightSidebar': 'Показать / скрыть браузер файлов','view.toggleReview': 'Показать / скрыть панель ревью',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 91f755cb12b..3d8d5762f05 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -454,6 +454,8 @@ export const zh = defineLocale({'composer.modelPicker': '打开模型选择器','composer.voice': '开始 / 停止语音对话','composer.dictate': '开始 / 停止听写',+ 'composer.reasoningUp': '提高推理等级',+ 'composer.reasoningDown': '降低推理等级','view.toggleSidebar': '切换会话侧边栏','view.toggleRightSidebar': '切换文件浏览器','view.toggleReview': '切换审查面板',diff --git a/apps/desktop/src/lib/keybinds/actions.test.ts b/apps/desktop/src/lib/keybinds/actions.test.tsindex ef0769602c9..9ab3e06304a 100644--- a/apps/desktop/src/lib/keybinds/actions.test.ts+++ b/apps/desktop/src/lib/keybinds/actions.test.ts@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'import { TRANSLATIONS } from '@/i18n/catalog'import { en } from '@/i18n/en'-import { defaultBindings, KEYBIND_ACTIONS, KEYBIND_READONLY, keybindAction } from './actions'+import { defaultBindings, KEYBIND_ACTIONS, KEYBIND_READONLY, keybindAction, keybindActionAllowedInEditableTarget } from './actions'import { canonicalizeCombo } from './combo'// Relationship checks between the action table and its consumers, not the@@ -40,6 +40,24 @@ describe('KEYBIND_ACTIONS', () => {expect(KEYBIND_ACTIONS.filter(candidate => candidate.id === 'composer.dictate')).toHaveLength(1)})+ // #71627: reasoning level up/down ship unbound (users pick their own chord)+ // and opt into firing from an editable target on MODIFIED combos only.+ it('registers reasoning level actions unbound, editable on modified combos only', () => {+ for (const id of ['composer.reasoningUp', 'composer.reasoningDown'] as const) {+ expect(keybindAction(id)).toMatchObject({ category: 'composer', defaults: [], editableTargetPolicy: 'modified' })+ expect(defaultBindings()[id]).toEqual([])+ expect(en.keybinds.actions[id]).toBeTruthy()+ }++ expect(keybindActionAllowedInEditableTarget('composer.reasoningUp', 'alt+.')).toBe(true)+ expect(keybindActionAllowedInEditableTarget('composer.reasoningDown', 'mod+alt+down')).toBe(true)+ // Bare / shift-only rebinds must never hijack typing.+ expect(keybindActionAllowedInEditableTarget('composer.reasoningUp', '.')).toBe(false)+ expect(keybindActionAllowedInEditableTarget('composer.reasoningUp', 'shift+.')).toBe(false)+ // Actions without the policy never qualify, modified combo or not.+ expect(keybindActionAllowedInEditableTarget('appearance.toggleMode', 'alt+x')).toBe(false)+ })+// jsdom never reports a Mac platform, so this is the Windows/Linux default.// Don't fake the host OS — assert the chord this runtime actually ships.it('ships a voice chord that does not claim the sidebar chord or any other shipped combo', () => {diff --git a/apps/desktop/src/lib/keybinds/actions.ts b/apps/desktop/src/lib/keybinds/actions.tsindex 3e08ae91ba0..da809cd701c 100644--- a/apps/desktop/src/lib/keybinds/actions.ts+++ b/apps/desktop/src/lib/keybinds/actions.ts@@ -33,6 +33,11 @@ export interface KeybindActionMeta {* with a later action is then layering, not a conflict.*/passthrough?: true+ /** `modified`: a combo carrying a non-Shift modifier may fire while an+ * editable target (the composer) has focus, beyond the global combo-safety+ * policy in `actionAllowedInInput`. Bare/shift-only rebinds never qualify,+ * so a text key stays typing-safe (#71627). */+ editableTargetPolicy?: 'modified'}// Positional switch slots for *named* profiles: ⌘1…⌘9 for profiles 1-9, then@@ -90,6 +95,13 @@ export const KEYBIND_ACTIONS: readonly KeybindActionMeta[] = [// Dictation is intentionally unbound: it is available for users who prefer// a keyboard trigger without claiming a chord from text entry by default.{ id: 'composer.dictate', category: 'composer', defaults: [] },+ // Reasoning level up/down — one notch through off → minimal → … → xhigh,+ // clamped at the ends (#71627). Unbound like dictate: the chords a user+ // picks (Alt+., Ctrl+Alt+↑, Numpad +/- …) are too personal to claim by+ // default. `editableTargetPolicy` lets a MODIFIED combo fire while the+ // composer has focus; bare/shift-only rebinds stay typing-safe.+ { id: 'composer.reasoningUp', category: 'composer', defaults: [], editableTargetPolicy: 'modified' },+ { id: 'composer.reasoningDown', category: 'composer', defaults: [], editableTargetPolicy: 'modified' },// ── Profiles ─────────────────────────────────────────────────────────────// Tab-slot actions BEFORE profile switchers: they claim ⌘1…⌘9 first and@@ -265,6 +277,21 @@ export function keybindAction(id: string): KeybindActionMeta | undefined {return ACTION_BY_ID.get(id) ?? allKeybindActions().find(action => action.id === id)}+/** True when `combo` carries a modifier beyond Shift (mod, ctrl, or alt). */+function comboHasNonShiftModifier(combo: string): boolean {+ const parts = combo.split('+')++ return parts.slice(0, -1).some(part => part !== 'shift')+}++/** An action's own allowance for firing inside an editable target: the+ * `editableTargetPolicy` gate that `actionAllowedInInput` consults. Only a+ * combo with a real modifier qualifies — a bare or shift-only rebind stays+ * with the input so it can never hijack typing. */+export function keybindActionAllowedInEditableTarget(id: string, combo: string): boolean {+ return keybindAction(id)?.editableTargetPolicy === 'modified' && comboHasNonShiftModifier(combo)+}+/** The contributed handler for an action id (built-ins wire theirs in use-keybinds). */export function contributedKeybindHandler(id: string): (() => void) | undefined {return contributedKeybinds().find(k => k.id === id)?.rundiff --git a/apps/desktop/src/lib/keybinds/combo.test.ts b/apps/desktop/src/lib/keybinds/combo.test.tsindex 07754ee8a56..73b95b206d7 100644--- a/apps/desktop/src/lib/keybinds/combo.test.ts+++ b/apps/desktop/src/lib/keybinds/combo.test.ts@@ -138,6 +138,22 @@ describe('actionAllowedInInput', () => {expect(comboFromEvent(keydown({ code: 'ArrowRight', metaKey: true, altKey: true }))).toBe('mod+alt+right')expect(comboFromEvent(keydown({ code: 'ArrowLeft', metaKey: true, altKey: true }))).toBe('mod+alt+left')})++ it('fires reasoning level actions from an editable target on modified chords, never on bare keys (#71627)', () => {+ // Alt/Numpad-style chords without a primary modifier — the shapes users+ // actually pick for runtime dials — reach the action while typing.+ expect(actionAllowedInInput('composer.reasoningUp', 'alt+.')).toBe(true)+ expect(actionAllowedInInput('composer.reasoningDown', 'alt+,')).toBe(true)+ expect(actionAllowedInInput('composer.reasoningUp', 'mod+alt+down')).toBe(true)+ // Primary-modifier chords were already global; the opt-in adds nothing new.+ expect(actionAllowedInInput('composer.reasoningUp', 'mod+shift+m')).toBe(true)++ // A bare or shift-only rebind stays with the input: typing '.' or 'U'+ // in the composer must never change the reasoning level.+ expect(actionAllowedInInput('composer.reasoningUp', '.')).toBe(false)+ expect(actionAllowedInInput('composer.reasoningUp', 'shift+.')).toBe(false)+ expect(actionAllowedInInput('composer.reasoningDown', ',')).toBe(false)+ })})describe('comboFromEvent — IME composition keydowns never resolve to combos (#84957)', () => {diff --git a/apps/desktop/src/lib/keybinds/combo.ts b/apps/desktop/src/lib/keybinds/combo.tsindex 0113c35c987..ad4fe12b2ee 100644--- a/apps/desktop/src/lib/keybinds/combo.ts+++ b/apps/desktop/src/lib/keybinds/combo.ts@@ -1,3 +1,5 @@+import { keybindActionAllowedInEditableTarget } from './actions'+// Keybind combo normalization + display.//// A combo is a canonical lowercase string like "mod+k", "mod+shift+]", "shift+x",@@ -313,5 +315,13 @@ export function actionAllowedInInput(actionId: string, combo: string): boolean {return true}+ // An action that opts in (reasoning up/down) fires from an editable target+ // on any modified combo — including Alt/Numpad chords without a primary+ // modifier (#71627). Bare/shift-only combos never qualify, so typing is+ // never hijacked.+ if (keybindActionAllowedInEditableTarget(actionId, combo)) {+ return true+ }+return INPUT_SAFE_ACTIONS.has(actionId)}