Skip to content

Commit 0e0be0d

Browse files
committed
test(doctor): preserve root-alias coverage with isolated temp directories
Integrate the landed Gateway rollback test repair from main and retain version-1 manifest recovery coverage after Vitest canonicalizes its temporary directory. Reuse the existing platform-root alias fixture and assertions.
2 parents faf2dc4 + 871b18d commit 0e0be0d

764 files changed

Lines changed: 30331 additions & 15530 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/labeler.yml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,6 @@
375375
- changed-files:
376376
- any-glob-to-any-file:
377377
- "extensions/copilot-proxy/**"
378-
"extensions: daytona":
379-
- changed-files:
380-
- any-glob-to-any-file:
381-
- "extensions/daytona/**"
382-
- "docs/gateway/daytona.md"
383378
"extensions: diagnostics-otel":
384379
- changed-files:
385380
- any-glob-to-any-file:

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,16 @@ jobs:
19231923
--configLoader runner
19241924
ui/src/e2e/control-ui-auth-transports.e2e.test.ts
19251925
1926+
- name: Test Control UI usage sessions owner attribution with a real Gateway
1927+
env:
1928+
OPENCLAW_CAPTURE_UI_PROOF: ${{ github.event_name == 'workflow_dispatch' && inputs.capture_ui_proof && '1' || '0' }}
1929+
OPENCLAW_UI_E2E_ARTIFACT_DIR: .artifacts/control-ui-e2e/real-gateway
1930+
run: >-
1931+
node scripts/run-vitest.mjs run
1932+
--config test/vitest/vitest.ui-e2e.config.ts
1933+
--configLoader runner
1934+
ui/src/e2e/usage-sessions-owner-attribution.e2e.test.ts
1935+
19261936
- name: Upload sanitized Control UI real-Gateway proof
19271937
if: always() && github.event_name == 'workflow_dispatch' && inputs.capture_ui_proof
19281938
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
@@ -2593,7 +2603,7 @@ jobs:
25932603
name: ${{ matrix.check_name }}
25942604
needs: [preflight]
25952605
if: ${{ !cancelled() && always() && needs.preflight.outputs.run_check == 'true' }}
2596-
runs-on: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'ubuntu-24.04' || (vars.OPENCLAW_CI_RUNNER_BACKEND == 'hybrid' && (github.event_name == 'workflow_dispatch' || github.run_attempt > 1 || (matrix.task != 'lint' && matrix.task != 'test-types' && matrix.task != 'dependencies'))) && 'ubuntu-24.04' || (github.event_name == 'workflow_dispatch' && inputs.release_gate) && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || contains(fromJSON('["OWNER","MEMBER","COLLABORATOR","CONTRIBUTOR"]'), github.event.pull_request.author_association)) && (matrix.runner || 'blacksmith-4vcpu-ubuntu-2404') || 'ubuntu-24.04') }}
2606+
runs-on: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'ubuntu-24.04' || (vars.OPENCLAW_CI_RUNNER_BACKEND == 'hybrid' && github.repository == 'openclaw/openclaw' && github.event_name == 'workflow_dispatch' && !inputs.release_gate && startsWith(inputs.dispatch_id, 'full-release-validation-') && inputs.target_context_ref != '' && needs.preflight.outputs.frozen_target == 'true' && matrix.task == 'lint') && (matrix.runner || 'blacksmith-4vcpu-ubuntu-2404') || (vars.OPENCLAW_CI_RUNNER_BACKEND == 'hybrid' && (github.event_name == 'workflow_dispatch' || github.run_attempt > 1 || (matrix.task != 'lint' && matrix.task != 'test-types' && matrix.task != 'dependencies'))) && 'ubuntu-24.04' || (github.event_name == 'workflow_dispatch' && inputs.release_gate) && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || contains(fromJSON('["OWNER","MEMBER","COLLABORATOR","CONTRIBUTOR"]'), github.event.pull_request.author_association)) && (matrix.runner || 'blacksmith-4vcpu-ubuntu-2404') || 'ubuntu-24.04') }}
25972607
timeout-minutes: 20
25982608
strategy:
25992609
fail-fast: false

