@@ -160,13 +160,24 @@ struct ChatMessage: Identifiable, Equatable {
160160 case system
161161 }
162162
163+ enum InputModality : Equatable {
164+ case text
165+ case voice
166+ }
167+
163168 var id = UUID ( )
164169 var role : Role
165170 var text : String
166171 var date = Date ( )
167172 var attachments : [ WakeAttachment ] = [ ]
168173 var toolEvents : [ ToolUseEvent ] = [ ]
169174 var isStreaming = false
175+ var inputModality : InputModality = . text
176+ var voiceDuration : TimeInterval ?
177+
178+ var isVoiceMessage : Bool {
179+ role == . user && inputModality == . voice
180+ }
170181}
171182
172183struct WakeAttachment : Identifiable , Equatable {
@@ -189,8 +200,13 @@ struct WakeQueuedPrompt: Identifiable, Equatable {
189200 var text : String
190201 var attachments : [ WakeAttachment ] = [ ]
191202 var date = Date ( )
203+ var inputModality : ChatMessage . InputModality = . text
204+ var voiceDuration : TimeInterval ?
192205
193206 var previewText : String {
207+ if inputModality == . voice {
208+ return " Voice message "
209+ }
194210 let trimmed = text. trimmingCharacters ( in: . whitespacesAndNewlines)
195211 if !trimmed. isEmpty {
196212 return trimmed
@@ -1590,7 +1606,6 @@ final class ElephantAppModel: ObservableObject {
15901606 if status. contains ( " completed " ) || status. contains ( " succeeded " ) || status == " success " {
15911607 onboardingFinalizationStatus = text ( . learningReady)
15921608 onboardingFinalizationComplete = true
1593- onboardingStep = 17
15941609 scheduleOnboardingAutoCompletion ( )
15951610 return
15961611 }
@@ -1602,7 +1617,6 @@ final class ElephantAppModel: ObservableObject {
16021617 }
16031618 onboardingFinalizationStatus = text ( . learningReady)
16041619 onboardingFinalizationComplete = true
1605- onboardingStep = 17
16061620 scheduleOnboardingAutoCompletion ( )
16071621 }
16081622
@@ -2787,12 +2801,20 @@ final class ElephantAppModel: ObservableObject {
27872801 }
27882802
27892803 func sendWakeMessage( ) async {
2804+ await enqueueWakeMessage ( inputModality: . text, voiceDuration: nil )
2805+ }
2806+
2807+ func sendVoiceWakeMessage( duration: TimeInterval ? ) async {
2808+ await enqueueWakeMessage ( inputModality: . voice, voiceDuration: duration)
2809+ }
2810+
2811+ private func enqueueWakeMessage( inputModality: ChatMessage . InputModality , voiceDuration: TimeInterval ? ) async {
27902812 let text = wakeDraft. trimmingCharacters ( in: . whitespacesAndNewlines)
27912813 let attachments = wakeAttachments
27922814 guard !text. isEmpty || !attachments. isEmpty else { return }
27932815 wakeDraft = " "
27942816 wakeAttachments = [ ]
2795- wakeQueue. append ( WakeQueuedPrompt ( text: text, attachments: attachments) )
2817+ wakeQueue. append ( WakeQueuedPrompt ( text: text, attachments: attachments, inputModality : inputModality , voiceDuration : voiceDuration ) )
27962818 focusComposer ( )
27972819 await drainWakeQueueIfNeeded ( )
27982820 }
@@ -2928,12 +2950,22 @@ final class ElephantAppModel: ObservableObject {
29282950 }
29292951 while !wakeQueue. isEmpty {
29302952 let item = wakeQueue. removeFirst ( )
2931- await runWakeMessage ( item. text, attachments: item. attachments)
2953+ await runWakeMessage (
2954+ item. text,
2955+ attachments: item. attachments,
2956+ inputModality: item. inputModality,
2957+ voiceDuration: item. voiceDuration
2958+ )
29322959 }
29332960 }
29342961
2935- private func runWakeMessage( _ text: String , attachments: [ WakeAttachment ] ) async {
2936- messages. append ( ChatMessage ( role: . user, text: text, attachments: attachments) )
2962+ private func runWakeMessage(
2963+ _ text: String ,
2964+ attachments: [ WakeAttachment ] ,
2965+ inputModality: ChatMessage . InputModality ,
2966+ voiceDuration: TimeInterval ?
2967+ ) async {
2968+ messages. append ( ChatMessage ( role: . user, text: text, attachments: attachments, inputModality: inputModality, voiceDuration: voiceDuration) )
29372969 chatScrollRevision += 1
29382970
29392971 let prompt = Self . wakePrompt ( text: text, attachments: attachments)
0 commit comments