Skip to content

Commit 5b4ffdc

Browse files
committed
chore: merge main to include session header test readiness fix
2 parents 62bf7f6 + d3d43eb commit 5b4ffdc

301 files changed

Lines changed: 9030 additions & 3830 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Docs: https://docs.openclaw.ai
6969

7070
### Fixes
7171

72+
- Codex image attachments: decode mixed-case `file://` URLs as local image paths while preserving existing file URL validation and platform behavior. (#121611) Thanks @sunlit-deng.
73+
7274
- **Control UI agent files:** keep confirmed saves and file metadata intact when older reads or list refreshes finish later, preserve newer drafts, and rebuild invalidated file lists without losing the open editor.
7375

7476
- **Control UI terminal transcript settlement:** retire live commentary, tool, and streamed reply projections atomically when the matching durable terminal message arrives, preventing duplicated final responses and transient row overlap after steering. Fixes #127209. Thanks @shakkernerd.

‎apps/.i18n/native-source.json‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import ai.openclaw.app.chat.SESSION_UNREAD_ACK_CAPABILITY
3333
import ai.openclaw.app.chat.SessionBranch
3434
import ai.openclaw.app.chat.SessionForkResult
3535
import ai.openclaw.app.chat.SessionRewindResult
36-
import ai.openclaw.app.chat.SystemSpeechSpeaker
3736
import ai.openclaw.app.gateway.DeviceAuthEntry
3837
import ai.openclaw.app.gateway.DeviceAuthStore
3938
import ai.openclaw.app.gateway.DeviceIdentityStore
@@ -100,6 +99,7 @@ import ai.openclaw.app.voice.AndroidOnDeviceVoiceWakeRecognizer
10099
import ai.openclaw.app.voice.GatewayTranscriptionSession
101100
import ai.openclaw.app.voice.MicCaptureManager
102101
import ai.openclaw.app.voice.PreviewVoiceWakeRecognizer
102+
import ai.openclaw.app.voice.SystemSpeechSpeaker
103103
import ai.openclaw.app.voice.TalkAudioPlayer
104104
import ai.openclaw.app.voice.TalkModeManager
105105
import ai.openclaw.app.voice.TalkPttOnceStart
@@ -1966,7 +1966,7 @@ class NodeRuntime private constructor(
19661966
).also { controller ->
19671967
scope.launch {
19681968
controller.state.collect { state ->
1969-
voiceWakeManager.setSuppressed(VoiceWakeSuppressionReason.MessageSpeech, state != null)
1969+
voiceWakeManager.setSuppressed(VoiceWakeSuppressionReason.MessageSpeech, state?.isActive == true)
19701970
}
19711971
}
19721972
}
Lines changed: 14 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
package ai.openclaw.app.chat
22

33
import ai.openclaw.app.gateway.GatewaySession
4+
import ai.openclaw.app.voice.LocalSpeechSpeaking
45
import ai.openclaw.app.voice.TalkAudioPlaying
56
import ai.openclaw.app.voice.TalkSpeakAudio
6-
import android.content.Context
7-
import android.speech.tts.TextToSpeech
8-
import android.speech.tts.UtteranceProgressListener
97
import android.util.Log
108
import kotlinx.coroutines.CancellationException
11-
import kotlinx.coroutines.CompletableDeferred
129
import kotlinx.coroutines.CoroutineScope
13-
import kotlinx.coroutines.Dispatchers
1410
import kotlinx.coroutines.Job
15-
import kotlinx.coroutines.NonCancellable
1611
import kotlinx.coroutines.flow.MutableStateFlow
1712
import kotlinx.coroutines.flow.StateFlow
1813
import kotlinx.coroutines.flow.asStateFlow
1914
import kotlinx.coroutines.launch
20-
import kotlinx.coroutines.withContext
2115
import kotlinx.serialization.Serializable
2216
import kotlinx.serialization.encodeToString
2317
import kotlinx.serialization.json.Json
@@ -28,26 +22,23 @@ private const val TAG = "MessageSpeech"
2822
internal enum class MessageSpeechPhase {
2923
Preparing,
3024
Speaking,
25+
Failed,
3126
}
3227

33-
/** Playback state for the chat Listen action; null when idle. */
28+
/** Listen state; a failed request remains retryable without claiming audio or microphone use. */
3429
internal data class MessageSpeechState(
3530
val messageId: String,
3631
val phase: MessageSpeechPhase,
37-
)
32+
) {
33+
val isActive: Boolean
34+
get() = phase != MessageSpeechPhase.Failed
35+
}
3836

