@sixb/app 0.2.4 → 0.2.5

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 (247) hide show
  1. package/assets/connector-icons/README.md +1 -0
  2. package/assets/connector-icons/ctm.png +0 -0
  3. package/dist/agent/activity-label.d.ts.map +1 -1
  4. package/dist/agent/agent-chat.d.ts +3 -1
  5. package/dist/agent/agent-chat.d.ts.map +1 -1
  6. package/dist/agent/agent-panel.d.ts.map +1 -1
  7. package/dist/agent/artifact-panel.d.ts +3 -1
  8. package/dist/agent/artifact-panel.d.ts.map +1 -1
  9. package/dist/agent/components/composer-settings.d.ts +1 -1
  10. package/dist/agent/components/composer-settings.d.ts.map +1 -1
  11. package/dist/agent/components/composer.d.ts +22 -5
  12. package/dist/agent/components/composer.d.ts.map +1 -1
  13. package/dist/agent/components/context-meter.d.ts +1 -1
  14. package/dist/agent/components/context-meter.d.ts.map +1 -1
  15. package/dist/agent/components/conversation-panel.d.ts +5 -2
  16. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  17. package/dist/agent/components/message-parts.d.ts +2 -1
  18. package/dist/agent/components/message-parts.d.ts.map +1 -1
  19. package/dist/agent/components/message-view.d.ts.map +1 -1
  20. package/dist/agent/components/pending-messages.d.ts +20 -0
  21. package/dist/agent/components/pending-messages.d.ts.map +1 -0
  22. package/dist/agent/components/sandbox-recovery.d.ts +11 -2
  23. package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
  24. package/dist/agent/components/threads-button.d.ts +1 -1
  25. package/dist/agent/components/threads-button.d.ts.map +1 -1
  26. package/dist/agent/components/transcript.d.ts.map +1 -1
  27. package/dist/agent/conversation.d.ts +3 -6
  28. package/dist/agent/conversation.d.ts.map +1 -1
  29. package/dist/agent/delegation/interpret.d.ts +5 -0
  30. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  31. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  32. package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
  33. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  34. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  35. package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
  36. package/dist/agent/i18n/en.d.ts +68 -0
  37. package/dist/agent/i18n/en.d.ts.map +1 -1
  38. package/dist/agent/i18n/fr.d.ts.map +1 -1
  39. package/dist/agent/i18n/index.d.ts +114 -0
  40. package/dist/agent/i18n/index.d.ts.map +1 -1
  41. package/dist/agent/inbox-handoff.d.ts +10 -0
  42. package/dist/agent/inbox-handoff.d.ts.map +1 -0
  43. package/dist/agent/live-run.d.ts +8 -1
  44. package/dist/agent/live-run.d.ts.map +1 -1
  45. package/dist/agent/search/interpret.d.ts +101 -0
  46. package/dist/agent/search/interpret.d.ts.map +1 -0
  47. package/dist/agent/search/search-tool-view.d.ts +10 -0
  48. package/dist/agent/search/search-tool-view.d.ts.map +1 -0
  49. package/dist/agent/thread-state.d.ts +26 -0
  50. package/dist/agent/thread-state.d.ts.map +1 -0
  51. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  52. package/dist/agent/tool-views/registry.d.ts +5 -6
  53. package/dist/agent/tool-views/registry.d.ts.map +1 -1
  54. package/dist/agent/types.d.ts +5 -1
  55. package/dist/agent/types.d.ts.map +1 -1
  56. package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
  57. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  58. package/dist/artifacts/card-preview.d.ts.map +1 -1
  59. package/dist/artifacts/editor/block-handle.d.ts +20 -0
  60. package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
  61. package/dist/artifacts/editor/blocks.d.ts +34 -0
  62. package/dist/artifacts/editor/blocks.d.ts.map +1 -0
  63. package/dist/artifacts/editor/callout-view.d.ts +7 -0
  64. package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
  65. package/dist/artifacts/editor/document-editor.d.ts +30 -0
  66. package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
  67. package/dist/artifacts/editor/figure-view.d.ts +12 -0
  68. package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
  69. package/dist/artifacts/editor/find-blocks.d.ts +6 -0
  70. package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
  71. package/dist/artifacts/editor/markdown-document.d.ts +12 -0
  72. package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
  73. package/dist/artifacts/editor/messages.d.ts +4 -0
  74. package/dist/artifacts/editor/messages.d.ts.map +1 -0
  75. package/dist/artifacts/editor/schema.d.ts +21 -0
  76. package/dist/artifacts/editor/schema.d.ts.map +1 -0
  77. package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
  78. package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
  79. package/dist/artifacts/editor/slash-menu.d.ts +43 -0
  80. package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
  81. package/dist/artifacts/editor/upload.d.ts +12 -0
  82. package/dist/artifacts/editor/upload.d.ts.map +1 -0
  83. package/dist/artifacts/file-source.d.ts +5 -0
  84. package/dist/artifacts/file-source.d.ts.map +1 -1
  85. package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
  86. package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
  87. package/dist/artifacts/frame-editor/commands.d.ts +93 -0
  88. package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
  89. package/dist/artifacts/frame-editor/entry.d.ts +2 -0
  90. package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
  91. package/dist/artifacts/frame-editor/frame.d.ts +5 -0
  92. package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
  93. package/dist/artifacts/frame-editor/keys.d.ts +8 -0
  94. package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
  95. package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
  96. package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
  97. package/dist/artifacts/frame-editor/schema.d.ts +34 -0
  98. package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
  99. package/dist/artifacts/frame-editor/style.d.ts +2 -0
  100. package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
  101. package/dist/artifacts/frame.d.ts +2 -2
  102. package/dist/artifacts/frame.d.ts.map +1 -1
  103. package/dist/artifacts/live/boards.d.ts +2 -0
  104. package/dist/artifacts/live/boards.d.ts.map +1 -1
  105. package/dist/artifacts/live/document.d.ts +32 -0
  106. package/dist/artifacts/live/document.d.ts.map +1 -0
  107. package/dist/artifacts/live/header.d.ts +4 -4
  108. package/dist/artifacts/live/header.d.ts.map +1 -1
  109. package/dist/artifacts/live/presence.d.ts.map +1 -1
  110. package/dist/artifacts/live/session.d.ts +2 -0
  111. package/dist/artifacts/live/session.d.ts.map +1 -1
  112. package/dist/artifacts/live/view.d.ts +4 -3
  113. package/dist/artifacts/live/view.d.ts.map +1 -1
  114. package/dist/artifacts/messages.d.ts +226 -2
  115. package/dist/artifacts/messages.d.ts.map +1 -1
  116. package/dist/artifacts/pdf.d.ts +8 -0
  117. package/dist/artifacts/pdf.d.ts.map +1 -0
  118. package/dist/artifacts/queries.d.ts +80 -0
  119. package/dist/artifacts/queries.d.ts.map +1 -1
  120. package/dist/artifacts/references/references.d.ts +3 -3
  121. package/dist/artifacts/references/references.d.ts.map +1 -1
  122. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
  123. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
  124. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
  125. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
  126. package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
  127. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
  128. package/dist/artifacts/renderers/designed-document.d.ts +28 -0
  129. package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
  130. package/dist/artifacts/renderers/document-tree.d.ts +2 -0
  131. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
  132. package/dist/artifacts/renderers/document.d.ts +9 -1
  133. package/dist/artifacts/renderers/document.d.ts.map +1 -1
  134. package/dist/artifacts/renderers/live-frame.d.ts +145 -0
  135. package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
  136. package/dist/artifacts/renderers/page-editor.d.ts +16 -0
  137. package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
  138. package/dist/artifacts/renderers/page.d.ts +10 -1
  139. package/dist/artifacts/renderers/page.d.ts.map +1 -1
  140. package/dist/artifacts/viewer.d.ts.map +1 -1
  141. package/dist/{chunk-kymx9y5e.js → chunk-4fex83k2.js} +10874 -4690
  142. package/dist/chunk-4fex83k2.js.map +239 -0
  143. package/dist/{chunk-yrcm1pbg.js → chunk-4wm09prf.js} +491 -2128
  144. package/dist/chunk-4wm09prf.js.map +27 -0
  145. package/dist/{chunk-pxd07kvx.js → chunk-5sgac68y.js} +1 -1
  146. package/dist/{chunk-970s5nkn.js → chunk-69qgh20f.js} +1 -1
  147. package/dist/chunk-y51c4tsz.js +11 -0
  148. package/dist/chunk-y51c4tsz.js.map +10 -0
  149. package/dist/index.d.ts +2 -1
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +11 -6
  152. package/dist/index.js.map +5 -5
  153. package/dist/pages/console/data/messages.d.ts +6 -0
  154. package/dist/pages/console/data/messages.d.ts.map +1 -1
  155. package/dist/pages/console/data/shared.d.ts.map +1 -1
  156. package/dist/pages.js +12 -5
  157. package/dist/pages.js.map +6 -6
  158. package/dist/shell/search-command.d.ts.map +1 -1
  159. package/package.json +22 -5
  160. package/src/agent/activity-label.ts +3 -0
  161. package/src/agent/agent-chat.tsx +56 -37
  162. package/src/agent/agent-execution-trace.tsx +2 -2
  163. package/src/agent/agent-panel.tsx +6 -4
  164. package/src/agent/agent.css +254 -0
  165. package/src/agent/artifact-panel.tsx +77 -22
  166. package/src/agent/components/composer-settings.tsx +20 -10
  167. package/src/agent/components/composer.tsx +342 -104
  168. package/src/agent/components/context-meter.tsx +7 -3
  169. package/src/agent/components/conversation-panel.tsx +69 -29
  170. package/src/agent/components/message-parts.tsx +367 -59
  171. package/src/agent/components/message-view.tsx +12 -2
  172. package/src/agent/components/pending-messages.tsx +338 -0
  173. package/src/agent/components/sandbox-recovery.tsx +36 -17
  174. package/src/agent/components/threads-button.tsx +3 -2
  175. package/src/agent/components/transcript.tsx +63 -34
  176. package/src/agent/conversation.ts +203 -54
  177. package/src/agent/delegation/interpret.ts +31 -7
  178. package/src/agent/hooks/use-agent-conversation.ts +348 -100
  179. package/src/agent/hooks/use-thread-stream.ts +10 -0
  180. package/src/agent/i18n/en.ts +87 -11
  181. package/src/agent/i18n/fr.ts +83 -12
  182. package/src/agent/inbox-handoff.ts +47 -0
  183. package/src/agent/live-run.ts +23 -2
  184. package/src/agent/react-router.tsx +2 -2
  185. package/src/agent/search/interpret.ts +367 -0
  186. package/src/agent/search/search-tool-view.tsx +235 -0
  187. package/src/agent/thread-state.ts +114 -0
  188. package/src/agent/tool-views/built-in.tsx +16 -0
  189. package/src/agent/tool-views/registry.tsx +28 -2
  190. package/src/agent/types.ts +7 -0
  191. package/src/agent/view-file/view-file-tool-view.tsx +33 -19
  192. package/src/artifacts/artifacts.css +398 -0
  193. package/src/artifacts/card-preview.tsx +6 -1
  194. package/src/artifacts/editor/block-handle.tsx +278 -0
  195. package/src/artifacts/editor/blocks.ts +216 -0
  196. package/src/artifacts/editor/callout-view.tsx +31 -0
  197. package/src/artifacts/editor/document-editor.tsx +484 -0
  198. package/src/artifacts/editor/figure-view.tsx +66 -0
  199. package/src/artifacts/editor/find-blocks.ts +19 -0
  200. package/src/artifacts/editor/markdown-document.tsx +72 -0
  201. package/src/artifacts/editor/messages.ts +4 -0
  202. package/src/artifacts/editor/schema.ts +159 -0
  203. package/src/artifacts/editor/selection-toolbar.tsx +364 -0
  204. package/src/artifacts/editor/slash-menu.tsx +251 -0
  205. package/src/artifacts/editor/upload.ts +40 -0
  206. package/src/artifacts/file-source.ts +11 -0
  207. package/src/artifacts/frame-editor/bundle.ts +8 -0
  208. package/src/artifacts/frame-editor/commands.ts +565 -0
  209. package/src/artifacts/frame-editor/entry.ts +6 -0
  210. package/src/artifacts/frame-editor/frame.ts +847 -0
  211. package/src/artifacts/frame-editor/generated/editor.txt +149 -0
  212. package/src/artifacts/frame-editor/generated.d.ts +5 -0
  213. package/src/artifacts/frame-editor/keys.ts +323 -0
  214. package/src/artifacts/frame-editor/protocol.ts +151 -0
  215. package/src/artifacts/frame-editor/schema.ts +293 -0
  216. package/src/artifacts/frame-editor/style.ts +58 -0
  217. package/src/artifacts/frame.tsx +11 -3
  218. package/src/artifacts/live/boards.ts +46 -3
  219. package/src/artifacts/live/document.ts +89 -0
  220. package/src/artifacts/live/header.tsx +9 -14
  221. package/src/artifacts/live/presence.ts +5 -1
  222. package/src/artifacts/live/session.ts +4 -2
  223. package/src/artifacts/live/view.ts +14 -8
  224. package/src/artifacts/messages.ts +138 -2
  225. package/src/artifacts/pdf.ts +50 -0
  226. package/src/artifacts/references/references.tsx +46 -11
  227. package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
  228. package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
  229. package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
  230. package/src/artifacts/renderers/canvas/comments.ts +8 -4
  231. package/src/artifacts/renderers/designed-document.tsx +277 -0
  232. package/src/artifacts/renderers/document-tree.ts +9 -0
  233. package/src/artifacts/renderers/document.tsx +13 -102
  234. package/src/artifacts/renderers/live-frame.ts +163 -0
  235. package/src/artifacts/renderers/page-editor.tsx +613 -0
  236. package/src/artifacts/renderers/page.tsx +21 -4
  237. package/src/artifacts/viewer.tsx +87 -41
  238. package/src/index.ts +6 -0
  239. package/src/pages/console/data/messages.ts +6 -0
  240. package/src/pages/console/data/projections.tsx +4 -0
  241. package/src/pages/console/data/shared.tsx +1 -0
  242. package/src/pages/console/ontology/lineage/trail.tsx +3 -0
  243. package/src/shell/search-command.tsx +2 -0
  244. package/dist/chunk-kymx9y5e.js.map +0 -211
  245. package/dist/chunk-yrcm1pbg.js.map +0 -34
  246. /package/dist/{chunk-pxd07kvx.js.map → chunk-5sgac68y.js.map} +0 -0
  247. /package/dist/{chunk-970s5nkn.js.map → chunk-69qgh20f.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { useLocale } from "@sixb/ui/lib/i18n"
2
2
  import { cn } from "@sixb/ui/lib/utils"
3
- import { type ReactNode, useState } from "react"
3
+ import { memo, type ReactNode, useState } from "react"
4
4
  import { formatRelativeTime, formatTokenCount, relativeTime } from "../format"
5
5
  import { useAgentMessages } from "../i18n"
6
6
  import type { AgentMessages } from "../i18n/en"
@@ -78,7 +78,11 @@ const PART_COLORS: Readonly<Record<ContextPartName, string>> = {
78
78
  * conversation uses, the room left, the share read from cache and the last condensing. Nothing
79
79
  * shows before the first answer.
80
80
  */
81
- export function ContextMeter({ context, modelName, condensing = false }: ContextMeterProps) {
81
+ export const ContextMeter = memo(function ContextMeter({
82
+ context,
83
+ modelName,
84
+ condensing = false,
85
+ }: ContextMeterProps) {
82
86
  const messages = useAgentMessages().contextMeter
83
87
  const locale = useLocale()
84
88
  const [open, setOpen] = useState(false)
@@ -136,7 +140,7 @@ export function ContextMeter({ context, modelName, condensing = false }: Context
136
140
  />
137
141
  </ComposerMenu>
138
142
  )
139
- }
143
+ })
140
144
 
141
145
  /** A share as the meter writes it: `2%`, `<1%` for a sliver, `104%` past the limit. */
142
146
  function sharePercent(share: number, locale: string): string {
@@ -1,15 +1,18 @@
1
1
  import { Button, Spinner } from "@sixb/ui/components"
2
2
  import { cn } from "@sixb/ui/lib/utils"
3
3
  import { Plus } from "lucide-react"
4
- import type { ReactNode } from "react"
4
+ import { memo, type ReactNode } from "react"
5
5
  import type { ConversationComposerProps } from "../hooks/use-agent-conversation"
6
6
  import { useAgentMessages } from "../i18n"
7
7
  import { QuestionComposer, type QuestionComposerProps } from "../questions/question-composer"
8
8
  import type { Agent, AgentContextInput, AgentThread } from "../types"
9
9
  import { Composer, type ComposerProps } from "./composer"
10
+ import { PendingMessages, type PendingMessagesProps } from "./pending-messages"
10
11
  import { ThreadsButton } from "./threads-button"
11
12
  import { Transcript, type TranscriptProps } from "./transcript"
12
13
 
14
+ const EMPTY_AMBIENT_CONTEXT: readonly AgentContextInput[] = []
15
+
13
16
  export interface ConversationPanelProps {
14
17
  readonly sandboxRecovery?: ReactNode
15
18
  /** A line above the composer, such as whose shared conversation this is. */
@@ -22,6 +25,8 @@ export interface ConversationPanelProps {
22
25
  readonly composer: ConversationComposerProps & Pick<ComposerProps, "newThreadControls">
23
26
  /** The Agent's question, which takes the composer's place while set. */
24
27
  readonly question?: QuestionComposerProps | null
28
+ /** What waits beside the running turn, above the composer. */
29
+ readonly pending?: PendingMessagesProps
25
30
  readonly messagesLoading: boolean
26
31
  readonly messagesError: string | null
27
32
  /** The selected durable thread, or null while composing a new one. */
@@ -46,6 +51,7 @@ export function ConversationPanel({
46
51
  transcript,
47
52
  composer,
48
53
  question = null,
54
+ pending,
49
55
  messagesLoading,
50
56
  messagesError,
51
57
  currentThread,
@@ -54,7 +60,7 @@ export function ConversationPanel({
54
60
  onNewChat,
55
61
  onOpenThreads,
56
62
  composerPlaceholder,
57
- ambientContext = [],
63
+ ambientContext = EMPTY_AMBIENT_CONTEXT,
58
64
  compact = false,
59
65
  welcomeContent,
60
66
  headerActions,
@@ -88,6 +94,11 @@ export function ConversationPanel({
88
94
  ) : null}
89
95
  {/* Kept while the question asks, so a draft written before it is still there after. */}
90
96
  <div className={asking ? "hidden" : "contents"}>
97
+ <PendingMessages
98
+ threadId={currentThread?.id ?? null}
99
+ {...pending}
100
+ className={compact ? "px-4 pb-2" : cn("pb-2", wideClassName)}
101
+ />
91
102
  <Composer
92
103
  {...composer}
93
104
  placeholder={composerPlaceholder}
@@ -99,35 +110,17 @@ export function ConversationPanel({
99
110
  </>
100
111
  )
101
112
 
102
- const threadsButton = onOpenThreads ? (
103
- <ThreadsButton
104
- currentThreadId={currentThread?.id ?? null}
105
- runningThreadCount={runningThreadCount}
106
- waitingThreadIds={waitingThreadIds}
107
- onOpen={onOpenThreads}
108
- />
109
- ) : null
110
-
111
113
  return (
112
114
  <div className="relative flex h-full min-h-0 flex-col" data-thread-id={currentThread?.id}>
113
- <header
114
- data-agent-conversation-header=""
115
- className={cn("flex shrink-0 items-center gap-1 px-2.5 py-2.5", compact && "h-11 py-1.5")}
116
- >
117
- <div className="ml-auto flex items-center gap-1">
118
- {headerActions}
119
- {threadsButton}
120
- <Button
121
- variant="ghost"
122
- size="icon-lg"
123
- onClick={onNewChat}
124
- aria-label={labels.threads.new}
125
- className="[&_svg]:size-5"
126
- >
127
- <Plus />
128
- </Button>
129
- </div>
130
- </header>
115
+ <ConversationHeader
116
+ compact={compact}
117
+ currentThreadId={currentThread?.id ?? null}
118
+ runningThreadCount={runningThreadCount}
119
+ waitingThreadIds={waitingThreadIds}
120
+ headerActions={headerActions}
121
+ onOpenThreads={onOpenThreads}
122
+ onNewChat={onNewChat}
123
+ />
131
124
 
132
125
  {showWelcome ? (
133
126
  <div
@@ -235,3 +228,50 @@ function LoadingInline({ label }: { label: string }) {
235
228
  </div>
236
229
  )
237
230
  }
231
+
232
+ const ConversationHeader = memo(function ConversationHeader({
233
+ compact,
234
+ currentThreadId,
235
+ runningThreadCount,
236
+ waitingThreadIds,
237
+ headerActions,
238
+ onOpenThreads,
239
+ onNewChat,
240
+ }: {
241
+ readonly compact: boolean
242
+ readonly currentThreadId: string | null
243
+ readonly runningThreadCount: number
244
+ readonly waitingThreadIds?: ReadonlySet<string>
245
+ readonly headerActions?: ReactNode
246
+ readonly onOpenThreads?: () => void
247
+ readonly onNewChat: () => void
248
+ }) {
249
+ const labels = useAgentMessages()
250
+ return (
251
+ <header
252
+ data-agent-conversation-header=""
253
+ className={cn("flex shrink-0 items-center gap-1 px-2.5 py-2.5", compact && "h-11 py-1.5")}
254
+ >
255
+ <div className="ml-auto flex items-center gap-1">
256
+ {headerActions}
257
+ {onOpenThreads ? (
258
+ <ThreadsButton
259
+ currentThreadId={currentThreadId}
260
+ runningThreadCount={runningThreadCount}
261
+ waitingThreadIds={waitingThreadIds}
262
+ onOpen={onOpenThreads}
263
+ />
264
+ ) : null}
265
+ <Button
266
+ variant="ghost"
267
+ size="icon-lg"
268
+ onClick={onNewChat}
269
+ aria-label={labels.threads.new}
270
+ className="[&_svg]:size-5"
271
+ >
272
+ <Plus />
273
+ </Button>
274
+ </div>
275
+ </header>
276
+ )
277
+ })
@@ -1,8 +1,37 @@
1
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
1
+ import {
2
+ Collapsible,
3
+ CollapsibleContent,
4
+ CollapsibleTrigger,
5
+ Drawer,
6
+ DrawerContent,
7
+ DrawerDescription,
8
+ DrawerTitle,
9
+ DrawerTrigger,
10
+ Markdown,
11
+ type MarkdownProps,
12
+ PHONE_QUERY,
13
+ } from "@sixb/ui/components"
2
14
  import { useLocale } from "@sixb/ui/lib/i18n"
3
15
  import { cn } from "@sixb/ui/lib/utils"
4
- import { ArrowUpRight, BookmarkCheck, ChevronRight, FileX, Wrench } from "lucide-react"
5
- import { memo, useState } from "react"
16
+ import {
17
+ ArrowDown,
18
+ ArrowUpRight,
19
+ BookmarkCheck,
20
+ ChevronRight,
21
+ FileX,
22
+ Wrench,
23
+ X,
24
+ } from "lucide-react"
25
+ import {
26
+ memo,
27
+ type ReactNode,
28
+ useCallback,
29
+ useEffect,
30
+ useLayoutEffect,
31
+ useRef,
32
+ useState,
33
+ type WheelEvent,
34
+ } from "react"
6
35
  import { formatFileSize } from "../../artifacts/file-size"
7
36
  import { ReferencingMarkdown } from "../../artifacts/references/references"
8
37
  import { viewerTargetKey } from "../../artifacts/target"
@@ -214,18 +243,48 @@ const FileBlock = memo(function FileBlock({
214
243
  * the newest step, keeping the main transcript informative without exposing debug detail. Inside,
215
244
  * items flow in one indented column and can expand inline when deeper inspection is useful.
216
245
  */
217
- function WorkGroup({
218
- parts,
219
- inProgress,
220
- nested = false,
221
- }: {
222
- parts: readonly NormalizedPart[]
223
- inProgress: boolean
224
- /** In a sub-agent's thread: closed like the chat's own work line, and without a scroll once open. */
225
- nested?: boolean
226
- }) {
246
+ interface WorkGroupProps {
247
+ readonly parts: readonly NormalizedPart[]
248
+ readonly inProgress: boolean
249
+ /** In a sub-agent's thread: closed like the chat's work line, without an inner scroll. */
250
+ readonly nested?: boolean
251
+ }
252
+
253
+ function sameElements<T>(a: readonly T[], b: readonly T[]): boolean {
254
+ if (a === b) return true
255
+ if (a.length !== b.length) return false
256
+ for (let i = 0; i < a.length; i++) {
257
+ if (!Object.is(a[i], b[i])) return false
258
+ }
259
+ return true
260
+ }
261
+
262
+ const DETACH_THRESHOLD_PX = 24
263
+ const REATTACH_THRESHOLD_PX = 12
264
+ const REASONING_COMPONENTS: MarkdownProps["components"] = { img: () => null }
265
+
266
+ function usePhoneSheet(enabled: boolean): boolean {
267
+ const [phone, setPhone] = useState(false)
268
+
269
+ useEffect(() => {
270
+ if (!enabled || typeof window === "undefined" || typeof window.matchMedia !== "function") {
271
+ setPhone(false)
272
+ return
273
+ }
274
+ const mql = window.matchMedia(PHONE_QUERY)
275
+ const onChange = () => setPhone(mql.matches)
276
+ setPhone(mql.matches)
277
+ mql.addEventListener("change", onChange)
278
+ return () => mql.removeEventListener("change", onChange)
279
+ }, [enabled])
280
+
281
+ return enabled && phone
282
+ }
283
+
284
+ function WorkGroupView({ parts, inProgress, nested = false }: WorkGroupProps) {
227
285
  const messages = useAgentMessages()
228
286
  const [open, setOpen] = useState(false)
287
+ const phoneSheet = usePhoneSheet(!nested)
229
288
  const sources = collectWebSources(parts)
230
289
  const searches = parts.flatMap((part) =>
231
290
  part.kind === "tool" && part.tool.toolName === "web_search" ? [part.tool] : []
@@ -250,39 +309,16 @@ function WorkGroup({
250
309
  // while it waits on the reader, and once it is done.
251
310
  const label = hasTools ? messages.activity.steps(toolCount) : messages.activity.reasoning
252
311
 
253
- return (
254
- <Collapsible open={open} onOpenChange={setOpen} className="max-w-full">
255
- <CollapsibleTrigger
256
- className={cn(
257
- ACTIVITY_STATUS_ROW_CLASS_NAME,
258
- "outline-none transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
259
- )}
260
- >
261
- {inProgress ? (
262
- <ActivityStatusText label={liveLabel} className="shimmer motion-reduce:animate-none" />
263
- ) : (
264
- <span>{label}</span>
265
- )}
266
- <ChevronRight className="size-3.5 shrink-0 opacity-50 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
267
- </CollapsibleTrigger>
268
- <CollapsibleContent>
269
- <div
270
- className={cn(
271
- "mt-2 ml-1 flex flex-col gap-3 border-l border-border py-0.5 pr-2 pl-3.5",
272
- !nested && "scrollbar-thin max-h-[min(24rem,50vh)] overflow-y-auto overscroll-contain"
273
- )}
274
- >
275
- {parts.map((part, index) => {
276
- if (part.kind === "reasoning") {
277
- return <GroupReasoning key={index} text={part.text} streaming={part.streaming} />
278
- }
279
- if (part.kind === "tool") {
280
- return <ToolCallRow key={index} tool={part.tool} parts={parts} />
281
- }
282
- return null
283
- })}
284
- </div>
285
- </CollapsibleContent>
312
+ const triggerLabel = inProgress ? (
313
+ <ActivityStatusText label={liveLabel} className="shimmer motion-reduce:animate-none" />
314
+ ) : (
315
+ <span>{label}</span>
316
+ )
317
+
318
+ const stepsContent = <WorkStepsList parts={parts} />
319
+
320
+ const afterTrigger = (
321
+ <>
286
322
  {made.length > 0 ? (
287
323
  <div className="mt-3 flex flex-col gap-5">
288
324
  {made.map(({ media, running }, index) => (
@@ -300,20 +336,287 @@ function WorkGroup({
300
336
  {searchFailed ? messages.activity.searchFailedHint : messages.activity.noSources}
301
337
  </p>
302
338
  ) : null}
339
+ </>
340
+ )
341
+
342
+ if (phoneSheet) {
343
+ return (
344
+ <div className="max-w-full">
345
+ <Drawer open={open} onOpenChange={setOpen}>
346
+ <DrawerTrigger asChild>
347
+ <button
348
+ type="button"
349
+ data-state={open ? "open" : "closed"}
350
+ className={cn(
351
+ ACTIVITY_STATUS_ROW_CLASS_NAME,
352
+ "outline-none transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
353
+ )}
354
+ >
355
+ {triggerLabel}
356
+ <ChevronRight className="size-3.5 shrink-0 opacity-50 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
357
+ </button>
358
+ </DrawerTrigger>
359
+ <DrawerContent data-work-sheet="" className="max-h-[82dvh] outline-none">
360
+ <div className="flex shrink-0 items-center justify-between gap-3 border-b border-border/60 px-4 pt-3 pb-2.5">
361
+ <div className="flex min-w-0 flex-1 items-center gap-2">
362
+ <DrawerTitle className="min-w-0 truncate text-sm font-semibold text-foreground">
363
+ {inProgress ? (
364
+ <ActivityStatusText
365
+ label={liveLabel}
366
+ className="shimmer motion-reduce:animate-none"
367
+ />
368
+ ) : (
369
+ label
370
+ )}
371
+ </DrawerTitle>
372
+ {inProgress && hasTools ? (
373
+ <span className="shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground">
374
+ {label}
375
+ </span>
376
+ ) : null}
377
+ </div>
378
+ <DrawerDescription className="sr-only">{label}</DrawerDescription>
379
+ <button
380
+ type="button"
381
+ onClick={() => setOpen(false)}
382
+ aria-label={messages.artifacts.close}
383
+ className="flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
384
+ >
385
+ <X className="size-4" aria-hidden="true" />
386
+ </button>
387
+ </div>
388
+ <WorkStepsScroll inProgress={inProgress} mobile>
389
+ {stepsContent}
390
+ </WorkStepsScroll>
391
+ </DrawerContent>
392
+ </Drawer>
393
+ {afterTrigger}
394
+ </div>
395
+ )
396
+ }
397
+
398
+ return (
399
+ <Collapsible open={open} onOpenChange={setOpen} className="max-w-full">
400
+ <CollapsibleTrigger
401
+ className={cn(
402
+ ACTIVITY_STATUS_ROW_CLASS_NAME,
403
+ "outline-none transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
404
+ )}
405
+ >
406
+ {triggerLabel}
407
+ <ChevronRight className="size-3.5 shrink-0 opacity-50 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
408
+ </CollapsibleTrigger>
409
+ <CollapsibleContent>
410
+ {nested ? (
411
+ <div className="mt-2 ml-1 flex flex-col gap-3 border-l border-border py-0.5 pr-2 pl-3.5">
412
+ {stepsContent}
413
+ </div>
414
+ ) : (
415
+ <WorkStepsScroll inProgress={inProgress}>{stepsContent}</WorkStepsScroll>
416
+ )}
417
+ </CollapsibleContent>
418
+ {afterTrigger}
303
419
  </Collapsible>
304
420
  )
305
421
  }
306
422
 
307
- /** Reasoning inside a work group: plain, quiet text that flows with the rest of the chain. */
308
- function GroupReasoning({ text, streaming }: { text: string; streaming: boolean }) {
423
+ function WorkStepsList({ parts }: { readonly parts: readonly NormalizedPart[] }) {
424
+ return (
425
+ <>
426
+ {parts.map((part, index) => {
427
+ if (part.kind === "reasoning") {
428
+ return <GroupReasoning key={index} text={part.text} streaming={part.streaming} />
429
+ }
430
+ if (part.kind === "tool") {
431
+ return <ToolCallRow key={index} tool={part.tool} parts={parts} />
432
+ }
433
+ return null
434
+ })}
435
+ </>
436
+ )
437
+ }
438
+
439
+ function WorkStepsScroll({
440
+ inProgress,
441
+ mobile = false,
442
+ children,
443
+ }: {
444
+ readonly inProgress: boolean
445
+ readonly mobile?: boolean
446
+ readonly children: ReactNode
447
+ }) {
448
+ const messages = useAgentMessages().activity
449
+ const scrollRef = useRef<HTMLDivElement>(null)
450
+ const contentRef = useRef<HTMLDivElement>(null)
451
+ const followingRef = useRef(inProgress)
452
+ const lastScrollTopRef = useRef(0)
453
+ const [detached, setDetached] = useState(false)
454
+
455
+ const syncEdges = useCallback((box: HTMLDivElement) => {
456
+ const remaining = box.scrollHeight - box.scrollTop - box.clientHeight
457
+ box.toggleAttribute("data-fade-top", box.scrollTop > 2)
458
+ box.toggleAttribute("data-fade-bottom", remaining > 2)
459
+ return remaining
460
+ }, [])
461
+
462
+ const pinToBottom = useCallback(
463
+ (box: HTMLDivElement) => {
464
+ box.scrollTop = Math.max(0, box.scrollHeight - box.clientHeight)
465
+ lastScrollTopRef.current = box.scrollTop
466
+ syncEdges(box)
467
+ },
468
+ [syncEdges]
469
+ )
470
+
471
+ // Active turns open pinned to the live bottom before paint; settled turns open at the top.
472
+ useLayoutEffect(() => {
473
+ const box = scrollRef.current
474
+ if (!box) return
475
+ if (inProgress) {
476
+ followingRef.current = true
477
+ setDetached(false)
478
+ pinToBottom(box)
479
+ } else {
480
+ followingRef.current = false
481
+ setDetached(false)
482
+ lastScrollTopRef.current = box.scrollTop
483
+ syncEdges(box)
484
+ }
485
+ }, [inProgress, pinToBottom, syncEdges])
486
+
487
+ // Follow newly streamed reasoning deltas and tool rows until the reader scrolls upward.
488
+ // biome-ignore lint/correctness/useExhaustiveDependencies: children drives synchronous follow on stream updates
489
+ useLayoutEffect(() => {
490
+ const box = scrollRef.current
491
+ if (!box) return
492
+ if (inProgress && followingRef.current) {
493
+ pinToBottom(box)
494
+ } else {
495
+ syncEdges(box)
496
+ }
497
+ }, [children, inProgress, pinToBottom, syncEdges])
498
+
499
+ useEffect(() => {
500
+ const box = scrollRef.current
501
+ const inner = contentRef.current
502
+ if (!box || !inner) return
503
+
504
+ const onResize = () => {
505
+ if (inProgress && followingRef.current) {
506
+ pinToBottom(box)
507
+ } else {
508
+ const remaining = syncEdges(box)
509
+ if (inProgress && !followingRef.current && remaining > DETACH_THRESHOLD_PX) {
510
+ setDetached((prev) => (prev ? prev : true))
511
+ }
512
+ }
513
+ }
514
+
515
+ const onScroll = () => {
516
+ const movedUp = box.scrollTop < lastScrollTopRef.current - 1
517
+ lastScrollTopRef.current = box.scrollTop
518
+ const remaining = syncEdges(box)
519
+ if (remaining <= REATTACH_THRESHOLD_PX) {
520
+ followingRef.current = true
521
+ setDetached((prev) => (prev ? false : prev))
522
+ } else if (movedUp && remaining > DETACH_THRESHOLD_PX) {
523
+ followingRef.current = false
524
+ if (inProgress) setDetached((prev) => (prev ? prev : true))
525
+ }
526
+ }
527
+
528
+ const observer = new ResizeObserver(onResize)
529
+ observer.observe(inner)
530
+ observer.observe(box)
531
+ box.addEventListener("scroll", onScroll, { passive: true })
532
+ return () => {
533
+ observer.disconnect()
534
+ box.removeEventListener("scroll", onScroll)
535
+ }
536
+ }, [inProgress, pinToBottom, syncEdges])
537
+
538
+ const releaseOnUpwardWheel = (event: WheelEvent<HTMLDivElement>) => {
539
+ if (event.deltaY >= 0) return
540
+ const box = scrollRef.current
541
+ if (!box || box.scrollHeight <= box.clientHeight) return
542
+ followingRef.current = false
543
+ if (inProgress && box.scrollHeight - box.scrollTop - box.clientHeight > REATTACH_THRESHOLD_PX) {
544
+ setDetached(true)
545
+ }
546
+ }
547
+
548
+ const jumpToLatest = () => {
549
+ const box = scrollRef.current
550
+ followingRef.current = true
551
+ setDetached(false)
552
+ if (box) pinToBottom(box)
553
+ }
554
+
555
+ return (
556
+ <div className={cn("relative min-h-0", mobile && "flex flex-1 flex-col")}>
557
+ <div
558
+ ref={scrollRef}
559
+ data-work-scroll=""
560
+ onWheel={releaseOnUpwardWheel}
561
+ className={cn(
562
+ "sixb-work-scroll scrollbar-thin overflow-y-auto overscroll-contain",
563
+ mobile
564
+ ? "max-h-[min(64dvh,32rem)] px-4 pt-3 pb-[max(1rem,env(safe-area-inset-bottom))]"
565
+ : "mt-2 ml-1 max-h-[min(24rem,50vh)] border-l border-border py-0.5 pr-2 pl-3.5"
566
+ )}
567
+ >
568
+ <div ref={contentRef} className="flex flex-col gap-3">
569
+ {children}
570
+ </div>
571
+ </div>
572
+ {inProgress && detached ? (
573
+ <button
574
+ type="button"
575
+ data-work-latest=""
576
+ onClick={jumpToLatest}
577
+ className="sixb-work-latest absolute bottom-2 left-1/2 z-10 flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium text-foreground outline-none transition-transform hover:scale-[1.02] active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-ring"
578
+ >
579
+ <span
580
+ className="size-1.5 rounded-full bg-sky-500 motion-safe:animate-pulse"
581
+ aria-hidden="true"
582
+ />
583
+ <span>{messages.latest}</span>
584
+ <ArrowDown className="size-3 text-muted-foreground" aria-hidden="true" />
585
+ </button>
586
+ ) : null}
587
+ </div>
588
+ )
589
+ }
590
+
591
+ function sameWorkGroup(prev: WorkGroupProps, next: WorkGroupProps): boolean {
592
+ return (
593
+ prev.inProgress === next.inProgress &&
594
+ (prev.nested ?? false) === (next.nested ?? false) &&
595
+ sameElements(prev.parts, next.parts)
596
+ )
597
+ }
598
+
599
+ const WorkGroup = memo(WorkGroupView, sameWorkGroup)
600
+
601
+ /** Reasoning inside a work group: structured Markdown notes subordinate to the main answer. */
602
+ const GroupReasoning = memo(function GroupReasoning({
603
+ text,
604
+ streaming,
605
+ }: {
606
+ text: string
607
+ streaming: boolean
608
+ }) {
309
609
  if (!text.trim()) return null
310
610
  return (
311
- <p className="text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground/80">
611
+ <Markdown
612
+ className="sixb-reasoning-prose"
613
+ components={REASONING_COMPONENTS}
614
+ data-streaming={streaming ? "true" : undefined}
615
+ >
312
616
  {text}
313
- {streaming ? <span className="shimmer">▍</span> : null}
314
- </p>
617
+ </Markdown>
315
618
  )
316
- }
619
+ })
317
620
 
318
621
  /**
319
622
  * A single tool call within a work group. A project view placed in the work takes the row; else
@@ -321,14 +624,13 @@ function GroupReasoning({ text, streaming }: { text: string; streaming: boolean
321
624
  * inspector. All keep their bodies borderless and inline so an expanded result flows within the
322
625
  * group rather than reading as a nested dropdown.
323
626
  */
324
- function ToolCallRow({
325
- tool,
326
- parts,
327
- }: {
328
- tool: NormalizedTool
627
+ interface ToolCallRowProps {
628
+ readonly tool: NormalizedTool
329
629
  /** The rest of its work, which names the children a wait is for. */
330
- parts: readonly NormalizedPart[]
331
- }) {
630
+ readonly parts: readonly NormalizedPart[]
631
+ }
632
+
633
+ function ToolCallRowView({ tool, parts }: ToolCallRowProps) {
332
634
  const view = useAgentToolView(tool.toolName)
333
635
  const row =
334
636
  view?.placement === "work" ? (
@@ -350,6 +652,12 @@ function ToolCallRow({
350
652
  )
351
653
  }
352
654
 
655
+ function sameToolCallRow(prev: ToolCallRowProps, next: ToolCallRowProps): boolean {
656
+ return Object.is(prev.tool, next.tool) && sameElements(prev.parts, next.parts)
657
+ }
658
+
659
+ const ToolCallRow = memo(ToolCallRowView, sameToolCallRow)
660
+
353
661
  /**
354
662
  * Under a call whose output was too large for the model's context, the whole output it saved: it
355
663
  * opens beside the conversation, or in a new tab where there is no panel.
@@ -20,11 +20,12 @@ import {
20
20
  RotateCcw,
21
21
  Unplug,
22
22
  } from "lucide-react"
23
- import { memo, type ReactNode } from "react"
23
+ import { memo, type ReactNode, useLayoutEffect, useRef } from "react"
24
24
  import type { FileSource } from "../../artifacts/file-source"
25
25
  import type { AgentConversationMessage } from "../conversation"
26
26
  import { useAgentMessages } from "../i18n"
27
27
  import type { AgentMessages } from "../i18n/en"
28
+ import { riseFromTray } from "../inbox-handoff"
28
29
  import { type AuthorLabel, useMessageAuthors } from "../message-authors"
29
30
  import { isContinuableDiagnostic } from "../run-presentation"
30
31
  import type { AgentFileRef } from "../types"
@@ -74,10 +75,19 @@ function UserMessage({
74
75
  const text = textOf(message)
75
76
  const files = message.parts.flatMap((part) => (part.type === "file" ? [part] : []))
76
77
  const pending = message.status === "pending"
78
+ const ref = useRef<HTMLDivElement>(null)
79
+
80
+ // A message the turn just read comes from the tray into its place; its saved copy, which keeps
81
+ // the row, stays put.
82
+ // biome-ignore lint/correctness/useExhaustiveDependencies: only as it first appears
83
+ useLayoutEffect(() => {
84
+ if (message.status === "streaming" && ref.current) riseFromTray(ref.current, message.key)
85
+ }, [])
86
+
77
87
  if (!text && files.length === 0 && message.context.length === 0) return null
78
88
 
79
89
  return (
80
- <div className="flex flex-col items-end gap-1.5">
90
+ <div ref={ref} className="flex flex-col items-end gap-1.5">
81
91
  {continued ? null : <AuthorLine author={authors?.labelOf(message.author)} />}
82
92
  <ContextChips
83
93
  entries={message.context}