@kabmo-labs/kabmo 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +319 -319
  3. package/dist/client/static/js/{index-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
  4. package/dist/client/static/js/index-tsgy3gd1.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
  7. package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
  8. package/src/client/components/common/code-surface/extensions.ts +7 -1
  9. package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
  10. package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
  11. package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
  12. package/src/client/components/common/session-row/index.tsx +205 -0
  13. package/src/client/components/common/session-row/session-row.test.tsx +144 -0
  14. package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
  15. package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
  16. package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
  17. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
  18. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
  19. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
  20. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +55 -0
  21. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -0
  22. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
  23. package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
  24. package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
  25. package/src/client/components/mobile/SessionSidebar.tsx +137 -146
  26. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
  27. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
  28. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
  29. package/src/client/components/settings/Modal.tsx +5 -27
  30. package/src/client/components/settings/Sidebar.tsx +1 -1
  31. package/src/client/components/settings/apply-side-effects.test.ts +102 -0
  32. package/src/client/components/settings/apply-side-effects.ts +90 -0
  33. package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
  34. package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
  35. package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
  36. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
  37. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
  38. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
  39. package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
  40. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
  41. package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
  42. package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
  43. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
  44. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
  45. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
  46. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -5
  47. package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
  48. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
  49. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +108 -67
  50. package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
  51. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
  52. package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
  53. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +158 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
  55. package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
  56. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
  58. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
  59. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
  60. package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
  61. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
  62. package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
  63. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
  64. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
  65. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
  66. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
  67. package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
  68. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
  69. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
  70. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
  71. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
  73. package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
  80. package/src/client/components/workspace/diff-panel/folding.ts +6 -1
  81. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
  82. package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
  83. package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
  84. package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
  85. package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
  86. package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
  87. package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
  88. package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
  89. package/src/client/data/settings/omp-schema.json +151 -6
  90. package/src/client/hooks/chat/composer/style.ts +66 -0
  91. package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
  92. package/src/client/hooks/settings/providers/login.ts +11 -2
  93. package/src/client/hooks/ui/window-event.ts +20 -4
  94. package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
  95. package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
  96. package/src/client/hooks/workspace/batch-archive.ts +78 -0
  97. package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
  98. package/src/client/hooks/workspace/sidebar-style.ts +66 -0
  99. package/src/client/tailwind.css +111 -0
  100. package/src/server/index.ts +10 -134
  101. package/src/server/lib/lifecycle/after-listen.ts +178 -0
  102. package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
  103. package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
  104. package/src/server/lib/lifecycle/tls.test.ts +7 -7
  105. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
  106. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
  107. package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
  108. package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
  109. package/src/server/lib/plugins/background.server.ts +17 -1
  110. package/src/server/lib/plugins/background.test.ts +33 -0
  111. package/src/server/routes/sessions/batch-archive.test.ts +113 -0
  112. package/src/server/routes/sessions/batch-archive.ts +80 -0
  113. package/src/server/routes/sessions/index.ts +4 -0
  114. package/src/shared/lib/chat/composer/style.test.ts +126 -0
  115. package/src/shared/lib/chat/composer/style.ts +171 -0
  116. package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
  117. package/src/shared/lib/chat/composer/tui-only.ts +5 -0
  118. package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
  119. package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
  120. package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
  121. package/src/shared/lib/chat/timeline/trace-groups.test.ts +120 -0
  122. package/src/shared/lib/chat/timeline/trace-groups.ts +68 -0
  123. package/src/shared/lib/settings/defaults.ts +6 -0
  124. package/src/shared/lib/workspace/session-focus.test.ts +93 -0
  125. package/src/shared/lib/workspace/session-focus.ts +71 -0
  126. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
  127. package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
  128. package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
  129. package/src/shared/lib/workspace/sidebar-style.ts +86 -0
  130. package/src/shared/types/omp/agent.ts +6 -0
  131. package/src/shared/types/settings/state.ts +31 -0
  132. package/dist/client/static/js/index-68w8h33q.css +0 -1
  133. package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
@@ -7,10 +7,7 @@ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
7
7
  import { useKabmoSettingsWriter } from '@/client/hooks/settings/use-kabmo-setting';
8
8
  import { useReloadOmpEngine } from '@/client/hooks/settings/reload-engine';
9
9
  import { useRestartKabmo } from '@/client/hooks/settings/restart-kabmo';
10
- import { applyDocumentTheme } from '@/client/hooks/ui/theme';
11
- import { applyChatWidthMode } from '@/client/hooks/chat/timeline/width-mode';
12
- import { EDITOR_FONT_CHANGED_EVENT } from '@/client/hooks/editor/font';
13
- import { EDITOR_THEME_CHANGED_EVENT } from '@/client/hooks/editor/theme';
10
+ import { applySettingsSideEffects } from '@/client/components/settings/apply-side-effects';
14
11
  import { useKabmoEvent } from '@/client/hooks/ui/window-event';
15
12
  import { SETTINGS_CATEGORIES, SettingsSidebar } from '@/client/components/settings/Sidebar';
16
13
  import { AppearanceSettings } from '@/client/components/settings/categories/AppearanceSettings';
@@ -96,28 +93,9 @@ export function SettingsModal({
96
93
  const handleUpdateSettings = (updater: Partial<SettingsState> | ((prev: SettingsState) => SettingsState)) => {
97
94
  setSettings(prev => {
98
95
  const next = typeof updater === 'function' ? updater(prev) : { ...prev, ...updater };
99
- if (typeof document !== 'undefined' && next.theme) {
100
- applyDocumentTheme(next.theme);
101
- }
102
- // The editor font is visual, so an open editor has to hear about the
103
- // change now — `appSettings` is a boot-time prop and would only show it
104
- // after a reload. Announced only when the value actually moved, so a
105
- // re-render of an unrelated setting does not churn every editor's stack.
106
- if (typeof window !== 'undefined' && next.editorFont !== prev.editorFont) {
107
- window.dispatchEvent(new CustomEvent(EDITOR_FONT_CHANGED_EVENT, { detail: next.editorFont }));
108
- }
109
- // Same rule for the editor's colour theme: it is visual, and every open
110
- // editor subscribes rather than reading the boot-time `appSettings`.
111
- if (typeof window !== 'undefined' && next.editorTheme !== prev.editorTheme) {
112
- window.dispatchEvent(new CustomEvent(EDITOR_THEME_CHANGED_EVENT, { detail: next.editorTheme }));
113
- }
114
- // The chat column's width is an attribute on `<html>` that CSS reads, so
115
- // it applies the moment the choice is made — `appSettings` is a boot-time
116
- // prop and would only show it after a reload. Announced only when the
117
- // value actually moved.
118
- if (next.chatWidthMode !== prev.chatWidthMode) {
119
- applyChatWidthMode(next.chatWidthMode);
120
- }
96
+ // Every visual consequence of this edit, applied now: the open surfaces
97
+ // subscribe rather than re-reading the boot-time `appSettings` prop.
98
+ applySettingsSideEffects(prev, next);
121
99
  // Only the keys this update actually touched are persisted. The modal
122
100
  // holds a full `SettingsState` snapshot taken when it opened, so writing
123
101
  // the whole object back would also republish every value it read at that
@@ -276,7 +254,7 @@ export function SettingsModal({
276
254
 
277
255
  {/* Scrollable Settings Body - Full Width across all categories */}
278
256
  <div
279
- className={`flex-1 scrollbar-overlay-container w-full ${['projects', 'providers', 'agents', 'behavior', 'commands', 'mcp', 'plugins', 'skills', 'skills-catalog', 'usage', 'panel-plugins'].includes(activeCategory) ? 'p-0 flex flex-col' : 'p-6 md:p-8 flex flex-col'}`}
257
+ className={`flex-1 scrollbar-overlay-container w-full ${['projects', 'providers', 'agents', 'behavior', 'commands', 'mcp', 'plugins', 'skills', 'skills-catalog', 'usage', 'panel-plugins', 'chats'].includes(activeCategory) ? 'p-0 flex flex-col' : 'p-6 md:p-8 flex flex-col'}`}
280
258
  style={{ paddingBottom: 'env(safe-area-inset-bottom, 0px)' }}
281
259
  >
282
260
  <div className="w-full h-full flex-1 flex flex-col">
@@ -14,7 +14,7 @@ export interface CategoryDef {
14
14
  export const SETTINGS_CATEGORIES: CategoryDef[] = [
15
15
  // KABMO
16
16
  { id: 'appearance', label: 'Appearance', icon: Palette, section: 'KABMO', description: 'Custom themes, typography scale, and layout density.' },
17
- { id: 'chats', label: 'Chats', icon: MessageSquare, section: 'KABMO', description: 'Chat width, message streaming, thinking blocks, and tool view modes.' },
17
+ { id: 'chats', label: 'Chats', icon: MessageSquare, section: 'KABMO', description: 'Chat width, composer style, tool call rendering, session titles, goal mode, and keybindings.' },
18
18
  { id: 'notifications', label: 'Notifications', icon: Bell, section: 'KABMO', description: 'Build failure alerts, sounds, and system popups.' },
19
19
  { id: 'usage', label: 'Usage', icon: BarChart3, section: 'KABMO', description: 'Build minutes quota, storage, and general usage.' },
20
20
  { id: 'token-usage', label: 'Token Usage', icon: Coins, section: 'KABMO', description: 'Token telemetry, cache, and cost breakdown.' },
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `applySettingsSideEffects`: announce what MOVED, and nothing else.
8
+ *
9
+ * The modal used to inline this chain, and two properties of it are invisible
10
+ * until broken:
11
+ *
12
+ * - **an unrelated edit announces nothing** — a re-render caused by, say, the
13
+ * goal model must not churn every editor's font stack or every timeline's
14
+ * renderer;
15
+ * - **the sidebar style is announced**, because the sidebar is visible BEHIND
16
+ * the settings modal — it is the one setting whose effect the user watches
17
+ * happen, and a missing announcement means the column keeps the old chrome
18
+ * until a reload.
19
+ */
20
+
21
+ import { afterEach, describe, expect, test } from 'bun:test';
22
+ import { Window } from 'happy-dom';
23
+ import { applySettingsSideEffects } from '@/client/components/settings/apply-side-effects';
24
+ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
25
+ import { SIDEBAR_STYLE_CHANGED_EVENT } from '@/client/hooks/workspace/sidebar-style';
26
+ import { EDITOR_FONT_CHANGED_EVENT } from '@/client/hooks/editor/font';
27
+ import type { SettingsState } from '@/shared/types';
28
+
29
+ const originalWindow = globalThis.window;
30
+ const originalDocument = globalThis.document;
31
+ const originalCustomEvent = globalThis.CustomEvent;
32
+
33
+ /**
34
+ * The side effects construct `CustomEvent`s, and happy-dom's `dispatchEvent`
35
+ * rejects an event from another realm — so the DOM installed here brings its
36
+ * own `CustomEvent` with it rather than reusing the runner's.
37
+ */
38
+ function installDom() {
39
+ const win = new Window({ url: 'http://localhost' });
40
+ const target = globalThis as unknown as Record<string, unknown>;
41
+ target.window = win;
42
+ target.document = win.document;
43
+ target.CustomEvent = (win as unknown as Record<string, unknown>).CustomEvent;
44
+ return win;
45
+ }
46
+
47
+ afterEach(() => {
48
+ const target = globalThis as unknown as Record<string, unknown>;
49
+ target.window = originalWindow;
50
+ target.document = originalDocument;
51
+ target.CustomEvent = originalCustomEvent;
52
+ });
53
+
54
+ function state(overrides: Partial<SettingsState> = {}): SettingsState {
55
+ return { ...DEFAULT_SETTINGS, ...overrides };
56
+ }
57
+
58
+ describe('applySettingsSideEffects', () => {
59
+ test('announces the sidebar style so the column behind the modal redraws', () => {
60
+ const win = installDom();
61
+ const seen: unknown[] = [];
62
+ win.addEventListener(SIDEBAR_STYLE_CHANGED_EVENT, (event) => seen.push((event as unknown as CustomEvent).detail));
63
+
64
+ applySettingsSideEffects(state(), state({ sidebarStyle: 'modern' }));
65
+
66
+ expect(seen).toEqual(['modern']);
67
+ });
68
+
69
+ test('does not announce a style that did not move', () => {
70
+ const win = installDom();
71
+ const seen: unknown[] = [];
72
+ win.addEventListener(SIDEBAR_STYLE_CHANGED_EVENT, (event) => seen.push((event as unknown as CustomEvent).detail));
73
+
74
+ applySettingsSideEffects(state({ sidebarStyle: 'modern' }), state({ sidebarStyle: 'modern' }));
75
+
76
+ expect(seen).toEqual([]);
77
+ });
78
+
79
+ test('an unrelated edit announces nothing at all', () => {
80
+ const win = installDom();
81
+ const events: string[] = [];
82
+ for (const name of [SIDEBAR_STYLE_CHANGED_EVENT, EDITOR_FONT_CHANGED_EVENT]) {
83
+ win.addEventListener(name, () => events.push(name));
84
+ }
85
+
86
+ applySettingsSideEffects(state(), state({ goalDefaultBudget: 5000 }));
87
+
88
+ expect(events).toEqual([]);
89
+ });
90
+
91
+ test('the editor font still announces when it moves', () => {
92
+ const win = installDom();
93
+ const seen: unknown[] = [];
94
+ win.addEventListener(EDITOR_FONT_CHANGED_EVENT, (event) => seen.push((event as unknown as CustomEvent).detail));
95
+
96
+ // Any family that is not the shipped default, or the value has not moved
97
+ // and nothing is announced.
98
+ applySettingsSideEffects(state(), state({ editorFont: 'JetBrains Mono' }));
99
+
100
+ expect(seen).toEqual(['JetBrains Mono']);
101
+ });
102
+ });
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The visual side-effects of a settings edit, applied the moment the value
8
+ * moves.
9
+ *
10
+ * Every one of these settings changes something ALREADY ON SCREEN, and
11
+ * `appSettings` is a boot-time prop the open surfaces only see again after a
12
+ * reload — so the modal has to announce the change, and each consumer
13
+ * subscribes (`useSidebarStyle`, `useToolRenderMode`, `useEditorFont`, …).
14
+ *
15
+ * It lives here rather than inside the modal for two reasons: the modal sits at
16
+ * the repo's 350-line ceiling, and this is a table of "value moved → announce",
17
+ * which has nothing to do with the modal's own job (reading a category,
18
+ * dispatching a write). Adding the sidebar style to a chain of `if`s in the
19
+ * component pushed it over.
20
+ *
21
+ * Two rules, both load-bearing:
22
+ *
23
+ * - **Announce only what moved.** A re-render from an unrelated setting must
24
+ * not churn every editor's font stack or every timeline's renderer.
25
+ * - **The theme is not an announcement.** It is written to `<html>` through
26
+ * `applyDocumentTheme`, the one writer, because consumers that cannot read
27
+ * CSS (the mermaid hydrator) learn about a palette from its event.
28
+ */
29
+
30
+ import type { SettingsState } from '@/shared/types';
31
+ import { applyDocumentTheme } from '@/client/hooks/ui/theme';
32
+ import { applyChatWidthMode } from '@/client/hooks/chat/timeline/width-mode';
33
+ import { applyToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
34
+ import { applySidebarStyle } from '@/client/hooks/workspace/sidebar-style';
35
+ import { applyComposerStyle } from '@/client/hooks/chat/composer/style';
36
+ import { EDITOR_FONT_CHANGED_EVENT } from '@/client/hooks/editor/font';
37
+ import { EDITOR_THEME_CHANGED_EVENT } from '@/client/hooks/editor/theme';
38
+
39
+ /**
40
+ * Apply `next` on top of `previous`.
41
+ *
42
+ * `previous` is the snapshot the modal held before the edit, so a caller that
43
+ * passes the same object twice announces nothing — which is what makes an
44
+ * unrelated toggle free.
45
+ */
46
+ export function applySettingsSideEffects(previous: SettingsState, next: SettingsState): void {
47
+ if (typeof document !== 'undefined' && next.theme) {
48
+ applyDocumentTheme(next.theme);
49
+ }
50
+
51
+ // The editor font is visual, so an open editor has to hear about the change
52
+ // now. Announced only when the value actually moved, so a re-render of an
53
+ // unrelated setting does not churn every editor's stack.
54
+ if (typeof window !== 'undefined' && next.editorFont !== previous.editorFont) {
55
+ window.dispatchEvent(new CustomEvent(EDITOR_FONT_CHANGED_EVENT, { detail: next.editorFont }));
56
+ }
57
+
58
+ // Same rule for the editor's colour theme: it is visual, and every open
59
+ // editor subscribes rather than reading the boot-time `appSettings`.
60
+ if (typeof window !== 'undefined' && next.editorTheme !== previous.editorTheme) {
61
+ window.dispatchEvent(new CustomEvent(EDITOR_THEME_CHANGED_EVENT, { detail: next.editorTheme }));
62
+ }
63
+
64
+ // The chat column's width is an attribute on `<html>` that CSS reads, so it
65
+ // applies the moment the choice is made.
66
+ if (next.chatWidthMode !== previous.chatWidthMode) {
67
+ applyChatWidthMode(next.chatWidthMode);
68
+ }
69
+
70
+ // The tool-render style picks a Preact renderer, so the open timeline has to
71
+ // hear about the change now.
72
+ if (next.toolRenderStyle !== previous.toolRenderStyle) {
73
+ applyToolRenderMode(next.toolRenderStyle);
74
+ }
75
+
76
+ // The sidebar style picks a Preact tree for the whole left column, and the
77
+ // sidebar is visible BEHIND this modal — so this is the one setting whose
78
+ // effect the user watches happen.
79
+ if (next.sidebarStyle !== previous.sidebarStyle) {
80
+ applySidebarStyle(next.sidebarStyle);
81
+ }
82
+
83
+ // The composer style reorders the card's rows. The composer is NOT visible
84
+ // behind the settings modal, so this only has to keep the next render
85
+ // honest — but it is announced the same way, because the timeline is a
86
+ // separate subtree that never re-reads `appSettings`.
87
+ if (next.composerStyle !== previous.composerStyle) {
88
+ applyComposerStyle(next.composerStyle);
89
+ }
90
+ }
@@ -1,7 +1,8 @@
1
- import { Palette } from 'lucide-preact';
1
+ import { Palette, PanelLeft } from 'lucide-preact';
2
2
  import type { SettingsState } from '@/shared/types';
3
3
  import { resolveThemeId } from '@/shared/lib/theme/catalog';
4
4
  import { ThemeGrid } from '@/client/components/settings/categories/appearance-settings/ThemeGrid';
5
+ import { SidebarStyleSection } from '@/client/components/settings/categories/appearance-settings/SidebarStyleSection';
5
6
  import { EditorFontSection } from '@/client/components/settings/categories/appearance-settings/EditorFontSection';
6
7
  import { EditorThemeSection } from '@/client/components/settings/categories/appearance-settings/EditorThemeSection';
7
8
  import { EditorIndentSection } from '@/client/components/settings/categories/appearance-settings/EditorIndentSection';
@@ -28,6 +29,15 @@ export function AppearanceSettings({ settings, onUpdate }: AppearanceSettingsPro
28
29
  />
29
30
  </section>
30
31
 
32
+ <section className="space-y-4">
33
+ <div className="flex items-center space-x-2 border-b border-ink/10 pb-2">
34
+ <PanelLeft size={16} className="text-ink/60" />
35
+ <h3 className="font-semibold text-sm uppercase tracking-wider text-ink/80">Layout</h3>
36
+ </div>
37
+
38
+ <SidebarStyleSection settings={settings} onUpdate={onUpdate} />
39
+ </section>
40
+
31
41
  <EditorFontSection settings={settings} onUpdate={onUpdate} />
32
42
 
33
43
  <EditorThemeSection settings={settings} onUpdate={onUpdate} />
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Chats is two panes, and a phone is two screens.
8
+ *
9
+ * Three facts are pinned here, each one a way the category can look right on a
10
+ * desktop and be unusable on a phone:
11
+ *
12
+ * - the sidebar lists every group and opens on the first one, so the category
13
+ * never lands on an empty detail;
14
+ * - choosing a group swaps the detail pane and writes NO setting — a row is
15
+ * navigation, not an edit;
16
+ * - on a phone the list yields to the chosen group, and the back bar returns to
17
+ * it. The panes are hidden by class (`hidden md:flex`), so the classes are
18
+ * what is asserted; if `ChatSettings` ever selects a group without calling
19
+ * `openDetail`, the phone stays on the list and this fails.
20
+ */
21
+
22
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
23
+ import { Window } from 'happy-dom';
24
+ import { h, render } from 'preact';
25
+ import { act } from 'preact/test-utils';
26
+ import { ChatSettings } from '@/client/components/settings/categories/ChatSettings';
27
+ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
28
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
29
+
30
+ let container: HTMLElement;
31
+ let updates = 0;
32
+
33
+ function mount(): void {
34
+ act(() => {
35
+ render(
36
+ h(ChatSettings, {
37
+ settings: DEFAULT_SETTINGS,
38
+ onUpdate: () => {
39
+ updates += 1;
40
+ },
41
+ }),
42
+ container,
43
+ );
44
+ });
45
+ }
46
+
47
+ /** The sidebar row whose label is exactly `label`. */
48
+ function groupRow(label: string): HTMLButtonElement {
49
+ const row = [...container.querySelectorAll('button')].find(
50
+ (button) => button.querySelector('span.font-semibold')?.textContent === label,
51
+ );
52
+ if (!row) throw new Error(`no group row labelled ${label}`);
53
+ return row as HTMLButtonElement;
54
+ }
55
+
56
+ /** The section headings the detail pane currently draws, in order. */
57
+ function headings(): string[] {
58
+ return [...container.querySelectorAll('h4')].map((heading) => heading.textContent ?? '');
59
+ }
60
+
61
+ /** The master/detail shell's two pane wrappers. */
62
+ function panes(): { list: HTMLElement; detail: HTMLElement } {
63
+ const root = container.firstElementChild as HTMLElement;
64
+ return { list: root.children[0] as HTMLElement, detail: root.children[1] as HTMLElement };
65
+ }
66
+
67
+ beforeEach(() => {
68
+ installDomGlobals(new Window());
69
+ container = document.createElement('div');
70
+ document.body.appendChild(container);
71
+ updates = 0;
72
+ });
73
+
74
+ afterEach(() => {
75
+ render(null, container);
76
+ container.remove();
77
+ restoreDomGlobals();
78
+ });
79
+
80
+ describe('ChatSettings master/detail', () => {
81
+ test('lists every group and opens on the first one', () => {
82
+ mount();
83
+
84
+ for (const label of ['Layout', 'Transcript', 'Sessions', 'Keyboard']) {
85
+ expect(groupRow(label)).toBeTruthy();
86
+ }
87
+
88
+ expect(groupRow('Layout').getAttribute('aria-current')).toBe('true');
89
+ expect(headings()).toEqual(['Chat Width', 'Composer']);
90
+ });
91
+
92
+ test('choosing a group swaps the detail and writes no setting', () => {
93
+ mount();
94
+
95
+ act(() => groupRow('Transcript').click());
96
+
97
+ expect(headings()).toEqual(['Tool Calls', 'Follow-up Dispatch']);
98
+ expect(groupRow('Transcript').getAttribute('aria-current')).toBe('true');
99
+ expect(updates).toBe(0);
100
+ });
101
+
102
+ test('on a phone the chosen group replaces the list, and the back bar returns to it', () => {
103
+ mount();
104
+ const { list, detail } = panes();
105
+
106
+ expect(list.className).not.toContain('hidden');
107
+ expect(detail.className).toContain('hidden');
108
+
109
+ act(() => groupRow('Keyboard').click());
110
+
111
+ expect(list.className).toContain('hidden');
112
+ expect(detail.className).not.toContain('hidden');
113
+
114
+ const back = container.querySelector('button[aria-label="Back to Chat settings"]');
115
+ expect(back).not.toBeNull();
116
+ act(() => (back as HTMLButtonElement).click());
117
+
118
+ expect(list.className).not.toContain('hidden');
119
+ expect(detail.className).toContain('hidden');
120
+ });
121
+ });
@@ -1,32 +1,97 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Chats.
8
+ *
9
+ * Seven sections, four groups: the sidebar in `groups.ts` decides what a reader
10
+ * sees first, and this file is the only place that maps a section id to the
11
+ * component drawing it. The `Record<ChatSectionId, …>` is deliberate — a new
12
+ * section id fails to compile until it has a renderer, and `groups.test.ts`
13
+ * fails until a group owns it, so neither half can drift.
14
+ *
15
+ * The two panes come from `SettingsMasterDetail`, the same shell Usage,
16
+ * Providers, Projects and the other list categories use: both panes are mounted
17
+ * at every width, and below `md` the phone shows the list, then the group, with
18
+ * a back bar — so a half-scrolled group and the selected row both survive the
19
+ * drill.
20
+ */
21
+
22
+ import type { ComponentChildren } from 'preact';
23
+ import { useState } from 'preact/hooks';
1
24
  import type { SettingsState } from '@/shared/types';
25
+ import { useSettingsMasterDetail } from '@/client/hooks/settings/master-detail';
26
+ import { SettingsMasterDetail } from '@/client/components/settings/master-detail';
27
+ import { ChatSettingsSidebar } from '@/client/components/settings/categories/chat-settings/SidebarList';
28
+ import {
29
+ CHAT_SETTING_GROUPS,
30
+ type ChatSectionId,
31
+ type ChatSettingGroupId,
32
+ } from '@/client/components/settings/categories/chat-settings/groups';
2
33
  import { ChatLayoutSection } from '@/client/components/settings/categories/chat-settings/LayoutSection';
34
+ import { ComposerStyleSection } from '@/client/components/settings/categories/chat-settings/ComposerStyleSection';
35
+ import { ChatToolRenderSection } from '@/client/components/settings/categories/chat-settings/ToolRenderSection';
3
36
  import { ChatFollowUpSection } from '@/client/components/settings/categories/chat-settings/FollowUpSection';
37
+ import { ChatTitleSection } from '@/client/components/settings/categories/chat-settings/TitleSection';
4
38
  import { ChatGoalSection } from '@/client/components/settings/categories/chat-settings/GoalSection';
5
39
  import { ChatKeybindingsSection } from '@/client/components/settings/categories/chat-settings/KeybindingsSection';
6
- import { ChatTitleSection } from '@/client/components/settings/categories/chat-settings/TitleSection';
7
40
 
8
41
  interface ChatSettingsProps {
9
42
  settings: SettingsState;
10
43
  onUpdate: (updater: Partial<SettingsState> | ((prev: SettingsState) => SettingsState)) => void;
11
44
  }
12
45
 
13
- export function ChatSettings({ settings, onUpdate }: ChatSettingsProps) {
14
- return (
15
- <div className="w-full space-y-7 text-xs text-ink pb-3">
16
- {/* 1. Chat Width (column width: compact / wide / full) */}
17
- <ChatLayoutSection settings={settings} onUpdate={onUpdate} />
46
+ type SectionProps = ChatSettingsProps;
47
+
48
+ /** Every section id, and the component that draws it. */
49
+ const SECTIONS: Record<ChatSectionId, (props: SectionProps) => ComponentChildren> = {
50
+ width: ChatLayoutSection,
51
+ composer: ComposerStyleSection,
52
+ 'tool-calls': ChatToolRenderSection,
53
+ 'follow-up': ChatFollowUpSection,
54
+ titles: ChatTitleSection,
55
+ goal: ChatGoalSection,
56
+ keybindings: ChatKeybindingsSection,
57
+ };
18
58
 
19
- {/* 2. Session Titles (automatic generation) */}
20
- <ChatTitleSection settings={settings} onUpdate={onUpdate} />
59
+ export function ChatSettings({ settings, onUpdate }: ChatSettingsProps) {
60
+ const masterDetail = useSettingsMasterDetail();
61
+ const [activeGroupId, setActiveGroupId] = useState<ChatSettingGroupId>(CHAT_SETTING_GROUPS[0].id);
21
62
 
22
- {/* 3. Follow-up Behavior (Interactive Selector Cards) */}
23
- <ChatFollowUpSection settings={settings} onUpdate={onUpdate} />
63
+ const group = CHAT_SETTING_GROUPS.find((entry) => entry.id === activeGroupId) ?? CHAT_SETTING_GROUPS[0];
24
64
 
25
- {/* 4. Goal Mode (auditor model + default budget) */}
26
- <ChatGoalSection settings={settings} onUpdate={onUpdate} />
65
+ return (
66
+ <SettingsMasterDetail
67
+ pane={masterDetail.pane}
68
+ onBack={masterDetail.back}
69
+ listLabel="Chat settings"
70
+ list={
71
+ <ChatSettingsSidebar
72
+ groups={CHAT_SETTING_GROUPS}
73
+ activeGroupId={group.id}
74
+ onSelectGroup={(id) => {
75
+ setActiveGroupId(id);
76
+ masterDetail.openDetail();
77
+ }}
78
+ />
79
+ }
80
+ detail={
81
+ <div className="flex-1 h-full overflow-hidden flex flex-col text-xs text-ink">
82
+ <div className="px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0">
83
+ <span className="text-xs font-semibold text-ink/75">{group.label}</span>
84
+ <p className="text-[11px] text-ink/60 leading-snug mt-0.5">{group.description}</p>
85
+ </div>
27
86
 
28
- {/* 5. Keyboard Shortcuts Configurator */}
29
- <ChatKeybindingsSection settings={settings} onUpdate={onUpdate} />
30
- </div>
87
+ <div className="flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6">
88
+ {group.sections.map((id) => {
89
+ const Section = SECTIONS[id];
90
+ return <Section key={id} settings={settings} onUpdate={onUpdate} />;
91
+ })}
92
+ </div>
93
+ </div>
94
+ }
95
+ />
31
96
  );
32
97
  }