@kabmo-labs/kabmo 0.24.0 → 0.25.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 (205) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +579 -510
  3. package/dist/client/static/js/index-bc9aa4mx.css +1 -0
  4. package/dist/client/static/js/{index-jcr5twtp.js → index-ga8cbpt4.js} +1072 -1174
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
  15. package/src/client/components/common/session-actions-menu/index.tsx +33 -2
  16. package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
  17. package/src/client/components/common/session-row/index.tsx +27 -1
  18. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  19. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
  20. package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
  21. package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
  22. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +36 -5
  23. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
  24. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  25. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
  26. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
  27. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -35
  28. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
  29. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
  30. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
  31. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  32. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  33. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
  34. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  35. package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
  36. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  37. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  38. package/src/client/components/workspace/chat-timeline/index.tsx +3 -1
  39. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  40. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  41. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  42. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  43. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  44. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  45. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  46. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  47. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  48. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  49. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  50. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  51. package/src/client/data/settings/omp-schema.json +1 -1
  52. package/src/client/data/theme/terminal.test.ts +25 -0
  53. package/src/client/data/theme/terminal.ts +96 -79
  54. package/src/client/hooks/chat/composer/items.test.ts +12 -26
  55. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  56. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  57. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  58. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  59. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  60. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  61. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  62. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  63. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  64. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  65. package/src/client/hooks/chat/timeline/send.ts +51 -50
  66. package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
  67. package/src/client/hooks/models/use-harness-update.test.ts +193 -0
  68. package/src/client/hooks/models/use-harness-update.ts +202 -0
  69. package/src/client/hooks/workspace/child-expansion.ts +33 -0
  70. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  71. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  72. package/src/client/lib/session-tree.test.ts +50 -0
  73. package/src/client/lib/session-tree.ts +59 -0
  74. package/src/client/tailwind.css +17 -11
  75. package/src/server/index.ts +2 -0
  76. package/src/server/lib/auth/guard.ts +10 -0
  77. package/src/server/lib/btw/session-copy.server.ts +6 -44
  78. package/src/server/lib/btw/session-copy.test.ts +2 -1
  79. package/src/server/lib/db/schema.ts +4 -0
  80. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  81. package/src/server/lib/db/seed.test.ts +1 -1
  82. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  83. package/src/server/lib/harness/acp/background-work.ts +320 -0
  84. package/src/server/lib/harness/acp/client.ts +2 -2
  85. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  86. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  87. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  88. package/src/server/lib/harness/acp/prompt.ts +19 -3
  89. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  90. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  91. package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
  92. package/src/server/lib/harness/acp/session-handshake.ts +27 -1
  93. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  94. package/src/server/lib/harness/acp/session-requests.ts +47 -0
  95. package/src/server/lib/harness/acp/session-turns.ts +20 -5
  96. package/src/server/lib/harness/acp/session.test-util.ts +23 -1
  97. package/src/server/lib/harness/acp/session.ts +59 -59
  98. package/src/server/lib/harness/acp/turn.test.ts +81 -0
  99. package/src/server/lib/harness/acp/turn.ts +26 -9
  100. package/src/server/lib/harness/acp/verbs.ts +12 -2
  101. package/src/server/lib/harness/launch.ts +3 -1
  102. package/src/server/lib/harness/spawn.server.ts +15 -2
  103. package/src/server/lib/harness/update-job-store.test.ts +126 -0
  104. package/src/server/lib/harness/update-job-store.ts +109 -0
  105. package/src/server/lib/harness/update-job.server.ts +203 -0
  106. package/src/server/lib/harness/update-worker.test.ts +153 -0
  107. package/src/server/lib/harness/update-worker.ts +197 -0
  108. package/src/server/lib/lifecycle/paths.ts +23 -0
  109. package/src/server/lib/omp/rpc/manager.ts +5 -5
  110. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  111. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  112. package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
  113. package/src/server/lib/omp/session/delete-flow.server.ts +47 -0
  114. package/src/server/lib/omp/session/delete.server.ts +5 -0
  115. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  116. package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
  117. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  118. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  119. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  120. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  121. package/src/server/lib/sessions/answers.server.ts +37 -0
  122. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  123. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  124. package/src/server/lib/sessions/fork.server.test.ts +209 -0
  125. package/src/server/lib/sessions/fork.server.ts +304 -0
  126. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  127. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  128. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  129. package/src/server/lib/sessions/notify.server.ts +212 -0
  130. package/src/server/lib/sessions/relation-types.ts +76 -0
  131. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  132. package/src/server/lib/sessions/relations.server.ts +337 -0
  133. package/src/server/lib/sessions/resolve.server.ts +106 -0
  134. package/src/server/lib/sessions/schema.server.ts +82 -0
  135. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  136. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  137. package/src/server/lib/sessions/spawn.server.test.ts +196 -0
  138. package/src/server/lib/sessions/spawn.server.ts +310 -0
  139. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  140. package/src/server/lib/terminal/output.test.ts +2 -2
  141. package/src/server/lib/terminal/output.ts +1 -1
  142. package/src/server/lib/terminal/resize.test.ts +99 -0
  143. package/src/server/lib/terminal/runtime.server.ts +26 -6
  144. package/src/server/lib/terminal/send-result.test.ts +18 -1
  145. package/src/server/lib/terminal/send-result.ts +26 -2
  146. package/src/server/lib/terminal/session.server.ts +6 -6
  147. package/src/server/lib/usage/new-api.test.ts +92 -0
  148. package/src/server/lib/usage/new-api.ts +131 -0
  149. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  150. package/src/server/lib/usage/provider-key.ts +33 -0
  151. package/src/server/lib/usage/providers.server.ts +10 -3
  152. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  153. package/src/server/lib/usage/vendor-http.ts +41 -0
  154. package/src/server/lib/usage/window.ts +55 -0
  155. package/src/server/routes/agent/command.ts +14 -1
  156. package/src/server/routes/agent/harness-command.ts +6 -0
  157. package/src/server/routes/agent/new.ts +15 -0
  158. package/src/server/routes/harness/add-provider.test.ts +9 -1
  159. package/src/server/routes/harness/import-action.ts +4 -0
  160. package/src/server/routes/harness/import.test.ts +1 -1
  161. package/src/server/routes/harness/index.ts +5 -1
  162. package/src/server/routes/harness/update-status.ts +26 -0
  163. package/src/server/routes/harness/update.test.ts +119 -0
  164. package/src/server/routes/harness/update.ts +59 -147
  165. package/src/server/routes/sessions/answer.ts +24 -0
  166. package/src/server/routes/sessions/batch-delete.ts +11 -5
  167. package/src/server/routes/sessions/delete.ts +4 -2
  168. package/src/server/routes/sessions/fork.ts +74 -0
  169. package/src/server/routes/sessions/index.ts +14 -0
  170. package/src/server/routes/sessions/relations.ts +85 -0
  171. package/src/server/routes/sessions/session.ts +4 -0
  172. package/src/server/routes/sessions/spawn.ts +134 -0
  173. package/src/server/routes/terminal/ws.ts +3 -3
  174. package/src/shared/lib/chat/composer/client.ts +31 -2
  175. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  176. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  177. package/src/shared/lib/chat/notice-text.ts +1 -1
  178. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  179. package/src/shared/lib/code/ansi.ts +1 -1
  180. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  181. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  182. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  183. package/src/shared/lib/harness/providers.ts +35 -1
  184. package/src/shared/lib/harness/update-job.ts +33 -0
  185. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  186. package/src/shared/lib/harness/update-plan.ts +12 -4
  187. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  188. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  189. package/src/shared/lib/theme/catalog.test.ts +13 -9
  190. package/src/shared/lib/theme/color.test.ts +2 -2
  191. package/src/shared/lib/theme/color.ts +4 -4
  192. package/src/shared/lib/theme/theme.test.ts +1 -1
  193. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  194. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  195. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  196. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  197. package/src/shared/types/chat.ts +1 -1
  198. package/src/shared/types/harness-update.ts +65 -0
  199. package/src/shared/types/omp/agent.ts +19 -2
  200. package/src/shared/types/workspace.ts +4 -0
  201. package/src/test-support/fake-omp-fork.ts +16 -2
  202. package/src/test-support/harness-table.test-util.ts +15 -1
  203. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  204. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  205. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -1,4 +1,4 @@
