@sixb/app 0.1.14 → 0.1.16

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 (167) hide show
  1. package/dist/agent/agent-chat.d.ts +8 -1
  2. package/dist/agent/agent-chat.d.ts.map +1 -1
  3. package/dist/agent/agent-panel.d.ts +8 -1
  4. package/dist/agent/agent-panel.d.ts.map +1 -1
  5. package/dist/agent/agent-surface.d.ts +8 -1
  6. package/dist/agent/agent-surface.d.ts.map +1 -1
  7. package/dist/agent/approvals.d.ts +1 -4
  8. package/dist/agent/approvals.d.ts.map +1 -1
  9. package/dist/agent/artifact-panel.d.ts +21 -2
  10. package/dist/agent/artifact-panel.d.ts.map +1 -1
  11. package/dist/agent/components/activity-status.d.ts +1 -1
  12. package/dist/agent/components/activity-status.d.ts.map +1 -1
  13. package/dist/agent/components/agent-threads.d.ts +15 -0
  14. package/dist/agent/components/agent-threads.d.ts.map +1 -0
  15. package/dist/agent/components/approval-card.d.ts +4 -4
  16. package/dist/agent/components/approval-card.d.ts.map +1 -1
  17. package/dist/agent/components/approval-mode-chip.d.ts +4 -6
  18. package/dist/agent/components/approval-mode-chip.d.ts.map +1 -1
  19. package/dist/agent/components/auto-model-chip.d.ts +2 -3
  20. package/dist/agent/components/auto-model-chip.d.ts.map +1 -1
  21. package/dist/agent/components/composer-menu.d.ts +42 -0
  22. package/dist/agent/components/composer-menu.d.ts.map +1 -0
  23. package/dist/agent/components/composer.d.ts +8 -5
  24. package/dist/agent/components/composer.d.ts.map +1 -1
  25. package/dist/agent/components/conversation-panel.d.ts +3 -12
  26. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  27. package/dist/agent/components/dictation-bar.d.ts +13 -0
  28. package/dist/agent/components/dictation-bar.d.ts.map +1 -0
  29. package/dist/agent/components/message-parts.d.ts.map +1 -1
  30. package/dist/agent/components/message-view.d.ts +3 -1
  31. package/dist/agent/components/message-view.d.ts.map +1 -1
  32. package/dist/agent/components/model-controls.d.ts +15 -0
  33. package/dist/agent/components/model-controls.d.ts.map +1 -1
  34. package/dist/agent/components/model-picker-row.d.ts +9 -2
  35. package/dist/agent/components/model-picker-row.d.ts.map +1 -1
  36. package/dist/agent/components/participant-input.d.ts +7 -6
  37. package/dist/agent/components/participant-input.d.ts.map +1 -1
  38. package/dist/agent/components/thread-people.d.ts +4 -4
  39. package/dist/agent/components/thread-people.d.ts.map +1 -1
  40. package/dist/agent/components/threads-button.d.ts +14 -0
  41. package/dist/agent/components/threads-button.d.ts.map +1 -0
  42. package/dist/agent/conversation.d.ts +3 -1
  43. package/dist/agent/conversation.d.ts.map +1 -1
  44. package/dist/agent/delegation/child-card.d.ts +24 -11
  45. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  46. package/dist/agent/delegation/child-cards.d.ts +2 -2
  47. package/dist/agent/delegation/child-cards.d.ts.map +1 -1
  48. package/dist/agent/delegation/child-group.d.ts +5 -4
  49. package/dist/agent/delegation/child-group.d.ts.map +1 -1
  50. package/dist/agent/delegation/child-parts.d.ts +17 -18
  51. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  52. package/dist/agent/delegation/child-work.d.ts +0 -13
  53. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  54. package/dist/agent/delegation/interpret.d.ts +0 -5
  55. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  56. package/dist/agent/delegation/model.d.ts +12 -6
  57. package/dist/agent/delegation/model.d.ts.map +1 -1
  58. package/dist/agent/dictation.d.ts +16 -0
  59. package/dist/agent/dictation.d.ts.map +1 -0
  60. package/dist/agent/hooks/use-agent-conversation.d.ts +3 -270
  61. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  62. package/dist/agent/hooks/use-people-suggestions.d.ts +21 -0
  63. package/dist/agent/hooks/use-people-suggestions.d.ts.map +1 -0
  64. package/dist/agent/hooks/use-thread-lists.d.ts +220 -0
  65. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -0
  66. package/dist/agent/i18n/en.d.ts +47 -36
  67. package/dist/agent/i18n/en.d.ts.map +1 -1
  68. package/dist/agent/i18n/fr.d.ts.map +1 -1
  69. package/dist/agent/i18n/index.d.ts +84 -72
  70. package/dist/agent/i18n/index.d.ts.map +1 -1
  71. package/dist/agent/react-router.d.ts +9 -0
  72. package/dist/agent/react-router.d.ts.map +1 -1
  73. package/dist/agent/run-presentation.d.ts +4 -1
  74. package/dist/agent/run-presentation.d.ts.map +1 -1
  75. package/dist/agent/thread-navigation.d.ts +8 -0
  76. package/dist/agent/thread-navigation.d.ts.map +1 -1
  77. package/dist/agent/thread-pages.d.ts +11 -0
  78. package/dist/agent/thread-pages.d.ts.map +1 -0
  79. package/dist/artifacts/person-avatar.d.ts +2 -2
  80. package/dist/{chunk-aes17xmx.js → chunk-12v6y89k.js} +4180 -3793
  81. package/dist/{chunk-aes17xmx.js.map → chunk-12v6y89k.js.map} +48 -42
  82. package/dist/{chunk-0yb22w6m.js → chunk-2a69ge8h.js} +1 -1
  83. package/dist/{chunk-vtp6nk44.js → chunk-bpj9mg5c.js} +1 -1
  84. package/dist/{chunk-1rhht9y0.js → chunk-hzy2g13h.js} +1 -1
  85. package/dist/createCustomApp.d.ts.map +1 -1
  86. package/dist/index.d.ts +2 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +19 -6
  89. package/dist/index.js.map +6 -6
  90. package/dist/pages/home.d.ts.map +1 -1
  91. package/dist/pages/observability/ai-usage/calls.d.ts.map +1 -1
  92. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  93. package/dist/pages/settings/messages.d.ts.map +1 -1
  94. package/dist/pages/values.d.ts +5 -0
  95. package/dist/pages/values.d.ts.map +1 -1
  96. package/dist/pages.d.ts +1 -1
  97. package/dist/pages.d.ts.map +1 -1
  98. package/dist/pages.js +60 -44
  99. package/dist/pages.js.map +8 -8
  100. package/dist/server.js +12 -6
  101. package/dist/server.js.map +3 -3
  102. package/dist/shell/agent-dock.d.ts.map +1 -1
  103. package/package.json +4 -4
  104. package/src/agent/agent-chat.tsx +15 -23
  105. package/src/agent/agent-panel.tsx +11 -0
  106. package/src/agent/agent-surface.tsx +11 -0
  107. package/src/agent/agent.css +33 -3
  108. package/src/agent/approvals.ts +4 -5
  109. package/src/agent/artifact-panel.tsx +113 -37
  110. package/src/agent/components/activity-status.tsx +1 -1
  111. package/src/agent/components/agent-threads.tsx +377 -0
  112. package/src/agent/components/approval-card.tsx +336 -327
  113. package/src/agent/components/approval-mode-chip.tsx +38 -145
  114. package/src/agent/components/auto-model-chip.tsx +103 -167
  115. package/src/agent/components/composer-menu.tsx +185 -0
  116. package/src/agent/components/composer.tsx +168 -103
  117. package/src/agent/components/context-chips.tsx +1 -1
  118. package/src/agent/components/conversation-panel.tsx +16 -36
  119. package/src/agent/components/dictation-bar.tsx +110 -0
  120. package/src/agent/components/file-attachment-card.tsx +5 -2
  121. package/src/agent/components/message-parts.tsx +27 -11
  122. package/src/agent/components/message-view.tsx +182 -68
  123. package/src/agent/components/model-controls.tsx +133 -125
  124. package/src/agent/components/model-picker-row.tsx +38 -17
  125. package/src/agent/components/participant-input.tsx +159 -31
  126. package/src/agent/components/reasoning-effort-slider.tsx +27 -27
  127. package/src/agent/components/shared-thread-notice.tsx +1 -1
  128. package/src/agent/components/thread-people.tsx +45 -15
  129. package/src/agent/components/threads-button.tsx +70 -0
  130. package/src/agent/components/transcript.tsx +30 -1
  131. package/src/agent/conversation.ts +25 -1
  132. package/src/agent/delegation/child-card.tsx +187 -247
  133. package/src/agent/delegation/child-cards.tsx +4 -7
  134. package/src/agent/delegation/child-group.tsx +179 -98
  135. package/src/agent/delegation/child-parts.tsx +71 -106
  136. package/src/agent/delegation/child-work.tsx +6 -52
  137. package/src/agent/delegation/interpret.ts +0 -28
  138. package/src/agent/delegation/model.ts +115 -39
  139. package/src/agent/dictation.ts +48 -0
  140. package/src/agent/hooks/use-agent-conversation.ts +10 -92
  141. package/src/agent/hooks/use-people-suggestions.ts +90 -0
  142. package/src/agent/hooks/use-thread-lists.ts +77 -0
  143. package/src/agent/i18n/en.ts +100 -83
  144. package/src/agent/i18n/fr.ts +109 -100
  145. package/src/agent/react-router.tsx +48 -5
  146. package/src/agent/run-presentation.ts +6 -2
  147. package/src/agent/thread-navigation.ts +16 -0
  148. package/src/agent/thread-pages.ts +24 -0
  149. package/src/artifacts/person-avatar.tsx +1 -1
  150. package/src/createCustomApp.ts +13 -6
  151. package/src/index.ts +7 -3
  152. package/src/pages/home.tsx +3 -1
  153. package/src/pages/observability/ai-usage/calls.tsx +2 -1
  154. package/src/pages/settings/memory-history.tsx +2 -1
  155. package/src/pages/settings/messages.ts +2 -3
  156. package/src/pages/values.tsx +23 -1
  157. package/src/pages.ts +5 -1
  158. package/src/shell/agent-dock.tsx +4 -2
  159. package/dist/agent/agents-page.d.ts +0 -4
  160. package/dist/agent/agents-page.d.ts.map +0 -1
  161. package/dist/agent/components/agent-thread-switcher.d.ts +0 -37
  162. package/dist/agent/components/agent-thread-switcher.d.ts.map +0 -1
  163. package/src/agent/agents-page.ts +0 -7
  164. package/src/agent/components/agent-thread-switcher.tsx +0 -519
  165. /package/dist/{chunk-0yb22w6m.js.map → chunk-2a69ge8h.js.map} +0 -0
  166. /package/dist/{chunk-vtp6nk44.js.map → chunk-bpj9mg5c.js.map} +0 -0
  167. /package/dist/{chunk-1rhht9y0.js.map → chunk-hzy2g13h.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"agent-dock.d.ts","sourceRoot":"","sources":["../../src/shell/agent-dock.tsx"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,SAAS,uCAmBxB"}
1
+ {"version":3,"file":"agent-dock.d.ts","sourceRoot":"","sources":["../../src/shell/agent-dock.tsx"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,SAAS,uCAoBxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/app",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
5
5
  "keywords": [
6
6
  "sixb",
@@ -54,9 +54,9 @@
54
54
  "prepack": "bun run build"
55
55
  },
56
56
  "dependencies": {
57
- "@sixb/client": "^0.1.22",
58
- "@sixb/core": "^0.1.22",
59
- "@sixb/ui": "^0.1.6",
57
+ "@sixb/client": "^0.1.23",
58
+ "@sixb/core": "^0.1.24",
59
+ "@sixb/ui": "^0.1.8",
60
60
  "@tailwindcss/cli": "^4.2.2",
61
61
  "@xyflow/react": "^12.10.2",
62
62
  "lucide-react": "^0.562.0",
@@ -21,6 +21,8 @@ export interface AgentChatProps {
21
21
  readonly threadId?: string | null
22
22
  readonly onNavigateHome: () => void
23
23
  readonly onNavigateThread: (threadId: string) => void
24
+ /** Open the page of every conversation, from the header's button; without it, there is none. */
25
+ readonly onOpenThreads?: () => void
24
26
  readonly className?: string
25
27
  readonly ambientContext?: readonly AgentContextInput[]
26
28
  readonly compact?: boolean
@@ -35,6 +37,11 @@ export interface AgentChatProps {
35
37
  readonly onArtifactTargetChange?: (target: ArtifactTarget | null) => void
36
38
  readonly conversationHeaderActions?: ReactNode
37
39
  readonly composerPlaceholder?: string
40
+ /**
41
+ * A microphone in the composer when the project declares a transcription model and the reader
42
+ * may call it. False hides it.
43
+ */
44
+ readonly dictation?: boolean
38
45
  }
39
46
 
40
47
  /** Route-independent conversation view; routing and embedded panels only adapt its callbacks. */
@@ -42,6 +49,7 @@ export function AgentChat({
42
49
  threadId: threadIdInput = null,
43
50
  onNavigateHome,
44
51
  onNavigateThread,
52
+ onOpenThreads,
45
53
  className,
46
54
  ambientContext = [],
47
55
  compact = false,
@@ -52,6 +60,7 @@ export function AgentChat({
52
60
  onArtifactTargetChange,
53
61
  conversationHeaderActions: hostHeaderActions,
54
62
  composerPlaceholder,
63
+ dictation = true,
55
64
  }: AgentChatProps) {
56
65
  const messages = useAgentMessages()
57
66
  const threadId = threadIdInput ?? null
@@ -136,35 +145,18 @@ export function AgentChat({
136
145
  <ConversationPanel
137
146
  agent={conversation.currentAgent}
138
147
  transcript={conversation.transcriptProps}
139
- composer={conversation.composerProps}
148
+ composer={
149
+ dictation
150
+ ? conversation.composerProps
151
+ : { ...conversation.composerProps, dictation: undefined }
152
+ }
140
153
  messagesLoading={conversation.messagesLoading}
141
154
  messagesError={conversation.messagesError ? messages.chat.messagesLoadFailed : null}
142
155
  currentThread={conversation.currentThread}
143
156
  runningThreadCount={conversation.runningThreadCount}
144
157
  waitingThreadIds={conversation.waitingThreadIds}
145
- threadsError={conversation.threadsError ? messages.chat.threadsLoadFailed : null}
146
- hasMoreThreads={conversation.threadsHasMore}
147
- loadingMoreThreads={conversation.threadsLoadingMore}
148
- loadMoreThreadsError={conversation.threadsLoadMoreError}
149
- onLoadMoreThreads={() => void conversation.loadMoreThreads()}
150
- agentThreads={conversation.agentThreads}
151
- sharedThreads={
152
- conversation.user
153
- ? {
154
- threads: conversation.sharedThreads,
155
- total: conversation.sharedThreadsTotal,
156
- error: conversation.sharedThreadsError
157
- ? messages.chat.sharedThreadsLoadFailed
158
- : null,
159
- hasMore: conversation.sharedThreadsHasMore,
160
- loadingMore: conversation.sharedThreadsLoadingMore,
161
- loadMoreError: conversation.sharedThreadsLoadMoreError,
162
- onLoadMore: () => void conversation.loadMoreSharedThreads(),
163
- }
164
- : undefined
165
- }
166
158
  onNewChat={onNavigateHome}
167
- onSelectThread={onNavigateThread}
159
+ onOpenThreads={onOpenThreads}
168
160
  sandboxRecovery={
169
161
  conversation.sandboxRecoveryProps ? (
170
162
  <SandboxRecovery {...conversation.sandboxRecoveryProps} />
@@ -12,12 +12,19 @@ export interface AgentPanelProps {
12
12
  readonly defaultThreadId?: string | null
13
13
  readonly onThreadChange?: (threadId: string | null) => void
14
14
  readonly onNewThread?: () => void
15
+ /** Open the page of every conversation, from the header's button. */
16
+ readonly onOpenThreads?: () => void
15
17
  /** Optional modeless artifact canvas owned by an enclosing application shell. */
16
18
  readonly artifactHost?: HTMLElement | null
17
19
  /** Keep artifacts beside the chat on desktop instead of opening a modal. */
18
20
  readonly splitArtifacts?: boolean
19
21
  readonly conversationHeaderActions?: ReactNode
20
22
  readonly composerPlaceholder?: string
23
+ /**
24
+ * A microphone in the composer when the project declares a transcription model and the reader
25
+ * may call it. False hides it.
26
+ */
27
+ readonly dictation?: boolean
21
28
  readonly compact?: boolean
22
29
  readonly className?: string
23
30
  /** Centered content for an empty conversation. Omit for the agent identity; null hides it. */
@@ -31,10 +38,12 @@ export function AgentPanel({
31
38
  defaultThreadId = null,
32
39
  onThreadChange,
33
40
  onNewThread,
41
+ onOpenThreads,
34
42
  artifactHost,
35
43
  splitArtifacts,
36
44
  conversationHeaderActions,
37
45
  composerPlaceholder,
46
+ dictation,
38
47
  compact = true,
39
48
  className,
40
49
  welcomeContent,
@@ -62,12 +71,14 @@ export function AgentPanel({
62
71
  splitArtifacts={splitArtifacts}
63
72
  conversationHeaderActions={conversationHeaderActions}
64
73
  composerPlaceholder={composerPlaceholder}
74
+ dictation={dictation}
65
75
  welcomeContent={welcomeContent}
66
76
  onNavigateHome={() => {
67
77
  changeThread(null)
68
78
  onNewThread?.()
69
79
  }}
70
80
  onNavigateThread={changeThread}
81
+ onOpenThreads={onOpenThreads}
71
82
  className={cn("min-h-0 overflow-hidden bg-background", className)}
72
83
  />
73
84
  )
@@ -44,6 +44,11 @@ export interface AgentSurfaceProps {
44
44
  readonly title?: string
45
45
  readonly launcherLabel?: string
46
46
  readonly composerPlaceholder?: string
47
+ /**
48
+ * A microphone in the composer when the project declares a transcription model and the reader
49
+ * may call it. False hides it.
50
+ */
51
+ readonly dictation?: boolean
47
52
  readonly context?: readonly AgentContextInput[]
48
53
  /** Controlled thread. The latest value is still remembered for a later dock transition. */
49
54
  readonly threadId?: string | null
@@ -51,6 +56,8 @@ export interface AgentSurfaceProps {
51
56
  readonly onThreadChange?: (threadId: string | null) => void
52
57
  /** Offer an explicit full-page view for the selected thread. */
53
58
  readonly onExpandThread?: (threadId: string) => void
59
+ /** Open the page of every conversation, from the header's button. */
60
+ readonly onOpenThreads?: () => void
54
61
  /** Controlled dock width. Numeric values are pixels. */
55
62
  readonly dockWidth?: CSSProperties["width"]
56
63
  readonly defaultDockWidth?: number
@@ -81,11 +88,13 @@ export function AgentSurface({
81
88
  title,
82
89
  launcherLabel,
83
90
  composerPlaceholder,
91
+ dictation,
84
92
  context,
85
93
  threadId,
86
94
  defaultThreadId = null,
87
95
  onThreadChange,
88
96
  onExpandThread,
97
+ onOpenThreads,
89
98
  dockWidth,
90
99
  defaultDockWidth = DEFAULT_AGENT_SURFACE_WIDTH,
91
100
  onDockWidthChange,
@@ -315,8 +324,10 @@ export function AgentSurface({
315
324
  compact={!fullPage}
316
325
  context={context}
317
326
  composerPlaceholder={composerPlaceholder}
327
+ dictation={dictation}
318
328
  threadId={currentThreadId}
319
329
  onThreadChange={changeThread}
330
+ onOpenThreads={onOpenThreads}
320
331
  welcomeContent={welcomeContent}
321
332
  conversationHeaderActions={
322
333
  fullPage && onRequestDock ? (
@@ -96,7 +96,6 @@
96
96
  pointer-events: none;
97
97
  border-radius: 9999px;
98
98
  background: var(--muted);
99
- box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--foreground) 10%, transparent);
100
99
  }
101
100
 
102
101
  .sixb-reasoning-fill {
@@ -118,10 +117,11 @@
118
117
  width: var(--sixb-reasoning-thumb-size);
119
118
  height: var(--sixb-reasoning-thumb-size);
120
119
  pointer-events: none;
121
- border: 1px solid rgb(0 0 0 / 0.1);
122
120
  border-radius: 9999px;
123
121
  background: white;
124
- box-shadow: var(--shadow-sm);
122
+ box-shadow:
123
+ 0 0 0 0.5px rgb(0 0 0 / 0.08),
124
+ 0 1px 3px rgb(0 0 0 / 0.16);
125
125
  transition: left var(--sixb-reasoning-motion);
126
126
  }
127
127
 
@@ -230,6 +230,36 @@
230
230
  }
231
231
  }
232
232
 
233
+ /* The composer's one surface: a hairline and a soft lift, no border. Focus darkens the hairline. */
234
+ .sixb-composer-surface {
235
+ box-shadow:
236
+ 0 0 0 1px rgb(0 0 0 / 0.06),
237
+ 0 1px 2px rgb(0 0 0 / 0.03),
238
+ 0 4px 16px rgb(0 0 0 / 0.035);
239
+ transition: box-shadow 200ms ease;
240
+ }
241
+
242
+ .sixb-composer-surface:focus-within {
243
+ box-shadow:
244
+ 0 0 0 1px rgb(0 0 0 / 0.1),
245
+ 0 1px 2px rgb(0 0 0 / 0.03),
246
+ 0 4px 16px rgb(0 0 0 / 0.045);
247
+ }
248
+
249
+ .sixb-composer-surface[data-dragging] {
250
+ box-shadow:
251
+ 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent),
252
+ 0 4px 16px rgb(0 0 0 / 0.045);
253
+ }
254
+
255
+ :is(.dark *).sixb-composer-surface {
256
+ box-shadow: 0 0 0 1px rgb(255 255 255 / 0.09);
257
+ }
258
+
259
+ :is(.dark *).sixb-composer-surface:focus-within {
260
+ box-shadow: 0 0 0 1px rgb(255 255 255 / 0.16);
261
+ }
262
+
233
263
  /* An image the agent is making: a soft glow drifting under a slow sheen, like a print developing. */
234
264
  @keyframes sixb-media-drift {
235
265
  from {
@@ -14,12 +14,11 @@ export const AGENT_APPROVAL_MODES = ["manual", "accept-edits", "auto"] as const
14
14
 
15
15
  export type AgentApprovalMode = (typeof AGENT_APPROVAL_MODES)[number]
16
16
 
17
- /**
18
- * The mode Shift+Tab switches to: between Manual and Accept edits only. Auto is chosen from the menu,
19
- * never reached by a key pressed in passing; from Auto, the key goes back to Manual.
20
- */
17
+ /** The mode Shift+Tab switches to: the next one, Manual to Accept edits to Auto and round again. */
21
18
  export function toggledApprovalMode(mode: AgentApprovalMode): AgentApprovalMode {
22
- return mode === "manual" ? "accept-edits" : "manual"
19
+ return AGENT_APPROVAL_MODES[
20
+ (AGENT_APPROVAL_MODES.indexOf(mode) + 1) % AGENT_APPROVAL_MODES.length
21
+ ]
23
22
  }
24
23
 
25
24
  /** From least to most allowed. */
@@ -9,6 +9,7 @@ import {
9
9
  } from "@sixb/ui/components"
10
10
  import { useIsMobile } from "@sixb/ui/hooks"
11
11
  import { cn } from "@sixb/ui/lib/utils"
12
+ import { ChevronLeft, X } from "lucide-react"
12
13
  import {
13
14
  createContext,
14
15
  memo,
@@ -40,15 +41,36 @@ import {
40
41
  } from "./artifact-panel-state"
41
42
  import { useAgentMessages } from "./i18n"
42
43
 
44
+ /**
45
+ * A place in the panel a part of the conversation fills itself, such as a sub-agent's thread: the
46
+ * panel draws its title and close, and the part renders into `slotHost` while it is the one open.
47
+ */
48
+ export interface SlotTarget {
49
+ readonly type: "slot"
50
+ readonly id: string
51
+ readonly title: string
52
+ /** A step back within the slot, such as from one sub-agent to all of them: an arrow before the title. */
53
+ readonly back?: { readonly label: string; readonly onBack: () => void }
54
+ }
55
+
56
+ export type PanelTarget = ViewerTarget | SlotTarget
57
+
58
+ /** Identity for "is this target the open one". */
59
+ export function panelTargetKey(target: PanelTarget): string {
60
+ return target.type === "slot" ? `slot:${target.id}` : viewerTargetKey(target)
61
+ }
62
+
43
63
  export interface ArtifactPanelValue {
44
64
  /** What is open, or null when nothing is. */
45
- readonly openTarget: ViewerTarget | null
65
+ readonly openTarget: PanelTarget | null
46
66
  /** The open target's identity, or null when nothing is open. */
47
67
  readonly openKey: string | null
48
- readonly open: (target: ViewerTarget) => void
68
+ readonly open: (target: PanelTarget) => void
49
69
  readonly close: () => void
50
70
  /** Where the panel opens: beside the conversation, over the app, or as a dialog. */
51
71
  readonly presentation: ArtifactPanelPresentation
72
+ /** The element an open slot renders into, once the panel has drawn it. */
73
+ readonly slotHost: HTMLElement | null
52
74
  }
53
75
 
54
76
  interface PanelHandle {
@@ -99,10 +121,11 @@ export function ArtifactPanelRoot({
99
121
  }: ArtifactPanelRootProps) {
100
122
  const messages = useAgentMessages().artifacts
101
123
  const idPrefix = useId()
102
- const [localTarget, setLocalTarget] = useState<ViewerTarget | null>(null)
103
- const target: ViewerTarget | null = routeTarget ?? localTarget
124
+ const [localTarget, setLocalTarget] = useState<PanelTarget | null>(null)
125
+ const target: PanelTarget | null = routeTarget ?? localTarget
104
126
  // What the reader followed a reference from, so the panel can take them back.
105
- const [trail, setTrail] = useState<readonly ViewerTarget[]>([])
127
+ const [trail, setTrail] = useState<readonly PanelTarget[]>([])
128
+ const [slotHost, setSlotHost] = useState<HTMLElement | null>(null)
106
129
  const presentation = artifactPanelPresentation({
107
130
  compact,
108
131
  isMobile: useIsMobile(),
@@ -122,7 +145,7 @@ export function ArtifactPanelRoot({
122
145
  }, [scopeKey])
123
146
 
124
147
  const show = useCallback(
125
- (next: ViewerTarget) => {
148
+ (next: PanelTarget) => {
126
149
  if (onRouteTargetChange && next.type === "artifact") {
127
150
  setLocalTarget(null)
128
151
  onRouteTargetChange(next)
@@ -134,9 +157,12 @@ export function ArtifactPanelRoot({
134
157
  [onRouteTargetChange, routeTarget]
135
158
  )
136
159
  const open = useCallback(
137
- (next: ViewerTarget) => {
160
+ (next: PanelTarget) => {
138
161
  const active = typeof document === "undefined" ? null : document.activeElement
139
- openerRef.current = active instanceof HTMLElement ? active : null
162
+ // A move within the open slot keeps where focus returns: what was clicked there goes next.
163
+ if (!(active instanceof HTMLElement && active.closest("[data-agent-slot-frame]"))) {
164
+ openerRef.current = active instanceof HTMLElement ? active : null
165
+ }
140
166
  setTrail([])
141
167
  show(next)
142
168
  reveal()
@@ -155,39 +181,43 @@ export function ArtifactPanelRoot({
155
181
  const value = useMemo<ArtifactPanelValue>(
156
182
  () => ({
157
183
  openTarget: target,
158
- openKey: target ? viewerTargetKey(target) : null,
184
+ openKey: target ? panelTargetKey(target) : null,
159
185
  open,
160
186
  close,
161
187
  presentation,
188
+ slotHost: target?.type === "slot" ? slotHost : null,
162
189
  }),
163
- [target, open, close, presentation]
190
+ [target, open, close, presentation, slotHost]
164
191
  )
165
- const viewer = target ? (
166
- <Viewer
167
- target={target}
168
- onTargetChange={show}
169
- onOpenReference={(next) => {
170
- setTrail((current) => [...current, target])
171
- show(next)
172
- }}
173
- chrome={{
174
- onClose: close,
175
- ...(trail.length > 0
176
- ? {
177
- onBack: () => {
178
- const previous = trail.at(-1)
179
- setTrail((current) => current.slice(0, -1))
180
- if (previous) show(previous)
181
- },
182
- }
183
- : {}),
184
- ...(target.type === "artifact" && pageLinks
185
- ? { fullPageHref: artifactTargetHref(target) }
186
- : {}),
187
- ...(pageLinks ? {} : { withoutPageLink: true }),
188
- }}
189
- />
190
- ) : null
192
+ const viewer =
193
+ target?.type === "slot" ? (
194
+ <SlotFrame title={target.title} back={target.back} onClose={close} hostRef={setSlotHost} />
195
+ ) : target ? (
196
+ <Viewer
197
+ target={target}
198
+ onTargetChange={show}
199
+ onOpenReference={(next) => {
200
+ setTrail((current) => [...current, target])
201
+ show(next)
202
+ }}
203
+ chrome={{
204
+ onClose: close,
205
+ ...(trail.length > 0
206
+ ? {
207
+ onBack: () => {
208
+ const previous = trail.at(-1)
209
+ setTrail((current) => current.slice(0, -1))
210
+ if (previous) show(previous)
211
+ },
212
+ }
213
+ : {}),
214
+ ...(target.type === "artifact" && pageLinks
215
+ ? { fullPageHref: artifactTargetHref(target) }
216
+ : {}),
217
+ ...(pageLinks ? {} : { withoutPageLink: true }),
218
+ }}
219
+ />
220
+ ) : null
191
221
 
192
222
  return (
193
223
  <ArtifactPanelContext.Provider value={value}>
@@ -195,7 +225,7 @@ export function ArtifactPanelRoot({
195
225
  <ArtifactWorkspace
196
226
  idPrefix={idPrefix}
197
227
  revealKey={
198
- presentation === "panel" && target ? `${viewerTargetKey(target)}:${revealCount}` : null
228
+ presentation === "panel" && target ? `${panelTargetKey(target)}:${revealCount}` : null
199
229
  }
200
230
  viewer={presentation === "panel" ? viewer : null}
201
231
  >
@@ -239,6 +269,52 @@ export function ArtifactPanelRoot({
239
269
  )
240
270
  }
241
271
 
272
+ /** The panel's frame for a slot: its title and close, and the element the slot renders into. */
273
+ function SlotFrame({
274
+ title,
275
+ back,
276
+ onClose,
277
+ hostRef,
278
+ }: {
279
+ readonly title: string
280
+ readonly back?: SlotTarget["back"]
281
+ readonly onClose: () => void
282
+ readonly hostRef: (element: HTMLElement | null) => void
283
+ }) {
284
+ const messages = useAgentMessages().artifacts
285
+ return (
286
+ <div data-agent-slot-frame="" className="flex h-full min-h-0 flex-col">
287
+ <div className={cn("flex h-12 shrink-0 items-center gap-1 pr-2", back ? "pl-2" : "pl-5")}>
288
+ {back ? (
289
+ <button
290
+ type="button"
291
+ onClick={back.onBack}
292
+ aria-label={back.label}
293
+ title={back.label}
294
+ 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"
295
+ >
296
+ <ChevronLeft className="size-4" aria-hidden="true" />
297
+ </button>
298
+ ) : null}
299
+ <h2 className="min-w-0 flex-1 truncate text-sm font-semibold text-foreground">{title}</h2>
300
+ <button
301
+ type="button"
302
+ onClick={onClose}
303
+ aria-label={messages.close}
304
+ 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"
305
+ >
306
+ <X className="size-4" aria-hidden="true" />
307
+ </button>
308
+ </div>
309
+ <div
310
+ ref={hostRef}
311
+ data-agent-slot=""
312
+ className="scrollbar-thin min-h-0 flex-1 overflow-y-auto px-5 pb-6"
313
+ />
314
+ </div>
315
+ )
316
+ }
317
+
242
318
  /**
243
319
  * Escape in a deck's overview or presentation takes the deck back to its slide; only then does it
244
320
  * close the dialog. The dialog hears Escape first, on the document, before the deck does.
@@ -4,7 +4,7 @@ import { useAgentMessages } from "../i18n"
4
4
  import { type AgentMessages, en } from "../i18n/en"
5
5
 
6
6
  export const ACTIVITY_STATUS_ROW_CLASS_NAME =
7
- "group flex w-fit max-w-full items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] leading-normal text-muted-foreground"
7
+ "group -ml-1 flex w-fit max-w-full items-center gap-1.5 rounded-md px-1 py-0.5 text-[13px] leading-normal text-muted-foreground"
8
8
 
9
9
  interface ActivityStatusStep {
10
10
  readonly afterMs: number