‎.github/workflows/pr-crabbox-gate-publisher.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
publish:
4040
name: Validate AWS proof and publish gate
4141
runs-on: ubuntu-24.04
42+
environment: qa-live-shared
4243
timeout-minutes: 10
4344
permissions:
4445
checks: write
@@ -80,8 +81,8 @@ jobs:
8081
env:
8182
CRABBOX_ACCESS_CLIENT_ID: ${{ secrets.CRABBOX_ACCESS_CLIENT_ID }}
8283
CRABBOX_ACCESS_CLIENT_SECRET: ${{ secrets.CRABBOX_ACCESS_CLIENT_SECRET }}
83-
CRABBOX_COORDINATOR: ${{ secrets.CRABBOX_COORDINATOR }}
84-
CRABBOX_COORDINATOR_TOKEN: ${{ secrets.CRABBOX_COORDINATOR_TOKEN }}
84+
CRABBOX_COORDINATOR: ${{ secrets.CRABBOX_COORDINATOR || secrets.OPENCLAW_QA_MANTIS_CRABBOX_COORDINATOR }}
85+
CRABBOX_COORDINATOR_TOKEN: ${{ secrets.CRABBOX_COORDINATOR_TOKEN || secrets.OPENCLAW_QA_MANTIS_CRABBOX_COORDINATOR_TOKEN }}
8586
GH_TOKEN: ${{ github.token }}
8687
GH_APP_TOKEN: ${{ steps.app-token.outputs.token || steps.app-token-fallback.outputs.token }}
8788
run: node scripts/pr-crabbox-gate-publisher.mjs

‎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+
- MCP Apps: let standalone operations finish across catalog refreshes within per-request server budgets, propagate App cancellation without cancelling shared catalog work, and reload restored history views without replaying interrupted operations. Thanks @tzy-17. (#119388)
73+
7274
- **Control UI command palette:** keep keyboard selection and Enter usable when reconnects or catalog refreshes replace search results, preserving the selected command while it remains available.
7375
- **Control UI Gateway labels:** keep the discovered machine name through recovery initialization and refresh open folder-browser labels when name discovery finishes.
7476
- **Android settings:** keep form fields and actions reachable above the keyboard, and respect bottom system insets without duplicating navigation padding.

‎apps/ios/Sources/Chat/IOSGatewayChatTransport.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ struct IOSGatewayChatTransport: OpenClawChatTransport {
328328
let request = OpenClawChatGatewayRequests.sessionsList(
329329
limit: limit,
330330
search: search,
331-
archived: archived)
331+
archived: archived,
332+
agentID: self.globalAgentId)
332333
let res = try await gateway.request(request)
333334
return try JSONDecoder().decode(OpenClawChatSessionsListResponse.self, from: res)
334335
}

‎apps/ios/Sources/Design/CommandCenterTab.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,8 @@ struct CommandSessionsScreen: View {
12761276
// New Group editor) alongside the fresh session list.
12771277
self.knownGroups = SessionGroupStore.load()
12781278
let requestsArchived = self.showArchived
1279+
let sourceGatewayID = self.appModel.chatTranscriptCacheGatewayID
1280+
let sourceAgentID = self.appModel.chatDeliveryAgentId
12791281
self.isLoading = true
12801282
self.loadErrorText = nil
12811283
defer { self.isLoading = false }
@@ -1288,7 +1290,9 @@ struct CommandSessionsScreen: View {
12881290
self.sessions = roster.sessions
12891291
} catch {
12901292
guard requestsArchived == self.showArchived else { return }
1291-
self.sessions = requestsArchived ? [] : await self.appModel.loadCachedChatSessions()
1293+
self.sessions = requestsArchived ? [] : await self.appModel.loadCachedChatSessions(
1294+
gatewayID: sourceGatewayID,
1295+
agentID: sourceAgentID)
12921296
self.loadErrorText = self.sessions.isEmpty ? "Try again after the gateway reconnects." : nil
12931297
}
12941298
}

