11import { create } from 'zustand'
22import { persist } from 'zustand/middleware'
3+ import { isMac , platformAlt } from '../utils/env'
34
45export type Shortcut = {
56 action : string
@@ -37,23 +38,27 @@ function isPersistedShortcutsState(value: unknown): value is PersistedShortcutsS
3738const defaultShortcuts : Record < string , Omit < Shortcut , 'defaultKey' > > = {
3839 hideOrShowMainWindow : {
3940 action : 'hideOrShowMainWindow' ,
40- key : 'Alt+H' ,
41+ key : ` ${ platformAlt } +H` ,
4142 category : 'Window Management'
4243 } ,
4344 ignoreOrEnableMouse : {
4445 action : 'ignoreOrEnableMouse' ,
45- key : 'Alt+M' ,
46+ key : ` ${ platformAlt } +M` ,
4647 category : 'Window Management'
4748 } ,
48- takeScreenshot : { action : 'takeScreenshot' , key : 'Alt+Enter' , category : 'Screenshot & AI' } ,
49+ takeScreenshot : {
50+ action : 'takeScreenshot' ,
51+ key : `${ platformAlt } +Enter` ,
52+ category : 'Screenshot & AI'
53+ } ,
4954 appendScreenshot : {
5055 action : 'appendScreenshot' ,
51- key : 'Alt +Shift+Enter' ,
56+ key : ` ${ platformAlt } +Shift+Enter` ,
5257 category : 'Screenshot & AI'
5358 } ,
5459 stopSolutionStream : {
5560 action : 'stopSolutionStream' ,
56- key : 'Alt+.' ,
61+ key : ` ${ platformAlt } +.` ,
5762 category : 'Screenshot & AI'
5863 } ,
5964 pageUp : { action : 'pageUp' , key : 'CommandOrControl+J' , category : 'Navigation' } ,
@@ -113,8 +118,8 @@ export const useShortcutsStore = create<ShortcutsStore>()(
113118 } ) ,
114119 {
115120 name : 'interview-coder-shortcuts' ,
116- version : 2 ,
117- migrate : ( state : unknown ) => {
121+ version : 3 ,
122+ migrate : ( state : unknown , version : number ) => {
118123 if ( ! isPersistedShortcutsState ( state ) || ! state . shortcuts ) return state as ShortcutsStore
119124 // Merge in any new default shortcuts that are missing
120125 const defaults = Object . fromEntries (
@@ -123,13 +128,26 @@ export const useShortcutsStore = create<ShortcutsStore>()(
123128 { ...shortcut , defaultKey : shortcut . key }
124129 ] )
125130 )
126- return {
131+ const merged = {
127132 ...state ,
128133 shortcuts : {
129134 ...defaults ,
130135 ...state . shortcuts
131136 }
132137 } as ShortcutsStore
138+
139+ // v2→v3: On Windows, migrate Alt shortcuts to CommandOrControl (Ctrl)
140+ if ( version < 3 && ! isMac ) {
141+ for ( const [ action , shortcut ] of Object . entries ( merged . shortcuts ) ) {
142+ merged . shortcuts [ action ] = {
143+ ...shortcut ,
144+ key : shortcut . key . replace ( / \b A l t \b / g, 'CommandOrControl' ) ,
145+ defaultKey : shortcut . defaultKey . replace ( / \b A l t \b / g, 'CommandOrControl' )
146+ }
147+ }
148+ }
149+
150+ return merged
133151 }
134152 }
135153 )
0 commit comments