-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSettingsContext.tsx
More file actions
executable file
·2107 lines (1917 loc) · 82.1 KB
/
SettingsContext.tsx
File metadata and controls
executable file
·2107 lines (1917 loc) · 82.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {
createContext,
useContext,
ParentProps,
createEffect,
onMount,
onCleanup,
Accessor,
createMemo,
batch,
} from "solid-js";
import { createStore, reconcile } from "solid-js/store";
import { invoke } from "@tauri-apps/api/core";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
// ============================================================================
// Settings Type Definitions
// ============================================================================
/** Unicode highlight settings */
export interface UnicodeHighlightSettings {
enabled: boolean;
invisibleCharacters: boolean;
ambiguousCharacters: boolean;
nonBasicASCII: boolean;
includeComments: boolean | "inUntrustedWorkspace";
includeStrings: boolean | "inUntrustedWorkspace";
allowedCharacters: Record<string, boolean>;
allowedLocales: Record<string, boolean>;
}
/** Inlay hints settings */
export interface InlayHintsSettings {
/** Enable inlay hints */
enabled: boolean;
/** Font size for inlay hints (in pixels). Use 0 to inherit from editor */
fontSize: number;
/** Font family for inlay hints. Empty string inherits from editor */
fontFamily: string;
/** Show type hints for variables */
showTypes: boolean;
/** Show parameter name hints in function calls */
showParameterNames: boolean;
/** Show return type hints */
showReturnTypes: boolean;
/** Maximum length of inlay hint text before truncation */
maxLength: number;
/** Padding around inlay hints */
padding: boolean;
}
/** Editor settings */
export interface EditorSettings {
fontFamily: string;
fontSize: number;
fontLigatures: boolean;
lineHeight: number;
tabSize: number;
insertSpaces: boolean;
wordWrap: "off" | "on" | "wordWrapColumn" | "bounded";
lineNumbers: "on" | "off" | "relative" | "interval";
minimapEnabled: boolean;
minimapWidth: number;
bracketPairColorization: boolean;
autoClosingBrackets: "always" | "languageDefined" | "beforeWhitespace" | "never";
autoIndent: boolean;
formatOnSave: boolean;
formatOnPaste: boolean;
formatOnType: boolean;
formatOnTypeTriggerCharacters: string[];
cursorStyle: "line" | "block" | "underline" | "line-thin" | "block-outline" | "underline-thin";
cursorBlink: "blink" | "smooth" | "phase" | "expand" | "solid";
renderWhitespace: "none" | "boundary" | "selection" | "trailing" | "all";
scrollBeyondLastLine: boolean;
smoothScrolling: boolean;
mouseWheelZoom: boolean;
linkedEditing: boolean;
renameOnType: boolean;
stickyScrollEnabled: boolean;
foldingEnabled: boolean;
showFoldingControls: "always" | "mouseover" | "never";
guidesIndentation: boolean;
guidesBracketPairs: boolean;
highlightActiveIndentGuide: boolean;
unicodeHighlight: UnicodeHighlightSettings;
enablePreview: boolean;
renderControlCharacters: boolean;
dropIntoEditor: { enabled: boolean; showDropSelector: "afterDrop" | "never" };
/** Large file optimizations */
largeFileOptimizations?: boolean;
/** Max tokenization line length */
maxTokenizationLineLength?: number;
/** Maximum lines for sticky scroll */
stickyScrollMaxLines?: number;
/** Enable vertical tabs layout */
verticalTabs: boolean;
/** Inlay hints configuration */
inlayHints: InlayHintsSettings;
/** Code Lens configuration */
codeLens: CodeLensSettings;
/** Semantic highlighting configuration */
semanticHighlighting: SemanticHighlightingSettings;
}
/** Semantic highlighting settings for LSP-based token coloring */
export interface SemanticHighlightingSettings {
/** Enable semantic highlighting from LSP */
enabled: boolean;
/** Show semantic tokens for strings (can be verbose in some languages) */
strings: boolean;
/** Show semantic tokens for comments */
comments: boolean;
}
/** Code Lens display settings */
export interface CodeLensSettings {
/** Enable Code Lens feature */
enabled: boolean;
/** Font family for Code Lens text */
fontFamily: string;
/** Font size for Code Lens text in pixels */
fontSize: number;
/** Show reference counts above functions/classes */
showReferences: boolean;
/** Show implementation counts for interfaces */
showImplementations: boolean;
/** Show run/debug actions for test functions */
showTestActions: boolean;
}
/** Activity bar location type alias */
export type ActivityBarLocation = "side" | "top" | "hidden";
/** Menu bar visibility type alias */
export type MenuBarVisibility = "classic" | "compact" | "toggle" | "hidden";
/** Panel position type alias */
export type PanelPosition = "bottom" | "left" | "right";
/** Panel alignment type alias */
export type PanelAlignment = "center" | "left" | "right" | "justify";
/** Title bar style type alias */
export type TitleBarStyle = "native" | "custom";
/** Breadcrumbs file path display mode */
export type BreadcrumbsFilePath = "on" | "off" | "last";
/** Breadcrumbs symbol path display mode */
export type BreadcrumbsSymbolPath = "on" | "off" | "last";
/** Breadcrumbs display settings */
export interface BreadcrumbsSettings {
/** Enable breadcrumbs navigation */
enabled: boolean;
/** File path display mode: on = full path, off = hidden, last = only filename */
filePath: BreadcrumbsFilePath;
/** Symbol path display mode: on = full hierarchy, off = hidden, last = only current symbol */
symbolPath: BreadcrumbsSymbolPath;
/** Show file type and symbol icons */
icons: boolean;
}
/** Theme settings */
export interface ThemeSettings {
theme: "dark" | "light" | "system";
iconTheme: string;
accentColor: string;
uiFontFamily: string;
uiFontSize: number;
zoomLevel: number;
sidebarPosition: "left" | "right";
activityBarVisible: boolean;
activityBarPosition: ActivityBarLocation;
statusBarVisible: boolean;
tabBarVisible: boolean;
breadcrumbsEnabled: boolean;
/** Detailed breadcrumbs configuration */
breadcrumbs: BreadcrumbsSettings;
wrapTabs: boolean;
menuBarVisibility: MenuBarVisibility;
panelPosition: PanelPosition;
panelAlignment: PanelAlignment;
/** Title bar style: native uses OS decorations, custom renders a VS Code-style title bar */
titleBarStyle: TitleBarStyle;
/** Show command center (search bar) in title bar */
commandCenterEnabled: boolean;
/** Auxiliary bar (secondary sidebar) visibility */
auxiliaryBarVisible: boolean;
}
/** Terminal decoration settings for command status indicators */
export interface TerminalDecorationSettings {
/** Enable command status decorations in gutter */
enabled: boolean;
/** Show command duration in tooltip */
showDuration: boolean;
/** Show exit code in tooltip */
showExitCode: boolean;
}
/** Image scaling mode for terminal images */
export type TerminalImageScaling = "auto" | "fit" | "fill" | "none";
/** Terminal image settings for inline image support (iTerm2/Sixel/Kitty protocols) */
export interface TerminalImageSettings {
/** Enable inline image rendering */
enabled: boolean;
/** Maximum single image size in bytes */
maxImageSize: number;
/** Maximum total memory for images in bytes */
maxTotalMemory: number;
/** Maximum number of images to keep in memory */
maxImages: number;
/** Image scaling mode */
imageScaling: TerminalImageScaling;
/** Enable iTerm2 inline images protocol */
enableITerm2: boolean;
/** Enable Sixel graphics protocol */
enableSixel: boolean;
/** Enable Kitty graphics protocol */
enableKitty: boolean;
}
/** Terminal auto-reply settings for automated responses to prompts */
export interface TerminalAutoReplySettings {
/** Enable auto-reply feature */
enabled: boolean;
/** Show notification when auto-reply triggers */
showNotification: boolean;
/** Default delay before sending reply (ms) */
defaultDelay: number;
}
/** Terminal settings */
export interface TerminalSettings {
shellPath: string;
shellArgs: string[];
fontFamily: string;
fontSize: number;
lineHeight: number;
cursorStyle: "block" | "underline" | "bar";
cursorBlink: boolean;
scrollback: number;
copyOnSelection: boolean;
env: Record<string, string>;
cwd: string;
integratedGpu: boolean;
colorScheme: string;
wordSeparators: string;
bell: "none" | "audible" | "visual";
/** Enable accessible view mode with screen reader support */
accessibleViewEnabled: boolean;
/** Announce command completions and output to screen readers */
screenReaderAnnounce: boolean;
/** Command status decorations in gutter */
decorations: TerminalDecorationSettings;
/** Inline image settings (iTerm2/Sixel/Kitty protocols) */
images: TerminalImageSettings;
/** Auto-reply settings for automated responses to terminal prompts */
autoReply: TerminalAutoReplySettings;
}
/** AI settings */
export interface AISettings {
supermavenEnabled: boolean;
supermavenApiKey: string;
copilotEnabled: boolean;
inlineSuggestEnabled: boolean;
inlineSuggestShowToolbar: boolean;
defaultProvider: string;
defaultModel: string;
}
/** Security settings */
export interface SecuritySettings {
sandboxMode: "workspace_write" | "directory_only" | "read_only";
approvalMode: "auto" | "ask_edit" | "ask_all";
networkAccess: boolean;
trustedWorkspaces: string[];
telemetryEnabled: boolean;
crashReportsEnabled: boolean;
}
/** Search settings */
export interface SearchSettings {
exclude: Record<string, boolean>;
useIgnoreFiles: boolean;
useGlobalIgnoreFiles: boolean;
followSymlinks: boolean;
contextLines: number;
/** Show line numbers in search results */
showLineNumbers: boolean;
}
/** JavaScript debug settings */
export interface JavaScriptDebugSettings {
autoAttachFilter: "disabled" | "always" | "smart" | "onlyWithFlag";
}
/** Variable visualizer settings for the debugger */
export interface VariableVisualizerSettings {
/** Enable custom variable visualizers */
enabled: boolean;
/** Number of bytes per row in hex viewer */
hexBytesPerRow: number;
/** Page size for array pagination */
arrayPageSize: number;
}
/** Debug settings */
export interface DebugSettings {
toolbarLocation: "floating" | "docked" | "commandCenter" | "hidden";
javascript: JavaScriptDebugSettings;
openDebugOnSessionStart: boolean;
closeReadonlyTabsOnEnd: boolean;
focusWindowOnBreak: boolean;
focusEditorOnBreak: boolean;
showInlineBreakpointCandidates: boolean;
variableVisualizers: VariableVisualizerSettings;
}
/** Git settings */
export interface GitSettings {
enabled: boolean;
autofetch: boolean;
autofetchPeriod: number;
confirmSync: boolean;
enableSmartCommit: boolean;
pruneOnFetch: boolean;
fetchTags: boolean;
followTagsWhenSync: boolean;
postCommitCommand: "none" | "push" | "sync";
defaultCloneDirectory: string;
branchSortOrder: "alphabetically" | "committerDate";
rebaseWhenSync: boolean;
}
/** HTTP settings */
export interface HttpSettings {
proxy: string;
proxyStrictSSL: boolean;
proxyAuthorization: string | null;
proxySupport: "off" | "on" | "fallback";
}
/** SSH authentication method type */
export type SSHAuthMethod = "password" | "key" | "agent";
/** Saved SSH connection profile */
export interface SSHConnectionProfile {
/** Unique profile identifier */
id: string;
/** Display name for this connection */
name: string;
/** Remote host address */
host: string;
/** SSH port (default: 22) */
port: number;
/** Username for authentication */
username: string;
/** Authentication method */
authMethod: SSHAuthMethod;
/** Path to private key file (for key auth) */
privateKeyPath?: string;
/** Whether the key requires a passphrase */
usePassphrase?: boolean;
/** Default working directory on remote */
remoteWorkingDirectory?: string;
/** Custom environment variables */
env?: Record<string, string>;
}
/** SSH settings */
export interface SSHSettings {
/** Default username for SSH connections */
defaultUsername: string;
/** Default SSH port */
defaultPort: number;
/** Path to SSH config file (e.g., ~/.ssh/config) */
configFilePath: string;
/** Default path to private key */
defaultKeyPath: string;
/** Connection timeout in seconds */
connectionTimeout: number;
/** Keep-alive interval in seconds (0 to disable) */
keepAliveInterval: number;
/** Default authentication method */
defaultAuthMethod: SSHAuthMethod;
/** Use SSH agent for authentication */
useAgent: boolean;
/** Saved connection profiles */
savedProfiles: SSHConnectionProfile[];
/** Auto-reconnect on connection drop */
autoReconnect: boolean;
/** Maximum reconnection attempts */
maxReconnectAttempts: number;
/** Reconnection delay in seconds */
reconnectDelay: number;
/** Enable compression */
compression: boolean;
/** Terminal type to request (e.g., "xterm-256color") */
terminalType: string;
}
/** Files settings */
export interface FilesSettings {
autoSave: "off" | "afterDelay" | "onFocusChange" | "onWindowChange";
autoSaveDelay: number;
hotExit: "off" | "onExit" | "onExitAndWindowClose";
defaultLanguage: string;
trimTrailingWhitespace: boolean;
insertFinalNewline: boolean;
trimFinalNewlines: boolean;
exclude: Record<string, boolean>;
watchExclude: Record<string, boolean>;
encoding: string;
eol: "auto" | "\n" | "\r\n";
confirmDragAndDrop: boolean;
confirmDelete: boolean;
enableTrash: boolean;
maxMemoryForLargeFilesMB: number;
/** File associations - maps glob patterns to Monaco language IDs */
associations: Record<string, string>;
}
/** File nesting patterns */
export interface FileNestingPatterns {
[pattern: string]: string;
}
/** File nesting settings */
export interface FileNestingSettings {
enabled: boolean;
patterns: FileNestingPatterns;
}
/** Explorer sort order */
export type ExplorerSortOrder = "default" | "mixed" | "filesFirst" | "type" | "modified";
/** Explorer settings */
export interface ExplorerSettings {
compactFolders: boolean;
fileNesting: FileNestingSettings;
indentGuidesEnabled: boolean;
sortOrder: ExplorerSortOrder;
}
/** Zen Mode settings */
export interface ZenModeSettings {
hideSidebar: boolean;
hideStatusBar: boolean;
hideMenuBar: boolean;
hidePanel: boolean;
centerLayout: boolean;
maxWidth: string;
fullScreen: boolean;
showLineNumbers: boolean;
silenceNotifications: boolean;
// NEW - Additional settings
/** Hide editor line numbers in Zen Mode */
hideLineNumbers: boolean;
/** Hide the tab bar in Zen Mode */
hideTabs: boolean;
/** Hide the activity bar in Zen Mode */
hideActivityBar: boolean;
/** Restore window state when exiting Zen Mode */
restore: boolean;
}
/** Centered Editor Layout settings (independent of Zen Mode) */
export interface CenteredLayoutSettings {
/** Whether centered layout is enabled */
enabled: boolean;
/** Maximum editor width in pixels (default 1200px) */
maxWidth: number;
/** Auto-adjust width based on viewport */
autoResize: boolean;
/** Ratio of side margins (0-0.4) */
sideMarginRatio: number;
}
/** Screencast Mode settings */
export interface ScreencastModeSettings {
enabled: boolean;
showKeys: boolean;
showMouse: boolean;
showCommands: boolean;
fontSize: number;
duration: number;
}
/** Command Palette / Quick Access settings */
export interface CommandPaletteSettings {
/** Number of history items to remember per provider (default 50, max 200) */
historyLength: number;
/** Preserve input when reopening the palette */
preserveInput: boolean;
}
/** Extension settings */
export interface ExtensionSettingsMap {
[extensionId: string]: Record<string, unknown>;
}
/** Language-specific editor override */
export interface LanguageEditorOverride {
fontFamily?: string;
fontSize?: number;
lineHeight?: number;
tabSize?: number;
insertSpaces?: boolean;
wordWrap?: "off" | "on" | "wordWrapColumn" | "bounded";
lineNumbers?: "on" | "off" | "relative" | "interval";
minimapEnabled?: boolean;
bracketPairColorization?: boolean;
autoClosingBrackets?: "always" | "languageDefined" | "beforeWhitespace" | "never";
autoIndent?: boolean;
formatOnSave?: boolean;
formatOnPaste?: boolean;
cursorStyle?: "line" | "block" | "underline" | "line-thin" | "block-outline" | "underline-thin";
renderWhitespace?: "none" | "boundary" | "selection" | "trailing" | "all";
guidesIndentation?: boolean;
guidesBracketPairs?: boolean;
foldingEnabled?: boolean;
stickyScrollEnabled?: boolean;
linkedEditing?: boolean;
verticalTabs?: boolean;
inlayHints?: Partial<InlayHintsSettings>;
}
export type LanguageOverridesMap = Record<string, LanguageEditorOverride>;
/** Tab sizing mode for workbench editor */
export type TabSizingMode = "fit" | "shrink" | "fixed";
/** Tab close button visibility */
export type TabCloseButtonVisibility = "always" | "onHover" | "never";
/** Tab close button position */
export type TabCloseButtonPosition = "left" | "right";
/** Workbench editor settings for tab behavior */
export interface WorkbenchEditorSettings {
/** Tab sizing mode: 'fit' = minimum space needed, 'shrink' = shrink to fit with min width, 'fixed' = all same width */
tabSizing: TabSizingMode;
/** Minimum width for tabs in shrink mode (pixels) */
tabSizingFixedMinWidth: number;
/** Fixed width for tabs in fixed mode (pixels) */
tabSizingFixedWidth: number;
/** Whether to wrap tabs to multiple rows */
wrapTabs: boolean;
/** When to show the tab close button */
showTabCloseButton: TabCloseButtonVisibility;
/** Position of the tab close button */
tabCloseButtonPosition: TabCloseButtonPosition;
/** Centered editor layout settings (independent of Zen Mode) */
centeredLayout: CenteredLayoutSettings;
}
/** Workbench settings container */
export interface WorkbenchSettings {
editor: WorkbenchEditorSettings;
}
/** Main settings interface */
export interface CortexSettings {
version: number;
editor: EditorSettings;
theme: ThemeSettings;
terminal: TerminalSettings;
ai: AISettings;
security: SecuritySettings;
files: FilesSettings;
explorer: ExplorerSettings;
zenMode: ZenModeSettings;
screencastMode: ScreencastModeSettings;
extensions: ExtensionSettingsMap;
vimEnabled: boolean;
languageOverrides: LanguageOverridesMap;
debug: DebugSettings;
search: SearchSettings;
git: GitSettings;
http: HttpSettings;
commandPalette: CommandPaletteSettings;
/** Workbench settings (tabs, layout, etc.) */
workbench: WorkbenchSettings;
}
// ============================================================================
// Default Settings
// ============================================================================
const DEFAULT_UNICODE_HIGHLIGHT: UnicodeHighlightSettings = {
enabled: true,
invisibleCharacters: true,
ambiguousCharacters: true,
nonBasicASCII: false,
includeComments: "inUntrustedWorkspace",
includeStrings: true,
allowedCharacters: {},
allowedLocales: { _os: true, _vscode: true },
};
const DEFAULT_INLAY_HINTS: InlayHintsSettings = {
enabled: true,
fontSize: 0,
fontFamily: "",
showTypes: true,
showParameterNames: true,
showReturnTypes: true,
maxLength: 25,
padding: true,
};
const DEFAULT_CODE_LENS: CodeLensSettings = {
enabled: true,
fontFamily: "",
fontSize: 12,
showReferences: true,
showImplementations: true,
showTestActions: true,
};
const DEFAULT_SEMANTIC_HIGHLIGHTING: SemanticHighlightingSettings = {
enabled: true,
strings: true,
comments: true,
};
const DEFAULT_EDITOR: EditorSettings = {
fontFamily: "JetBrains Mono, Fira Code, Consolas, monospace",
fontSize: 14,
fontLigatures: true,
lineHeight: 1.5,
tabSize: 2,
insertSpaces: true,
wordWrap: "off",
lineNumbers: "on",
minimapEnabled: true,
minimapWidth: 100,
bracketPairColorization: true,
autoClosingBrackets: "always",
autoIndent: true,
formatOnSave: false,
formatOnPaste: false,
formatOnType: false,
formatOnTypeTriggerCharacters: [";", "}", "\n"],
cursorStyle: "line",
cursorBlink: "blink",
renderWhitespace: "selection",
scrollBeyondLastLine: true,
smoothScrolling: true,
mouseWheelZoom: false,
linkedEditing: true,
renameOnType: false,
stickyScrollEnabled: false,
foldingEnabled: true,
showFoldingControls: "mouseover",
guidesIndentation: true,
guidesBracketPairs: true,
highlightActiveIndentGuide: true,
unicodeHighlight: DEFAULT_UNICODE_HIGHLIGHT,
enablePreview: true,
renderControlCharacters: false,
dropIntoEditor: { enabled: true, showDropSelector: "afterDrop" },
verticalTabs: false,
inlayHints: DEFAULT_INLAY_HINTS,
codeLens: DEFAULT_CODE_LENS,
semanticHighlighting: DEFAULT_SEMANTIC_HIGHLIGHTING,
};
const DEFAULT_BREADCRUMBS: BreadcrumbsSettings = {
enabled: true,
filePath: "on",
symbolPath: "on",
icons: true,
};
const DEFAULT_THEME: ThemeSettings = {
theme: "dark",
iconTheme: "default",
accentColor: "#6366f1",
uiFontFamily: "Inter, system-ui, sans-serif",
uiFontSize: 13,
zoomLevel: 1.0,
sidebarPosition: "left",
activityBarVisible: true,
activityBarPosition: "top",
statusBarVisible: true,
tabBarVisible: true,
breadcrumbsEnabled: true,
breadcrumbs: DEFAULT_BREADCRUMBS,
wrapTabs: false,
menuBarVisibility: "classic",
panelPosition: "bottom",
panelAlignment: "center",
commandCenterEnabled: true,
titleBarStyle: "custom",
auxiliaryBarVisible: false,
};
const DEFAULT_TERMINAL: TerminalSettings = {
shellPath: "",
shellArgs: [],
fontFamily: "JetBrains Mono, Fira Code, Consolas, monospace",
fontSize: 14,
lineHeight: 1.2,
cursorStyle: "block",
cursorBlink: true,
scrollback: 10000,
copyOnSelection: false,
env: {},
cwd: "",
integratedGpu: true,
colorScheme: "default-dark",
wordSeparators: " ()[]{}',\"`─",
bell: "none",
accessibleViewEnabled: false,
screenReaderAnnounce: true,
decorations: {
enabled: true,
showDuration: true,
showExitCode: true,
},
images: {
enabled: true,
maxImageSize: 10 * 1024 * 1024, // 10MB per image
maxTotalMemory: 100 * 1024 * 1024, // 100MB total
maxImages: 50,
imageScaling: "auto",
enableITerm2: true,
enableSixel: true,
enableKitty: true,
},
autoReply: {
enabled: false, // Disabled by default for safety
showNotification: true,
defaultDelay: 100,
},
};
const DEFAULT_AI: AISettings = {
supermavenEnabled: false,
supermavenApiKey: "",
copilotEnabled: false,
inlineSuggestEnabled: true,
inlineSuggestShowToolbar: true,
defaultProvider: "anthropic",
defaultModel: "claude-sonnet-4-20250514",
};
const DEFAULT_SECURITY: SecuritySettings = {
sandboxMode: "workspace_write",
approvalMode: "auto",
networkAccess: true,
trustedWorkspaces: [],
telemetryEnabled: false,
crashReportsEnabled: false,
};
const DEFAULT_SEARCH: SearchSettings = {
exclude: {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
},
useIgnoreFiles: true,
useGlobalIgnoreFiles: true,
followSymlinks: true,
contextLines: 2,
showLineNumbers: true,
};
const DEFAULT_VARIABLE_VISUALIZERS: VariableVisualizerSettings = {
enabled: true,
hexBytesPerRow: 16,
arrayPageSize: 50,
};
const DEFAULT_DEBUG: DebugSettings = {
toolbarLocation: "floating",
javascript: { autoAttachFilter: "disabled" },
openDebugOnSessionStart: true,
closeReadonlyTabsOnEnd: false,
focusWindowOnBreak: true,
focusEditorOnBreak: true,
showInlineBreakpointCandidates: true,
variableVisualizers: DEFAULT_VARIABLE_VISUALIZERS,
};
const DEFAULT_GIT: GitSettings = {
enabled: true,
autofetch: true,
autofetchPeriod: 180,
confirmSync: true,
enableSmartCommit: true,
pruneOnFetch: false,
fetchTags: true,
followTagsWhenSync: false,
postCommitCommand: "none",
defaultCloneDirectory: "",
branchSortOrder: "committerDate",
rebaseWhenSync: false,
};
const DEFAULT_HTTP: HttpSettings = {
proxy: "",
proxyStrictSSL: true,
proxyAuthorization: null,
proxySupport: "off",
};
const DEFAULT_FILES: FilesSettings = {
autoSave: "off",
autoSaveDelay: 1000,
hotExit: "onExit",
defaultLanguage: "",
trimTrailingWhitespace: false,
insertFinalNewline: false,
trimFinalNewlines: false,
exclude: {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true,
},
watchExclude: {
"**/.git/objects/**": true,
"**/node_modules/**": true,
},
encoding: "utf8",
eol: "auto",
confirmDragAndDrop: true,
confirmDelete: true,
enableTrash: true,
maxMemoryForLargeFilesMB: 4096,
associations: {},
};
const DEFAULT_FILE_NESTING: FileNestingPatterns = {
"*.ts": "${basename}.js, ${basename}.d.ts",
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml",
"tsconfig.json": "tsconfig.*.json",
};
const DEFAULT_EXPLORER: ExplorerSettings = {
compactFolders: true,
fileNesting: { enabled: true, patterns: DEFAULT_FILE_NESTING },
indentGuidesEnabled: true,
sortOrder: "default",
};
const DEFAULT_ZEN_MODE: ZenModeSettings = {
hideSidebar: true,
hideStatusBar: true,
hideMenuBar: true,
hidePanel: true,
centerLayout: true,
maxWidth: "900px",
fullScreen: false,
showLineNumbers: true,
silenceNotifications: true,
// New settings
hideLineNumbers: false,
hideTabs: false,
hideActivityBar: true,
restore: true,
};
const DEFAULT_CENTERED_LAYOUT: CenteredLayoutSettings = {
enabled: false,
maxWidth: 1200,
autoResize: true,
sideMarginRatio: 0.15,
};
const DEFAULT_SCREENCAST_MODE: ScreencastModeSettings = {
enabled: false,
showKeys: true,
showMouse: true,
showCommands: true,
fontSize: 24,
duration: 2000,
};
export const DEFAULT_COMMAND_PALETTE: CommandPaletteSettings = {
historyLength: 50,
preserveInput: false,
};
export const DEFAULT_WORKBENCH_EDITOR: WorkbenchEditorSettings = {
tabSizing: "fit",
tabSizingFixedMinWidth: 80,
tabSizingFixedWidth: 120,
wrapTabs: false,
showTabCloseButton: "onHover",
tabCloseButtonPosition: "right",
centeredLayout: DEFAULT_CENTERED_LAYOUT,
};
export const DEFAULT_WORKBENCH: WorkbenchSettings = {
editor: DEFAULT_WORKBENCH_EDITOR,
};
export const DEFAULT_SETTINGS: CortexSettings = {
version: 1,
editor: DEFAULT_EDITOR,
theme: DEFAULT_THEME,
terminal: DEFAULT_TERMINAL,
ai: DEFAULT_AI,
security: DEFAULT_SECURITY,
files: DEFAULT_FILES,
explorer: DEFAULT_EXPLORER,
zenMode: DEFAULT_ZEN_MODE,
screencastMode: DEFAULT_SCREENCAST_MODE,
extensions: {},
vimEnabled: false,
languageOverrides: {},
debug: DEFAULT_DEBUG,
search: DEFAULT_SEARCH,
git: DEFAULT_GIT,
http: DEFAULT_HTTP,
commandPalette: DEFAULT_COMMAND_PALETTE,
workbench: DEFAULT_WORKBENCH,
};
// ============================================================================
// Workspace Types
// ============================================================================
export type PartialCortexSettings = {
[K in keyof CortexSettings]?: K extends "extensions" | "languageOverrides"
? CortexSettings[K]
: Partial<CortexSettings[K]>;
};
export type SettingSource = "user" | "workspace" | "folder" | "default";
export type SettingsScope = "user" | "workspace" | "folder";
export interface SettingsState {
settings: CortexSettings;
loading: boolean;
saving: boolean;
error: string | null;
settingsPath: string;
isDirty: boolean;
lastSaved: number | null;
}
export interface WorkspaceSettingsState {
userSettings: CortexSettings;
workspaceSettings: PartialCortexSettings;
folderSettings: Record<string, PartialCortexSettings>;
workspacePath: string | null;
workspaceSettingsPath: string | null;
userSettingsPath: string;
loading: boolean;
savingUser: boolean;
savingWorkspace: boolean;
savingFolder: boolean;
error: string | null;
lastSaved: number | null;
}
// ============================================================================
// Context Interface
// ============================================================================
export interface SettingsContextValue {
state: SettingsState;
settings: Accessor<CortexSettings>;
userSettings: Accessor<CortexSettings>;
workspaceSettings: Accessor<PartialCortexSettings>;
effectiveSettings: Accessor<CortexSettings>;
workspacePath: Accessor<string | null>;
hasWorkspace: Accessor<boolean>;
folderSettings: Accessor<Record<string, PartialCortexSettings>>;
loadSettings: () => Promise<void>;
saveSettings: () => Promise<void>;
updateSettings: <K extends keyof CortexSettings>(section: K, value: CortexSettings[K]) => Promise<void>;
updateEditorSetting: <K extends keyof EditorSettings>(key: K, value: EditorSettings[K]) => Promise<void>;
updateInlayHintsSetting: <K extends keyof InlayHintsSettings>(key: K, value: InlayHintsSettings[K]) => Promise<void>;
updateCodeLensSetting: <K extends keyof CodeLensSettings>(key: K, value: CodeLensSettings[K]) => Promise<void>;
updateThemeSetting: <K extends keyof ThemeSettings>(key: K, value: ThemeSettings[K]) => Promise<void>;
updateTerminalSetting: <K extends keyof TerminalSettings>(key: K, value: TerminalSettings[K]) => Promise<void>;
updateAISetting: <K extends keyof AISettings>(key: K, value: AISettings[K]) => Promise<void>;
updateSecuritySetting: <K extends keyof SecuritySettings>(key: K, value: SecuritySettings[K]) => Promise<void>;
updateFilesSetting: <K extends keyof FilesSettings>(key: K, value: FilesSettings[K]) => Promise<void>;
updateExplorerSetting: <K extends keyof ExplorerSettings>(key: K, value: ExplorerSettings[K]) => Promise<void>;
updateZenModeSetting: <K extends keyof ZenModeSettings>(key: K, value: ZenModeSettings[K]) => Promise<void>;
updateScreencastModeSetting: <K extends keyof ScreencastModeSettings>(key: K, value: ScreencastModeSettings[K]) => Promise<void>;
updateSearchSetting: <K extends keyof SearchSettings>(key: K, value: SearchSettings[K]) => Promise<void>;
updateDebugSetting: <K extends keyof DebugSettings>(key: K, value: DebugSettings[K]) => Promise<void>;
updateGitSetting: <K extends keyof GitSettings>(key: K, value: GitSettings[K]) => Promise<void>;
updateHttpSetting: <K extends keyof HttpSettings>(key: K, value: HttpSettings[K]) => Promise<void>;