1
- import { Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
1
+ import { Boxes, Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
2
2
  import type { SessionItemData } from '@/shared/types';
3
3
  import { useInlineRename } from '@/client/hooks/ui/inline-rename';
4
4
  import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
@@ -18,8 +18,12 @@ export interface MobileSessionRowProps {
18
18
  awaitingInput?: boolean;
19
19
  /** Relative age of the session, or null when no usable timestamp exists. */
20
20
  timeAgo: string | null;
21
- /** The session has a subagent roster (on disk or live), so it can be expanded. */
21
+ /** The session has a subagent roster (on disk or live). */
22
22
  hasSubagents?: boolean;
23
+ subagentsExpanded?: boolean;
24
+ onToggleSubagents?: () => void;
25
+ /** The session has child sessions, so it can be expanded as a tree. */
26
+ expandable?: boolean;
23
27
  isExpanded?: boolean;
24
28
  onToggleExpand?: () => void;
25
29
  onSelect: () => void;
@@ -51,6 +55,9 @@ export function MobileSessionRow({
51
55
  awaitingInput = false,
52
56
  timeAgo,
53
57
  hasSubagents = false,
58
+ subagentsExpanded = false,
59
+ onToggleSubagents,
60
+ expandable = false,
54
61
  isExpanded = false,
55
62
  onToggleExpand,
56
63
  onSelect,
@@ -90,7 +97,7 @@ export function MobileSessionRow({
90
97
  // Touch has no hover to reveal a hidden toggle the way desktop does, so it is
91
98
  // pinned whenever the row has a roster; a hidden one would leave the roster
92
99
  // unreachable on a phone.
93
- const showChevron = hasSubagents && Boolean(onToggleExpand);
100
+ const showChevron = expandable && Boolean(onToggleExpand);
94
101
  const title = session.title.charAt(0).toUpperCase() + session.title.slice(1);
95
102
 
96
103
  if (isEditing) {
@@ -223,15 +230,29 @@ export function MobileSessionRow({
223
230
  </button>
224
231
  )}
225
232
 
233
+ {/* The roster badge is a separate control from the tree chevron. */}
234
+ {hasSubagents && onToggleSubagents && !selectable && (
235
+ <button
236
+ type="button"
237
+ onClick={onToggleSubagents}
238
+ title="Subagents (tool calls)"
239
+ aria-label="Subagents"
240
+ aria-expanded={subagentsExpanded}
241
+ className="flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/40 hover:text-ink rounded-lg cursor-pointer"
242
+ >
243
+ <Boxes size={15} />
244
+ </button>
245
+ )}
246
+
226
247
  {/* Last element, so its glyph shares the trigger's column — the same
227
248
  inset pair and the same 4px ink margin. */}
228
249
  {showChevron && !selectable && (
229
250
  <button
230
251
  type="button"
231
252
  onClick={onToggleExpand}
232
- title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
253
+ title={isExpanded ? 'Collapse child sessions' : 'Expand child sessions'}
233
254
  aria-expanded={isExpanded}
234
- aria-label={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
255
+ aria-label={isExpanded ? 'Collapse child sessions' : 'Expand child sessions'}
235
256
  className="flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/50 hover:text-ink rounded-lg cursor-pointer"
236
257
  >
237
258
  {isExpanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
@@ -242,6 +263,7 @@ export function MobileSessionRow({
242
263
  {menu.anchor && (
243
264
  <SessionActionsMenu
244
265
  anchor={menu.anchor}
266
+ sessionId={session.id}
245
267
  isArchived={session.is_archived === 1}
246
268
  onRename={onRename ? startRename : undefined}
247
269
  onRenameWithAi={onRenameWithAi}
@@ -2,6 +2,7 @@ import type { Dispatch, SetStateAction } from 'preact/compat';
2
2
  import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input/index';
3
3
  import { BtwForm } from '@/client/components/workspace/btw-panel/index';
4
4
  import { useBtwMode } from '@/client/hooks/chat/btw/mode';
5
+ import { ComposerDockFrame } from '@/client/components/workspace/chat-timeline/ComposerDockFrame';
5
6
  import { GeneratingIndicator } from '@/client/components/workspace/chat-timeline/GeneratingIndicator';
6
7
  import { QueueList } from '@/client/components/workspace/chat-timeline/QueueList';
7
8
  import type { Attachment, QueuedMessage } from '@/shared/types';
@@ -121,76 +122,69 @@ export function ComposerDock({
121
122
  const btw = useBtwMode(sessionId);
122
123
 
123
124
  return (
124
- <div
125
- className={`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${isMobile ? 'px-3 pt-1' : 'p-4 pt-1'}`}
126
- style={isMobile ? { paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom, 0px))' } : undefined}
127
- >
128
- {/* `relative` keeps the queue/indicator stack anchored above the input
129
- while the side-question form takes the composer's place. */}
130
- <div className="chat-column relative">
131
- {/* Plugin banner strip: above the input, in the chat's own composer.
132
- An empty slot renders nothing, so a Kabmo with no plugins keeps
133
- this dock byte-identical. */}
134
- <PluginComposerBanners />
135
- {showGeneratingIndicator && (
136
- <GeneratingIndicator
137
- modelName={modelName}
138
- generatingVerb={generatingVerb}
139
- provider={provider}
140
- providerNames={providerNames}
141
- {...(harness ? { harness } : {})}
142
- />
143
- )}
144
- <QueueList
145
- queue={messageQueue}
146
- onRemove={onRemoveQueueItem}
147
- onReorder={onReorderQueue}
148
- onEdit={onEditQueueItem}
149
- onSendNow={onSendNowQueueItem}
125
+ <ComposerDockFrame isMobile={isMobile}>
126
+ {/* Plugin banner strip: above the input, in the chat's own composer.
127
+ An empty slot renders nothing, so a Kabmo with no plugins keeps
128
+ this dock byte-identical. */}
129
+ <PluginComposerBanners />
130
+ {showGeneratingIndicator && (
131
+ <GeneratingIndicator
132
+ modelName={modelName}
133
+ generatingVerb={generatingVerb}
134
+ provider={provider}
135
+ providerNames={providerNames}
136
+ {...(harness ? { harness } : {})}
150
137
  />
151
- {btw.open ? (
152
- <BtwForm
153
- mode={btw}
154
- appSettings={appSettings}
155
- composerModelRef={composerModelRef}
156
- rootPath={rootPath}
157
- variant={variant}
158
- modelName={modelName}
159
- provider={provider}
160
- providerNames={providerNames}
161
- />
162
- ) : (
163
- <ChatInput
164
- value={inputValue}
165
- onChange={setInputValue}
166
- sessionId={sessionId}
167
- rootPath={rootPath}
168
- attachments={attachments}
169
- onAttachmentsChange={setAttachments}
170
- onSend={onSend}
171
- isGenerating={isGenerating}
172
- chatRunning={showGeneratingIndicator}
173
- onStop={onStop}
174
- appSettings={appSettings}
175
- onThinkingLevelChange={onThinkingLevelChange}
176
- onModelChange={onModelChange}
177
- accessMode={accessMode}
178
- onAccessModeChange={onAccessModeChange}
179
- modes={modes}
180
- composerModelRef={composerModelRef}
181
- deferredComposerPickRef={deferredComposerPickRef}
182
- sessionModel={sessionModel}
183
- sessionThinkingLevel={sessionThinkingLevel}
184
- harness={harness}
185
- harnessEditable={harnessEditable}
186
- onSelectHarness={onSelectHarness}
187
- variant={variant}
188
- expandable
189
- hero={hero}
190
- shrinkWhileReading={shrinkWhileReading}
191
- />
192
- )}
193
- </div>
194
- </div>
138
+ )}
139
+ <QueueList
140
+ queue={messageQueue}
141
+ onRemove={onRemoveQueueItem}
142
+ onReorder={onReorderQueue}
143
+ onEdit={onEditQueueItem}
144
+ onSendNow={onSendNowQueueItem}
145
+ />
146
+ {btw.open ? (
147
+ <BtwForm
148
+ mode={btw}
149
+ appSettings={appSettings}
150
+ composerModelRef={composerModelRef}
151
+ rootPath={rootPath}
152
+ variant={variant}
153
+ modelName={modelName}
154
+ provider={provider}
155
+ providerNames={providerNames}
156
+ />
157
+ ) : (
158
+ <ChatInput
159
+ value={inputValue}
160
+ onChange={setInputValue}
161
+ sessionId={sessionId}
162
+ rootPath={rootPath}
163
+ attachments={attachments}
164
+ onAttachmentsChange={setAttachments}
165
+ onSend={onSend}
166
+ isGenerating={isGenerating}
167
+ chatRunning={showGeneratingIndicator}
168
+ onStop={onStop}
169
+ appSettings={appSettings}
170
+ onThinkingLevelChange={onThinkingLevelChange}
171
+ onModelChange={onModelChange}
172
+ accessMode={accessMode}
173
+ onAccessModeChange={onAccessModeChange}
174
+ modes={modes}
175
+ composerModelRef={composerModelRef}
176
+ deferredComposerPickRef={deferredComposerPickRef}
177
+ sessionModel={sessionModel}
178
+ sessionThinkingLevel={sessionThinkingLevel}
179
+ harness={harness}
180
+ harnessEditable={harnessEditable}
181
+ onSelectHarness={onSelectHarness}
182
+ variant={variant}
183
+ expandable
184
+ hero={hero}
185
+ shrinkWhileReading={shrinkWhileReading}
186
+ />
187
+ )}
188
+ </ComposerDockFrame>
195
189
  );
196
190
  }
@@ -0,0 +1,35 @@
1
+ import type { ComponentChildren } from 'preact';
2
+
3
+ interface ComposerDockFrameProps {
4
+ isMobile: boolean;
5
+ children: ComponentChildren;
6
+ }
7
+
8
+ /**
9
+ * The dock's frame: the padding, the chat-column width and the phone's
10
+ * safe-area inset every "rows above the composer" stack shares.
11
+ *
12
+ * It exists because that dock is drawn in two places — the real timeline
13
+ * (`ComposerDock`) and the pending `new-…` chat, whose composer lives in
14
+ * `EmptyWorkspacePrompt` until the spawn adopts it. Spelled out separately, the
15
+ * two drifted: the pending view kept the landing page's `p-8` and its
16
+ * `space-y-3` stack, while the dock used `p-4 pt-1` with the rows flush. The
17
+ * generating indicator therefore sat **28px higher** while the spawn was in
18
+ * flight (`Loading…`, 141px above the pane's bottom) than once the run streamed
19
+ * (`Thinking…`, 113px) — the row jumped at the moment the chat was adopted, and
20
+ * the jump read as two different indicators.
21
+ *
22
+ * The `relative` belongs here: it keeps the queue/indicator stack anchored
23
+ * above the input while the side-question form takes the composer's place.
24
+ */
25
+ export function ComposerDockFrame({ isMobile, children }: ComposerDockFrameProps) {
26
+ return (
27
+ <div
28
+ data-composer-dock=""
29
+ className={`border-t-0 bg-transparent flex-shrink-0 ${isMobile ? 'px-3 pt-1' : 'p-4 pt-1'}`}
30
+ style={isMobile ? { paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom, 0px))' } : undefined}
31
+ >
32
+ <div className="chat-column relative">{children}</div>
33
+ </div>
34
+ );
35
+ }
@@ -5,6 +5,7 @@ import type { Attachment, ChatMessageData, WorkspaceFolderData } from '@/shared/
5
5
  import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input/index';
6
6
  import { ChatMessageItem } from '@/client/components/workspace/chat-timeline/MessageItem';
7
7
  import { RunFooter } from '@/client/components/workspace/chat-timeline/RunFooter';
8
+ import { ComposerDockFrame } from '@/client/components/workspace/chat-timeline/ComposerDockFrame';
8
9
  import { GeneratingIndicator } from '@/client/components/workspace/chat-timeline/GeneratingIndicator';
9
10
  import { resolveRunFooters, streamingRowIndex } from '@/shared/lib/chat/timeline/run-footer';
10
11
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
@@ -159,65 +160,81 @@ export function EmptyWorkspacePrompt({
159
160
  }
160
161
  }, [messages.length]);
161
162
 
163
+ const isMobile = variant === 'mobile';
164
+ // A chat with rows to show (or a prompt in flight) draws the SAME dock the
165
+ // real timeline does. It used to keep this page's centred `p-8` column and a
166
+ // `space-y-3` stack, so the generating indicator — and the composer under it
167
+ // — sat 28px higher while the spawn was in flight (`Loading…`, 141px from the
168
+ // pane's bottom) than once the run streamed in the real timeline
169
+ // (`Thinking…`, 113px). The row jumped at the moment the chat was adopted,
170
+ // which read as two different indicators.
171
+ const docked = messages.length > 0 || isGenerating;
172
+
173
+ const heldPrompt = heldWait ? (
174
+ <div className="flex items-center gap-2 rounded-lg border border-ink/15 bg-ink/[0.03] px-3 py-2 text-xs text-ink/70">
175
+ <Hourglass size={12} className="shrink-0 animate-pulse text-ink/60" />
176
+ <span className="min-w-0 flex-1 truncate">
177
+ Waiting for {heldWait.title ?? 'another session'} to finish before this prompt is sent.
178
+ </span>
179
+ {onCancelWait && (
180
+ <button
181
+ type="button"
182
+ data-testid="cancel-held-prompt"
183
+ onClick={onCancelWait}
184
+ className="shrink-0 rounded border border-ink/20 px-2 py-0.5 text-[11px] text-ink/70 hover:bg-ink/5 hover:text-ink cursor-pointer"
185
+ >
186
+ Cancel
187
+ </button>
188
+ )}
189
+ </div>
190
+ ) : null;
191
+
192
+ const composer = (
193
+ <ChatInput
194
+ value={inputValue}
195
+ onChange={setInputValue}
196
+ rootPath={rootPath}
197
+ attachments={inputAttachments}
198
+ onAttachmentsChange={setInputAttachments}
199
+ onSend={onSend}
200
+ isGenerating={isGenerating}
201
+ disabled={!selectedFolderId || Boolean(heldWait)}
202
+ className="w-full shrink-0"
203
+ appSettings={appSettings}
204
+ onThinkingLevelChange={onThinkingLevelChange}
205
+ onModelChange={onModelChange}
206
+ sessionModel={sessionModel}
207
+ sessionThinkingLevel={sessionThinkingLevel}
208
+ accessMode={accessMode}
209
+ onAccessModeChange={onAccessModeChange}
210
+ modes={modes}
211
+ composerModelRef={composerModelRef}
212
+ deferredComposerPickRef={deferredComposerPickRef}
213
+ {...(harness ? { harness } : {})}
214
+ harnessEditable={harnessEditable}
215
+ {...(onSelectHarness ? { onSelectHarness } : {})}
216
+ variant={variant}
217
+ expandable
218
+ // A brand-new chat has no turns: the `stage` composer style draws its
219
+ // wider, taller card here and nowhere else.
220
+ hero={messages.length === 0}
221
+ />
222
+ );
223
+
162
224
  return (
163
- <div className={`flex flex-col h-full bg-canvas ${variant === 'mobile' ? 'px-3 py-4' : 'p-8'} ${className}`}
164
- style={variant === 'mobile' ? { paddingBottom: 'max(1rem, env(safe-area-inset-bottom, 0px))' } : undefined}
225
+ <div
226
+ className={`flex flex-col h-full bg-canvas ${docked ? '' : isMobile ? 'px-3 py-4' : 'p-8'} ${className}`}
227
+ style={!docked && isMobile ? { paddingBottom: 'max(1rem, env(safe-area-inset-bottom, 0px))' } : undefined}
165
228
  >
166
- <div
167
- className={`chat-column flex flex-col min-h-0 space-y-3 ${
168
- messages.length > 0 ? 'flex-1' : 'my-auto justify-center'
169
- }`}
170
- >
171
- {/* Workspace Selection Seamless Dropdown (No border, transparent
172
- background). Hidden once a chat has been sent — the session now has
173
- a target workspace, so the composer is the only focus. */}
174
- {messages.length === 0 && (
175
- <div className="flex items-center gap-1 flex-wrap">
176
- {/* Two controls, because they answer two questions: the workspace
177
- (which project) and the worktree (which checkout of it). The
178
- worktree control draws itself only for a git repository, and it
179
- reads its list on mount because its own trigger names the branch
180
- the project root holds. */}
181
- <WorkspacePicker
182
- folders={folders as WorkspaceFolderData[]}
183
- selectedFolderId={selectedFolderId}
184
- setSelectedFolderId={setSelectedFolderId}
185
- onClearWorktree={() => onSpawnTargetChange?.(null)}
186
- />
187
- {onSpawnTargetChange && (
188
- <WorktreePicker
189
- folders={folders as WorkspaceFolderData[]}
190
- selectedFolderId={selectedFolderId}
191
- target={spawnTarget}
192
- setTarget={onSpawnTargetChange}
193
- onReport={onWorktreeReport}
194
- />
195
- )}
196
- {/* The wait picker sits BESIDE the workspace picker, because both
197
- answer the same question about the chat that has not started:
198
- where it runs, and what it waits for. It only appears while there
199
- is something to wait for (or a pick already made). */}
200
- {onWaitingForChange && (waitingFor || candidates.length > 0) && (
201
- <WaitingDependencyPicker
202
- folders={folders}
203
- streamStatusMap={streamStatusMap}
204
- sessionId={null}
205
- titleFor={titleForSession}
206
- value={waitingFor}
207
- onChange={onWaitingForChange}
208
- />
209
- )}
210
- </div>
211
- )}
212
-
213
- {/* Pending session timeline: optimistic bubbles render here immediately
214
- on send, then the real session (UUID) takes over the ChatTimeline.
215
- Only shown when there are messages so the empty composer stays
216
- centered next to the workspace picker. */}
217
- {messages.length > 0 && (
229
+ {docked ? (
230
+ <>
231
+ {/* The pending transcript reserves the box the real timeline's own
232
+ scroller does (`TimelineBody`), so adoption moves no text either. */}
218
233
  <div
219
234
  ref={timelineRef}
220
- className="flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain"
235
+ className={`flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain ${
236
+ isMobile ? 'pl-4 pr-3 py-3 pb-8' : 'p-4 pb-10'
237
+ }`}
221
238
  >
222
239
  <div className="chat-column">
223
240
  {messages.map((msg, idx) => {
@@ -232,7 +249,7 @@ export function EmptyWorkspacePrompt({
232
249
  isStreaming={isLoading}
233
250
  onUndo={onUndo}
234
251
  onNewChat={onNewChat}
235
- isMobile={variant === 'mobile'}
252
+ isMobile={isMobile}
236
253
  className={isAiFragment ? 'mt-1' : 'mt-8'}
237
254
  />
238
255
  {footer && (
@@ -256,71 +273,71 @@ export function EmptyWorkspacePrompt({
256
273
  })}
257
274
  </div>
258
275
  </div>
259
- )}
260
276
 
261
- {/* Docked above the input, mirroring chat-timeline/index.tsx so the
262
- indicator does not jump when a pending new chat adopts its omp
263
- session and the main timeline branch takes over rendering. */}
264
- {isGenerating && (
265
- <GeneratingIndicator
266
- modelName={modelName}
267
- generatingVerb={generatingVerb}
268
- provider={provider}
269
- providerNames={providerNames}
270
- {...(harness ? { harness } : {})}
271
- />
272
- )}
273
- {/* A held prompt owns this chat until it is released: there is no
274
- session to send a second prompt to, and a composer that looked live
275
- would accept one that could not be delivered. */}
276
- {heldWait && (
277
- <div className="flex items-center gap-2 rounded-lg border border-ink/15 bg-ink/[0.03] px-3 py-2 text-xs text-ink/70">
278
- <Hourglass size={12} className="shrink-0 animate-pulse text-ink/60" />
279
- <span className="min-w-0 flex-1 truncate">
280
- Waiting for {heldWait.title ?? 'another session'} to finish before this prompt is sent.
281
- </span>
282
- {onCancelWait && (
283
- <button
284
- type="button"
285
- data-testid="cancel-held-prompt"
286
- onClick={onCancelWait}
287
- className="shrink-0 rounded border border-ink/20 px-2 py-0.5 text-[11px] text-ink/70 hover:bg-ink/5 hover:text-ink cursor-pointer"
288
- >
289
- Cancel
290
- </button>
277
+ {/* One frame with the real dock (`ComposerDock`), so the indicator and
278
+ the composer cannot sit at two different heights. */}
279
+ <ComposerDockFrame isMobile={isMobile}>
280
+ {isGenerating && (
281
+ <GeneratingIndicator
282
+ modelName={modelName}
283
+ generatingVerb={generatingVerb}
284
+ provider={provider}
285
+ providerNames={providerNames}
286
+ {...(harness ? { harness } : {})}
287
+ />
288
+ )}
289
+ {heldPrompt}
290
+ {composer}
291
+ </ComposerDockFrame>
292
+ </>
293
+ ) : (
294
+ <div className="chat-column flex flex-col min-h-0 my-auto justify-center space-y-3">
295
+ {/* Workspace Selection Seamless Dropdown (No border, transparent
296
+ background). A chat with rows keeps its target and drops the
297
+ picker; this branch is only the chat that has not started. */}
298
+ <div className="flex items-center gap-1 flex-wrap">
299
+ {/* Two controls, because they answer two questions: the workspace
300
+ (which project) and the worktree (which checkout of it). The
301
+ worktree control draws itself only for a git repository, and it
302
+ reads its list on mount because its own trigger names the branch
303
+ the project root holds. */}
304
+ <WorkspacePicker
305
+ folders={folders as WorkspaceFolderData[]}
306
+ selectedFolderId={selectedFolderId}
307
+ setSelectedFolderId={setSelectedFolderId}
308
+ onClearWorktree={() => onSpawnTargetChange?.(null)}
309
+ />
310
+ {onSpawnTargetChange && (
311
+ <WorktreePicker
312
+ folders={folders as WorkspaceFolderData[]}
313
+ selectedFolderId={selectedFolderId}
314
+ target={spawnTarget}
315
+ setTarget={onSpawnTargetChange}
316
+ onReport={onWorktreeReport}
317
+ />
318
+ )}
319
+ {/* The wait picker sits BESIDE the workspace picker, because both
320
+ answer the same question about the chat that has not started:
321
+ where it runs, and what it waits for. It only appears while
322
+ there is something to wait for (or a pick already made). */}
323
+ {onWaitingForChange && (waitingFor || candidates.length > 0) && (
324
+ <WaitingDependencyPicker
325
+ folders={folders}
326
+ streamStatusMap={streamStatusMap}
327
+ sessionId={null}
328
+ titleFor={titleForSession}
329
+ value={waitingFor}
330
+ onChange={onWaitingForChange}
331
+ />
291
332
  )}
292
333
  </div>
293
- )}
294
- <ChatInput
295
- value={inputValue}
296
- onChange={setInputValue}
297
- rootPath={rootPath}
298
- attachments={inputAttachments}
299
- onAttachmentsChange={setInputAttachments}
300
- onSend={onSend}
301
- isGenerating={isGenerating}
302
- disabled={!selectedFolderId || Boolean(heldWait)}
303
- className="w-full shrink-0"
304
- appSettings={appSettings}
305
- onThinkingLevelChange={onThinkingLevelChange}
306
- onModelChange={onModelChange}
307
- sessionModel={sessionModel}
308
- sessionThinkingLevel={sessionThinkingLevel}
309
- accessMode={accessMode}
310
- onAccessModeChange={onAccessModeChange}
311
- modes={modes}
312
- composerModelRef={composerModelRef}
313
- deferredComposerPickRef={deferredComposerPickRef}
314
- {...(harness ? { harness } : {})}
315
- harnessEditable={harnessEditable}
316
- {...(onSelectHarness ? { onSelectHarness } : {})}
317
- variant={variant}
318
- expandable
319
- // A brand-new chat has no turns: the `stage` composer style draws its
320
- // wider, taller card here and nowhere else.
321
- hero={messages.length === 0}
322
- />
323
- </div>
334
+ {/* A held prompt owns this chat until it is released: there is no
335
+ session to send a second prompt to, and a composer that looked live
336
+ would accept one that could not be delivered. */}
337
+ {heldPrompt}
338
+ {composer}
339
+ </div>
340
+ )}
324
341
  </div>
325
342
  );
326
343
  }
@@ -1,7 +1,7 @@
1
1
  import type { TargetedMouseEvent } from 'preact';
2
2
  import { useMemo } from 'preact/hooks';
3
3
  import { memo } from 'preact/compat';
4
- import { AlertCircle, Bot, Info, MessageSquarePlus, Undo2, User } from 'lucide-preact';
4
+ import { AlertCircle, Bot, GitFork, Info, MessageSquarePlus, Undo2, User } from 'lucide-preact';
5
5
  import type { Attachment, ChatMessageData } from '@/shared/types';
6
6
  import { toAttachmentList } from '@/shared/lib/chat/attachments';
7
7
  import { ThinkingSection } from '@/client/components/workspace/chat-timeline/ThinkingSection';
@@ -29,6 +29,8 @@ interface ChatMessageItemProps {
29
29
  * it from the new chat.
30
30
  */
31
31
  onNewChat?: (content: string, attachments?: Attachment[]) => void;
32
+ /** Branch the chat before/at this row. Absent draws no button. */
33
+ onFork?: (msgId: string) => void;
32
34
 
33
35
  /** Extra classes on the root wrapper (e.g. spacing between messages). */
34
36
  className?: string;
@@ -52,6 +54,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
52
54
  isStreaming = false,
53
55
  onUndo,
54
56
  onNewChat,
57
+ onFork,
55
58
  className = '',
56
59
  isPrevAssistant = false,
57
60
  userActions = true,
@@ -155,6 +158,24 @@ export const ChatMessageItem = memo(function ChatMessageItem({
155
158
  emptyTitle="Nothing to copy — attachment-only prompt"
156
159
  />
157
160
 
161
+ {/* Fork Button — branches the session at this row, leaving the
162
+ source untouched. Separate from New Chat: a fork carries the
163
+ history, a new chat does not. */}
164
+ {userActions && onFork && (
165
+ <button
166
+ type="button"
167
+ className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
168
+ title="Fork from here"
169
+ aria-label="Fork this session from this message"
170
+ onClick={(e) => {
171
+ e.preventDefault();
172
+ onFork(msg.id);
173
+ }}
174
+ >
175
+ <GitFork size={12} />
176
+ </button>
177
+ )}
178
+
158
179
  {/* New Chat Button */}
159
180
  {userActions && (
160
181
  <button
@@ -28,6 +28,8 @@ export interface MessageListProps {
28
28
  onRetry?: (id: string) => void;
29
29
  /** Seeds a new chat from a row. A user row also hands over its attachments. */
30
30
  onNewChat?: (content: string, attachments?: Attachment[]) => void;
31
+ /** Branch the session at a user row. */
32
+ onFork?: (msgId: string) => void;
31
33
  isMobile?: boolean;
32
34
  /**
33
35
  * Whether chat-owning actions render: a USER row's Undo / New-chat, and the
@@ -71,6 +73,7 @@ export const MessageList = memo(function MessageList({
71
73
  onUndo,
72
74
  onRetry,
73
75
  onNewChat,
76
+ onFork,
74
77
  isMobile = false,
75
78
  userActions = true,
76
79
  rowWindow,
@@ -139,6 +142,7 @@ export const MessageList = memo(function MessageList({
139
142
  isStreaming={isLoading}
140
143
  onUndo={onUndo}
141
144
  onNewChat={onNewChat}
145
+ onFork={onFork}
142
146
  isPrevAssistant={isPrevAssistant}
143
147
  userActions={userActions}
144
148
  isMobile={isMobile}
@@ -35,6 +35,7 @@ interface TimelineBodyProps {
35
35
  onUndo: (id: string, content?: string) => void;
36
36
  onRetry: (id: string) => void;
37
37
  onNewChat: (content: string, attachments?: Attachment[]) => void;
38
+ onFork?: (msgId: string) => void;
38
39
  showScrollBottom: boolean;
39
40
  jumpToBottom: (behavior?: ScrollBehavior) => void;
40
41
  /** Which rows of `messages` are mounted (see `useTimelineRowWindow`). */
@@ -70,6 +71,7 @@ export function TimelineBody({
70
71
  onUndo,
71
72
  onRetry,
72
73
  onNewChat,
74
+ onFork,
73
75
  showScrollBottom,
74
76
  jumpToBottom,
75
77
  rowWindow,
@@ -123,6 +125,7 @@ export function TimelineBody({
123
125
  onUndo={onUndo}
124
126
  onRetry={onRetry}
125
127
  onNewChat={onNewChat}
128
+ onFork={onFork}
126
129
  isMobile={isMobile}
127
130
  rowWindow={rowWindow}
128
131
  />