@@ -87,6 +87,8 @@ struct OpenClawChatComposer: View {
8787 let isAttachmentInputEnabled : Bool
8888 let messagePlaceholder : String ?
8989 let talkControl : OpenClawChatTalkControl ?
90+ let voiceNoteControl : OpenClawChatVoiceNoteControl ?
91+ @ State private var stagingVoiceNoteURL : URL ?
9092
9193 #if !os( macOS )
9294 @ State private var pickerItems : [ PhotosPickerItem ] = [ ]
@@ -101,15 +103,20 @@ struct OpenClawChatComposer: View {
101103
102104 var body : some View {
103105 VStack ( alignment : . leading , spacing : 4 ) {
104- if self . showsToolbar {
106+ if self . showsToolbar , self . voiceNoteControl ? . recorder . isRecording != true {
105107 self . composerToolbar
106108 }
107109
108110 if self . showsAttachments , ! self . viewModel . attachments . isEmpty {
109111 self . attachmentsStrip
110112 }
111113
112- self . editor
114+ if let voiceNoteControl , voiceNoteControl . recorder . isRecording {
115+ OpenClawVoiceNoteRecordingRow ( recorder : voiceNoteControl . recorder )
116+ . padding ( self . editorPadding )
117+ } else {
118+ self . editor
119+ }
113120 }
114121 . padding ( self . composerPadding )
115122 . background {
@@ -163,6 +170,18 @@ struct OpenClawChatComposer: View {
163170 self . viewModel . loadSlashCommandsIfNeeded ( )
164171 }
165172 #endif
173+ . onChange ( of : self . voiceNoteControl ? . recorder . completedRecording ) { _ , recording in
174+ guard recording != nil else { return }
175+ self . stageCompletedVoiceNoteIfNeeded ( )
176+ }
177+ . onChange ( of : self . voiceNoteControl ? . recorder . errorMessage ) { _ , message in
178+ if let message {
179+ self . viewModel . errorText = message
180+ }
181+ }
182+ . onAppear {
183+ self . stageCompletedVoiceNoteIfNeeded ( )
184+ }
166185 }
167186
168187 private var composerToolbar : some View {
@@ -193,6 +212,13 @@ struct OpenClawChatComposer: View {
193212 if self . style == . standard {
194213 self . refreshButton
195214 self . attachmentPicker
215+ if let voiceNoteControl , ! voiceNoteControl . isTalkActive {
216+ OpenClawVoiceNoteButton (
217+ control : voiceNoteControl ,
218+ compact : false ,
219+ isComposerEnabled : self . isComposerEnabled ,
220+ isAttachmentInputEnabled : self . isAttachmentInputEnabled )
221+ }
196222 }
197223 }
198224 . padding ( . horizontal , 10 )
@@ -400,13 +426,27 @@ struct OpenClawChatComposer: View {
400426 . scaledToFill ( )
401427 . frame ( width : 22 , height : 22 )
402428 . clipShape ( RoundedRectangle ( cornerRadius : 6 , style : . continuous ) )
429+ } else if att . mimeType . hasPrefix ( " audio/ " ) {
430+ Image ( systemName : " waveform " )
431+ Text ( " Voice note " )
432+ . font ( OpenClawChatTypography . caption )
433+ if let durationSeconds = att . durationSeconds {
434+ Text ( openClawVoiceNoteDurationLabel ( durationSeconds ) )
435+ . font ( OpenClawChatTypography . caption )
436+ . foregroundStyle ( . secondary )
437+ }
403438 } else {
404439 Image ( systemName : " photo " )
440+ Text ( att . fileName )
441+ . font ( OpenClawChatTypography . caption )
442+ . lineLimit ( 1 )
405443 }
406444
407- Text ( att . fileName )
408- . font ( OpenClawChatTypography . caption )
409- . lineLimit ( 1 )
445+ if att . preview != nil {
446+ Text ( att . fileName )
447+ . font ( OpenClawChatTypography . caption )
448+ . lineLimit ( 1 )
449+ }
410450
411451 Button {
412452 self . viewModel . removeAttachment ( att . id )
@@ -497,6 +537,15 @@ struct OpenClawChatComposer: View {
497537 self . attachmentPicker
498538 . frame ( width : self . cleanIconControlSize , height : self . cleanEditorMinHeight )
499539
540+ if let voiceNoteControl , ! voiceNoteControl . isTalkActive {
541+ OpenClawVoiceNoteButton (
542+ control : voiceNoteControl ,
543+ compact : true ,
544+ isComposerEnabled : self . isComposerEnabled ,
545+ isAttachmentInputEnabled : self . isAttachmentInputEnabled )
546+ . frame ( width : self . cleanIconControlSize , height : self . cleanEditorMinHeight )
547+ }
548+
500549 self . editorOverlay
501550 . padding ( . vertical , self . cleanEditorTextPadding )
502551 . padding ( . horizontal , 14 )
@@ -1030,10 +1079,31 @@ struct OpenClawChatComposer: View {
10301079
10311080 private var canSendMessage : Bool {
10321081 self . isComposerEnabled
1082+ && self . voiceNoteControl ? . recorder . completedRecording == nil
10331083 && self . viewModel . canSend
10341084 && ( self . isAttachmentInputEnabled || self . viewModel . attachments . isEmpty )
10351085 }
10361086
1087+ private func stageCompletedVoiceNoteIfNeeded ( ) {
1088+ guard let recorder = self . voiceNoteControl ? . recorder ,
1089+ let recording = recorder . completedRecording ,
1090+ self . stagingVoiceNoteURL != recording . fileURL
1091+ else { return }
1092+
1093+ self . stagingVoiceNoteURL = recording . fileURL
1094+ Task {
1095+ await self . viewModel . addVoiceNoteAttachment (
1096+ fileURL : recording . fileURL ,
1097+ durationSeconds : recording . durationSeconds )
1098+ if recorder . completedRecording == recording {
1099+ recorder . clearCompletedRecording ( )
1100+ }
1101+ if self . stagingVoiceNoteURL == recording . fileURL {
1102+ self . stagingVoiceNoteURL = nil
1103+ }
1104+ }
1105+ }
1106+
10371107 private var connectionStatusText : String {
10381108 self . connectionOK ? " Gateway connected " : " Connecting... "
10391109 }
0 commit comments