‎apps/ios/Sources/Design/IPadActivityScreen.swift‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,20 @@ struct IPadActivityScreen: View {
208208

209209
private func refreshSessions() async {
210210
guard self.scenePhase == .active else { return }
211-
guard self.sessionsAvailable else {
212-
self.sessions = await self.appModel.loadCachedChatSessions()
213-
self.loadErrorText = nil
214-
return
215-
}
216-
217211
self.isLoading = true
218212
self.loadErrorText = nil
219213
defer { self.isLoading = false }
220214

221215
do {
222-
let transport = self.appModel.makeChatTransport()
223-
let response = try await transport.listSessions(limit: CommandCenterTab.recentSessionsFetchLimit)
224-
self.sessions = response.sessions
225-
await self.appModel.storeCachedChatSessions(response.sessions)
216+
let roster = try await self.appModel.loadChatSessionRoster(
217+
limit: CommandCenterTab.recentSessionsFetchLimit)
218+
self.sessions = roster.sessions
226219
} catch {
227-
self.sessions = await self.appModel.loadCachedChatSessions()
220+
let sourceGatewayID = self.appModel.chatTranscriptCacheGatewayID
221+
let sourceAgentID = self.appModel.chatDeliveryAgentId
222+
self.sessions = await self.appModel.loadCachedChatSessions(
223+
gatewayID: sourceGatewayID,
224+
agentID: sourceAgentID)
228225
self.loadErrorText = self.sessions.isEmpty ? "Try again after the gateway reconnects." : nil
229226
}
230227
}

‎apps/ios/Sources/Model/NodeAppModel.swift‎

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,12 @@ final class NodeAppModel {
650650
return stableID
651651
}
652652

653-
/// Recreation key for the chat view model. Includes the cache gateway
654-
/// identity: switching paired gateways while the transport mode stays
655-
/// "operator" must rebuild the view model so transcripts are never read
656-
/// from or written under another gateway's cache scope.
653+
/// Session-list refresh identity. Gateway and agent changes must restart
654+
/// requests so no roster or cached projection crosses either owner.
657655
var chatViewModelIdentityID: String {
658656
let gatewayID = self.chatTranscriptCacheGatewayIdentityComponent
659-
return "\(self.chatTransportModeID)|\(gatewayID)|\(self.chatTranscriptCacheGeneration)"
657+
let agentID = self.chatDeliveryAgentId ?? ""
658+
return "\(self.chatTransportModeID)|\(gatewayID)|\(agentID)|\(self.chatTranscriptCacheGeneration)"
660659
}
661660

662661
/// Stable owner key for the long-lived chat view model. Connectivity still
@@ -732,14 +731,37 @@ final class NodeAppModel {
732731
self.synchronizeTalkSessionKey()
733732
}
734733

735-
func loadCachedChatSessions() async -> [OpenClawChatSessionEntry] {
736-
guard let cache = self.makeChatOfflineStore() else { return [] }
737-
return await cache.loadSessions()
734+
func loadCachedChatSessions(
735+
gatewayID: String?,
736+
agentID: String?) async -> [OpenClawChatSessionEntry]
737+
{
738+
guard GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, gatewayID),
739+
let cache = self.makeChatOfflineStore(),
740+
GatewayStableIdentifier.matches(cache.gatewayID, gatewayID)
741+
else { return [] }
742+
let sessions = await cache.loadSessions(agentID: agentID)
743+
guard GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, gatewayID),
744+
self.chatDeliveryAgentId == agentID
745+
else { return [] }
746+
return sessions.filter {
747+
ChatSessionSidebarModel.isSessionInActiveAgentScope(
748+
key: $0.key,
749+
agentID: $0.agentId,
750+
activeAgentID: agentID)
751+
}
738752
}
739753

740-
func storeCachedChatSessions(_ sessions: [OpenClawChatSessionEntry]) async {
741-
guard let cache = self.makeChatOfflineStore() else { return }
742-
await cache.storeSessions(sessions)
754+
func storeCachedChatSessions(
755+
_ sessions: [OpenClawChatSessionEntry],
756+
gatewayID: String?,
757+
agentID: String?) async
758+
{
759+
guard GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, gatewayID),
760+
self.chatDeliveryAgentId == agentID,
761+
let cache = self.makeChatOfflineStore(),
762+
GatewayStableIdentifier.matches(cache.gatewayID, gatewayID)
763+
else { return }
764+
await cache.storeSessions(sessions, agentID: agentID)
743765
}
744766

745767
/// Delete one forgotten gateway's cache and durable state, or both
@@ -1691,6 +1713,8 @@ final class NodeAppModel {
16911713
}
16921714
if selectedAgentChanged {
16931715
self.focusedChatSessionKey = nil
1716+
self.shareDeliveryChannel = nil
1717+
self.shareDeliveryTo = nil
16941718
}
16951719
self.synchronizeTalkSessionKey()
16961720
if let relay = ShareGatewayRelaySettings.loadConfig() {
@@ -1704,6 +1728,13 @@ final class NodeAppModel {
17041728
deliveryChannel: self.shareDeliveryChannel,
17051729
deliveryTo: self.shareDeliveryTo))
17061730
}
1731+
if selectedAgentChanged {
1732+
// Delivery metadata belongs to the selected agent. Rehydrate it
1733+
// after the selection commit; request-time identity fences stale replies.
1734+
Task { [weak self] in
1735+
await self?.refreshShareRouteFromGateway()
1736+
}
1737+
}
17071738
}
17081739

