Skip to content

Commit befc14c

Browse files
Merge remote-tracking branch 'origin/main' into pr-125065
# Conflicts: # packages/gateway-protocol/src/index.ts
2 parents c62c44d + 3e0c980 commit befc14c

503 files changed

Lines changed: 12715 additions & 5486 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.

‎.github/workflows/website-installer-sync.yml‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ jobs:
3838
steps:
3939
- name: Checkout
4040
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
41-
- name: Install ShellCheck
42-
run: sudo apt-get update -y && sudo apt-get install -y shellcheck
43-
4441
- name: Shell syntax
4542
run: bash -n scripts/install.sh scripts/install-cli.sh
4643

@@ -387,10 +384,6 @@ jobs:
387384
with:
388385
node-version: "24"
389386

390-
- name: Install ShellCheck
391-
if: steps.changes.outputs.changed == 'true'
392-
run: sudo apt-get update -y && sudo apt-get install -y shellcheck
393-
394387
- name: Verify website with synced installers
395388
if: steps.changes.outputs.changed == 'true'
396389
working-directory: openclaw.ai

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

Lines changed: 11 additions & 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/chat/ChatController.kt‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6658,6 +6658,7 @@ class ChatController internal constructor(
66586658
.asArrayOrNull()
66596659
?.mapNotNull { it.asStringOrNull()?.trim()?.takeIf(String::isNotEmpty) },
66606660
hasActiveRunMetadata = "hasActiveRun" in obj || "activeRunIds" in obj,
6661+
hasActiveRunIdsMetadata = "activeRunIds" in obj,
66616662
parentSessionKey = obj["parentSessionKey"].asStringOrNull()?.trim(),
66626663
spawnedBy = obj["spawnedBy"].asStringOrNull()?.trim(),
66636664
hasActiveSubagentRun = obj["hasActiveSubagentRun"].asBooleanOrNull(),
@@ -6877,13 +6878,15 @@ class ChatController internal constructor(
68776878
upsertSessionEntry(
68786879
info,
68796880
preserveExistingContextUsageWithoutTotal = true,
6881+
replaceActiveRunIds = true,
68806882
publishRunState = publishRunState,
68816883
)
68826884
}
68836885

68846886
private fun upsertSessionEntry(
68856887
entry: ChatSessionEntry,
68866888
preserveExistingContextUsageWithoutTotal: Boolean = false,
6889+
replaceActiveRunIds: Boolean = false,
68876890
clearedFields: Set<String> = emptySet(),
68886891
publishRunState: Boolean = true,
68896892
) {
@@ -6898,6 +6901,7 @@ class ChatController internal constructor(
68986901
existing = it[index],
68996902
next = entry,
69006903
preserveExistingContextUsageWithoutTotal = preserveExistingContextUsageWithoutTotal,
6904+
replaceActiveRunIds = replaceActiveRunIds,
69016905
)
69026906
if (clearedFields.isNotEmpty()) {
69036907
applied =
@@ -7532,10 +7536,12 @@ internal fun mergeChatSessionEntry(
75327536
existing: ChatSessionEntry,
75337537
next: ChatSessionEntry,
75347538
preserveExistingContextUsageWithoutTotal: Boolean = false,
7539+
replaceActiveRunIds: Boolean = false,
75357540
): ChatSessionEntry {
75367541
val preserveExistingContextUsage = preserveExistingContextUsageWithoutTotal && next.totalTokens == null
75377542
val hasActiveRun = if (next.hasActiveRunMetadata) next.hasActiveRun else existing.hasActiveRun
7538-
val activeRunIds = if (next.hasActiveRunMetadata) next.activeRunIds else existing.activeRunIds
7543+
val activeRunIds =
7544+
if (replaceActiveRunIds || next.hasActiveRunIdsMetadata) next.activeRunIds else existing.activeRunIds
75397545
val observerDigest =
75407546
reconcileSessionObserverDigest(
75417547
existing = existing.observerDigest,
@@ -7600,6 +7606,12 @@ internal fun mergeChatSessionEntry(
76007606
hasActiveRun = hasActiveRun,
76017607
activeRunIds = activeRunIds,
76027608
hasActiveRunMetadata = existing.hasActiveRunMetadata || next.hasActiveRunMetadata,
7609+
hasActiveRunIdsMetadata =
7610+
if (replaceActiveRunIds) {
7611+
next.hasActiveRunIdsMetadata
7612+
} else {
7613+
existing.hasActiveRunIdsMetadata || next.hasActiveRunIdsMetadata
7614+
},
76037615
parentSessionKey = next.parentSessionKey ?: existing.parentSessionKey,
76047616
spawnedBy = next.spawnedBy ?: existing.spawnedBy,
76057617
hasActiveSubagentRun = next.hasActiveSubagentRun ?: existing.hasActiveSubagentRun,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ data class ChatSessionEntry(
332332
val hasActiveRun: Boolean? = null,
333333
val activeRunIds: List<String>? = null,
334334
val hasActiveRunMetadata: Boolean = hasActiveRun != null || activeRunIds != null,
335+
val hasActiveRunIdsMetadata: Boolean = activeRunIds != null,
335336
val parentSessionKey: String? = null,
336337
val spawnedBy: String? = null,
337338
val hasActiveSubagentRun: Boolean? = null,

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,26 @@ internal fun DesktopScreen(
103103
}
104104
}
105105

106-
/** Builds the desktop document route; credentials stay in ControlUiWebView's startup script. */
106+
/** Builds the desktop focus route; credentials stay in ControlUiWebView's startup script. */
107107
internal fun desktopUrl(
108108
baseUrl: String,
109109
source: String? = null,
110110
session: String? = null,
111111
): String {
112-
val baseUri = baseUrl.trimEnd('/').toUri()
113-
val routePath = "${baseUri.encodedPath.orEmpty().trimEnd('/')}/"
112+
val normalizedSource = source?.trim()?.takeIf(String::isNotEmpty)
113+
val normalizedSession = session?.trim()?.takeIf(String::isNotEmpty)
114114
val builder =
115-
baseUri
115+
baseUrl
116+
.trimEnd('/')
117+
.toUri()
116118
.buildUpon()
117-
.encodedPath(routePath)
118119
.clearQuery()
119120
.fragment(null)
120-
.appendQueryParameter("view", "desktop")
121-
source?.let { builder.appendQueryParameter("source", it) }
122-
session?.let { builder.appendQueryParameter("session", it) }
121+
.appendPath("focus")
122+
.appendPath("desktop")
123+
when {
124+
normalizedSource != null -> builder.appendPath("source").appendPath(normalizedSource)
125+
normalizedSession != null -> builder.appendPath("session").appendPath(normalizedSession)
126+
}
123127
return builder.build().toString()
124128
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import androidx.compose.ui.Alignment
2727
import androidx.compose.ui.Modifier
2828
import androidx.compose.ui.text.style.TextOverflow
2929
import androidx.compose.ui.unit.dp
30+
import androidx.core.net.toUri
3031

3132
/**
3233
* Full-height terminal surface: embeds the gateway-served terminal-only
33-
* Control UI document (`/?view=terminal`, the same ghostty-web surface the
34+
* Control UI focus document (`/focus/terminal`, the same ghostty-web surface the
3435
* desktop Control UI uses) for the currently connected gateway.
3536
*/
3637
@Composable
@@ -61,7 +62,7 @@ internal fun TerminalSettingsScreen(
6162
key(page) {
6263
ControlUiWebView(
6364
page = page,
64-
url = "${page.baseUrl}/?view=terminal",
65+
url = terminalUrl(page.baseUrl),
6566
modifier = Modifier.fillMaxSize(),
6667
)
6768
}
@@ -75,3 +76,16 @@ internal fun TerminalSettingsScreen(
7576
}
7677
}
7778
}
79+
80+
/** Builds the terminal focus route without putting gateway credentials in the URL. */
81+
internal fun terminalUrl(baseUrl: String): String =
82+
baseUrl
83+
.trimEnd('/')
84+
.toUri()
85+
.buildUpon()
86+
.clearQuery()
87+
.fragment(null)
88+
.appendPath("focus")
89+
.appendPath("terminal")
90+
.build()
91+
.toString()

‎apps/android/app/src/test/java/ai/openclaw/app/GatewayBootstrapAuthTest.kt‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import kotlinx.coroutines.Job
3030
import kotlinx.coroutines.asCoroutineDispatcher
3131
import kotlinx.coroutines.async
3232
import kotlinx.coroutines.cancelAndJoin
33+
import kotlinx.coroutines.currentCoroutineContext
3334
import kotlinx.coroutines.delay
3435
import kotlinx.coroutines.flow.MutableStateFlow
3536
import kotlinx.coroutines.runBlocking
@@ -438,37 +439,26 @@ class GatewayBootstrapAuthTest {
438439
fun connect_ignoresStaleTlsProbeAfterDisconnect() =
439440
runBlocking {
440441
val fingerprint = "aa".repeat(32)
441-
val probeStarted = CompletableDeferred<Unit>()
442+
val probeJob = CompletableDeferred<Job>()
442443
val probeResult = CompletableDeferred<GatewayTlsProbeResult>()
443444
val (_, prefs, runtime) =
444445
gatewayFixture { _, _ ->
445-
probeStarted.complete(Unit)
446+
probeJob.complete(checkNotNull(currentCoroutineContext()[Job]))
446447
probeResult.await()
447448
}
448449
val endpoint = GatewayEndpoint.manual(host = "gateway.example", port = 18789)
449450
prefs.saveGatewayTlsFingerprint(endpoint.stableId, fingerprint)
450-
val runtimeScope = readField<CoroutineScope>(runtime, "scope")
451-
val existingJobs =
452-
runtimeScope.coroutineContext[Job]
453-
?.children
454-
?.toSet()
455-
.orEmpty()
456451

457452
runtime.connect(
458453
endpoint,
459454
auth(token = "shared-token"),
460455
)
461-
probeStarted.await()
462-
val probeJob =
463-
runtimeScope.coroutineContext[Job]
464-
?.children
465-
?.singleOrNull { it !in existingJobs }
466-
?: error("Expected one TLS probe job")
456+
val tlsProbeJob = probeJob.await()
467457

468458
runtime.disconnect()
469459
probeResult.complete(GatewayTlsProbeResult(fingerprintSha256 = fingerprint))
470460
// Join the owning coroutine so assertions run after its stale-attempt guard.
471-
probeJob.join()
461+
tlsProbeJob.join()
472462

473463
assertNull(runtime.pendingGatewayTrust.value)
474464
assertNull(desiredBootstrapToken(runtime, "nodeSession"))

‎apps/android/app/src/test/java/ai/openclaw/app/chat/ChatControllerReconnectRestoreTest.kt‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,29 @@ class ChatControllerReconnectRestoreTest {
482482
assertEquals(1, controller.messages.value.size)
483483
}
484484

485+
@Test
486+
fun reconnectHistoryOmissionClearsStaleExactRunIds() =
487+
runTest {
488+
val gateway = ScriptedGateway(json)
489+
val controller = loadController(gateway, history(emptyList()))
490+
controller.handleGatewayEvent(
491+
"sessions.changed",
492+
"""{"reason":"patch","session":{"key":"main","agentId":"main","hasActiveRun":true,"activeRunIds":["run-stale"]}}""",
493+
)
494+
assertEquals("run-stale", controller.selectedActiveRunPresentation.value.runId)
495+
496+
gateway.respondWith(
497+
"chat.history",
498+
history(emptyList(), hasActiveRun = true, activeRunIds = null),
499+
)
500+
val pendingSessionList = CompletableDeferred<String>()
501+
gateway.respond("sessions.list") { pendingSessionList.await() }
502+
reconnect(controller)
503+
504+
assertEquals(1, controller.selectedActiveRunPresentation.value.count)
505+
assertNull(controller.selectedActiveRunPresentation.value.runId)
506+
}
507+
485508
@Test
486509
fun reconnectStaysUnhealthyUntilRecoveryHistoryApplies() =
487510
runTest {

‎apps/android/app/src/test/java/ai/openclaw/app/chat/ChatControllerUsageStreamTest.kt‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ class ChatControllerUsageStreamTest {
110110
assertEquals("main:active", presentation.clockKey)
111111
}
112112

113+
@Test
114+
@OptIn(ExperimentalCoroutinesApi::class)
115+
fun activeRunIdTombstoneClearsExactIdsWhileOmissionPreservesThem() =
116+
runTest {
117+
val gateway = ScriptedGateway(json)
118+
val controller = ChatController(scope = backgroundScope, json = json, requestGateway = gateway::request)
119+
controller.handleGatewayEvent("sessions.changed", advertise("run-exact"))
120+
assertEquals("run-exact", controller.selectedActiveRunPresentation.value.runId)
121+
122+
controller.handleGatewayEvent(
123+
"sessions.changed",
124+
"""{"reason":"patch","session":{"key":"main","agentId":"main","hasActiveRun":true}}""",
125+
)
126+
assertEquals("run-exact", controller.selectedActiveRunPresentation.value.runId)
127+
128+
controller.handleGatewayEvent(
129+
"sessions.changed",
130+
"""{"reason":"patch","session":{"key":"main","agentId":"main","hasActiveRun":true,"activeRunIds":null}}""",
131+
)
132+
assertEquals(1, controller.selectedActiveRunPresentation.value.count)
133+
assertNull(controller.selectedActiveRunPresentation.value.runId)
134+
}
135+
113136
@Test
114137
@OptIn(ExperimentalCoroutinesApi::class)
115138
fun idlessReplacementRunGetsANewStartedAtClockKey() =

0 commit comments

Comments
 (0)