Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
7814fd2
test: prove startup dials during backup refresh
azooz2003-bit Sep 28, 2026
4f6f58b
fix: dial cached route before startup backup refresh
azooz2003-bit Sep 28, 2026
d8a9c75
perf: reuse hydrated pairing snapshot during startup
azooz2003-bit Sep 28, 2026
16cd25d
perf: start cached pairing dial during startup hydration
azooz2003-bit Sep 28, 2026
12ef215
fix: bind optional cached pairing row correctly
azooz2003-bit Sep 28, 2026
93d0db5
Revert "fix: bind optional cached pairing row correctly"
azooz2003-bit Sep 28, 2026
c9a6b58
Revert "perf: start cached pairing dial during startup hydration"
azooz2003-bit Sep 28, 2026
792a561
Revert "perf: reuse hydrated pairing snapshot during startup"
azooz2003-bit Sep 28, 2026
73bc8cf
test: reject injected credentials during cached startup verification
azooz2003-bit Sep 28, 2026
6372c0c
test: measure cached pairing release-gate startup
azooz2003-bit Sep 28, 2026
1ece6fc
test: persist onboarding before cached launch
azooz2003-bit Sep 28, 2026
0cf1b27
perf: combine startup workspace and host status
azooz2003-bit Sep 28, 2026
9fac2b6
perf: build combined host proof from live service
azooz2003-bit Sep 28, 2026
5c504e8
fix: match cached host status in combined workspace response
azooz2003-bit Sep 28, 2026
5901f7d
test: preserve admitted identity in combined startup status
azooz2003-bit Sep 29, 2026
a396428
fix: use v2 identity for combined host status
azooz2003-bit Sep 29, 2026
b980721
perf: preconnect iroh before first authenticated request
azooz2003-bit Sep 29, 2026
582713d
fix: drain parallel iroh preconnect task
azooz2003-bit Sep 29, 2026
c146010
perf: publish startup workspace rows before pairing persistence
azooz2003-bit Sep 29, 2026
27c401b
Revert "perf: publish startup workspace rows before pairing persistence"
azooz2003-bit Sep 29, 2026
814ebe7
perf: reuse hydrated pairing cache during startup
azooz2003-bit Sep 29, 2026
73bd646
fix: avoid speculative duplicate Iroh dials
azooz2003-bit Sep 29, 2026
2b64a40
test: preserve simulator startup diagnostics in release gates
azooz2003-bit Sep 29, 2026
0ba4041
Merge remote-tracking branch 'origin/main' into fix-v2-startup-local-…
azooz2003-bit Sep 29, 2026
2bbb2ef
fix: remove merge artifact from mobile shell
azooz2003-bit Sep 29, 2026
fa8f1c1
fix: retry stored Mac after auth restore
azooz2003-bit Sep 29, 2026
6a17189
fix: keep release gate on workspace list
azooz2003-bit Sep 29, 2026
1e87a6e
fix simulator launch environment propagation
azooz2003-bit Sep 29, 2026
241ba19
test: avoid asserting startup cache implementation details
azooz2003-bit Sep 29, 2026
db62464
test: pass remote workspace flag through overrides
azooz2003-bit Sep 29, 2026
1a91f7c
test: keep workspace creation override signatures current
azooz2003-bit Sep 29, 2026
f7db0fa
Merge remote-tracking branch 'origin/main' into fix-v2-startup-local-…
azooz2003-bit Sep 29, 2026
bf90a77
fix mobile attach parsing with CLI diagnostics
azooz2003-bit Sep 29, 2026
4fe8ac5
Warm cached v2 state before auth bootstrap
azooz2003-bit Sep 29, 2026
5aeab39
Enforce sub-2.5-second workspace startup gate
azooz2003-bit Sep 29, 2026
99ca1d8
Cache scoped workspace rows during v2 startup
azooz2003-bit Sep 29, 2026
8bc596e
Verify relay renewal at its real lifetime
azooz2003-bit Sep 29, 2026
61a88a2
Fix workspace snapshot initializer ordering
azooz2003-bit Sep 29, 2026
a93af42
Give real relay gate cleanup time
azooz2003-bit Sep 29, 2026
4f7f4b5
Restore scoped workspace snapshots before paired Mac load
azooz2003-bit Sep 29, 2026
cb9d421
Prevent stale workspace snapshots from resurfacing
azooz2003-bit Sep 30, 2026
5696ef1
Close workspace snapshot scope races
azooz2003-bit Sep 30, 2026
41659c1
Add real Codex and background coverage to Iroh gate
azooz2003-bit Sep 30, 2026
14dc577
Upload real Iroh usage evidence
azooz2003-bit Sep 30, 2026
eb1aa35
Preserve local demo workspace ownership
azooz2003-bit Sep 30, 2026
451933a
Retain foreground state during snapshot reconciliation
azooz2003-bit Sep 30, 2026
c84fb67
ci: install axe before iOS Iroh gate
azooz2003-bit Sep 30, 2026
c5cb772
fix: measure cached workspace rows before Iroh readiness
azooz2003-bit Sep 30, 2026
f3928a3
fix: persist every complete workspace snapshot
azooz2003-bit Sep 30, 2026
9574395
Measure release gate rows at UIKit visibility
azooz2003-bit Sep 30, 2026
5f67eea
Allow full relay gate to publish its verdict
azooz2003-bit Sep 30, 2026
45f19d0
Keep IROH gate independent of Ghostty helper fetches
azooz2003-bit Sep 30, 2026
185be6c
Make iOS e2e driver open a workspace
azooz2003-bit Sep 30, 2026
908e2ee
Merge green main into v2 startup branch
azooz2003-bit Sep 30, 2026
76178d0
Document complete iOS e2e driver contract
azooz2003-bit Sep 30, 2026
02bb470
Bind iOS e2e checks to the Codex workspace
azooz2003-bit Sep 30, 2026
849ed89
Harden v2 startup state and workspace targeting
azooz2003-bit Sep 30, 2026
e52cb3e
Recover backup pairing when only demo row is cached
azooz2003-bit Sep 30, 2026
35c7723
Measure app-side foreground readiness
azooz2003-bit Sep 30, 2026
5bd6005
Require real Codex workload evidence
azooz2003-bit Sep 30, 2026
c7cb704
Bind real-use replay to the requested workspace
azooz2003-bit Sep 30, 2026
01b0f64
Make release-gate evidence durable and ordered
azooz2003-bit Sep 30, 2026
2359026
Allow hosted runner for manual Iroh acceptance gate
azooz2003-bit Sep 30, 2026
5afde77
Use supported hosted macOS label for manual gate
azooz2003-bit Sep 30, 2026
9ecd5aa
Allow trusted owned runner for manual gate
azooz2003-bit Sep 30, 2026
b934ccf
Route manual gate through selected owned pool
azooz2003-bit Sep 30, 2026
1db5b80
Pin manual gate to an available trusted Mac
azooz2003-bit Sep 30, 2026
8c4cfb5
Use staging environment for staging release gates
azooz2003-bit Sep 30, 2026
1c10a44
Leave staging gate outside protected environments
azooz2003-bit Sep 30, 2026
a06061a
Keep release gate on approved runner route
azooz2003-bit Sep 30, 2026
59cbda2
Fix cached endpoint warmup self lifetime
azooz2003-bit Sep 30, 2026
82618ef
Await actor epoch during cached warmup
azooz2003-bit Sep 30, 2026
4cbdeea
Measure inline link view before hit testing
azooz2003-bit Sep 30, 2026
6c9f137
Merge main (a66a8bb122fa) into fix-v2-startup-local-route-impl
azooz2003-bit Sep 30, 2026
07b9624
Hit test the measured text line in inline link regression
azooz2003-bit Sep 30, 2026
c5a9d15
Keep close tab test queue drain compatible with main
azooz2003-bit Sep 30, 2026
a11fc3c
test: restore cmuxTests compile on main
lawrencecchen Sep 30, 2026
c3b97e1
Use shared queue drain helper after compile repair
azooz2003-bit Oct 1, 2026
beadd57
test: drive hook state recovery through the bundled CLI
lawrencecchen Oct 1, 2026
d9724bc
test: compile the vm ready poll policy into cmuxCLITests
lawrencecchen Oct 1, 2026
27fba71
Merge main (039832207a63) into fix-v2-startup-local-route-impl
azooz2003-bit Oct 1, 2026
1887e53
fix: close release gate workload hazards
azooz2003-bit Oct 1, 2026
1ce9bc8
fix: preserve and prune cached workspace snapshots
azooz2003-bit Oct 1, 2026
344cac1
fix: bound cached startup and redact snapshots
azooz2003-bit Oct 1, 2026
5c5388e
Stabilize real usage release gate lifecycle
azooz2003-bit Oct 1, 2026
2f5c012
Normalize hidden Mac snapshot identities
azooz2003-bit Oct 1, 2026
6b68c8c
Keep real usage terminals available for verification
azooz2003-bit Oct 1, 2026
07f7c13
Bound snapshot maintenance and relay gate timing
azooz2003-bit Oct 1, 2026
7ea8285
Persist workspace snapshots off the main actor
azooz2003-bit Oct 1, 2026
0583749
Move snapshot restore off the main actor
azooz2003-bit Oct 1, 2026
b1f7a18
Await workspace snapshot removal
azooz2003-bit Oct 1, 2026
4c78ecf
Preserve v2 runtime ownership through auth and soak
azooz2003-bit Oct 1, 2026
08c8047
Make explicit snapshot deletion win races
azooz2003-bit Oct 1, 2026
6985f9e
Repair cached runtime reconciliation and warmup retries
azooz2003-bit Oct 1, 2026
1b444a0
Keep attach tickets in memory during retries
azooz2003-bit Oct 1, 2026
00959bf
Revalidate scope after cached snapshot restore
azooz2003-bit Oct 1, 2026
b834f86
Bound cached endpoint warmup and diagnostics
azooz2003-bit Oct 1, 2026
a34c7ee
Bound endpoint warmup timeout independently of cancellation
azooz2003-bit Oct 1, 2026
5386126
Scope paired Mac cache before reconnect reuse
azooz2003-bit Oct 1, 2026
2fa7297
Validate combined host status before reuse
azooz2003-bit Oct 1, 2026
f06f502
Use shared deadline scheduler for endpoint warmup
azooz2003-bit Oct 1, 2026
40aa04e
Harden startup identity cache and snapshot invalidation
azooz2003-bit Oct 1, 2026
c589ff8
Bound Codex workload log polling
azooz2003-bit Oct 1, 2026
c5caca7
Serialize snapshot encoding in persistence actor
azooz2003-bit Oct 1, 2026
97e5a7f
Cancel timed out endpoint warmup
azooz2003-bit Oct 1, 2026
859ca92
Retry endpoint warmup after transient failures
azooz2003-bit Oct 1, 2026
b908dde
Bound endpoint warmup retries and retry on foreground
azooz2003-bit Oct 1, 2026
2ca91b5
Harden forget cleanup and Codex iteration proof
azooz2003-bit Oct 1, 2026
f66904b
Allow full relay rollover soak to finish
azooz2003-bit Oct 1, 2026
c21b0a8
Publish warmup recovery and preserve workspace IDs
azooz2003-bit Oct 1, 2026
825e0d3
Fail closed when release gate V2 origin is unset
azooz2003-bit Oct 1, 2026
5ea8219
Merge remote-tracking branch 'origin/main' into fix-v2-startup-local-…
azooz2003-bit Oct 1, 2026
2c33e92
Fix post-merge compile blockers
azooz2003-bit Oct 1, 2026
538aaf6
Normalize instance tags and fix browser restoration compile
azooz2003-bit Oct 1, 2026
4b7b837
Fix canonical identity and accent color compile errors
azooz2003-bit Oct 1, 2026
0117647
Fix isolated test window geometry cleanup
azooz2003-bit Oct 1, 2026
94acff9
Repair stale macOS test compile references
azooz2003-bit Oct 1, 2026
5955b67
Include CLI error type in app target
azooz2003-bit Oct 1, 2026
0d2b312
Include CLI error type in CLI tests
azooz2003-bit Oct 1, 2026
eba8488
Fix drag cleanup and message inbox fixture
azooz2003-bit Oct 1, 2026
f59f37d
Remove stale Cloud reorder indicator on cleanup
azooz2003-bit Oct 1, 2026
2f574d6
Treat aborted Codex turns as terminal monitor events
azooz2003-bit Oct 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/iroh-release-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ on:
options:
- basic
- stress