17091740
func setGlobalWakeWords(_ words: [String]) async {
@@ -5193,23 +5224,32 @@ extension NodeAppModel {
51935224
}
51945225

51955226
do {
5227+
guard let sourceGatewayID = self.chatTranscriptCacheGatewayID,
5228+
let sourceRoute = await operatorGateway.currentRoute(ifGatewayID: sourceGatewayID)
5229+
else { return }
5230+
let sourceAgentID = self.chatDeliveryAgentId
5231+
let sourceMainSessionKey = self.mainSessionKey
51965232
let request = OpenClawChatGatewayRequests.sessionsList(
51975233
limit: 80,
51985234
search: nil,
51995235
archived: false,
5236+
agentID: sourceAgentID,
52005237
timeoutMs: 10000)
5201-
let response = try await operatorGateway.request(request)
5238+
let response = try await operatorGateway.request(request, ifCurrentRoute: sourceRoute)
52025239
let decoded = try JSONDecoder().decode(SessionsListResult.self, from: response)
5203-
let currentKey = self.mainSessionKey
52045240
let sorted = decoded.sessions.sorted { ($0.updatedAt ?? 0) > ($1.updatedAt ?? 0) }
52055241
let exactMatch = sorted.first { row in
5206-
row.key == currentKey && normalize(row.lastChannel) != nil && normalize(row.lastTo) != nil
5242+
row.key == sourceMainSessionKey && normalize(row.lastChannel) != nil && normalize(row.lastTo) != nil
52075243
}
52085244
let selected = exactMatch
52095245
let channel = normalize(selected?.lastChannel)
52105246
let to = normalize(selected?.lastTo)
52115247

5212-
guard shouldApply() else { return }
5248+
guard shouldApply(),
5249+
GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, sourceGatewayID),
5250+
self.chatDeliveryAgentId == sourceAgentID,
5251+
self.mainSessionKey == sourceMainSessionKey
5252+
else { return }
52135253
await MainActor.run {
52145254
self.shareDeliveryChannel = channel
52155255
self.shareDeliveryTo = to

‎apps/ios/Sources/RootSidebarModel.swift‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,19 @@ extension NodeAppModel {
9494
archived: Bool = false,
9595
allowCachedFallback: Bool = true) async throws -> ChatSessionRosterSnapshot
9696
{
97+
let sourceGatewayID = self.chatTranscriptCacheGatewayID
98+
let sourceAgentID = self.chatDeliveryAgentId
9799
guard self.isLocalChatFixtureEnabled || self.isOperatorGatewayConnected else {
98100
guard allowCachedFallback else { throw URLError(.notConnectedToInternet) }
99101
return await ChatSessionRosterSnapshot(
100-
sessions: archived ? [] : self.loadCachedChatSessions(),
102+
sessions: archived ? [] : self.loadCachedChatSessions(
103+
gatewayID: sourceGatewayID,
104+
agentID: sourceAgentID),
101105
isCached: true,
102106
isComplete: false)
103107
}
104108

105109
do {
106-
let sourceGatewayID = self.chatTranscriptCacheGatewayID
107110
let snapshot: ChatSessionRosterSnapshot
108111
if self.isLocalChatFixtureEnabled {
109112
let response = try await self.makeChatTransport().listSessions(limit: limit, archived: archived)
@@ -124,21 +127,28 @@ extension NodeAppModel {
124127
limit: limit,
125128
search: nil,
126129
archived: archived,
130+
agentID: sourceAgentID,
127131
offset: offset)
128132
let data = try await self.operatorSession.request(request, ifCurrentRoute: route)
129133
return try JSONDecoder().decode(OpenClawChatSessionsListResponse.self, from: data)
130134
}
131-
guard GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, sourceGatewayID) else {
135+
guard GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, sourceGatewayID),
136+
self.chatDeliveryAgentId == sourceAgentID
137+
else {
132138
throw CancellationError()
133139
}
134140
}
135141

136142
if !archived {
137143
// An interrupted page must not replace a more complete offline roster.
138144
if snapshot.isComplete {
139-
await self.storeCachedChatSessions(snapshot.sessions)
145+
await self.storeCachedChatSessions(
146+
snapshot.sessions,
147+
gatewayID: sourceGatewayID,
148+
agentID: sourceAgentID)
140149
if let sourceGatewayID,
141-
!GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, sourceGatewayID)
150+
!GatewayStableIdentifier.matches(self.chatTranscriptCacheGatewayID, sourceGatewayID) ||
151+
self.chatDeliveryAgentId != sourceAgentID
142152
{
143153
throw CancellationError()
144154
}
@@ -149,7 +159,9 @@ extension NodeAppModel {
149159
throw CancellationError()
150160
} catch {
151161
guard allowCachedFallback, !archived else { throw error }
152-
let cached = await self.loadCachedChatSessions()
162+
let cached = await self.loadCachedChatSessions(
163+
gatewayID: sourceGatewayID,
164+
agentID: sourceAgentID)
153165
guard !cached.isEmpty else { throw error }
154166
return ChatSessionRosterSnapshot(sessions: cached, isCached: true, isComplete: false)
155167
}
@@ -460,7 +472,8 @@ final class RootSidebarModel {
460472
case let .sessionObserver(digest):
461473
self.sessions = ChatSessionSidebarModel.applying(
462474
observerDigest: digest,
463-
to: self.sessions)
475+
to: self.sessions,
476+
activeAgentId: appModel.chatDeliveryAgentId)
464477
case .seqGap:
465478
await self.refreshSessions(appModel: appModel)
466479
return true

‎apps/ios/Tests/GatewayConnectionControllerTests.swift‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ private func waitUntil(
20432043
token: nil,
20442044
password: nil,
20452045
sessionKey: "main")
2046-
defaults.set(try JSONEncoder().encode(otherRelay), forKey: "share.gatewayRelay.config.v1")
2046+
try defaults.set(JSONEncoder().encode(otherRelay), forKey: "share.gatewayRelay.config.v1")
20472047
let mismatched = try #require(ShareGatewayRelaySettings.loadConfig())
20482048
#expect(mismatched.token == nil)
20492049
#expect(mismatched.password == nil)
@@ -2638,7 +2638,7 @@ private func waitUntil(
26382638
useTLS: false,
26392639
lastConnectedAtMs: nil))
26402640
let appModel = NodeAppModel()
2641-
let session = OpenClawChatSessionEntry(
2641+
var session = OpenClawChatSessionEntry(
26422642
key: "agent:main:a",
26432643
kind: nil,
26442644
displayName: "Gateway A session",
@@ -2658,12 +2658,34 @@ private func waitUntil(
26582658
modelProvider: nil,
26592659
model: nil,
26602660
contextTokens: nil)
2661-
2662-
await appModel.storeCachedChatSessions([session])
2661+
session.agentId = "main"
2662+
var matchingBare = session
2663+
matchingBare.key = "shared-tool"
2664+
var ownerlessPrefixed = session
2665+
ownerlessPrefixed.key = "agent:main:legacy"
2666+
ownerlessPrefixed.agentId = nil
2667+
appModel.gatewayDefaultAgentId = "main"
2668+
2669+
await appModel.storeCachedChatSessions(
2670+
[session, matchingBare, ownerlessPrefixed],
2671+
gatewayID: gatewayA,
2672+
agentID: "main")
2673+
var workGlobal = session
2674+
workGlobal.key = "global"
2675+
workGlobal.agentId = "work"
2676+
appModel.selectedAgentId = "work"
2677+
await appModel.storeCachedChatSessions([workGlobal], gatewayID: gatewayA, agentID: "work")
26632678
_ = GatewaySettingsStore.setActiveGateway(stableID: gatewayB)
2664-
#expect(await appModel.loadCachedChatSessions().isEmpty)
2679+
#expect(await appModel.loadCachedChatSessions(gatewayID: gatewayB, agentID: "work").isEmpty)
26652680
_ = GatewaySettingsStore.setActiveGateway(stableID: gatewayA)
2666-
#expect(await appModel.loadCachedChatSessions() == [session])
2681+
appModel.selectedAgentId = "main"
2682+
#expect(await appModel.loadCachedChatSessions(gatewayID: gatewayA, agentID: "main") == [
2683+
session,
2684+
matchingBare,
2685+
ownerlessPrefixed,
2686+
])
2687+
appModel.selectedAgentId = "work"
2688+
#expect(await appModel.loadCachedChatSessions(gatewayID: gatewayA, agentID: "work") == [workGlobal])
26672689
}
26682690

26692691
private static func makeNodeOptions(

0 commit comments

Comments
 (0)