@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
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Appearance → Session sidebar.
8
+ *
9
+ * Two cards, because there are exactly two answers — and the drawing in each is
10
+ * a MINIATURE of the real thing, not an icon: a user choosing a shell for a
11
+ * list they look at all day needs to see the row density and where the controls
12
+ * sit. The miniature is drawn from tokens only (`bg-ink/10`, `text-ink/40`), so
13
+ * it follows the palette like everything else.
14
+ *
15
+ * The cards are `aria-pressed` buttons rather than radios in a form: there is
16
+ * no submit, the choice applies on click, and the settings modal's own
17
+ * `onUpdate` is what persists it. `applySidebarStyle` is called by that path —
18
+ * this file never writes settings itself, so the live apply and the stored copy
19
+ * cannot disagree.
20
+ */
21
+
22
+ import type { ComponentType } from 'preact/compat';
23
+ import type { SettingsState } from '@/shared/types';
24
+ import {
25
+ SIDEBAR_STYLES,
26
+ SIDEBAR_STYLE_COPY,
27
+ resolveSidebarStyle,
28
+ type SidebarStyle,
29
+ } from '@/shared/lib/workspace/sidebar-style';
30
+
31
+ interface SidebarStyleSectionProps {
32
+ settings: SettingsState;
33
+ onUpdate: (updater: Partial<SettingsState> | ((previous: SettingsState) => SettingsState)) => void;
34
+ }
35
+
36
+ /** A row in the miniature: the leading slot, a title bar, optional trailing. */
37
+ function MiniRow({ width, active = false, trailing = false }: { width: number; active?: boolean; trailing?: boolean }) {
38
+ return (
39
+ <span className="flex h-[9px] items-center gap-1 px-1">
40
+ <span className={`h-[5px] w-[5px] shrink-0 rounded-full ${active ? 'bg-ink' : 'bg-ink/25'}`} />
41
+ <span
42
+ className={`h-[3px] rounded-full ${active ? 'bg-ink/70' : 'bg-ink/25'}`}
43
+ style={{ width: `${width}%` }}
44
+ />
45
+ {trailing && <span className="ml-auto h-[3px] w-[6px] rounded-full bg-ink/20" />}
46
+ </span>
47
+ );
48
+ }
49
+
50
+ /**
51
+ * The classic frame: a toolbar of boxed controls over compact rows.
52
+ */
53
+ function ClassicMiniature() {
54
+ return (
55
+ <span className="flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1" aria-hidden="true">
56
+ <span className="flex items-center gap-0.5">
57
+ <span className="h-[7px] w-[30%] rounded-sm bg-ink/80" />
58
+ <span className="h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper" />
59
+ <span className="h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper" />
60
+ <span className="ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper" />
61
+ <span className="h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper" />
62
+ </span>
63
+ <span className="flex h-[7px] items-center gap-1 px-1">
64
+ <span className="h-[3px] w-[45%] rounded-full bg-ink/45" />
65
+ </span>
66
+ <MiniRow width={62} trailing />
67
+ <MiniRow width={50} active trailing />
68
+ <MiniRow width={44} trailing />
69
+ <MiniRow width={56} trailing />
70
+ </span>
71
+ );
72
+ }
73
+
74
+ /**
75
+ * The modern frame: a permanent search line, filter chips, a workspace header
76
+ * and taller rows with one trailing column.
77
+ */
78
+ function ModernMiniature() {
79
+ return (
80
+ <span className="flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1" aria-hidden="true">
81
+ <span className="flex h-[7px] items-center rounded-sm bg-ink/5 px-1">
82
+ <span className="h-[3px] w-[38%] rounded-full bg-ink/30" />
83
+ </span>
84
+ <span className="flex items-center gap-0.5">
85
+ <span className="h-[6px] w-[16%] rounded-full bg-ink/80" />
86
+ <span className="h-[6px] w-[22%] rounded-full border border-ink/20" />
87
+ <span className="h-[6px] w-[12%] rounded-full border border-ink/20" />
88
+ </span>
89
+ <span className="flex h-[9px] items-center gap-1 px-1">
90
+ <span className="h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50" />
91
+ <span className="h-[3px] w-[40%] rounded-full bg-ink/45" />
92
+ <span className="ml-auto h-[3px] w-[5px] rounded-full bg-ink/20" />
93
+ </span>
94
+ <MiniRow width={62} active trailing />
95
+ <MiniRow width={50} trailing />
96
+ <MiniRow width={44} trailing />
97
+ </span>
98
+ );
99
+ }
100
+
101
+ const MINIATURES: Record<SidebarStyle, ComponentType> = {
102
+ classic: ClassicMiniature,
103
+ modern: ModernMiniature,
104
+ };
105
+
106
+ export function SidebarStyleSection({ settings, onUpdate }: SidebarStyleSectionProps) {
107
+ const selected = resolveSidebarStyle(settings.sidebarStyle);
108
+
109
+ return (
110
+ <section className="space-y-3">
111
+ <div>
112
+ <h4 className="text-xs font-semibold text-ink">Session sidebar</h4>
113
+ <p className="mt-0.5 text-[11px] text-ink/50">
114
+ How the left column draws its workspaces and chats. Both styles list the same
115
+ workspaces and offer the same actions; the choice applies to desktop and phone,
116
+ and takes effect immediately.
117
+ </p>
118
+ </div>
119
+
120
+ <div className="grid grid-cols-1 gap-2.5 sm:grid-cols-2" role="group" aria-label="Session sidebar style">
121
+ {SIDEBAR_STYLES.map((style) => {
122
+ const copy = SIDEBAR_STYLE_COPY[style];
123
+ const isSelected = style === selected;
124
+ const Miniature = MINIATURES[style];
125
+ return (
126
+ <button
127
+ key={style}
128
+ type="button"
129
+ onClick={() => onUpdate({ sidebarStyle: style })}
130
+ aria-pressed={isSelected}
131
+ aria-label={`${copy.label} sidebar — ${copy.description}`}
132
+ className={`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${
133
+ isSelected
134
+ ? 'border-ink/40 bg-ink/5'
135
+ : 'border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5'
136
+ }`}
137
+ >
138
+ <span className="block h-[86px]">
139
+ <Miniature />
140
+ </span>
141
+ <span className="flex items-center gap-1.5">
142
+ <span className="text-xs font-semibold text-ink">{copy.label}</span>
143
+ <span className="font-mono text-[10px] text-ink/40">{copy.caption}</span>
144
+ {isSelected && (
145
+ <span className="ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[9px] font-semibold text-paper">
146
+ active
147
+ </span>
148
+ )}
149
+ </span>
150
+ <span className="text-[11px] leading-relaxed text-ink/60">{copy.description}</span>
151
+ </button>
152
+ );
153
+ })}
154
+ </div>
155
+ </section>
156
+ );
157
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Chats → Composer.
8
+ *
9
+ * Four cards, because there are exactly four answers, and the drawing in each
10
+ * is a MINIATURE of the real card — same row order, same trailing controls —
11
+ * rather than an icon. A user choosing the shape of the thing they type into
12
+ * all day needs to see where the draft sits relative to the controls; a label
13
+ * alone cannot show that.
14
+ *
15
+ * The miniature is DRAWN FROM THE SAME TABLE the composer renders from
16
+ * (`composerStyleLayout().wire`), so a style whose order changes cannot leave
17
+ * its picture behind. Tokens only (`bg-ink/10`, `border-ink/15`), so it follows
18
+ * the palette like everything else.
19
+ *
20
+ * The cards are `aria-pressed` buttons rather than radios: there is no submit,
21
+ * the choice applies on click, and the modal's own `onUpdate` persists it and
22
+ * runs the side effects. This file never writes settings itself.
23
+ */
24
+
25
+ import type { SettingsState } from '@/shared/types';
26
+ import {
27
+ COMPOSER_STYLES,
28
+ COMPOSER_STYLE_COPY,
29
+ composerStyleLayout,
30
+ resolveComposerStyle,
31
+ type ComposerStyle,
32
+ } from '@/shared/lib/chat/composer/style';
33
+
34
+ interface ComposerStyleSectionProps {
35
+ settings: SettingsState;
36
+ onUpdate: (updater: Partial<SettingsState> | ((previous: SettingsState) => SettingsState)) => void;
37
+ }
38
+
39
+ /** One chip in the miniature: an attachment/file pill. */
40
+ function MiniChip({ active = false }: { active?: boolean }) {
41
+ return (
42
+ <span className={`h-[6px] w-[16px] rounded-sm border ${active ? 'border-ink/40 bg-ink/15' : 'border-ink/20 bg-ink/5'}`} />
43
+ );
44
+ }
45
+
46
+ /**
47
+ * The draft bar in the miniature: three text lines, the last one short, so it
48
+ * reads as a text box rather than a divider.
49
+ */
50
+ function MiniDraft({ hero = false }: { hero?: boolean }) {
51
+ return (
52
+ <span className={`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${hero ? 'flex-1 justify-center' : ''}`}>
53
+ <span className="h-[2.5px] w-[72%] rounded-full bg-ink/25" />
54
+ <span className="h-[2.5px] w-[54%] rounded-full bg-ink/20" />
55
+ <span className="h-[2.5px] w-[30%] rounded-full bg-ink/15" />
56
+ </span>
57
+ );
58
+ }
59
+
60
+ /**
61
+ * The trailing control row in the miniature: the model pill, the mode toggles
62
+ * and the send button, in the order the real toolbar draws them.
63
+ */
64
+ function MiniControls({ rail = false }: { rail?: boolean }) {
65
+ if (rail) {
66
+ return (
67
+ <span className="flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono">
68
+ <span className="h-[2.5px] w-[14px] rounded-full bg-ink/30" />
69
+ <span className="h-[2.5px] w-[9px] rounded-full bg-ink/20" />
70
+ <span className="h-[2.5px] w-[11px] rounded-full bg-ink/20" />
71
+ <span className="ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80" />
72
+ </span>
73
+ );
74
+ }
75
+ return (
76
+ <span className="flex items-center gap-1 px-1">
77
+ <span className="h-[6px] w-[20px] rounded-sm bg-ink/15" />
78
+ <span className="h-[6px] w-[10px] rounded-sm bg-ink/10" />
79
+ <span className="ml-auto h-[7px] w-[7px] rounded-full border border-ink/25" />
80
+ <span className="h-[7px] w-[7px] rounded-sm bg-ink/80" />
81
+ </span>
82
+ );
83
+ }
84
+
85
+ /**
86
+ * The frame each style draws in the settings card. A table rather than a
87
+ * ternary chain: the composer's own frame is CSS keyed by
88
+ * `[data-composer-style]`, and this is its miniature — the two are separate
89
+ * facts, but neither may be missing a style.
90
+ */
91
+ const MINIATURE_FRAME: Record<ComposerStyle, string> = {
92
+ classic: 'rounded-md bg-paper border-ink/10',
93
+ calm: 'rounded-lg bg-paper border-ink/10',
94
+ console: 'rounded-sm bg-paper border-ink/10',
95
+ stage: 'rounded-md bg-paper border-ink/15',
96
+ // The glass card is translucent in the product; drawn small it needs an
97
+ // OPAQUE hint instead, because there is nothing behind it to show through.
98
+ glass: 'rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent',
99
+ };
100
+
101
+ /**
102
+ * The card, drawn from the style's own row order. `wire` is the same list the
103
+ * renderer loops over, so this picture cannot disagree with the product.
104
+ */
105
+ function Miniature({ style }: { style: ComposerStyle }) {
106
+ const layout = composerStyleLayout({ style, hero: style === 'stage' });
107
+ return (
108
+ <span
109
+ className={`flex h-full flex-col gap-1 border p-1 ${MINIATURE_FRAME[style]}`}
110
+ aria-hidden="true"
111
+ >
112
+ {layout.wire.map((row, index) =>
113
+ row === 'draft' ? (
114
+ <MiniDraft key={index} hero={style === 'stage'} />
115
+ ) : row === 'chip' ? (
116
+ <span key={index} className="flex items-center gap-1 px-1">
117
+ <MiniChip active={style !== 'calm'} />
118
+ <MiniChip />
119
+ </span>
120
+ ) : (
121
+ <MiniControls key={index} rail={layout.toolbarTone === 'rail'} />
122
+ ),
123
+ )}
124
+ </span>
125
+ );
126
+ }
127
+
128
+ export function ComposerStyleSection({ settings, onUpdate }: ComposerStyleSectionProps) {
129
+ const selected = resolveComposerStyle(settings.composerStyle);
130
+
131
+ return (
132
+ <section className="space-y-3">
133
+ <div>
134
+ <h4 className="text-sm font-semibold text-ink">Composer</h4>
135
+ <p className="mt-0.5 text-[11px] text-ink/60">
136
+ The shape of the box you type into. Every style offers the same controls — attachments,
137
+ plan and goal, access mode, model, thinking, voice, send — and only their order and frame
138
+ change. Applies to desktop and phone, and takes effect immediately.
139
+ </p>
140
+ </div>
141
+
142
+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2" role="group" aria-label="Composer style">
143
+ {COMPOSER_STYLES.map((style) => {
144
+ const copy = COMPOSER_STYLE_COPY[style];
145
+ const isSelected = style === selected;
146
+ return (
147
+ <button
148
+ key={style}
149
+ type="button"
150
+ onClick={() => onUpdate({ composerStyle: style })}
151
+ aria-pressed={isSelected}
152
+ aria-label={`${copy.label} composer — ${copy.description}`}
153
+ className={`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${
154
+ isSelected
155
+ ? 'border-ink/40 bg-ink/5'
156
+ : 'border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5'
157
+ }`}
158
+ >
159
+ <span className="block h-[92px]">
160
+ <Miniature style={style} />
161
+ </span>
162
+ <span className="flex items-center gap-1.5">
163
+ <span className="text-xs font-semibold text-ink">{copy.label}</span>
164
+ {isSelected && (
165
+ <span className="ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[9px] font-semibold text-paper">
166
+ active
167
+ </span>
168
+ )}
169
+ </span>
170
+ <span className="text-[11px] leading-relaxed text-ink/60">{copy.description}</span>
171
+ </button>
172
+ );
173
+ })}
174
+ </div>
175
+ </section>
176
+ );
177
+ }
@@ -50,7 +50,7 @@ export function ChatLayoutSection({ settings, onUpdate }: ChatLayoutSectionProps
50
50
  </p>
51
51
  </div>
52
52
 
53
- <div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
53
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-3" role="group" aria-label="Chat width">
54
54
  {CHAT_WIDTH_MODES.map((mode) => {
55
55
  const copy = CHAT_WIDTH_MODE_COPY[mode];
56
56
  const isSelected = selected === mode;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Chats, the list pane: one row per group, the same shape the Usage
8
+ * category's provider list uses (a mark, a name, a one-line hint, the active
9
+ * row tinted). Width and border belong to the pane, not to the row: the master
10
+ * detail shell stacks the two panes on a phone, where the list is full width.
11
+ */
12
+
13
+ import type { ChatSettingGroup, ChatSettingGroupId } from '@/client/components/settings/categories/chat-settings/groups';
14
+
15
+ interface ChatSettingsSidebarProps {
16
+ groups: readonly ChatSettingGroup[];
17
+ activeGroupId: ChatSettingGroupId;
18
+ onSelectGroup: (id: ChatSettingGroupId) => void;
19
+ }
20
+
21
+ export function ChatSettingsSidebar({
22
+ groups,
23
+ activeGroupId,
24
+ onSelectGroup,
25
+ }: ChatSettingsSidebarProps) {
26
+ return (
27
+ <div className="w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none">
28
+ <div className="px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between">
29
+ <span className="text-xs font-semibold text-ink">
30
+ {groups.length} group{groups.length === 1 ? '' : 's'}
31
+ </span>
32
+ </div>
33
+
34
+ <div className="flex-1 scrollbar-overlay-container p-1.5 text-xs">
35
+ <div className="space-y-0.5">
36
+ {groups.map((group) => {
37
+ const isActive = group.id === activeGroupId;
38
+ const Icon = group.icon;
39
+
40
+ return (
41
+ <button
42
+ key={group.id}
43
+ type="button"
44
+ onClick={() => onSelectGroup(group.id)}
45
+ aria-current={isActive ? 'true' : undefined}
46
+ className={`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${
47
+ isActive
48
+ ? 'bg-ink/10 text-ink font-medium shadow-2xs'
49
+ : 'text-ink/80 hover:bg-ink/5 hover:text-ink'
50
+ }`}
51
+ >
52
+ <span className="flex items-center gap-1.5 min-w-0">
53
+ <span
54
+ aria-hidden
55
+ className={`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${
56
+ isActive ? 'bg-ink/10 text-ink' : 'bg-ink/5 text-ink/70'
57
+ }`}
58
+ >
59
+ <Icon size={12} />
60
+ </span>
61
+ <span className="font-semibold text-xs text-ink truncate">{group.label}</span>
62
+ </span>
63
+ <span className="text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]">
64
+ {group.hint}
65
+ </span>
66
+ </button>
67
+ );
68
+ })}
69
+ </div>
70
+ </div>
71
+ </div>
72
+ );
73
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * How a tool call is drawn in the transcript.
8
+ *
9
+ * Four cards, one per renderer, in the order `TOOL_RENDER_MODES` declares:
10
+ * fullest first. Each card carries a miniature of its own renderer, because the
11
+ * difference between the modes is SHAPE — a label alone cannot show a rail or a
12
+ * status line. The miniature is drawn from the same primitives the transcript
13
+ * uses (a hairline, a dot, a mono line), so the preview is honest about what
14
+ * the reader will get.
15
+ *
16
+ * The copy lives in `shared/lib/chat/timeline/tool-render-mode.ts`, so this
17
+ * file states neither the names nor the descriptions.
18
+ */
19
+
20
+ import { Check } from 'lucide-preact';
21
+ import type { SettingsState } from '@/shared/types';
22
+ import {
23
+ TOOL_RENDER_MODE_COPY,
24
+ TOOL_RENDER_MODES,
25
+ type ToolRenderMode,
26
+ } from '@/shared/lib/chat/timeline/tool-render-mode';
27
+
28
+ interface ChatToolRenderSectionProps {
29
+ settings: SettingsState;
30
+ onUpdate: (updater: Partial<SettingsState> | ((prev: SettingsState) => SettingsState)) => void;
31
+ }
32
+
33
+ /** The miniature per mode. Presentation only — no setting reads it. */
34
+ function ModePreview({ mode }: { mode: ToolRenderMode }) {
35
+ if (mode === 'card') {
36
+ return (
37
+ <div aria-hidden className="space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5">
38
+ <div className="flex items-center gap-1">
39
+ <span className="h-1.5 w-1.5 rounded-full bg-ink/50" />
40
+ <span className="h-1 w-10 rounded-full bg-ink/35" />
41
+ <span className="ml-auto h-1 w-5 rounded-full bg-ink/20" />
42
+ </div>
43
+ <div className="h-1 w-16 rounded-full bg-ink/15" />
44
+ </div>
45
+ );
46
+ }
47
+ if (mode === 'compact') {
48
+ return (
49
+ <div aria-hidden className="space-y-1.5 rounded-md border border-transparent px-1 py-1">
50
+ {[0, 1].map((row) => (
51
+ <div key={row} className="flex items-center gap-1">
52
+ <span className="h-1.5 w-1.5 rounded-full bg-ink/40" />
53
+ <span className="h-1 w-8 rounded-full bg-ink/30" />
54
+ <span className="ml-auto h-1 w-6 rounded-full bg-ink/15" />
55
+ </div>
56
+ ))}
57
+ </div>
58
+ );
59
+ }
60
+ if (mode === 'trace') {
61
+ return (
62
+ <div aria-hidden className="relative ml-1 pl-3 py-1">
63
+ <span className="absolute left-[3px] top-1 bottom-1 w-px bg-ink/20" />
64
+ {[0, 1, 2].map((row) => (
65
+ <div key={row} className="flex items-center gap-1 py-0.5">
66
+ <span className="h-1.5 w-1.5 rounded-full bg-ink/40" />
67
+ <span className="h-1 w-10 rounded-full bg-ink/25" />
68
+ </div>
69
+ ))}
70
+ </div>
71
+ );
72
+ }
73
+ return (
74
+ <div aria-hidden className="space-y-1.5 px-1 py-1">
75
+ <div className="h-1 w-20 rounded-full bg-ink/25" />
76
+ <div className="h-1 w-14 rounded-full bg-ink/15" />
77
+ </div>
78
+ );
79
+ }
80
+
81
+ export function ChatToolRenderSection({ settings, onUpdate }: ChatToolRenderSectionProps) {
82
+ const selected = settings.toolRenderStyle;
83
+
84
+ return (
85
+ <section className="space-y-3">
86
+ <div>
87
+ <h4 className="text-sm font-semibold text-ink">Tool Calls</h4>
88
+ <p className="text-[11px] text-ink/60 mt-0.5">
89
+ How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body.
90
+ </p>
91
+ </div>
92
+
93
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
94
+ {TOOL_RENDER_MODES.map((mode) => {
95
+ const copy = TOOL_RENDER_MODE_COPY[mode];
96
+ const isSelected = selected === mode;
97
+ return (
98
+ <div
99
+ key={mode}
100
+ onClick={() => onUpdate({ toolRenderStyle: mode })}
101
+ role="button"
102
+ tabIndex={0}
103
+ aria-pressed={isSelected}
104
+ onKeyDown={(e) => {
105
+ if (e.key === 'Enter' || e.key === ' ') {
106
+ e.preventDefault();
107
+ onUpdate({ toolRenderStyle: mode });
108
+ }
109
+ }}
110
+ className={`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${
111
+ isSelected
112
+ ? 'border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs'
113
+ : 'border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]'
114
+ }`}
115
+ >
116
+ <div>
117
+ <div className="flex items-center justify-between mb-2">
118
+ <span className="font-semibold text-xs text-ink">{copy.label}</span>
119
+ <div
120
+ className={`w-4 h-4 rounded-full border flex items-center justify-center ${
121
+ isSelected ? 'border-ink bg-ink text-paper' : 'border-ink/30 bg-transparent'
122
+ }`}
123
+ >
124
+ {isSelected && <Check size={10} strokeWidth={3} />}
125
+ </div>
126
+ </div>
127
+
128
+ <div className="mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1">
129
+ <ModePreview mode={mode} />
130
+ </div>
131
+
132
+ <p className="text-[11px] text-ink/65 leading-relaxed">{copy.description}</p>
133
+ </div>
134
+ </div>
135
+ );
136
+ })}
137
+ </div>
138
+
139
+ <p className="text-[10px] text-ink/45 font-mono">
140
+ The style is global: it applies to every session, and the composer keeps its own frame.
141
+ </p>
142
+ </section>
143
+ );
144
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Settings → Chats sidebar's group table.
8
+ *
9
+ * The failure this prevents is a section that exists but cannot be reached: the
10
+ * category's detail pane renders `group.sections`, so a section missing from
11
+ * every group is invisible in the product while its file, its imports and its
12
+ * unit tests all still pass. The reverse — one section listed under two groups —
13
+ * renders it twice and makes an edit in one place look like it did nothing.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import {
18
+ CHAT_SECTION_IDS,
19
+ CHAT_SETTING_GROUPS,
20
+ } from '@/client/components/settings/categories/chat-settings/groups';
21
+
22
+ describe('chat setting groups', () => {
23
+ test('every section is owned by exactly one group', () => {
24
+ const assigned = CHAT_SETTING_GROUPS.flatMap((group) => group.sections);
25
+
26
+ expect(assigned).toHaveLength(CHAT_SECTION_IDS.length);
27
+ expect([...assigned].sort()).toEqual([...CHAT_SECTION_IDS].sort());
28
+ });
29
+
30
+ test('group ids are unique and each row states a label, a hint and a description', () => {
31
+ const ids = CHAT_SETTING_GROUPS.map((group) => group.id);
32
+ expect(new Set(ids).size).toBe(ids.length);
33
+
34
+ for (const group of CHAT_SETTING_GROUPS) {
35
+ expect(group.label.trim()).not.toBe('');
36
+ expect(group.hint.trim()).not.toBe('');
37
+ expect(group.description.trim()).not.toBe('');
38
+ expect(typeof group.icon).toBe('function');
39
+ expect(group.sections.length).toBeGreaterThan(0);
40
+ }
41
+ });
42
+ });
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Settings → Chats sidebar: four groups over the seven chat sections.
8
+ *
9
+ * The category used to be one scrolling column, which made a reader scroll past
10
+ * composer frames to reach a keyboard chord. Grouping is a NAVIGATION fact, so
11
+ * it lives here as data: the sidebar renders this list, and the detail pane
12
+ * renders the sections each group names. `CHAT_SECTION_IDS` is the union's
13
+ * source, so a section added to the category must be assigned to a group (the
14
+ * `Record<ChatSectionId, …>` in `ChatSettings` refuses to compile otherwise)
15
+ * and the sidebar cannot silently drop one.
16
+ */
17
+
18
+ import type { LucideIcon } from 'lucide-preact';
19
+ import { Keyboard, ListOrdered, MessageSquare, PanelLeft } from 'lucide-preact';
20
+
21
+ /** Every section a group can own. */
22
+ export const CHAT_SECTION_IDS = [
23
+ 'width',
24
+ 'composer',
25
+ 'tool-calls',
26
+ 'follow-up',
27
+ 'titles',
28
+ 'goal',
29
+ 'keybindings',
30
+ ] as const;
31
+
32
+ export type ChatSectionId = (typeof CHAT_SECTION_IDS)[number];
33
+
34
+ export type ChatSettingGroupId = 'layout' | 'transcript' | 'sessions' | 'keys';
35
+
36
+ export interface ChatSettingGroup {
37
+ id: ChatSettingGroupId;
38
+ label: string;
39
+ /** One line under the label in the sidebar. */
40
+ hint: string;
41
+ /** Stated above the group's sections in the detail pane. */
42
+ description: string;
43
+ icon: LucideIcon;
44
+ sections: readonly ChatSectionId[];
45
+ }
46
+
47
+ export const CHAT_SETTING_GROUPS: readonly ChatSettingGroup[] = [
48
+ {
49
+ id: 'layout',
50
+ label: 'Layout',
51
+ hint: 'Chat width and composer shape',
52
+ description: 'How wide the conversation is drawn, and the shape of the box you type into.',
53
+ icon: PanelLeft,
54
+ sections: ['width', 'composer'],
55
+ },
56
+ {
57
+ id: 'transcript',
58
+ label: 'Transcript',
59
+ hint: 'Tool calls and follow-up dispatch',
60
+ description:
61
+ 'How a tool call is drawn, and what happens to a prompt sent while the agent is still running.',
62
+ icon: ListOrdered,
63
+ sections: ['tool-calls', 'follow-up'],
64
+ },
65
+ {
66
+ id: 'sessions',
67
+ label: 'Sessions',
68
+ hint: 'Titles and goal mode',
69
+ description: 'How a session gets its name, and the defaults a new goal starts with.',
70
+ icon: MessageSquare,
71
+ sections: ['titles', 'goal'],
72
+ },
73
+ {
74
+ id: 'keys',
75
+ label: 'Keyboard',
76
+ hint: 'Send, newline and steering keys',
77
+ description: 'Which chord sends a prompt, inserts a newline, or steers the running turn.',
78
+ icon: Keyboard,
79
+ sections: ['keybindings'],
80
+ },
81
+ ];