permissions:
contents: read

Expand Down Expand Up @@ -256,6 +255,10 @@ jobs:
# reload's standalone-driver shortcut fails while merging opaque SwiftUI
# return types on Xcode 26.3 before either endpoint can launch.
CMUX_RELOAD_APP_EMIT_MODULE: "1"
# The release gate exercises IROH and does not need the optional Ghostty
# CLI helper. Avoid an unrelated network fetch from Ghostty's Zig build
# turning a transport verdict into a runner TLS failure.
CMUX_SKIP_ZIG_BUILD: "1"
strategy:
fail-fast: false
# The app-backed modes share one temporary account per environment.
Expand All @@ -265,7 +268,11 @@ jobs:
matrix:
mode: ${{ fromJSON(inputs.mode == 'all' && '["automatic","relay-only","relay-expiry","direct-only","private-path"]' || format('["{0}"]', inputs.mode)) }}
runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'macos-26' || (vars.CI_PAID_MACOS_OVERFLOW == '1' && vars.MACOS_RUNNER_15 || 'blacksmith-6vcpu-macos-15') }}
timeout-minutes: 120
# The real relay rollover probe waits through the 30-minute credential
# lifetime after the one-hour workload. Keep enough room for the hosted
# build, simulator setup, artifact upload, and runner cleanup so a passing
# report is not converted into a cancelled job at the hard deadline.
timeout-minutes: 180
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down Expand Up @@ -294,6 +301,17 @@ jobs:
with:
bun-version: "1.4.2"