3937
/** Renders message text to an audio clip; null means fall back to local TTS. */
4038
internal fun interface MessageSpeechSynthesizing {
4139
suspend fun synthesize(text: String): TalkSpeakAudio?
4240
}
4341

44-
/** Speaks text with the on-device engine when the gateway cannot render audio. */
45-
internal interface LocalSpeechSpeaking {
46-
suspend fun speak(text: String)
47-
48-
fun stop()
49-
}
50-
5142
/** Gateway tts.speak client using the general configured TTS provider chain. */
5243
internal class MessageSpeechClient(
5344
private val session: GatewaySession? = null,
@@ -141,7 +132,7 @@ internal class MessageSpeechController(
141132
messageId: String,
142133
text: String,
143134
) {
144-
if (_state.value?.messageId == messageId) {
135+
if (_state.value?.let { it.messageId == messageId && it.isActive } == true) {
145136
stop()
146137
return
147138
}
@@ -175,8 +166,13 @@ internal class MessageSpeechController(
175166
if (!playClip(clip) && generation.get() == token) {
176167
localSpeech.speak(spoken)
177168
}
169+
} catch (err: CancellationException) {
170+
throw err
171+
} catch (err: Throwable) {
172+
Log.w(TAG, "local speech failed: ${err.message ?: err::class.simpleName}")
173+
if (generation.get() == token) _state.value = MessageSpeechState(messageId, MessageSpeechPhase.Failed)
178174
} finally {
179-
if (generation.get() == token) _state.value = null
175+
if (generation.get() == token && _state.value?.isActive == true) _state.value = null
180176
}
181177
}
182178
}
@@ -194,110 +190,3 @@ internal class MessageSpeechController(
194190
}
195191
}
196192
}
197-
198-
/** Minimal on-device TTS wrapper for the chat Listen fallback voice. */
199-
internal class SystemSpeechSpeaker(
200-
private val context: Context,
201-
) : LocalSpeechSpeaking {
202-
private val lock = Any()
203-
private var engine: TextToSpeech? = null
204-
private var ready: CompletableDeferred<Boolean>? = null
205-
private var active: CompletableDeferred<Unit>? = null
206-
207-
override suspend fun speak(text: String) {
208-
val engine = ensureEngine() ?: return
209-
val utteranceId = "chat-listen-${System.nanoTime()}"
210-
val done = CompletableDeferred<Unit>()
211-
synchronized(lock) {
212-
active?.cancel()
213-
active = done
214-
}
215-
withContext(Dispatchers.Main.immediate) {
216-
engine.setOnUtteranceProgressListener(
217-
object : UtteranceProgressListener() {
218-
override fun onStart(id: String?) {}
219-
220-
override fun onDone(id: String?) {
221-
if (id == utteranceId) done.complete(Unit)
222-
}
223-
224-
@Deprecated("Deprecated in Java")
225-
override fun onError(id: String?) {
226-
if (id == utteranceId) done.complete(Unit)
227-
}
228-
229-
override fun onError(
230-
id: String?,
231-
errorCode: Int,
232-
) {
233-
if (id == utteranceId) done.complete(Unit)
234-
}
235-
},
236-
)
237-
if (engine.speak(text, TextToSpeech.QUEUE_FLUSH, null, utteranceId) != TextToSpeech.SUCCESS) {
238-
done.complete(Unit)
239-
}
240-
}
241-
try {
242-
done.await()
243-
} finally {
244-
synchronized(lock) {
245-
if (active === done) active = null
246-
}
247-
}
248-
}
249-
250-
override fun stop() {
251-
synchronized(lock) {
252-
active?.cancel()
253-
active = null
254-
}
255-
engine?.stop()
256-
}
257-
258-
private suspend fun ensureEngine(): TextToSpeech? {
259-
val current = synchronized(lock) { ready }
260-
val pending = current ?: createEngine()
261-
if (pending.await()) return synchronized(lock) { engine }
262-
263-
// A failed Android TTS service can recover later; do not cache its failed initialization.
264-
val failedEngine =
265-
synchronized(lock) {
266-
if (ready !== pending) return null
267-
ready = null
268-
engine.also { engine = null }
269-
}
270-
withContext(Dispatchers.Main.immediate) { failedEngine?.shutdown() }
271-
return null
272-
}
273-
274-
private suspend fun createEngine(): CompletableDeferred<Boolean> {
275-
val pending = CompletableDeferred<Boolean>()
276-
val ownsInitialization =
277-
synchronized(lock) {
278-
if (ready != null) {
279-
false
280-
} else {
281-
ready = pending
282-
true
283-
}
284-
}
285-
if (!ownsInitialization) return synchronized(lock) { checkNotNull(ready) }
286-
287-
val created =
288-
try {
289-
// Finish publishing the constructed engine even if the Listen job is stopped mid-init.
290-
withContext(NonCancellable + Dispatchers.Main.immediate) {
291-
TextToSpeech(context) { status -> pending.complete(status == TextToSpeech.SUCCESS) }
292-
}
293-
} catch (err: Throwable) {
294-
Log.d(TAG, "system TTS initialization failed: ${err.message ?: err::class.simpleName}")
295-
pending.complete(false)
296-
null
297-
}
298-
synchronized(lock) {
299-
if (ready === pending) engine = created else created?.shutdown()
300-
}
301-
return pending
302-
}
303-
}

