@sixb/app 0.1.15 → 0.1.17

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 (125) hide show
  1. package/README.md +8 -0
  2. package/dist/agent/agent-chat.d.ts +8 -1
  3. package/dist/agent/agent-chat.d.ts.map +1 -1
  4. package/dist/agent/agent-panel.d.ts +8 -1
  5. package/dist/agent/agent-panel.d.ts.map +1 -1
  6. package/dist/agent/agent-surface.d.ts +8 -1
  7. package/dist/agent/agent-surface.d.ts.map +1 -1
  8. package/dist/agent/approvals.d.ts +1 -4
  9. package/dist/agent/approvals.d.ts.map +1 -1
  10. package/dist/agent/artifact-panel.d.ts +21 -2
  11. package/dist/agent/artifact-panel.d.ts.map +1 -1
  12. package/dist/agent/components/activity-status.d.ts +1 -1
  13. package/dist/agent/components/activity-status.d.ts.map +1 -1
  14. package/dist/agent/components/agent-threads.d.ts +15 -0
  15. package/dist/agent/components/agent-threads.d.ts.map +1 -0
  16. package/dist/agent/components/approval-card.d.ts +4 -4
  17. package/dist/agent/components/approval-card.d.ts.map +1 -1
  18. package/dist/agent/components/approval-mode-chip.d.ts +4 -6
  19. package/dist/agent/components/approval-mode-chip.d.ts.map +1 -1
  20. package/dist/agent/components/auto-model-chip.d.ts +2 -3
  21. package/dist/agent/components/auto-model-chip.d.ts.map +1 -1
  22. package/dist/agent/components/composer-menu.d.ts +42 -0
  23. package/dist/agent/components/composer-menu.d.ts.map +1 -0
  24. package/dist/agent/components/composer.d.ts +8 -5
  25. package/dist/agent/components/composer.d.ts.map +1 -1
  26. package/dist/agent/components/conversation-panel.d.ts +3 -12
  27. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  28. package/dist/agent/components/dictation-bar.d.ts +13 -0
  29. package/dist/agent/components/dictation-bar.d.ts.map +1 -0
  30. package/dist/agent/components/message-parts.d.ts.map +1 -1
  31. package/dist/agent/components/message-view.d.ts +3 -1
  32. package/dist/agent/components/message-view.d.ts.map +1 -1
  33. package/dist/agent/components/model-controls.d.ts +15 -0
  34. package/dist/agent/components/model-controls.d.ts.map +1 -1
  35. package/dist/agent/components/model-picker-row.d.ts +9 -2
  36. package/dist/agent/components/model-picker-row.d.ts.map +1 -1
  37. package/dist/agent/components/participant-input.d.ts +7 -6
  38. package/dist/agent/components/participant-input.d.ts.map +1 -1
  39. package/dist/agent/components/thread-people.d.ts +4 -4
  40. package/dist/agent/components/thread-people.d.ts.map +1 -1
  41. package/dist/agent/components/threads-button.d.ts +14 -0
  42. package/dist/agent/components/threads-button.d.ts.map +1 -0
  43. package/dist/agent/conversation.d.ts +3 -1
  44. package/dist/agent/conversation.d.ts.map +1 -1
  45. package/dist/agent/delegation/child-card.d.ts +24 -11
  46. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  47. package/dist/agent/delegation/child-cards.d.ts +2 -2
  48. package/dist/agent/delegation/child-cards.d.ts.map +1 -1
  49. package/dist/agent/delegation/child-group.d.ts +5 -4
  50. package/dist/agent/delegation/child-group.d.ts.map +1 -1
  51. package/dist/agent/delegation/child-parts.d.ts +17 -18
  52. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  53. package/dist/agent/delegation/child-work.d.ts +0 -13
  54. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  55. package/dist/agent/delegation/interpret.d.ts +0 -5
  56. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  57. package/dist/agent/delegation/model.d.ts +12 -6
  58. package/dist/agent/delegation/model.d.ts.map +1 -1
  59. package/dist/agent/dictation.d.ts +16 -0
  60. package/dist/agent/dictation.d.ts.map +1 -0
  61. package/dist/agent/hooks/use-agent-conversation.d.ts +3 -270
  62. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  63. package/dist/agent/hooks/use-people-suggestions.d.ts +21 -0
  64. package/dist/agent/hooks/use-people-suggestions.d.ts.map +1 -0
  65. package/dist/agent/hooks/use-thread-lists.d.ts +220 -0
  66. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -0
  67. package/dist/agent/i18n/en.d.ts +47 -36
  68. package/dist/agent/i18n/en.d.ts.map +1 -1
  69. package/dist/agent/i18n/fr.d.ts.map +1 -1
  70. package/dist/agent/i18n/index.d.ts +84 -72
  71. package/dist/agent/i18n/index.d.ts.map +1 -1
  72. package/dist/agent/react-router.d.ts +9 -0
  73. package/dist/agent/react-router.d.ts.map +1 -1
  74. package/dist/agent/run-presentation.d.ts +4 -1
  75. package/dist/agent/run-presentation.d.ts.map +1 -1
  76. package/dist/agent/thread-navigation.d.ts +8 -0
  77. package/dist/agent/thread-navigation.d.ts.map +1 -1
  78. package/dist/agent/thread-pages.d.ts +11 -0
  79. package/dist/agent/thread-pages.d.ts.map +1 -0
  80. package/dist/artifacts/person-avatar.d.ts +2 -2
  81. package/dist/{chunk-twjs2sb9.js → chunk-12v6y89k.js} +1661 -1485
  82. package/dist/{chunk-twjs2sb9.js.map → chunk-12v6y89k.js.map} +10 -8
  83. package/dist/{chunk-qh1panvd.js → chunk-2a69ge8h.js} +1 -1
  84. package/dist/{chunk-736c9akn.js → chunk-bpj9mg5c.js} +1 -1
  85. package/dist/{chunk-n0cxwvej.js → chunk-hzy2g13h.js} +1 -1
  86. package/dist/codegen.d.ts.map +1 -1
  87. package/dist/createCustomApp.d.ts.map +1 -1
  88. package/dist/frame-origins.d.ts +10 -0
  89. package/dist/frame-origins.d.ts.map +1 -0
  90. package/dist/index.d.ts +2 -1
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +6 -2
  93. package/dist/index.js.map +4 -4
  94. package/dist/pages/home.d.ts.map +1 -1
  95. package/dist/pages/observability/ai-usage/calls.d.ts.map +1 -1
  96. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  97. package/dist/pages/settings/messages.d.ts.map +1 -1
  98. package/dist/pages/values.d.ts +5 -0
  99. package/dist/pages/values.d.ts.map +1 -1
  100. package/dist/pages.d.ts +1 -1
  101. package/dist/pages.d.ts.map +1 -1
  102. package/dist/pages.js +2 -2
  103. package/dist/server.js +97 -22
  104. package/dist/server.js.map +6 -5
  105. package/dist/shell/agent-dock.d.ts.map +1 -1
  106. package/package.json +4 -4
  107. package/src/agent/agent-chat.tsx +11 -1
  108. package/src/agent/agent-panel.tsx +7 -0
  109. package/src/agent/agent-surface.tsx +7 -0
  110. package/src/agent/components/composer.tsx +143 -73
  111. package/src/agent/components/dictation-bar.tsx +110 -0
  112. package/src/agent/dictation.ts +48 -0
  113. package/src/agent/hooks/use-agent-conversation.ts +3 -0
  114. package/src/agent/i18n/en.ts +4 -0
  115. package/src/agent/i18n/fr.ts +4 -0
  116. package/src/codegen.ts +44 -0
  117. package/src/createCustomApp.ts +53 -26
  118. package/src/frame-origins.ts +61 -0
  119. package/dist/agent/agents-page.d.ts +0 -4
  120. package/dist/agent/agents-page.d.ts.map +0 -1
  121. package/dist/agent/components/agent-thread-switcher.d.ts +0 -37
  122. package/dist/agent/components/agent-thread-switcher.d.ts.map +0 -1
  123. /package/dist/{chunk-qh1panvd.js.map → chunk-2a69ge8h.js.map} +0 -0
  124. /package/dist/{chunk-736c9akn.js.map → chunk-bpj9mg5c.js.map} +0 -0
  125. /package/dist/{chunk-n0cxwvej.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.15",
3
+ "version": "0.1.17",
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.23",
59
- "@sixb/ui": "^0.1.7",
57
+ "@sixb/client": "^0.1.23",
58
+ "@sixb/core": "^0.1.25",
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",
@@ -37,6 +37,11 @@ export interface AgentChatProps {
37
37
  readonly onArtifactTargetChange?: (target: ArtifactTarget | null) => void
38
38
  readonly conversationHeaderActions?: ReactNode
39
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
40
45
  }
41
46
 
42
47
  /** Route-independent conversation view; routing and embedded panels only adapt its callbacks. */
@@ -55,6 +60,7 @@ export function AgentChat({
55
60
  onArtifactTargetChange,
56
61
  conversationHeaderActions: hostHeaderActions,
57
62
  composerPlaceholder,
63
+ dictation = true,
58
64
  }: AgentChatProps) {
59
65
  const messages = useAgentMessages()
60
66
  const threadId = threadIdInput ?? null
@@ -139,7 +145,11 @@ export function AgentChat({
139
145
  <ConversationPanel
140
146
  agent={conversation.currentAgent}
141
147
  transcript={conversation.transcriptProps}
142
- composer={conversation.composerProps}
148
+ composer={
149
+ dictation
150
+ ? conversation.composerProps
151
+ : { ...conversation.composerProps, dictation: undefined }
152
+ }
143
153
  messagesLoading={conversation.messagesLoading}
144
154
  messagesError={conversation.messagesError ? messages.chat.messagesLoadFailed : null}
145
155
  currentThread={conversation.currentThread}
@@ -20,6 +20,11 @@ export interface AgentPanelProps {
20
20
  readonly splitArtifacts?: boolean
21
21
  readonly conversationHeaderActions?: ReactNode
22
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
23
28
  readonly compact?: boolean
24
29
  readonly className?: string
25
30
  /** Centered content for an empty conversation. Omit for the agent identity; null hides it. */
@@ -38,6 +43,7 @@ export function AgentPanel({
38
43
  splitArtifacts,
39
44
  conversationHeaderActions,
40
45
  composerPlaceholder,
46
+ dictation,
41
47
  compact = true,
42
48
  className,
43
49
  welcomeContent,
@@ -65,6 +71,7 @@ export function AgentPanel({
65
71
  splitArtifacts={splitArtifacts}
66
72
  conversationHeaderActions={conversationHeaderActions}
67
73
  composerPlaceholder={composerPlaceholder}
74
+ dictation={dictation}
68
75
  welcomeContent={welcomeContent}
69
76
  onNavigateHome={() => {
70
77
  changeThread(null)
@@ -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
@@ -83,6 +88,7 @@ export function AgentSurface({
83
88
  title,
84
89
  launcherLabel,
85
90
  composerPlaceholder,
91
+ dictation,
86
92
  context,
87
93
  threadId,
88
94
  defaultThreadId = null,
@@ -318,6 +324,7 @@ export function AgentSurface({
318
324
  compact={!fullPage}
319
325
  context={context}
320
326
  composerPlaceholder={composerPlaceholder}
327
+ dictation={dictation}
321
328
  threadId={currentThreadId}
322
329
  onThreadChange={changeThread}
323
330
  onOpenThreads={onOpenThreads}
@@ -8,7 +8,16 @@ import {
8
8
  MAX_AGENT_CONTEXT_LABEL_LENGTH,
9
9
  } from "@sixb/core/agents/context"
10
10
  import type { ModelReasoningLevel } from "@sixb/core/models"
11
- import { Marker, MarkerContent, MarkerIcon, Spinner, Textarea } from "@sixb/ui/components"
11
+ import {
12
+ DictationButton,
13
+ Marker,
14
+ MarkerContent,
15
+ MarkerIcon,
16
+ Spinner,
17
+ Textarea,
18
+ } from "@sixb/ui/components"
19
+ import { useDictation } from "@sixb/ui/hooks"
20
+ import type { SpeechRecognizer } from "@sixb/ui/lib/speech"
12
21
  import { cn } from "@sixb/ui/lib/utils"
13
22
  import { useQuery } from "@tanstack/react-query"
14
23
  import {
@@ -46,6 +55,7 @@ import {
46
55
  import { ApprovalModeChip } from "./approval-mode-chip"
47
56
  import { ContextChips } from "./context-chips"
48
57
  import { ContextPicker } from "./context-picker"
58
+ import { DictationBar } from "./dictation-bar"
49
59
  import { ModelControls } from "./model-controls"
50
60
 
51
61
  export interface ComposerProps {
@@ -107,6 +117,11 @@ export interface ComposerProps {
107
117
  readonly onApprovalModeChange?: (mode: AgentApprovalMode) => void
108
118
  /** A turn waits for the reader's approval: the input says how to answer it or move on. */
109
119
  readonly awaitingApproval?: boolean
120
+ /**
121
+ * Dictate the message: a microphone records it, and the transcript lands at the end of the
122
+ * input. Omit for no microphone.
123
+ */
124
+ readonly dictation?: SpeechRecognizer
110
125
  }
111
126
 
112
127
  type ComposerAttachment =
@@ -178,6 +193,7 @@ export function Composer({
178
193
  approvalMode,
179
194
  onApprovalModeChange,
180
195
  awaitingApproval = false,
196
+ dictation,
181
197
  }: ComposerProps) {
182
198
  const agentMessages = useAgentMessages()
183
199
  const messages = agentMessages.composer
@@ -198,6 +214,17 @@ export function Composer({
198
214
  const fileInputRef = useRef<HTMLInputElement>(null)
199
215
  const dragDepthRef = useRef(0)
200
216
  const uploadFile = useUploadFile()
217
+ // The transcript is appended to the text as it was when dictation started, so the input stays
218
+ // read-only until it lands. Recording ends only when the reader stops it: no restarts. A
219
+ // composer disabled meanwhile, by someone else's turn, only keeps a new dictation from starting.
220
+ const voice = useDictation({
221
+ value,
222
+ onChange: setValue,
223
+ recognizer: dictation,
224
+ disabled: !dictation,
225
+ autoRestart: false,
226
+ })
227
+ const wasDictatingRef = useRef(false)
201
228
  const wasRunningRef = useRef(Boolean(running))
202
229
  const dismissedAmbientRef = useRef(new Set<string>())
203
230
  const ambientKey = JSON.stringify(ambientContext.map(agentContextFingerprint))
@@ -242,6 +269,7 @@ export function Composer({
242
269
  !pending &&
243
270
  !running &&
244
271
  !uploading &&
272
+ !voice.isActive &&
245
273
  failedCount === 0
246
274
 
247
275
  // Reconcile page context by canonical identity. A removed ambient chip stays removed for the
@@ -293,6 +321,17 @@ export function Composer({
293
321
  textareaRef.current?.focus()
294
322
  }, [draftNonce])
295
323
 
324
+ // However a dictation ends, the focus returns to the input, the caret after any transcript.
325
+ useEffect(() => {
326
+ const wasDictating = wasDictatingRef.current
327
+ wasDictatingRef.current = voice.isActive
328
+ const input = textareaRef.current
329
+ if (!wasDictating || voice.isActive || !input) return
330
+
331
+ input.focus()
332
+ input.setSelectionRange(input.value.length, input.value.length)
333
+ }, [voice.isActive])
334
+
296
335
  useEffect(() => {
297
336
  const wasRunning = wasRunningRef.current
298
337
  wasRunningRef.current = Boolean(running)
@@ -335,6 +374,7 @@ export function Composer({
335
374
  if (!canSend) return
336
375
  onSend(value.trim(), readyAttachments, contextEntries)
337
376
  setValue("")
377
+ voice.reset()
338
378
  setAttachments([])
339
379
  dismissedAmbientRef.current.clear()
340
380
  setContextEntries(ambientContext.map((context) => ({ context, origin: "ambient" })))
@@ -541,6 +581,14 @@ export function Composer({
541
581
  // Shift+Tab in an empty input cycles Manual, Accept edits and Auto, as in a terminal agent. Once
542
582
  // something is typed, it moves focus back as everywhere else.
543
583
  const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
584
+ // While dictating, Enter finishes and Escape cancels from the input too, as from the bar.
585
+ if (voice.isActive) {
586
+ if (event.key === "Enter") voice.stop()
587
+ else if (event.key === "Escape") voice.abort()
588
+ else return
589
+ event.preventDefault()
590
+ return
591
+ }
544
592
  if (
545
593
  event.key === "Tab" &&
546
594
  event.shiftKey &&
@@ -610,7 +658,8 @@ export function Composer({
610
658
  ? messages.uploadingAttachment
611
659
  : failedCount > 0
612
660
  ? messages.attachmentsFailed(failedCount)
613
- : hint
661
+ : (voice.error ?? hint)
662
+ const statusIsError = !uploading && (failedCount > 0 || voice.error !== null)
614
663
 
615
664
  const showPermissions = approvalMode !== undefined && onApprovalModeChange !== undefined
616
665
 
@@ -673,6 +722,7 @@ export function Composer({
673
722
  value={value}
674
723
  onChange={(event) => {
675
724
  setValue(event.target.value)
725
+ if (voice.error) voice.reset()
676
726
  setDismissedMention(null)
677
727
  updateMention(event.target.value, event.target.selectionStart)
678
728
  }}
@@ -681,87 +731,107 @@ export function Composer({
681
731
  }
682
732
  onKeyDown={handleKeyDown}
683
733
  disabled={disabled}
734
+ readOnly={voice.isActive}
684
735
  rows={1}
685
736
  placeholder={
686
- awaitingApproval
687
- ? agentMessages.approvals.composerPlaceholder
688
- : (placeholder ?? messages.placeholder)
737
+ voice.status === "stopping"
738
+ ? messages.dictationTranscribing
739
+ : voice.isActive
740
+ ? messages.dictationListening
741
+ : awaitingApproval
742
+ ? agentMessages.approvals.composerPlaceholder
743
+ : (placeholder ?? messages.placeholder)
689
744
  }
690
745
  aria-label={messages.message}
691
746
  className="max-h-[200px] min-h-9 w-full resize-none overflow-y-hidden border-0 bg-transparent px-0 py-1 text-[15px] leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 md:text-[15px]"
692
747
  />
693
748
  </div>
694
749
  <div className="relative flex min-w-0 items-center gap-0.5 px-2 pb-2">
695
- <input
696
- ref={fileInputRef}
697
- type="file"
698
- multiple
699
- className="sr-only"
700
- onChange={(event) => handleFilesSelected(event.target.files)}
701
- disabled={!canAttachFiles}
702
- aria-hidden="true"
703
- />
704
- <button
705
- type="button"
706
- onClick={() => fileInputRef.current?.click()}
707
- disabled={!canAttachFiles}
708
- aria-label={messages.attachFiles}
709
- className={cn(
710
- "flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
711
- "hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40",
712
- "disabled:cursor-not-allowed disabled:opacity-50"
713
- )}
714
- >
715
- <Plus className="size-[18px]" strokeWidth={1.75} />
716
- </button>
717
- {showPermissions ? (
718
- <ApprovalModeChip mode={approvalMode} onChange={changeApprovalMode} />
719
- ) : null}
720
- <span className="min-w-2 flex-1" />
721
- {onSelectModel && onSelectReasoning ? (
722
- <ModelControls
723
- models={models}
724
- selectedModel={selectedModel}
725
- selectedReasoning={selectedReasoning}
726
- loading={modelsLoading}
727
- error={modelsError}
728
- disabled={disabled || pending || running}
729
- onSelectModel={onSelectModel}
730
- onSelectReasoning={onSelectReasoning}
731
- onResetReasoning={onResetReasoning}
732
- usingDefault={usingDefaultModel}
733
- onResetToDefault={onResetModelSelection}
734
- routing={modelRouting}
735
- />
736
- ) : null}
737
- {running && onStop ? (
738
- <button
739
- type="button"
740
- onClick={onStop}
741
- disabled={stopping}
742
- aria-label={messages.stop}
743
- className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
744
- >
745
- {stopping ? (
746
- <Spinner className="size-3.5" />
747
- ) : (
748
- <Square className="size-2.5 fill-current" />
749
- )}
750
- </button>
750
+ {voice.isActive ? (
751
+ <DictationBar dictation={voice} doneClassName={SEND_BUTTON_CLASS_NAME} />
751
752
  ) : (
752
- <button
753
- type="button"
754
- onClick={submit}
755
- disabled={!canSend}
756
- aria-label={messages.send}
757
- className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
758
- >
759
- {pending || uploading ? (
760
- <Spinner className="size-3.5" />
753
+ <>
754
+ <input
755
+ ref={fileInputRef}
756
+ type="file"
757
+ multiple
758
+ className="sr-only"
759
+ onChange={(event) => handleFilesSelected(event.target.files)}
760
+ disabled={!canAttachFiles}
761
+ aria-hidden="true"
762
+ />
763
+ <button
764
+ type="button"
765
+ onClick={() => fileInputRef.current?.click()}
766
+ disabled={!canAttachFiles}
767
+ aria-label={messages.attachFiles}
768
+ className={cn(
769
+ "flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
770
+ "hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40",
771
+ "disabled:cursor-not-allowed disabled:opacity-50"
772
+ )}
773
+ >
774
+ <Plus className="size-[18px]" strokeWidth={1.75} />
775
+ </button>
776
+ {showPermissions ? (
777
+ <ApprovalModeChip mode={approvalMode} onChange={changeApprovalMode} />
778
+ ) : null}
779
+ <span className="min-w-2 flex-1" />
780
+ {onSelectModel && onSelectReasoning ? (
781
+ <ModelControls
782
+ models={models}
783
+ selectedModel={selectedModel}
784
+ selectedReasoning={selectedReasoning}
785
+ loading={modelsLoading}
786
+ error={modelsError}
787
+ disabled={disabled || pending || running}
788
+ onSelectModel={onSelectModel}
789
+ onSelectReasoning={onSelectReasoning}
790
+ onResetReasoning={onResetReasoning}
791
+ usingDefault={usingDefaultModel}
792
+ onResetToDefault={onResetModelSelection}
793
+ routing={modelRouting}
794
+ />
795
+ ) : null}
796
+ {dictation ? (
797
+ <DictationButton
798
+ dictation={voice}
799
+ disabled={disabled}
800
+ variant="ghost"
801
+ size="icon-sm"
802
+ className="ml-1 bg-transparent text-muted-foreground shadow-none hover:text-foreground"
803
+ />
804
+ ) : null}
805
+ {running && onStop ? (
806
+ <button
807
+ type="button"
808
+ onClick={onStop}
809
+ disabled={stopping}
810
+ aria-label={messages.stop}
811
+ className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
812
+ >
813
+ {stopping ? (
814
+ <Spinner className="size-3.5" />
815
+ ) : (
816
+ <Square className="size-2.5 fill-current" />
817
+ )}
818
+ </button>
761
819
  ) : (
762
- <ArrowUp className="size-4" strokeWidth={2.25} />
820
+ <button
821
+ type="button"
822
+ onClick={submit}
823
+ disabled={!canSend}
824
+ aria-label={messages.send}
825
+ className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
826
+ >
827
+ {pending || uploading ? (
828
+ <Spinner className="size-3.5" />
829
+ ) : (
830
+ <ArrowUp className="size-4" strokeWidth={2.25} />
831
+ )}
832
+ </button>
763
833
  )}
764
- </button>
834
+ </>
765
835
  )}
766
836
  </div>
767
837
  </div>
@@ -772,7 +842,7 @@ export function Composer({
772
842
  <p
773
843
  className={cn(
774
844
  "mt-2 truncate px-4 text-xs text-muted-foreground",
775
- failedCount > 0 && "text-destructive"
845
+ statusIsError && "text-destructive"
776
846
  )}
777
847
  title={statusHint}
778
848
  >
@@ -0,0 +1,110 @@
1
+ import { DictationWaveform, Spinner } from "@sixb/ui/components"
2
+ import type { SpeechRecognitionState } from "@sixb/ui/hooks"
3
+ import { cn } from "@sixb/ui/lib/utils"
4
+ import { Check, X } from "lucide-react"
5
+ import { type KeyboardEvent, useEffect, useState } from "react"
6
+ import { useAgentMessages } from "../i18n"
7
+
8
+ export interface DictationBarProps {
9
+ /** A dictation under way: starting, listening, or transcribing. */
10
+ readonly dictation: SpeechRecognitionState
11
+ /** The filled control's look, so Done sits where Send was. */
12
+ readonly doneClassName: string
13
+ }
14
+
15
+ /**
16
+ * The composer's toolbar while a message is dictated: cancel, the voice as a waveform, how long it
17
+ * has run, and Done. Done takes the focus, so Enter or Space finishes and Escape cancels.
18
+ */
19
+ export function DictationBar({ dictation, doneClassName }: DictationBarProps) {
20
+ const messages = useAgentMessages().composer
21
+ const transcribing = dictation.status === "stopping"
22
+ const seconds = useRecordingSeconds(dictation.status === "listening")
23
+
24
+ const cancelOnEscape = (event: KeyboardEvent) => {
25
+ if (event.key !== "Escape") return
26
+ event.preventDefault()
27
+ dictation.abort()
28
+ }
29
+
30
+ return (
31
+ // Escape is a shortcut: both buttons stay reachable with the keyboard.
32
+ <div className="flex min-w-0 flex-1 items-center gap-2" onKeyDown={cancelOnEscape}>
33
+ <button
34
+ type="button"
35
+ onClick={dictation.abort}
36
+ aria-label={messages.cancelDictation}
37
+ title={messages.cancelDictation}
38
+ className={cn(
39
+ "flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
40
+ "hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40"
41
+ )}
42
+ >
43
+ <X className="size-[18px]" strokeWidth={1.75} />
44
+ </button>
45
+
46
+ <DictationWaveform
47
+ dictation={dictation}
48
+ className={cn(
49
+ "min-w-0 flex-1 text-foreground/60 transition-opacity duration-300",
50
+ transcribing && "opacity-30"
51
+ )}
52
+ />
53
+
54
+ <span
55
+ className="w-10 shrink-0 text-right text-xs text-muted-foreground tabular-nums"
56
+ aria-hidden="true"
57
+ >
58
+ {formatSeconds(seconds)}
59
+ </span>
60
+ <span className="sr-only" role="status">
61
+ {transcribing ? messages.dictationTranscribing : messages.dictationListening}
62
+ </span>
63
+
64
+ <button
65
+ type="button"
66
+ // The reader just pressed the microphone: Done is what comes next. It stays focusable while
67
+ // transcribing, so the focus, and Escape with it, stay in the bar.
68
+ autoFocus
69
+ onClick={transcribing ? undefined : dictation.stop}
70
+ aria-disabled={transcribing}
71
+ aria-label={messages.finishDictation}
72
+ title={messages.finishDictation}
73
+ className={cn(
74
+ doneClassName,
75
+ "ml-1 aria-disabled:bg-foreground/25 dark:aria-disabled:bg-white/20"
76
+ )}
77
+ >
78
+ {transcribing ? (
79
+ <Spinner className="size-3.5" />
80
+ ) : (
81
+ <Check className="size-4" strokeWidth={2.25} />
82
+ )}
83
+ </button>
84
+ </div>
85
+ )
86
+ }
87
+
88
+ /** Whole seconds since recording started, held while it is transcribed. */
89
+ function useRecordingSeconds(recording: boolean): number {
90
+ const [seconds, setSeconds] = useState(0)
91
+
92
+ useEffect(() => {
93
+ if (!recording) return
94
+
95
+ const startedAt = Date.now()
96
+ setSeconds(0)
97
+ const timer = setInterval(() => {
98
+ setSeconds(Math.floor((Date.now() - startedAt) / 1000))
99
+ }, 250)
100
+ return () => clearInterval(timer)
101
+ }, [recording])
102
+
103
+ return seconds
104
+ }
105
+
106
+ function formatSeconds(total: number): string {
107
+ const minutes = Math.floor(total / 60)
108
+ const seconds = total % 60
109
+ return `${minutes}:${String(seconds).padStart(2, "0")}`
110
+ }
@@ -0,0 +1,48 @@
1
+ import { type ListModelsResponse, transcribeAudio } from "@sixb/client"
2
+ import { createRecordingSpeechRecognizer, type SpeechRecognizer } from "@sixb/ui/lib/speech"
3
+
4
+ // btoa takes a string of byte characters; spreading the whole recording would overflow the stack.
5
+ const BASE64_CHUNK_BYTES = 0x8000
6
+
7
+ const projectRecognizer = createRecordingSpeechRecognizer({
8
+ id: "sixb-transcription",
9
+ transcribe: transcribeDictation,
10
+ })
11
+
12
+ /**
13
+ * The recognizer behind the chat's microphone, when the project declares a transcription model
14
+ * and the reader may call it; otherwise none, and the chat shows no microphone. Never the
15
+ * browser's own recognition, which sends the audio to Google or Apple.
16
+ */
17
+ export function projectDictation(
18
+ catalog: ListModelsResponse | undefined
19
+ ): SpeechRecognizer | undefined {
20
+ if (!catalog?.capabilities.run || catalog.audio.transcription.length === 0) return undefined
21
+ return projectRecognizer
22
+ }
23
+
24
+ /**
25
+ * Transcribes a recording with the project's default transcription model. The audio travels
26
+ * inline in the request: it reaches the model without ever being stored.
27
+ */
28
+ export async function transcribeDictation(
29
+ audio: Blob,
30
+ { signal }: { readonly signal: AbortSignal }
31
+ ): Promise<string> {
32
+ const { data } = await transcribeAudio({
33
+ body: { audio: { data: await toBase64(audio), mediaType: audio.type } },
34
+ signal,
35
+ throwOnError: true,
36
+ })
37
+ return data.text
38
+ }
39
+
40
+ async function toBase64(audio: Blob): Promise<string> {
41
+ const bytes = new Uint8Array(await audio.arrayBuffer())
42
+ let binary = ""
43
+ for (let offset = 0; offset < bytes.length; offset += BASE64_CHUNK_BYTES) {
44
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + BASE64_CHUNK_BYTES))
45
+ }
46
+
47
+ return btoa(binary)
48
+ }
@@ -44,6 +44,7 @@ import type { SandboxRecoveryProps } from "../components/sandbox-recovery"
44
44
  import type { TranscriptProps } from "../components/transcript"
45
45
  import { conversationMessages, conversationTurn, type PendingUserMessage } from "../conversation"
46
46
  import type { TranscriptDelegation } from "../delegation/context"
47
+ import { projectDictation } from "../dictation"
47
48
  import { useAgentMessages } from "../i18n"
48
49
  import { knownName } from "../message-authors"
49
50
  import {
@@ -134,6 +135,7 @@ export type ConversationComposerProps = Pick<
134
135
  | "approvalMode"
135
136
  | "onApprovalModeChange"
136
137
  | "awaitingApproval"
138
+ | "dictation"
137
139
  >
138
140
 
139
141
  export type AgentConversation = ReturnType<typeof useAgentConversation>
@@ -963,6 +965,7 @@ export function useAgentConversation({ threadId, onThreadCreated }: UseAgentConv
963
965
  approvalMode,
964
966
  onApprovalModeChange: setApprovalMode,
965
967
  awaitingApproval,
968
+ dictation: projectDictation(modelsQuery.data),
966
969
  }
967
970
 
968
971
  const sandboxRecoveryProps: SandboxRecoveryProps | null = sandboxRecovery
@@ -70,6 +70,10 @@ export const en = {
70
70
  removeUnnamedAttachment: "Remove attachment",
71
71
  addFiles: "Add files",
72
72
  dropFiles: "Drop any file here to attach it to the conversation.",
73
+ dictationListening: "Listening…",
74
+ dictationTranscribing: "Transcribing…",
75
+ cancelDictation: "Cancel dictation",
76
+ finishDictation: "Done",
73
77
  },
74
78
  files: {
75
79
  spreadsheet: "Spreadsheet",
@@ -66,6 +66,10 @@ export const fr: Translation<AgentMessages> = {
66
66
  removeUnnamedAttachment: "Retirer la pièce jointe",
67
67
  addFiles: "Ajouter des fichiers",
68
68
  dropFiles: "Déposez un fichier ici pour le joindre à la conversation.",
69
+ dictationListening: "À l’écoute…",
70
+ dictationTranscribing: "Transcription…",
71
+ cancelDictation: "Annuler la dictée",
72
+ finishDictation: "Terminer",
69
73
  },
70
74
  files: {
71
75
  spreadsheet: "Feuille de calcul",