- name: Install AXe simulator driver
if: ${{ matrix.mode == 'automatic' || matrix.mode == 'relay-only' || matrix.mode == 'relay-expiry' }}
run: |
set -euo pipefail
# ios-e2e-run.sh uses AXe for accessibility and HID input. Hosted
# runners do not guarantee it in PATH, so install the maintained
# Homebrew formula explicitly before any simulator interaction.
brew install cameroncooke/axe/axe
command -v axe
axe --version

- name: Install web runtime dependencies
if: ${{ matrix.mode == 'automatic' || matrix.mode == 'relay-only' || matrix.mode == 'relay-expiry' }}
working-directory: web
Expand Down Expand Up @@ -390,6 +408,9 @@ jobs:
if [[ "${{ matrix.mode }}" == automatic || "${{ matrix.mode }}" == relay-only ]]; then
GATE_ARGS+=(--soak-profile "${{ inputs.soak_profile }}")
fi
if [[ "${{ inputs.environment }}" == production && "${{ matrix.mode }}" == relay-only && "${{ inputs.soak_profile }}" == stress ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This new run-step embeds workflow inputs directly into the generated shell script. Bind them through env: and compare shell variables instead, so input values cannot alter shell parsing and the workflow follows the repository’s CI convention.

(Based on your team's feedback about workflow input interpolation.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/iroh-release-gate.yml, line 411:

<comment>This new run-step embeds workflow inputs directly into the generated shell script. Bind them through `env:` and compare shell variables instead, so input values cannot alter shell parsing and the workflow follows the repository’s CI convention.

(Based on your team's feedback about workflow input interpolation.) </comment>

<file context>
@@ -390,6 +408,9 @@ jobs:
           if [[ "${{ matrix.mode }}" == automatic || "${{ matrix.mode }}" == relay-only ]]; then
             GATE_ARGS+=(--soak-profile "${{ inputs.soak_profile }}")
           fi
+          if [[ "${{ inputs.environment }}" == production && "${{ matrix.mode }}" == relay-only && "${{ inputs.soak_profile }}" == stress ]]; then
+            GATE_ARGS+=(--real-usage)
+          fi
</file context>

GATE_ARGS+=(--real-usage)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: --real-usage launches three real Codex sessions, but this job never installs the Codex CLI or provisions its authentication. On a clean macOS runner the workload exits with command not found or login required, making every production relay-only stress run fail; add a runner-specific Codex setup and credential preflight before enabling this branch.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/iroh-release-gate.yml, line 412:

<comment>`--real-usage` launches three real Codex sessions, but this job never installs the Codex CLI or provisions its authentication. On a clean macOS runner the workload exits with `command not found` or `login required`, making every production relay-only stress run fail; add a runner-specific Codex setup and credential preflight before enabling this branch.</comment>

<file context>
@@ -390,6 +408,9 @@ jobs:
             GATE_ARGS+=(--soak-profile "${{ inputs.soak_profile }}")
           fi
+          if [[ "${{ inputs.environment }}" == production && "${{ matrix.mode }}" == relay-only && "${{ inputs.soak_profile }}" == stress ]]; then
+            GATE_ARGS+=(--real-usage)
+          fi
           ./scripts/run-iroh-release-gate.sh "${GATE_ARGS[@]}"
</file context>

Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
fi
./scripts/run-iroh-release-gate.sh "${GATE_ARGS[@]}"

- name: Upload redacted verdict
Expand All @@ -402,7 +423,10 @@ jobs:
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-mac.cmuxdiag
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-ios-failure.log
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-ios-failure.png
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-ios-*.jsonl
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-ios-*.log
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-mac-failure.cmuxdiag
${{ runner.temp }}/iroh-release-gate-${{ matrix.mode }}-real-usage/**
if-no-files-found: warn
retention-days: 7

Expand Down
8 changes: 7 additions & 1 deletion CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30774,7 +30774,7 @@ struct CMUXCLI {
candidate = failure
candidateCanPublishBeforeTerminal = turnId == nil || payloadTurnId == turnId || sawRelevantTurn
}
case "task_complete", "turn_complete":
case "task_complete", "turn_complete", "turn_aborted":
let payloadTurnId = firstString(in: payload, keys: ["turn_id", "turnId"])
if let turnId {
guard payloadTurnId == turnId else {
Expand All @@ -30783,6 +30783,12 @@ struct CMUXCLI {
}
sawRelevantTurn = true
sawTerminalTurn = true
// An interrupted turn is still terminal for the monitor. It
// has no final response to classify as a failure, so let the
// normal Stop replay retire its stale prompt record.
if eventType == "turn_aborted" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: An aborted turn can still publish a stale error from an earlier error or stream_error event because this branch leaves candidate populated before the shared failure checks. Clear candidate and candidateCanPublishBeforeTerminal before continuing so turn_aborted remains terminal without being classified as a failure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At CLI/cmux.swift, line 30789:

<comment>An aborted turn can still publish a stale error from an earlier `error` or `stream_error` event because this branch leaves `candidate` populated before the shared failure checks. Clear `candidate` and `candidateCanPublishBeforeTerminal` before continuing so `turn_aborted` remains terminal without being classified as a failure.</comment>

<file context>
@@ -30783,6 +30783,12 @@ struct CMUXCLI {
+                // An interrupted turn is still terminal for the monitor. It
+                // has no final response to classify as a failure, so let the
+                // normal Stop replay retire its stale prompt record.
+                if eventType == "turn_aborted" {
+                    continue
+                }
</file context>

continue
}
// Codex persists fatal turn failures inside task_complete.error. Standalone
// error events are transient, and a failed turn may still contain partial
// assistant output, so the terminal error must be authoritative.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public final class MobileReleaseGateUIProbe {
if row.select() {
rows.removeAll()
} else {
measured.removeAll()
// Cached rows can render before their Mac transport is connected.
// Keep the observed appearance time and retry selection when the
// live row is updated, instead of discarding the evidence and
// measuring only the slower authenticated snapshot.
phase = .awaitingSelection
rows.removeValue(forKey: id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@ struct MobileReleaseGateUIProbeTests {
#expect(probe.latencies() == measured)
}

@Test func keepsCachedRowTimingUntilLiveSelectionIsAvailable() async throws {
let probe = MobileReleaseGateUIProbe()
var connected = false
var failedSelectionAttempts = 0
probe.closeWorkspace = {
probe.terminalDidUnmount(surfaceID: "terminal")
}
probe.revealWorkspace = { _ in
probe.registerVisibleWorkspace("workspace") {
guard connected else {
failedSelectionAttempts += 1
return false
}
probe.record(.workspaceSelectionTapped)
probe.recordTerminalFrame(surfaceID: "terminal", containsText: true)
return true
}
connected = true
probe.registerVisibleWorkspace("workspace") {
probe.record(.workspaceSelectionTapped)
probe.recordTerminalFrame(surfaceID: "terminal", containsText: true)
return true
}
}
try await probe.exercise(workspaceID: "workspace", surfaceID: "terminal")
#expect(failedSelectionAttempts == 1)
#expect(probe.latencies()["app_launch_request_to_workspace_rows_visible"] != nil)
}

@Test func revealsRequestedRowsAndDoesNotInspectTextAfterCompletion() async throws {
let probe = MobileReleaseGateUIProbe()
probe.closeWorkspace = { probe.terminalDidUnmount(surfaceID: "terminal") }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import Foundation

public extension AuthCoordinator {
/// The locally persisted account and team used only to warm read-only v2
/// state while Stack validates the session. It is never sufficient for a
/// server request or a mutation.
var cachedTeamIdentity: CachedTeamIdentity? {
guard sessionCache.hasTokens,
let accountID = currentUser?.id,
!accountID.isEmpty,
let teamID = selectedTeamID,
!teamID.isEmpty else { return nil }
return CachedTeamIdentity(accountID: accountID, teamID: teamID)
}

/// Current account and selected team, without accessing either credential.
var authenticatedTeamScope: AuthenticatedTeamScope? {
guard let session = publishedAuthenticatedSessionIdentity,
Expand Down Expand Up @@ -39,6 +51,17 @@ public extension AuthCoordinator {
}
}

/// A persisted account/team pair used for local-only startup warming.
public struct CachedTeamIdentity: Sendable, Equatable {
public let accountID: String
public let teamID: String

public init(accountID: String, teamID: String) {
self.accountID = accountID
self.teamID = teamID
}
}

extension AuthCoordinator {
func publishAuthenticatedTeamScope() {
let next = authenticatedTeamScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ public final class MobileCoreRPCClient: MobileSyncing, Sendable {
public func sendRequestAndAuthenticatedHostStatus(
_ requestData: Data,
timeoutNanoseconds: UInt64? = nil,
hostStatusTimeoutNanoseconds: @Sendable () -> UInt64? = { nil }
hostStatusTimeoutNanoseconds: @Sendable () -> UInt64? = { nil },
acceptCombinedHostStatus: Bool = false
) async throws -> (response: Data, hostStatusResponse: Data) {
guard let request = try JSONSerialization.jsonObject(with: requestData) as? [String: Any],
Self.requestRequiresAuth(request) else {
Expand All @@ -371,6 +372,12 @@ public final class MobileCoreRPCClient: MobileSyncing, Sendable {
requestData,
timeoutNanoseconds: timeoutNanoseconds
)
if acceptCombinedHostStatus,
let combinedHostStatus = Self.combinedHostStatusResponse(
in: authorized.response
) {
return (authorized.response, combinedHostStatus)
}
let hostStatusTimeout = hostStatusTimeoutNanoseconds()
if hostStatusTimeout == 0 {
throw MobileShellConnectionError.requestTimedOut
Expand All @@ -383,6 +390,22 @@ public final class MobileCoreRPCClient: MobileSyncing, Sendable {
return (authorized.response, hostStatus.response)
}

/// Extracts the authenticated host proof included in a v2 workspace-list
/// response. Older Macs omit this field, so callers continue with the
/// separate host-status request.
private static func combinedHostStatusResponse(in data: Data) -> Data? {
guard let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let hostStatus = object["host_status"] as? [String: Any],
JSONSerialization.isValidJSONObject(hostStatus) else {
return nil
}
guard let encoded = try? JSONSerialization.data(withJSONObject: hostStatus),
(try? MobileHostStatusResponse.decode(encoded)) != nil else {
return nil
}
return encoded
}

private func sendRequestOperation(
_ requestData: Data,
timeoutNanoseconds: UInt64?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,17 @@ public struct MobileSyncWorkspaceListResponse: Decodable, Sendable {
public let createdWorkspaceID: String?
/// Identifier of a terminal created by the request, if any.
public let createdTerminalID: String?
/// Authenticated host metadata returned by the v2 mobile workspace-list
/// method. Older Macs omit this field and the caller falls back to the
/// separate host-status request.
public let hostStatus: MobileHostStatusResponse?

private enum CodingKeys: String, CodingKey {
case workspaces
case groups
case createdWorkspaceID = "created_workspace_id"
case createdTerminalID = "created_terminal_id"
case hostStatus = "host_status"
}

/// Decodes a workspace-list response, defaulting `groups` to empty so a Mac
Expand All @@ -341,6 +346,7 @@ public struct MobileSyncWorkspaceListResponse: Decodable, Sendable {
groups = try container.decodeIfPresent([Group].self, forKey: .groups) ?? []
createdWorkspaceID = try container.decodeIfPresent(String.self, forKey: .createdWorkspaceID)
createdTerminalID = try container.decodeIfPresent(String.self, forKey: .createdTerminalID)
hostStatus = try container.decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus) throws when host_status is present but malformed (e.g. capabilities as a non-array, or a non-object value), and since the workspace-list decode at MobileShellComposite.swift:11009 is a hard try, one bad field now fails the entire workspace-list refresh on the connection path. That contradicts the lenient-decode convention this module already uses: MobileHostStatusResponse decodes theme, phonePush, and macCompatibleMacTags with try? specifically so a malformed field cannot fail the whole payload. Decode hostStatus the same way so a malformed value yields nil and the caller falls back to the separate host-status request, exactly as the doc comment describes for absent values.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At Packages/iOS/CmuxMobileRPC/Sources/CmuxMobileRPC/MobileSyncWorkspaceListResponse.swift, line 349:

<comment>`decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus)` throws when `host_status` is present but malformed (e.g. `capabilities` as a non-array, or a non-object value), and since the workspace-list decode at MobileShellComposite.swift:11009 is a hard `try`, one bad field now fails the entire workspace-list refresh on the connection path. That contradicts the lenient-decode convention this module already uses: `MobileHostStatusResponse` decodes `theme`, `phonePush`, and `macCompatibleMacTags` with `try?` specifically so a malformed field cannot fail the whole payload. Decode `hostStatus` the same way so a malformed value yields `nil` and the caller falls back to the separate host-status request, exactly as the doc comment describes for absent values.</comment>

<file context>
@@ -341,6 +346,7 @@ public struct MobileSyncWorkspaceListResponse: Decodable, Sendable {
         groups = try container.decodeIfPresent([Group].self, forKey: .groups) ?? []
         createdWorkspaceID = try container.decodeIfPresent(String.self, forKey: .createdWorkspaceID)
         createdTerminalID = try container.decodeIfPresent(String.self, forKey: .createdTerminalID)
+        hostStatus = try container.decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus)
     }
 
</file context>
Suggested change
hostStatus = try container.decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus)
hostStatus = (try? container.decodeIfPresent(MobileHostStatusResponse.self, forKey: .hostStatus)) ?? nil

}

/// Decode a workspace-list response from raw JSON data.
Expand All @@ -363,12 +369,14 @@ extension MobileSyncWorkspaceListResponse {
groups: [Group],
groupsFieldWasPresent: Bool = true,
createdWorkspaceID: String?,
createdTerminalID: String?
createdTerminalID: String?,
hostStatus: MobileHostStatusResponse? = nil
) {
self.workspaces = workspaces
self.groups = groups
self.groupsFieldWasPresent = groupsFieldWasPresent
self.createdWorkspaceID = createdWorkspaceID
self.createdTerminalID = createdTerminalID
self.hostStatus = hostStatus
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ extension MobileShellComposite {
return scoped.union(userWide)
}

/// Matches a stored hidden marker to a typed app-instance key. Older
/// markers can use a raw device id or preserve different casing, so a
/// string lookup is not sufficient for cached snapshot restoration.
/// A raw marker remains scoped to the legacy untagged pairing; a tagged
/// marker matches only the same tagged app instance.
func isHiddenMacPairingKey(
_ key: MacPairingKey,
hiddenIDs: Set<String>
) -> Bool {
let expectedDeviceID = cmxCanonicalDeviceID(key.canonicalMacDeviceID).lowercased()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The lowercasing makes isHiddenMacPairingKey treat a case-differing legacy marker as hidden, but the other hidden-state checks in this file — visibleStoredPairedMacs and isHiddenMacDeviceID — still compare raw markers with exact string membership, and cmxCanonicalDeviceID only lowercases UUIDs (non-UUID IDs are returned byte-for-byte). So for a marker like "MAC-A" against a row key "mac-a", restoreWorkspaceSnapshots now suppresses the cached workspace while the row stays visible in the list and routing still treats the Mac as unhidden. Apply the same case-insensitive canonical comparison in isHiddenMacDeviceID and visibleStoredPairedMacs (handling both bare device markers and composite pairing IDs) so the three checks agree, or the hide state is only half-applied.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite+HiddenMacs.swift, line 43:

<comment>The lowercasing makes isHiddenMacPairingKey treat a case-differing legacy marker as hidden, but the other hidden-state checks in this file — visibleStoredPairedMacs and isHiddenMacDeviceID — still compare raw markers with exact string membership, and cmxCanonicalDeviceID only lowercases UUIDs (non-UUID IDs are returned byte-for-byte). So for a marker like "MAC-A" against a row key "mac-a", restoreWorkspaceSnapshots now suppresses the cached workspace while the row stays visible in the list and routing still treats the Mac as unhidden. Apply the same case-insensitive canonical comparison in isHiddenMacDeviceID and visibleStoredPairedMacs (handling both bare device markers and composite pairing IDs) so the three checks agree, or the hide state is only half-applied.</comment>

<file context>
@@ -40,11 +40,11 @@ extension MobileShellComposite {
         hiddenIDs: Set<String>
     ) -> Bool {
-        let expectedDeviceID = cmxCanonicalDeviceID(key.canonicalMacDeviceID)
+        let expectedDeviceID = cmxCanonicalDeviceID(key.canonicalMacDeviceID).lowercased()
         let expectedTag = macInstanceTagAuthority.normalize(key.normalizedInstanceTag)?.lowercased()
         return hiddenIDs.contains { marker in
</file context>

let expectedTag = macInstanceTagAuthority.normalize(key.normalizedInstanceTag)?.lowercased()
return hiddenIDs.contains { marker in
let identity = MobilePairedMac.pairingIdentity(from: marker)
guard cmxCanonicalDeviceID(identity.macDeviceID).lowercased() == expectedDeviceID else {
return false
}
return macInstanceTagAuthority.normalize(identity.instanceTag)?.lowercased() == expectedTag
}
}

func visibleStoredPairedMacs(
from loadedMacs: [MobilePairedMac],
scope: MobileShellScopeSnapshot
Expand Down Expand Up @@ -428,6 +448,38 @@ extension MobileShellComposite {
// rowless and clear them, so the hidden entry the user retries from
// would vanish while a failed sibling keeps its revoked binding.
if deletion.cleaned {
if let workspaceSnapshotStore {
let snapshotAccountID = computer.stackUserID ?? scope.userID
let deletedScopes = deletion.deletedScopes.isEmpty
? [MobilePairedMacExactScope(
macDeviceID: computer.macDeviceID,
instanceTag: computer.instanceTag,
stackUserID: snapshotAccountID,
teamID: computer.teamID
)]
: deletion.deletedScopes
for deletedScope in deletedScopes
where (deletedScope.stackUserID ?? snapshotAccountID) == snapshotAccountID {
// Legacy paired rows may not carry a team. Their workspace
// snapshot was written under the currently selected team,
// so clear that scoped key as well as the old team-less key.
var snapshotTeamIDs = [deletedScope.teamID]
if deletedScope.teamID == nil, let currentTeamID = scope.teamID {
snapshotTeamIDs.append(currentTeamID)
}
for snapshotTeamID in snapshotTeamIDs {
await workspaceSnapshotStore.remove(
userID: snapshotAccountID,
teamID: snapshotTeamID,
pairing: MacPairingKey(
macDeviceID: deletedScope.macDeviceID,
instanceTag: deletedScope.instanceTag
),
force: true
)
}
}
}
rememberForgottenMacRecovery(
for: computer,
accountID: scope.userID,
Expand Down
Loading
Loading