‎apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatScreen.kt‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fun ChatScreen(
330330
val micCooldown by viewModel.micCooldown.collectAsState()
331331
val talkModeEnabled by viewModel.talkModeEnabled.collectAsState()
332332
val talkModeListening by viewModel.talkModeListening.collectAsState()
333-
val inlineMediaPlaybackBlocked = messageSpeechState != null || talkModeEnabled || talkModeListening
333+
val inlineMediaPlaybackBlocked = messageSpeechState?.isActive == true || talkModeEnabled || talkModeListening
334334
val thinkingSupported =
335335
chatThinkingSupported(
336336
selection = thinkingLevelSelection,
@@ -1781,7 +1781,7 @@ internal fun ChatBubble(
17811781
onRewind = entryId?.let { value -> { onRewindMessage(value) } },
17821782
onFork = entryId?.let { value -> { onForkMessage(value) } },
17831783
enabled = !live,
1784-
listenActive = messageSpeech != null,
1784+
listenActive = messageSpeech?.isActive == true,
17851785
onToggleListen = toggleListen,
17861786
modifier =
17871787
Modifier
@@ -1869,7 +1869,7 @@ internal fun ChatBubble(
18691869
messageSpeech?.let { speech ->
18701870
FullChatSpeechIndicator(
18711871
phase = speech.phase,
1872-
onStop = { onToggleListen(checkNotNull(messageId), messageText) },
1872+
onToggle = { onToggleListen(checkNotNull(messageId), messageText) },
18731873
)
18741874
}
18751875
timestampMs?.let {
@@ -1889,10 +1889,10 @@ internal fun ChatBubble(
18891889
@Composable
18901890
private fun FullChatSpeechIndicator(
18911891
phase: MessageSpeechPhase,
1892-
onStop: () -> Unit,
1892+
onToggle: () -> Unit,
18931893
) {
18941894
Surface(
1895-
onClick = onStop,
1895+
onClick = onToggle,
18961896
shape = RoundedCornerShape(999.dp),
18971897
color = ClawTheme.colors.surfacePressed,
18981898
) {
@@ -1903,17 +1903,22 @@ private fun FullChatSpeechIndicator(
19031903
) {
19041904
Icon(
19051905
imageVector =
1906-
if (phase == MessageSpeechPhase.Preparing) {
1907-
Icons.Default.HourglassEmpty
1908-
} else {
1909-
Icons.AutoMirrored.Filled.VolumeUp
1906+
when (phase) {
1907+
MessageSpeechPhase.Preparing -> Icons.Default.HourglassEmpty
1908+
MessageSpeechPhase.Speaking -> Icons.AutoMirrored.Filled.VolumeUp
1909+
MessageSpeechPhase.Failed -> Icons.Default.Refresh
19101910
},
19111911
contentDescription = null,
19121912
modifier = Modifier.size(14.dp),
19131913
tint = ClawTheme.colors.textMuted,
19141914
)
19151915
Text(
1916-
text = if (phase == MessageSpeechPhase.Preparing) nativeString("Preparing audio…") else nativeString("Speaking…"),
1916+
text =
1917+
when (phase) {
1918+
MessageSpeechPhase.Preparing -> nativeString("Preparing audio…")
1919+
MessageSpeechPhase.Speaking -> nativeString("Speaking…")
1920+
MessageSpeechPhase.Failed -> nativeString("Audio error · Retry")
1921+
},
19171922
style = ClawTheme.type.caption,
19181923
color = ClawTheme.colors.textMuted,
19191924
)

0 commit comments

Comments
 (0)