diff --git a/.github/workflows/backend-migrations.yml b/.github/workflows/backend-migrations.yml index ae20cf66ac7f..362c114feca3 100644 --- a/.github/workflows/backend-migrations.yml +++ b/.github/workflows/backend-migrations.yml @@ -70,10 +70,12 @@ jobs: # installation's API quota ran out under load and failed the plan on UI PRs (#17602). # The same backend/db/migrations tree as the base means no migration change; a # different one (the PR's change, or a base move it has not merged) is listed below. - git -C trusted fetch --quiet --no-tags --depth=1 origin "$HEAD_SHA" - base_tree=$(git -C trusted rev-parse --verify --quiet "$BASE_SHA:backend/db/migrations" || echo none) - head_tree=$(git -C trusted rev-parse --verify --quiet "$HEAD_SHA:backend/db/migrations" || echo none) - if [ "$base_tree" = "$head_tree" ]; then + # This is only an optimization. A fork head may not be fetchable from + # the base remote; missing trees must also fall back to the files API. + if git -C trusted fetch --quiet --no-tags --depth=1 origin "$HEAD_SHA" && + base_tree=$(git -C trusted rev-parse --verify --quiet "$BASE_SHA:backend/db/migrations") && + head_tree=$(git -C trusted rev-parse --verify --quiet "$HEAD_SHA:backend/db/migrations") && + [ "$base_tree" = "$head_tree" ]; then echo "migrations=false" >> "$GITHUB_OUTPUT"; echo "no migration changes (backend/db/migrations matches the base)"; exit 0 fi gh api --paginate "repos/$REPO/pulls/$PR/files" --jq '.[] | "\(.status)\t\(.filename)\t\(.previous_filename // "")"' > changes.tsv diff --git a/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareService.swift b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareService.swift new file mode 100644 index 000000000000..0e93d64d8f7f --- /dev/null +++ b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareService.swift @@ -0,0 +1,174 @@ +import Foundation + +/// The publication calls Share needs, scoped to the machine's owning team. +/// `VMClient` is the live implementation; tests use a fake. +public protocol CloudPortPublishing: Sendable { + func listPublications(scopeTeamID: String?) async throws -> [VMPublication] + func createDefaultPublication(vmID: String, port: Int, scopeTeamID: String?) async throws -> VMPublication + func deletePublication(id: String, scopeTeamID: String?) async throws +} + +extension VMClient: CloudPortPublishing { + /// No access mode and no team: the server picks team access for a team + /// machine and owner-only access for a personal one. Repeating it is safe: + /// the generated hostname is fixed per machine and port, so the server + /// returns the existing row and resumes provisioning it, including a row a + /// teammate created. + public func createDefaultPublication(vmID: String, port: Int, scopeTeamID: String?) async throws -> VMPublication { + try await createPublication( + vmID: vmID, + port: port, + hostname: nil, + accessMode: nil, + teamID: nil, + scopeTeamID: scopeTeamID + ) + } +} + +public enum CloudPortShareError: Error, Equatable, Sendable { + /// The link exists but did not start serving within the wait. + case stillProvisioning +} + +/// Finds or creates the shareable link for one machine port, and waits until +/// it serves before handing it back, so a copied link is never a dead one. +/// +/// The wait polls because the service has no push channel for publication +/// readiness; the delays and the sleep are injected so tests run without real +/// time. +public struct CloudPortShareService: Sendable { + public typealias Sleep = @Sendable (Duration) async throws -> Void + /// Asks the link once, signed out, whether the edge can serve it, and + /// returns the HTTP status, or nil when the edge could not be reached. + public typealias Probe = @Sendable (URL) async -> Int? + + /// Waits between readiness checks, about a minute in total. Creation + /// provisions the route right away; the wait covers the edge catching up. + public static let defaultPollDelays: [Duration] = [ + .seconds(1), .seconds(2), .seconds(3), .seconds(4), .seconds(5), + .seconds(5), .seconds(10), .seconds(10), .seconds(10), .seconds(10), + ] + + private let api: any CloudPortPublishing + private let pollDelays: [Duration] + private let sleep: Sleep + private let probe: Probe + + public init( + api: any CloudPortPublishing, + pollDelays: [Duration] = CloudPortShareService.defaultPollDelays, + sleep: @escaping Sleep = { try await Task.sleep(for: $0) }, + probe: @escaping Probe = CloudPortShareService.signedOutStatus + ) { + self.api = api + self.pollDelays = pollDelays + self.sleep = sleep + self.probe = probe + } + + /// The live cmux-generated link for this port, if there is one. A custom + /// domain on the same port is left alone: it may still be waiting on the + /// user's DNS, and it isn't the link Share hands out. + public func existing(vmID: String, port: Int, teamID: String?) async throws -> VMPublication? { + try await api.listPublications(scopeTeamID: teamID).first { + $0.vmID == vmID && $0.port == port && $0.domainKind == "generated" && Self.isLive($0.state) + } + } + + /// Reuses the port's generated link (whatever its access) or creates one + /// with the server's default access, then waits until the link itself + /// answers: `active` on the server can run ahead of the edge, which shows + /// a 503 page until its authorization check and route are ready. + public func share(vmID: String, port: Int, teamID: String?) async throws -> VMPublication { + do { + return try await shareUntilReady(vmID: vmID, port: port, teamID: teamID) + } catch { + // A cancelled request can finish with a transport or API error. + // Preserve cancellation so callers do not show a stale failure. + try Task.checkCancellation() + throw error + } + } + + private func shareUntilReady(vmID: String, port: Int, teamID: String?) async throws -> VMPublication { + try Task.checkCancellation() + var delays = pollDelays.makeIterator() + var publication = try await existing(vmID: vmID, port: port, teamID: teamID) + while true { + try Task.checkCancellation() + if publication?.state != "active" { + // Creating again resumes a provisioning or unavailable row. A + // row still being removed (409) or a busy provisioning lease + // (503) only means "not yet". + do { + publication = try await api.createDefaultPublication(vmID: vmID, port: port, scopeTeamID: teamID) + } catch VMClientError.httpStatus(let status, _) where status == 409 || status == 503 { + publication = nil + } + try Task.checkCancellation() + } + if let current = publication, current.state == "active", await serves(current) { + try Task.checkCancellation() + return current + } + try Task.checkCancellation() + guard let delay = delays.next() else { throw CloudPortShareError.stillProvisioning } + try await sleep(delay) + } + } + + /// Unpublishes the port. Its link stops working on the next request. + public func stopSharing(publicationID: String, teamID: String?) async throws { + try await api.deletePublication(id: publicationID, scopeTeamID: teamID) + } + + /// Probe both access modes with HEAD. A public app can return any ordinary + /// HTTP response, including 404, once the edge is forwarding; edge 5xx + /// responses and network failures still mean that the route is not ready. + /// A protected link must answer the signed-out probe with 401, or serve or + /// redirect; an edge 503 or unknown-route 404 waits in that mode. + private func serves(_ publication: VMPublication) async -> Bool { + guard let url = URL(string: publication.url), let status = await probe(url) else { return false } + if publication.accessMode == .public { return status < 500 } + return (200..<400).contains(status) || status == 401 + } + + /// A signed-out HEAD to a protected link. The authorization check can + /// reject it or redirect to sign-in; redirects are never followed. + /// If the publication becomes public during the request, the app receives + /// a safe-method readiness check rather than a POST that could mutate data. + public static let signedOutStatus: Probe = { url in + await signedOutStatus(url, configuration: .ephemeral) + } + + /// The configuration overload keeps the transport test deterministic while + /// production continues to use an ephemeral, cookie-free session. + static func signedOutStatus(_ url: URL, configuration: URLSessionConfiguration) async -> Int? { + configuration.timeoutIntervalForRequest = 5 + configuration.httpCookieStorage = nil + configuration.httpShouldSetCookies = false + let session = URLSession(configuration: configuration, delegate: NoRedirects(), delegateQueue: nil) + defer { session.finishTasksAndInvalidate() } + var request = URLRequest(url: url) + request.httpMethod = "HEAD" + guard let (_, response) = try? await session.data(for: request) else { return nil } + return (response as? HTTPURLResponse)?.statusCode + } + + /// `disabling` and `disabled` rows are on their way out and can't be reused. + private static func isLive(_ state: String) -> Bool { + state != "disabling" && state != "disabled" + } +} + +private final class NoRedirects: NSObject, URLSessionTaskDelegate, Sendable { + func urlSession( + _ session: URLSession, + task: URLSessionTask, + willPerformHTTPRedirection response: HTTPURLResponse, + newRequest request: URLRequest + ) async -> URLRequest? { + nil + } +} diff --git a/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareStore.swift b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareStore.swift new file mode 100644 index 000000000000..1d2905d1cf33 --- /dev/null +++ b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/CloudPortShareStore.swift @@ -0,0 +1,87 @@ +import Foundation +import Observation + +/// Per-port Share progress, so the port row can show a spinner while its link +/// is being made and a checkmark once it has been copied. +@MainActor +@Observable +public final class CloudPortShareStore { + public enum Phase: Equatable, Sendable { + case creating + case copied(VMPublicationAccessMode) + /// The link is ready but wasn't copied, because the clipboard changed + /// while it was being made. Clicking again copies it at once. + case ready + case failed + } + + public struct Key: Hashable, Sendable { + public let machineID: String + public let port: Int + public init(machineID: String, port: Int) { + self.machineID = machineID + self.port = port + } + } + + public typealias Sleep = @Sendable (Duration) async throws -> Void + + public static let shared = CloudPortShareStore() + + public private(set) var phases: [Key: Phase] = [:] + @ObservationIgnored private var resetTasks: [Key: Task] = [:] + @ObservationIgnored private var operationIDs: [Key: UUID] = [:] + @ObservationIgnored private let sleep: Sleep + + /// `sleep` times the auto-dismiss of a finished phase (a brief "copied" + /// note); it is injected so tests don't wait in real time. + public init(sleep: @escaping Sleep = { try await Task.sleep(for: $0) }) { + self.sleep = sleep + } + + public func phase(for key: Key) -> Phase? { phases[key] } + + public func isCreating(_ key: Key) -> Bool { phases[key] == .creating } + + /// Starts a new operation and returns its identity. A late completion from + /// an older operation cannot clear or overwrite a replacement. + public func beginCreating(_ key: Key) -> UUID? { + guard phases[key] != .creating else { return nil } + let id = UUID() + operationIDs[key] = id + set(.creating, for: key) + return id + } + + /// Shows `phase` on the row; a finished phase clears itself after `holdFor`. + public func set(_ phase: Phase, for key: Key, holdFor: Duration? = nil) { + resetTasks[key]?.cancel() + resetTasks[key] = nil + phases[key] = phase + guard let holdFor else { return } + let sleep = sleep + resetTasks[key] = Task { @MainActor [weak self] in + do { try await sleep(holdFor) } catch { return } + guard let self, self.phases[key] == phase else { return } + self.phases[key] = nil + self.resetTasks[key] = nil + } + } + + public func clear(_ key: Key) { + resetTasks[key]?.cancel() + resetTasks[key] = nil + phases[key] = nil + operationIDs[key] = nil + } + + public func set(_ phase: Phase, for key: Key, operationID: UUID, holdFor: Duration? = nil) { + guard operationIDs[key] == operationID else { return } + set(phase, for: key, holdFor: holdFor) + } + + public func clear(_ key: Key, operationID: UUID) { + guard operationIDs[key] == operationID else { return } + clear(key) + } +} diff --git a/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/VMClient.swift b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/VMClient.swift index 33b330f10751..ed2150899540 100644 --- a/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/VMClient.swift +++ b/Packages/macOS/CmuxCloud/Sources/CmuxCloud/VMClient/VMClient.swift @@ -1178,9 +1178,11 @@ public actor VMClient { try await listPage(allowWhenCloudDisabled: false, expectedTeamScope: nil) } - public func listPublications() async throws -> [VMPublication] { + /// `scopeTeamID` runs the request as that team (a machine's owning team) + /// instead of the selected one; nil keeps the selected team. + public func listPublications(scopeTeamID: String? = nil) async throws -> [VMPublication] { return try await withOperation(.publication, foreground: true) { - let (data, http) = try await request("GET", path: "/api/vm/publications") + let (data, http) = try await request("GET", path: "/api/vm/publications", teamID: scopeTeamID) try ensureOK(http, data: data) let object = try decodeJSONObject(data) guard let items = (object["publications"] as? [[String: Any]]) @@ -1236,7 +1238,8 @@ public actor VMClient { accessMode: VMPublicationAccessMode?, teamID: String?, organizationSlug: String? = nil, - confirmPublic: Bool = false + confirmPublic: Bool = false, + scopeTeamID: String? = nil ) async throws -> VMPublication { return try await withOperation(.publication, foreground: true) { var body: [String: Any] = [ @@ -1251,19 +1254,21 @@ public actor VMClient { let (data, http) = try await request( "POST", path: "/api/vm/publications", - jsonBody: body + jsonBody: body, + teamID: scopeTeamID ) try ensureOK(http, data: data) return try Self.decodePublicationMutation(try decodeJSONObject(data)) } } - public func verifyPublication(id: String) async throws -> VMPublication { + public func verifyPublication(id: String, scopeTeamID: String? = nil) async throws -> VMPublication { return try await withOperation(.publication, foreground: true) { let encodedID = try pathSegment(id, fieldName: "publication id") let (data, http) = try await request( "POST", - path: "/api/vm/publications/\(encodedID)/verify" + path: "/api/vm/publications/\(encodedID)/verify", + teamID: scopeTeamID ) try ensureOK(http, data: data) return try Self.decodePublicationMutation(try decodeJSONObject(data)) @@ -1274,7 +1279,8 @@ public actor VMClient { id: String, accessMode: VMPublicationAccessMode, teamID: String?, - confirmPublic: Bool = false + confirmPublic: Bool = false, + scopeTeamID: String? = nil ) async throws -> VMPublication { return try await withOperation(.publication, foreground: true) { let encodedID = try pathSegment(id, fieldName: "publication id") @@ -1287,7 +1293,8 @@ public actor VMClient { let (data, http) = try await request( "PATCH", path: "/api/vm/publications/\(encodedID)", - jsonBody: body + jsonBody: body, + teamID: scopeTeamID ) try ensureOK(http, data: data) return try Self.decodePublicationMutation(try decodeJSONObject(data)) @@ -1306,10 +1313,10 @@ public actor VMClient { } } - public func deletePublication(id: String) async throws { + public func deletePublication(id: String, scopeTeamID: String? = nil) async throws { return try await withOperation(.publication, foreground: true) { let encodedID = try pathSegment(id, fieldName: "publication id") - let (data, http) = try await request("DELETE", path: "/api/vm/publications/\(encodedID)") + let (data, http) = try await request("DELETE", path: "/api/vm/publications/\(encodedID)", teamID: scopeTeamID) try ensureOK(http, data: data) } } diff --git a/Packages/macOS/CmuxCloud/Tests/CmuxCloudTests/CloudPortShareServiceTests.swift b/Packages/macOS/CmuxCloud/Tests/CmuxCloudTests/CloudPortShareServiceTests.swift new file mode 100644 index 000000000000..f8e37e5495f5 --- /dev/null +++ b/Packages/macOS/CmuxCloud/Tests/CmuxCloudTests/CloudPortShareServiceTests.swift @@ -0,0 +1,316 @@ +@testable import CmuxCloud +import Foundation +import Testing + +@Suite("Cloud port share service") +struct CloudPortShareServiceTests { + enum CancellationPoint: CaseIterable, Sendable { + case beforeStart, list, create, probe, retryDelay + } + + @Test("cancellation stops sharing even when a dependency finishes normally", arguments: CancellationPoint.allCases) + func cancellationStopsSharing(at point: CancellationPoint) async { + let entered = Gate() + let release = Gate() + let pause: @Sendable () async -> Void = { + await entered.open() + await release.wait() + } + let api = FakePublishing( + creates: [.row(publication(state: point == .retryDelay ? "provisioning" : "active"))], + beforeListReturn: { if point == .list { await pause() } }, + beforeCreateReturn: { if point == .create { await pause() } } + ) + let service = CloudPortShareService( + api: api, + pollDelays: [.seconds(1)], + sleep: { _ in if point == .retryDelay { await pause() } }, + probe: { _ in + if point == .probe { await pause() } + return 401 + } + ) + let task = Task { + if point == .beforeStart { await pause() } + return try await service.share(vmID: "brave-otter", port: 8000, teamID: "team-1") + } + await entered.wait() + task.cancel() + await release.open() + await #expect(throws: CancellationError.self) { _ = try await task.value } + let expectedCalls: [String] = point == .beforeStart ? [] : point == .list + ? ["list team-1"] : ["list team-1", "create brave-otter:8000 team-1"] + #expect(await api.calls == expectedCalls) + } + + @Test("the signed-out readiness request uses a safe HTTP method") + func readinessRequestIsSafe() async throws { + let url = try #require(URL(string: "https://port-share-probe-test.invalid/")) + let configuration = URLSessionConfiguration.ephemeral + configuration.protocolClasses = [PortShareProbeProtocol.self] + let status = await CloudPortShareService.signedOutStatus(url, configuration: configuration) + #expect(status == 200) + let request = try #require(PortShareProbeProtocol.capturedRequest()) + #expect(request.httpMethod == "HEAD") + #expect(request.httpBody == nil) + #expect(request.value(forHTTPHeaderField: "Authorization") == nil) + #expect(request.value(forHTTPHeaderField: "Cookie") == nil) + } + + @Test("creates a link with the server default and waits until it serves") + func createsAndWaits() async throws { + let api = FakePublishing(creates: [.row(publication(state: "provisioning")), .row(publication(state: "active"))]) + let link = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: "team-1") + #expect(link.state == "active") + #expect(await api.calls == [ + "list team-1", + "create brave-otter:8000 team-1", + "create brave-otter:8000 team-1", + ]) + } + + @Test("reuses the port's existing generated link instead of creating another") + func reusesExisting() async throws { + let api = FakePublishing(listed: [ + publication(id: "other", port: 3000, state: "active"), + publication(id: "mine", state: "active"), + ]) + let link = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: "team-1") + #expect(link.id == "mine") + #expect(await api.calls == ["list team-1"]) + } + + @Test("a custom domain on the same port is not the link Share hands out") + func ignoresCustomDomain() async throws { + let api = FakePublishing( + listed: [publication(id: "custom", state: "provisioning", domainKind: "custom")], + creates: [.row(publication(id: "generated", state: "active"))] + ) + let link = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: nil) + #expect(link.id == "generated") + } + + @Test("a link being removed or a busy server only means not yet") + func retriesTransientConflicts() async throws { + let api = FakePublishing( + listed: [publication(id: "old", state: "disabling")], + creates: [.status(409), .status(503), .row(publication(id: "new", state: "active"))] + ) + let link = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: nil) + #expect(link.id == "new") + } + + @Test("an unavailable link is resumed by creating again, not given up on") + func resumesUnavailable() async throws { + let api = FakePublishing( + listed: [publication(state: "unavailable")], + creates: [.row(publication(state: "active"))] + ) + let link = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: nil) + #expect(link.state == "active") + } + + @Test("other server errors end the share") + func otherErrorsThrow() async { + let api = FakePublishing(creates: [.status(404)]) + await #expect(throws: VMClientError.self) { + _ = try await service(api).share(vmID: "brave-otter", port: 8000, teamID: nil) + } + } + + @Test("gives up with stillProvisioning once the waits run out") + func timesOut() async { + let api = FakePublishing(creates: [.row(publication(state: "provisioning"))]) + await #expect(throws: CloudPortShareError.stillProvisioning) { + _ = try await service(api, delays: [.seconds(1), .seconds(1)]).share(vmID: "brave-otter", port: 8000, teamID: nil) + } + } + + @Test("waits past the edge's 503 and unknown-route 404 before handing back a link") + func waitsForEdge() async throws { + let api = FakePublishing(creates: [.row(publication(state: "active"))]) + let statuses = Statuses([503, nil, 404, 401]) + let link = try await service(api, probe: { _ in await statuses.next() }).share(vmID: "brave-otter", port: 8000, teamID: nil) + #expect(link.state == "active") + #expect(await statuses.remaining == 0) + } + + @Test("an edge that never answers is stillProvisioning, not a copied 503") + func edgeNeverReady() async { + let api = FakePublishing(creates: [.row(publication(state: "active"))]) + await #expect(throws: CloudPortShareError.stillProvisioning) { + _ = try await service(api, delays: [.seconds(1)], probe: { _ in 503 }).share(vmID: "brave-otter", port: 8000, teamID: nil) + } + } + + @Test("a public link waits for the edge before copying") + func publicWaitsForEdge() async throws { + let api = FakePublishing(creates: [.row(publication(state: "active", access: .public))]) + let statuses = Statuses([503, 200]) + let link = try await service(api, probe: { _ in await statuses.next() }) + .share(vmID: "brave-otter", port: 8000, teamID: nil) + #expect(link.accessMode == .public) + #expect(await statuses.remaining == 0) + } + + private func service( + _ api: FakePublishing, + delays: [Duration] = [.seconds(1), .seconds(1), .seconds(1), .seconds(1)], + probe: @escaping CloudPortShareService.Probe = { _ in 401 } + ) -> CloudPortShareService { + CloudPortShareService(api: api, pollDelays: delays, sleep: { _ in }, probe: probe) + } +} + +@Suite("Cloud port share store") +@MainActor +struct CloudPortShareStoreTests { + private let key = CloudPortShareStore.Key(machineID: "brave-otter", port: 8000) + + @Test("a held phase clears itself after the hold") + func holdClears() async { + let gate = Gate() + let store = CloudPortShareStore(sleep: { _ in await gate.wait() }) + store.set(.copied(.team), for: key, holdFor: .seconds(2)) + #expect(store.phase(for: key) == .copied(.team)) + await gate.open() + await waitUntil { store.phase(for: key) == nil } + #expect(store.phase(for: key) == nil) + } + + @Test("a newer phase is not cleared by an older phase's hold") + func newerPhaseSurvives() async { + let gate = Gate() + let store = CloudPortShareStore(sleep: { _ in await gate.wait() }) + store.set(.failed, for: key, holdFor: .seconds(4)) + store.set(.creating, for: key) + await gate.open() + for _ in 0..<20 { await Task.yield() } + #expect(store.phase(for: key) == .creating) + } + + @Test("a cancelled operation cannot clear its replacement") + func cancelledOperationDoesNotClearReplacement() throws { + let store = CloudPortShareStore() + let first = try #require(store.beginCreating(key)) + store.clear(key, operationID: first) + let replacement = try #require(store.beginCreating(key)) + store.clear(key, operationID: first) + #expect(store.phase(for: key) == .creating) + store.clear(key, operationID: replacement) + #expect(store.phase(for: key) == nil) + } + + private func waitUntil(_ condition: @MainActor () -> Bool) async { + for _ in 0..<100 where !condition() { await Task.yield() } + } +} + +private func publication( + id: String = "pub-1", + port: Int = 8000, + state: String, + access: VMPublicationAccessMode = .team, + domainKind: String = "generated" +) -> VMPublication { + VMPublication( + id: id, + hostname: "brave-otter--team--\(port).cmux.sh", + url: "https://brave-otter--team--\(port).cmux.sh", + domainKind: domainKind, + vmID: "brave-otter", + port: port, + accessMode: access, + teamID: access == .team ? "team-1" : nil, + state: state, + routingRevision: 1, + verification: nil + ) +} + +private actor Statuses { + private var values: [Int?] + init(_ values: [Int?]) { self.values = values } + var remaining: Int { values.count } + func next() -> Int? { values.isEmpty ? 401 : values.removeFirst() } +} + +/// Holds sleepers until the test opens it. +private actor Gate { + private var isOpen = false + private var waiters: [CheckedContinuation] = [] + func wait() async { + if isOpen { return } + await withCheckedContinuation { waiters.append($0) } + } + func open() { + isOpen = true + waiters.forEach { $0.resume() } + waiters = [] + } +} + +private actor FakePublishing: CloudPortPublishing { + enum Create { + case row(VMPublication) + case status(Int) + } + + private(set) var calls: [String] = [] + private let listed: [VMPublication] + private var creates: [Create] + private let beforeListReturn: @Sendable () async -> Void + private let beforeCreateReturn: @Sendable () async -> Void + + init( + listed: [VMPublication] = [], creates: [Create] = [], + beforeListReturn: @escaping @Sendable () async -> Void = {}, + beforeCreateReturn: @escaping @Sendable () async -> Void = {} + ) { + self.listed = listed + self.creates = creates + self.beforeListReturn = beforeListReturn + self.beforeCreateReturn = beforeCreateReturn + } + + func listPublications(scopeTeamID: String?) async throws -> [VMPublication] { + calls.append("list \(scopeTeamID ?? "-")") + await beforeListReturn() + return listed + } + + /// Plays the scripted answers in order, repeating the last one. + func createDefaultPublication(vmID: String, port: Int, scopeTeamID: String?) async throws -> VMPublication { + calls.append("create \(vmID):\(port) \(scopeTeamID ?? "-")") + await beforeCreateReturn() + guard let next = creates.first else { throw VMClientError.httpStatus(500, "no scripted create") } + if creates.count > 1 { creates.removeFirst() } + switch next { + case .row(let publication): return publication + case .status(let status): throw VMClientError.httpStatus(status, "{}") + } + } + + func deletePublication(id: String, scopeTeamID: String?) async throws { + calls.append("delete \(id) \(scopeTeamID ?? "-")") + } +} + +/// Intercepts only this test's hostname; other URLSession traffic is unaffected. +private final class PortShareProbeProtocol: URLProtocol, @unchecked Sendable { + private static let lock = NSLock() + nonisolated(unsafe) private static var captured: URLRequest? + + static func capturedRequest() -> URLRequest? { lock.withLock { captured } } + override class func canInit(with request: URLRequest) -> Bool { + request.url?.host == "port-share-probe-test.invalid" + } + override class func canonicalRequest(for request: URLRequest) -> URLRequest { request } + override func startLoading() { + Self.lock.withLock { Self.captured = request } + let response = HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: nil, headerFields: nil)! + client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed) + client?.urlProtocolDidFinishLoading(self) + } + override func stopLoading() {} +} diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index 2e866503ac08..83580312d8a1 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -60,6 +60,65 @@ } } }, + "cloudTree.port.share.error.timeout": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "The link is still being set up. Try sharing again in a minute." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "لا يزال الرابط قيد الإعداد. حاول المشاركة مرة أخرى بعد دقيقة." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Der Link wird noch eingerichtet. Versuche es in einer Minute erneut." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "El enlace aún se está configurando. Vuelve a compartirlo en un minuto." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Le lien est encore en cours de configuration. Réessayez de le partager dans une minute." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクはまだ準備中です。1分ほどしてからもう一度共有してください。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 아직 설정하는 중입니다. 1분 후에 다시 공유해 보세요." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "链接仍在设置中。请一分钟后再尝试共享。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "連結仍在設定中。請在一分鐘後再試著分享。" + } + } + } + }, "cli.remotes.error.invalidArguments": { "extractionState": "manual", "localizations": { @@ -119,6 +178,65 @@ } } }, + "cloudTree.port.share.error.unavailable": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "The Cloud service couldn't create a link for this port. Try again." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تعذّر على خدمة السحابة إنشاء رابط لهذا المنفذ. حاول مرة أخرى." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Der Cloud-Dienst konnte keinen Link für diesen Port erstellen. Versuche es erneut." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "El servicio Cloud no pudo crear un enlace para este puerto. Inténtalo de nuevo." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Le service Cloud n’a pas pu créer de lien pour ce port. Réessayez." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "Cloud サービスでこのポートのリンクを作成できませんでした。もう一度お試しください。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Cloud 서비스에서 이 포트의 링크를 만들지 못했습니다. 다시 시도하세요." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "Cloud 服务无法为此端口创建链接。请重试。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "Cloud 服務無法為此連接埠建立連結。請再試一次。" + } + } + } + }, "cli.remotes.error.unexpectedArgument": { "extractionState": "manual", "localizations": { @@ -178,6 +296,65 @@ } } }, + "cloudTree.port.share.copiedPersonal": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Link copied. Only you can open it." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تم نسخ الرابط. يمكنك أنت فقط فتحه." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link kopiert. Nur du kannst ihn öffnen." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Enlace copiado. Solo tú puedes abrirlo." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Lien copié. Vous seul pouvez l’ouvrir." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクをコピーしました。開けるのはあなただけです。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 복사했습니다. 나만 열 수 있습니다." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "已复制链接。只有你可以打开。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "已拷貝連結。只有你可以開啟。" + } + } + } + }, "cli.remotes.error.unknownFlag": { "extractionState": "manual", "localizations": { @@ -237,6 +414,65 @@ } } }, + "cloudTree.port.share.copiedPublic": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Link copied. Anyone with the link can open it." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تم نسخ الرابط. يمكن لأي شخص لديه الرابط فتحه." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link kopiert. Jeder mit dem Link kann ihn öffnen." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Enlace copiado. Cualquiera con el enlace puede abrirlo." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Lien copié. Toute personne disposant du lien peut l’ouvrir." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクをコピーしました。リンクを知っている人なら誰でも開けます。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 복사했습니다. 링크가 있는 누구나 열 수 있습니다." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "已复制链接。任何拥有链接的人都可以打开。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "已拷貝連結。任何擁有連結的人都可以開啟。" + } + } + } + }, "projectPanel.reload": { "extractionState": "manual", "localizations": { @@ -296,6 +532,65 @@ } } }, + "cloudTree.port.share.copiedTeam": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Link copied. Your team can open it after signing in." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تم نسخ الرابط. يمكن لفريقك فتحه بعد تسجيل الدخول." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link kopiert. Dein Team kann ihn nach der Anmeldung öffnen." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Enlace copiado. Tu equipo puede abrirlo después de iniciar sesión." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Lien copié. Votre équipe peut l’ouvrir après s’être connectée." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクをコピーしました。チームのメンバーはサインイン後に開けます。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 복사했습니다. 팀원은 로그인한 후 열 수 있습니다." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "已复制链接。你的团队登录后即可打开。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "已拷貝連結。你的團隊登入後即可開啟。" + } + } + } + }, "projectPanel.reloadErrors": { "extractionState": "manual", "localizations": { @@ -355,6 +650,65 @@ } } }, + "cloudTree.port.share.creating": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Creating link…" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "جارٍ إنشاء الرابط…" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link wird erstellt…" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Creando el enlace…" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Création du lien…" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクを作成しています…" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 만드는 중…" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "正在创建链接…" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "正在建立連結…" + } + } + } + }, "projectPanel.dismissReloadErrors": { "extractionState": "manual", "localizations": { @@ -414,6 +768,65 @@ } } }, + "cloudTree.port.share.failed": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Couldn't create link" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تعذّر إنشاء الرابط" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link konnte nicht erstellt werden" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "No se pudo crear el enlace" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Impossible de créer le lien" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクを作成できませんでした" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크를 만들 수 없음" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "无法创建链接" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "無法建立連結" + } + } + } + }, "projectPanel.scheme": { "extractionState": "manual", "localizations": { @@ -473,6 +886,65 @@ } } }, + "cloudTree.port.share.copied": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Copied to clipboard" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "تم النسخ إلى الحافظة" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "In die Zwischenablage kopiert" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Copiado al portapapeles" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Copié dans le presse-papiers" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "クリップボードにコピーしました" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "클립보드에 복사됨" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "已复制到剪贴板" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "已拷貝到剪貼板" + } + } + } + }, "projectPanel.configuration": { "extractionState": "manual", "localizations": { @@ -532,6 +1004,65 @@ } } }, + "cloudTree.menu.copyShareLink": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Copy Share Link" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "نسخ رابط المشاركة" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Freigabelink kopieren" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Copiar enlace para compartir" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Copier le lien de partage" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "共有リンクをコピー" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "공유 링크 복사" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "复制共享链接" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "拷貝分享連結" + } + } + } + }, "projectPanel.loadingFormat": { "extractionState": "manual", "localizations": { @@ -591,6 +1122,65 @@ } } }, + "cloudTree.port.shareLink": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Share Link" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "مشاركة الرابط" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link teilen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Compartir enlace" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Partager le lien" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクを共有" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크 공유" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "共享链接" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "分享連結" + } + } + } + }, "projectPanel.failedFormat": { "extractionState": "manual", "localizations": { @@ -650,6 +1240,65 @@ } } }, + "cloudTree.port.share.ready": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Link ready" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "الرابط جاهز" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link bereit" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Enlace listo" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Lien prêt" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクの準備ができました" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크 준비됨" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "链接已就绪" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "連結已就緒" + } + } + } + }, "settings.automation.rules.createFailed.title": { "extractionState": "manual", "localizations": { @@ -775,6 +1424,65 @@ } } }, + "cloudTree.port.share.readyHelp": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "The link is ready. Click to copy it." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "الرابط جاهز. انقر لنسخه." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Der Link ist bereit. Klicke, um ihn zu kopieren." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "El enlace está listo. Haz clic para copiarlo." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Le lien est prêt. Cliquez pour le copier." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクの準備ができました。クリックしてコピーします。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크가 준비되었습니다. 클릭하여 복사하세요." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "链接已就绪。点按即可复制。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "連結已就緒。按一下即可拷貝。" + } + } + } + }, "settings.automation.rules.createFailed.message": { "extractionState": "manual", "localizations": { @@ -236663,380 +237371,380 @@ } }, "machines.new.plan.loading": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "Loading your Cloud machine plan…" - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "جارٍ تحميل خطة جهاز Cloud…" - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Učitavanje plana Cloud mašine…" - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "Indlæser din Cloud-maskineplan…" - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "Dein Cloud-Maschinentarif wird geladen…" - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "Cargando el plan de tu máquina Cloud…" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Chargement du forfait de votre machine Cloud…" - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "Caricamento del piano della macchina Cloud…" - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "Cloud マシンのプランを読み込んでいます…" - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "កំពុងផ្ទុកគម្រោងម៉ាស៊ីន Cloud របស់អ្នក…" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "Cloud 머신 요금제를 불러오는 중…" - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "Laster inn Cloud-maskinplanen din…" - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "Wczytywanie planu maszyny Cloud…" - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "Carregando o plano da sua máquina Cloud…" - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "Загрузка тарифа машины Cloud…" - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "กำลังโหลดแผนเครื่อง Cloud ของคุณ…" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "Cloud makine planınız yükleniyor…" - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "Завантаження тарифу машини Cloud…" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "正在加载你的 Cloud 机器方案…" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "正在載入您的 Cloud 機器方案…" + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Loading your Cloud machine plan…" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "جارٍ تحميل خطة جهاز Cloud…" + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "Učitavanje plana Cloud mašine…" + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "Indlæser din Cloud-maskineplan…" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Dein Cloud-Maschinentarif wird geladen…" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Cargando el plan de tu máquina Cloud…" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Chargement du forfait de votre machine Cloud…" + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "Caricamento del piano della macchina Cloud…" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "Cloud マシンのプランを読み込んでいます…" + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "កំពុងផ្ទុកគម្រោងម៉ាស៊ីន Cloud របស់អ្នក…" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Cloud 머신 요금제를 불러오는 중…" + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "Laster inn Cloud-maskinplanen din…" + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "Wczytywanie planu maszyny Cloud…" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Carregando o plano da sua máquina Cloud…" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Загрузка тарифа машины Cloud…" + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "กำลังโหลดแผนเครื่อง Cloud ของคุณ…" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "Cloud makine planınız yükleniyor…" + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "Завантаження тарифу машини Cloud…" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "正在加载你的 Cloud 机器方案…" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "正在載入您的 Cloud 機器方案…" + } } } - } - }, + }, "machines.new.plan.retry": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "Retry" - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "إعادة المحاولة" - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Pokušaj ponovo" - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "Prøv igen" - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "Erneut versuchen" - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "Reintentar" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Réessayer" - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "Riprova" - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "再試行" - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "ព្យាយាមម្ដងទៀត" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "재시도" - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "Prøv igjen" - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "Ponów" - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "Tentar Novamente" - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "Повторить" - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "ลองใหม่" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "Tekrar Dene" - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "Повторити" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "重试" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "重試" + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Retry" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "إعادة المحاولة" + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "Pokušaj ponovo" + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "Prøv igen" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Erneut versuchen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Reintentar" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Réessayer" + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "Riprova" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "再試行" + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "ព្យាយាមម្ដងទៀត" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "재시도" + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "Prøv igjen" + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "Ponów" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Tentar Novamente" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Повторить" + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "ลองใหม่" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "Tekrar Dene" + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "Повторити" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "重试" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "重試" + } } } - } - }, + }, "machines.new.plan.error": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "Cloud plan details are still loading. Retry in a moment." - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "لا تزال تفاصيل خطة Cloud قيد التحميل. أعد المحاولة بعد قليل." - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Detalji Cloud plana se još učitavaju. Pokušajte ponovo za trenutak." - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "Cloud-planens detaljer indlæses stadig. Prøv igen om et øjeblik." - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "Die Details des Cloud-Tarifs werden noch geladen. Versuche es gleich noch einmal." - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "Los detalles del plan de Cloud aún se están cargando. Vuelve a intentarlo en un momento." - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Les détails du forfait Cloud sont encore en cours de chargement. Réessayez dans un instant." - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "I dettagli del piano Cloud sono ancora in caricamento. Riprova tra un momento." - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "Cloud プランの詳細を読み込み中です。しばらくしてから再試行してください。" - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "ព័ត៌មានលម្អិតនៃគម្រោង Cloud នៅតែកំពុងផ្ទុក។ សូមព្យាយាមម្ដងទៀតបន្តិចទៀត។" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "Cloud 요금제 정보를 아직 불러오는 중입니다. 잠시 후 다시 시도하세요." - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "Detaljene for Cloud-planen lastes fortsatt inn. Prøv igjen om et øyeblikk." - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "Szczegóły planu Cloud wciąż się wczytują. Spróbuj ponownie za chwilę." - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "Os detalhes do plano Cloud ainda estão carregando. Tente novamente em instantes." - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "Сведения о тарифе Cloud ещё загружаются. Повторите попытку через мгновение." - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "รายละเอียดแผน Cloud ยังโหลดอยู่ โปรดลองใหม่อีกครั้งในอีกสักครู่" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "Cloud planı ayrıntıları hâlâ yükleniyor. Birazdan tekrar deneyin." - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "Відомості про тариф Cloud ще завантажуються. Повторіть спробу через мить." - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "Cloud 方案详情仍在加载。请稍后重试。" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "Cloud 方案詳細資料仍在載入。請稍後重試。" + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Cloud plan details are still loading. Retry in a moment." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "لا تزال تفاصيل خطة Cloud قيد التحميل. أعد المحاولة بعد قليل." + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "Detalji Cloud plana se još učitavaju. Pokušajte ponovo za trenutak." + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "Cloud-planens detaljer indlæses stadig. Prøv igen om et øjeblik." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Die Details des Cloud-Tarifs werden noch geladen. Versuche es gleich noch einmal." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Los detalles del plan de Cloud aún se están cargando. Vuelve a intentarlo en un momento." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Les détails du forfait Cloud sont encore en cours de chargement. Réessayez dans un instant." + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "I dettagli del piano Cloud sono ancora in caricamento. Riprova tra un momento." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "Cloud プランの詳細を読み込み中です。しばらくしてから再試行してください。" + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "ព័ត៌មានលម្អិតនៃគម្រោង Cloud នៅតែកំពុងផ្ទុក។ សូមព្យាយាមម្ដងទៀតបន្តិចទៀត។" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Cloud 요금제 정보를 아직 불러오는 중입니다. 잠시 후 다시 시도하세요." + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "Detaljene for Cloud-planen lastes fortsatt inn. Prøv igjen om et øyeblikk." + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "Szczegóły planu Cloud wciąż się wczytują. Spróbuj ponownie za chwilę." + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Os detalhes do plano Cloud ainda estão carregando. Tente novamente em instantes." + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Сведения о тарифе Cloud ещё загружаются. Повторите попытку через мгновение." + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "รายละเอียดแผน Cloud ยังโหลดอยู่ โปรดลองใหม่อีกครั้งในอีกสักครู่" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "Cloud planı ayrıntıları hâlâ yükleniyor. Birazdan tekrar deneyin." + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "Відомості про тариф Cloud ще завантажуються. Повторіть спробу через мить." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "Cloud 方案详情仍在加载。请稍后重试。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "Cloud 方案詳細資料仍在載入。請稍後重試。" + } } } - } - }, + }, "machines.new": { "extractionState": "manual", "localizations": { @@ -566099,65 +566807,6 @@ } } }, - "settings.search.alias.setting.workspaceColors.brighten-dark-mode": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color" - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 明るく ダークモード ワークスペース 色 塗りつぶし" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 调亮 深色模式 工作区 颜色 填充" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 調亮 深色模式 工作區 顏色 填滿" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 밝게 다크 모드 작업 공간 색상 채우기" - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color aufhellen dunkler Modus Arbeitsbereich Farben Füllung" - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color aclarar modo oscuro espacio de trabajo colores relleno" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color éclaircir mode sombre espace de travail couleurs remplissage" - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color تفتيح الوضع الداكن مساحة العمل الألوان تعبئة" - } - } - } - }, "settings.workspaceColors.subtleSelection": { "extractionState": "manual", "localizations": { @@ -612702,70 +613351,70 @@ "value": "Cloud Machines 需要 cmux Pro" } }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Cloud Machines zahtijevaju cmux Pro" + "bs": { + "stringUnit": { + "state": "translated", + "value": "Cloud Machines zahtijevaju cmux Pro" } }, "da": { "stringUnit": { "state": "translated", - "value": "Cloud Machines kræver cmux Pro" + "value": "Cloud Machines kræver cmux Pro" } }, "it": { "stringUnit": { "state": "translated", - "value": "Cloud Machines richiedono cmux Pro" + "value": "Cloud Machines richiedono cmux Pro" } }, "km": { "stringUnit": { "state": "translated", - "value": "Cloud Machines ត្រូវការ cmux Pro" + "value": "Cloud Machines ត្រូវការ cmux Pro" } }, "nb": { "stringUnit": { "state": "translated", - "value": "Cloud Machines krever cmux Pro" + "value": "Cloud Machines krever cmux Pro" } }, "pl": { "stringUnit": { "state": "translated", - "value": "Cloud Machines wymagają cmux Pro" + "value": "Cloud Machines wymagają cmux Pro" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "O Cloud Machines requer cmux Pro" + "value": "O Cloud Machines requer cmux Pro" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Для Cloud Machines требуется cmux Pro" + "value": "Для Cloud Machines требуется cmux Pro" } }, "th": { "stringUnit": { "state": "translated", - "value": "Cloud Machines ต้องใช้ cmux Pro" + "value": "Cloud Machines ต้องใช้ cmux Pro" } }, "tr": { "stringUnit": { "state": "translated", - "value": "Cloud Machines için cmux Pro gerekir" + "value": "Cloud Machines için cmux Pro gerekir" } }, "uk": { "stringUnit": { "state": "translated", - "value": "Для Cloud Machines потрібен cmux Pro" + "value": "Для Cloud Machines потрібен cmux Pro" } } } @@ -622485,381 +623134,6 @@ } } }, - "settings.browser.showLinkHoverURL": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "Show Link URLs on Hover" - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "إظهار عنوان الرابط عند التمرير فوقه" - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "Link-URLs beim Überfahren anzeigen" - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "Mostrar la URL de los enlaces al pasar el puntero" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Afficher l’URL des liens au survol" - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "リンクにポインタを置いたときに URL を表示" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "링크에 포인터를 올리면 URL 표시" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "悬停时显示链接网址" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "滑鼠懸停時顯示連結網址" - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Prikaži URL linka pri prelasku pokazivačem" - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "Vis linkets URL, når markøren holdes over" - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "Mostra l’URL dei link al passaggio del puntatore" - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "បង្ហាញ URL របស់តំណនៅពេលដាក់ទស្សន៍ទ្រនិចលើ" - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "Vis lenkens URL når pekeren holdes over" - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "Pokazuj adres URL linku po najechaniu" - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "Mostrar URL do link ao passar o cursor" - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "Показывать URL ссылки при наведении" - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "แสดง URL ของลิงก์เมื่อวางเมาส์เหนือลิงก์" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "Üzerine gelindiğinde bağlantı URL’sini göster" - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "Показувати URL посилання при наведенні" - } - } - } - }, - "settings.browser.showLinkHoverURL.subtitle": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "Shows a link's destination at the bottom of a browser pane while the pointer is over it or it has keyboard focus." - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "يعرض وجهة الرابط أسفل لوحة المتصفح عندما يكون المؤشر فوقه أو عندما يكون التركيز عليه من لوحة المفاتيح." - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "Zeigt das Ziel eines Links unten im Browserbereich an, solange sich der Zeiger darüber befindet oder der Link den Tastaturfokus hat." - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "Muestra el destino de un enlace en la parte inferior del panel del navegador mientras el puntero está sobre él o cuando el enlace recibe el foco del teclado." - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Affiche la destination d’un lien en bas du panneau du navigateur lorsque le pointeur le survole ou que le lien a le focus clavier." - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "ポインタがリンク上にある間、またはリンクにキーボードフォーカスがある間、ブラウザペインの下部にリンク先を表示します。" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "포인터가 링크 위에 있거나 링크에 키보드 포커스가 있는 동안 브라우저 패널 하단에 링크의 대상 주소를 표시합니다." - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "指针停留在链接上或链接获得键盘焦点时,在浏览器面板底部显示链接的目标地址。" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "指標停留在連結上或連結取得鍵盤焦點時,在瀏覽器面板底部顯示連結的目的地。" - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "Prikazuje odredište linka na dnu panela preglednika dok je pokazivač iznad njega ili dok link ima fokus tastature." - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "Viser linkets destination nederst i browserpanelet, mens markøren er over det, eller mens linket har tastaturfokus." - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "Mostra la destinazione di un link nella parte inferiore del pannello del browser mentre il puntatore è sopra di esso o quando il link ha il focus della tastiera." - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "បង្ហាញទិសដៅរបស់តំណនៅផ្នែកខាងក្រោមនៃផ្ទាំងកម្មវិធីរុករក ខណៈពេលដែលទស្សន៍ទ្រនិចស្ថិតនៅលើវា ឬនៅពេលតំណទទួលបានការផ្ដោតពីក្ដារចុច។" - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "Viser lenkens mål nederst i nettleserpanelet mens pekeren er over den, eller mens lenken har tastaturfokus." - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "Pokazuje adres docelowy linku u dołu panelu przeglądarki, gdy wskaźnik znajduje się nad nim lub gdy link ma fokus klawiatury." - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "Mostra o destino de um link na parte inferior do painel do navegador enquanto o cursor está sobre ele ou quando o link tem o foco do teclado." - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "Показывает адрес ссылки в нижней части панели браузера, пока указатель находится над ней или пока ссылка находится в фокусе клавиатуры." - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "แสดงปลายทางของลิงก์ที่ด้านล่างของแผงเบราว์เซอร์ขณะที่ตัวชี้อยู่เหนือลิงก์หรือเมื่อลิงก์ได้รับโฟกัสจากแป้นพิมพ์" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "İmleç bir bağlantının üzerindeyken veya bağlantı klavye odağındayken bağlantının hedefini tarayıcı panelinin altında gösterir." - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "Показує адресу посилання в нижній частині панелі браузера, поки вказівник знаходиться над ним або поки посилання має фокус клавіатури." - } - } - } - }, - "settings.search.alias.setting.browser.link-hover-url": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview" - } - }, - "ar": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview رابط تمرير وجهة عنوان شريط الحالة معاينة" - } - }, - "de": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link überfahren ziel adresse statusleiste vorschau" - } - }, - "es": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview enlace pasar puntero destino dirección barra de estado vista previa" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview lien survol destination adresse barre d’état aperçu" - } - }, - "ja": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview リンク ホバー URL リンク先 ステータスバー プレビュー" - } - }, - "ko": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview 링크 호버 주소 대상 상태 표시줄 미리보기" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview 链接 悬停 网址 目标 状态栏 预览" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview 連結 懸停 網址 目的地 狀態列 預覽" - } - }, - "bs": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link prelazak pokazivačem odredište adresa statusna traka pregled" - } - }, - "da": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link markør over destination adresse statuslinje forhåndsvisning" - } - }, - "it": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link passaggio puntatore destinazione indirizzo barra di stato anteprima" - } - }, - "km": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview តំណ ទស្សន៍ទ្រនិច ទិសដៅ អាសយដ្ឋាន របារស្ថានភាព មើលជាមុន" - } - }, - "nb": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview lenke peker over mål adresse statuslinje forhåndsvisning" - } - }, - "pl": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link najechanie adres docelowy pasek stanu podgląd" - } - }, - "pt-BR": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview link passar cursor destino endereço barra de status pré-visualização" - } - }, - "ru": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview ссылка наведение адрес назначение строка состояния предпросмотр" - } - }, - "th": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview ลิงก์ วางเมาส์ ปลายทาง ที่อยู่ แถบสถานะ ดูตัวอย่าง" - } - }, - "tr": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview bağlantı üzerine gelme hedef adres durum çubuğu önizleme" - } - }, - "uk": { - "stringUnit": { - "state": "translated", - "value": "browser.showLinkHoverURL link hover url destination address status bar preview посилання наведення адреса призначення рядок стану попередній перегляд" - } - } - } - }, "cli.browser.help.replDescription": { "extractionState": "manual", "localizations": { @@ -623922,6 +624196,440 @@ } } }, + "settings.search.alias.setting.workspaceColors.brighten-dark-mode": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 明るく ダークモード ワークスペース 色 塗りつぶし" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 调亮 深色模式 工作区 颜色 填充" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 調亮 深色模式 工作區 顏色 填滿" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color 밝게 다크 모드 작업 공간 색상 채우기" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color aufhellen dunkler Modus Arbeitsbereich Farben Füllung" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color aclarar modo oscuro espacio de trabajo colores relleno" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color éclaircir mode sombre espace de travail couleurs remplissage" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "workspaceColors.brightenInDarkMode brighten lighten dark mode workspace colors fill dim muted exact color تفتيح الوضع الداكن مساحة العمل الألوان تعبئة" + } + } + } + }, + "settings.browser.showLinkHoverURL": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Show Link URLs on Hover" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "إظهار عنوان الرابط عند التمرير فوقه" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Link-URLs beim Überfahren anzeigen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Mostrar la URL de los enlaces al pasar el puntero" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Afficher l’URL des liens au survol" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "リンクにポインタを置いたときに URL を表示" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "링크에 포인터를 올리면 URL 표시" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "悬停时显示链接网址" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "滑鼠懸停時顯示連結網址" + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "Prikaži URL linka pri prelasku pokazivačem" + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "Vis linkets URL, når markøren holdes over" + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "Mostra l’URL dei link al passaggio del puntatore" + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "បង្ហាញ URL របស់តំណនៅពេលដាក់ទស្សន៍ទ្រនិចលើ" + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "Vis lenkens URL når pekeren holdes over" + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "Pokazuj adres URL linku po najechaniu" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Mostrar URL do link ao passar o cursor" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Показывать URL ссылки при наведении" + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "แสดง URL ของลิงก์เมื่อวางเมาส์เหนือลิงก์" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "Üzerine gelindiğinde bağlantı URL’sini göster" + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "Показувати URL посилання при наведенні" + } + } + } + }, + "settings.browser.showLinkHoverURL.subtitle": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Shows a link's destination at the bottom of a browser pane while the pointer is over it or it has keyboard focus." + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "يعرض وجهة الرابط أسفل لوحة المتصفح عندما يكون المؤشر فوقه أو عندما يكون التركيز عليه من لوحة المفاتيح." + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "Zeigt das Ziel eines Links unten im Browserbereich an, solange sich der Zeiger darüber befindet oder der Link den Tastaturfokus hat." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Muestra el destino de un enlace en la parte inferior del panel del navegador mientras el puntero está sobre él o cuando el enlace recibe el foco del teclado." + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Affiche la destination d’un lien en bas du panneau du navigateur lorsque le pointeur le survole ou que le lien a le focus clavier." + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "ポインタがリンク上にある間、またはリンクにキーボードフォーカスがある間、ブラウザペインの下部にリンク先を表示します。" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "포인터가 링크 위에 있거나 링크에 키보드 포커스가 있는 동안 브라우저 패널 하단에 링크의 대상 주소를 표시합니다." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "指针停留在链接上或链接获得键盘焦点时,在浏览器面板底部显示链接的目标地址。" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "指標停留在連結上或連結取得鍵盤焦點時,在瀏覽器面板底部顯示連結的目的地。" + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "Prikazuje odredište linka na dnu panela preglednika dok je pokazivač iznad njega ili dok link ima fokus tastature." + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "Viser linkets destination nederst i browserpanelet, mens markøren er over det, eller mens linket har tastaturfokus." + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "Mostra la destinazione di un link nella parte inferiore del pannello del browser mentre il puntatore è sopra di esso o quando il link ha il focus della tastiera." + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "បង្ហាញទិសដៅរបស់តំណនៅផ្នែកខាងក្រោមនៃផ្ទាំងកម្មវិធីរុករក ខណៈពេលដែលទស្សន៍ទ្រនិចស្ថិតនៅលើវា ឬនៅពេលតំណទទួលបានការផ្ដោតពីក្ដារចុច។" + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "Viser lenkens mål nederst i nettleserpanelet mens pekeren er over den, eller mens lenken har tastaturfokus." + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "Pokazuje adres docelowy linku u dołu panelu przeglądarki, gdy wskaźnik znajduje się nad nim lub gdy link ma fokus klawiatury." + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Mostra o destino de um link na parte inferior do painel do navegador enquanto o cursor está sobre ele ou quando o link tem o foco do teclado." + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Показывает адрес ссылки в нижней части панели браузера, пока указатель находится над ней или пока ссылка находится в фокусе клавиатуры." + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "แสดงปลายทางของลิงก์ที่ด้านล่างของแผงเบราว์เซอร์ขณะที่ตัวชี้อยู่เหนือลิงก์หรือเมื่อลิงก์ได้รับโฟกัสจากแป้นพิมพ์" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "İmleç bir bağlantının üzerindeyken veya bağlantı klavye odağındayken bağlantının hedefini tarayıcı panelinin altında gösterir." + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "Показує адресу посилання в нижній частині панелі браузера, поки вказівник знаходиться над ним або поки посилання має фокус клавіатури." + } + } + } + }, + "settings.search.alias.setting.browser.link-hover-url": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview" + } + }, + "ar": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview رابط تمرير وجهة عنوان شريط الحالة معاينة" + } + }, + "de": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link überfahren ziel adresse statusleiste vorschau" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview enlace pasar puntero destino dirección barra de estado vista previa" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview lien survol destination adresse barre d’état aperçu" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview リンク ホバー URL リンク先 ステータスバー プレビュー" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview 링크 호버 주소 대상 상태 표시줄 미리보기" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview 链接 悬停 网址 目标 状态栏 预览" + } + }, + "zh-Hant": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview 連結 懸停 網址 目的地 狀態列 預覽" + } + }, + "bs": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link prelazak pokazivačem odredište adresa statusna traka pregled" + } + }, + "da": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link markør over destination adresse statuslinje forhåndsvisning" + } + }, + "it": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link passaggio puntatore destinazione indirizzo barra di stato anteprima" + } + }, + "km": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview តំណ ទស្សន៍ទ្រនិច ទិសដៅ អាសយដ្ឋាន របារស្ថានភាព មើលជាមុន" + } + }, + "nb": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview lenke peker over mål adresse statuslinje forhåndsvisning" + } + }, + "pl": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link najechanie adres docelowy pasek stanu podgląd" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview link passar cursor destino endereço barra de status pré-visualização" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview ссылка наведение адрес назначение строка состояния предпросмотр" + } + }, + "th": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview ลิงก์ วางเมาส์ ปลายทาง ที่อยู่ แถบสถานะ ดูตัวอย่าง" + } + }, + "tr": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview bağlantı üzerine gelme hedef adres durum çubuğu önizleme" + } + }, + "uk": { + "stringUnit": { + "state": "translated", + "value": "browser.showLinkHoverURL link hover url destination address status bar preview посилання наведення адреса призначення рядок стану попередній перегляд" + } + } + } + }, "cloud.enable.title.enable": { "extractionState": "manual", "localizations": { @@ -644107,8 +644815,7 @@ } } }, - - "featureFlags.macAccountDirectory.title": { + "featureFlags.macAccountDirectory.title": { "extractionState": "manual", "localizations": { "en": { @@ -644167,8 +644874,7 @@ } } }, - - "featureFlags.macAccountDirectory.description": { + "featureFlags.macAccountDirectory.description": { "extractionState": "manual", "localizations": { "en": { diff --git a/Resources/bin/cmux-claude-wrapper b/Resources/bin/cmux-claude-wrapper index 3b7c6b0807a6..693c396c847b 100755 --- a/Resources/bin/cmux-claude-wrapper +++ b/Resources/bin/cmux-claude-wrapper @@ -1413,25 +1413,23 @@ cmux_claude_sideload_flags_disabled_uncached() { local domain_dump flag_value local newline=$'\n' local flag_prefix=$'\n disableSideloadFlags = ' - local escaped_newline='\\n' quoted_one='"1' quoted_end='";' + local quoted_one='"1' quoted_end='";' if domain_dump="$("$defaults_bin" read "$plist_domain" 2>/dev/null)"; then domain_dump="$newline$domain_dump$newline" [[ "$domain_dump" == *"$newline policyHelper = "* ]] && return 0 flag_value="${domain_dump#*"$flag_prefix"}" if [[ "$flag_value" != "$domain_dump" ]]; then flag_value="${flag_value%%"$newline"*}" - # The per-key read printed `1` for true, 1, 1.0 and "1", which - # all dump as `1;`. It also printed `1` for "1" followed by - # newlines, because $(...) strips them; that dumps as - # `"1\\n";`, `"1\\n\\n";` and so on. + # The per-key read printed 1 for true, 1, 1.0 and "1", which + # all dump as 1;. For quoted values, ask the key-specific form + # to preserve the old per-key decision without depending on + # how this macOS version escapes backslashes in a whole-domain + # dump. Command substitution still strips trailing newlines. [[ "$flag_value" == "1;" ]] && return 0 - if [[ "$flag_value" == "$quoted_one$escaped_newline"*"$quoted_end" ]]; then - flag_value="${flag_value#"$quoted_one"}" - flag_value="${flag_value%"$quoted_end"}" - while [[ "$flag_value" == "$escaped_newline"* ]]; do - flag_value="${flag_value#"$escaped_newline"}" - done - [[ -z "$flag_value" ]] && return 0 + if [[ "$flag_value" == "$quoted_one"*"$quoted_end" && "$flag_value" == *\\* ]]; then + local per_key_value + per_key_value="$("$defaults_bin" read "$plist_domain" disableSideloadFlags 2>/dev/null)" || per_key_value="" + [[ "$per_key_value" == "1" ]] && return 0 fi fi fi diff --git a/Sources/Cloud/CloudCreateTeamSheetPresenter.swift b/Sources/Cloud/CloudCreateTeamSheetPresenter.swift index 91758c19757e..b0390ac97ea1 100644 --- a/Sources/Cloud/CloudCreateTeamSheetPresenter.swift +++ b/Sources/Cloud/CloudCreateTeamSheetPresenter.swift @@ -8,6 +8,7 @@ import SwiftUI final class CloudCreateTeamSheetPresenter: NSObject, NSWindowDelegate { private let resolveHostWindow: @MainActor (NSWindow?) -> NSWindow? private var sheetWindow: NSWindow? + private var sheetController: CloudSheetWindow? private weak var hostWindow: NSWindow? /// Identifies the current sheet, so a late finish from an earlier sheet /// cannot close this one. @@ -61,6 +62,7 @@ final class CloudCreateTeamSheetPresenter: NSObject, NSWindowDelegate { window.delegate = self window.title = String(localized: "cloud.teamPicker.createSheet.title", defaultValue: "Create Team") window.isReleasedWhenClosed = false + sheetController = sheet sheetWindow = window let host = resolveHostWindow(preferredWindow ?? NSApp.keyWindow) @@ -92,6 +94,7 @@ final class CloudCreateTeamSheetPresenter: NSObject, NSWindowDelegate { } private func reset() { + sheetController = nil sheetWindow = nil hostWindow = nil sessionID = nil diff --git a/Sources/Cloud/CloudNetworkPolicySheetPresenter.swift b/Sources/Cloud/CloudNetworkPolicySheetPresenter.swift index 053f0a444e34..36fdda7fdf7e 100644 --- a/Sources/Cloud/CloudNetworkPolicySheetPresenter.swift +++ b/Sources/Cloud/CloudNetworkPolicySheetPresenter.swift @@ -10,6 +10,7 @@ final class CloudNetworkPolicySheetPresenter { static let shared = CloudNetworkPolicySheetPresenter() private var sheetWindow: NSWindow? + private var sheetController: CloudSheetWindow? private var hostWindow: NSWindow? private var model: CloudNetworkPolicySheetModel? private var loadTask: Task? @@ -40,6 +41,7 @@ final class CloudNetworkPolicySheetPresenter { window.title = String(localized: "cloud.network.section.label", defaultValue: "Network") window.isReleasedWhenClosed = false self.model = model + sheetController = sheet sheetWindow = window loadTask = Task { [weak model] in await model?.load() } @@ -61,6 +63,7 @@ final class CloudNetworkPolicySheetPresenter { host.endSheet(window) } window.orderOut(nil) + sheetController = nil sheetWindow = nil hostWindow = nil model = nil diff --git a/Sources/Cloud/CloudSheetWindow.swift b/Sources/Cloud/CloudSheetWindow.swift index 5988683966bf..05733f368dfe 100644 --- a/Sources/Cloud/CloudSheetWindow.swift +++ b/Sources/Cloud/CloudSheetWindow.swift @@ -22,39 +22,122 @@ import SwiftUI @MainActor final class CloudSheetWindow { let window: NSWindow + private let initialContentSize: NSSize private var isOpening = false private var pendingContentSize: NSSize? private var isResizeScheduled = false + // AppKit may expand an attached sheet from its bottom edge before the + // deferred geometry callback runs. Keep the first stable top edge so a + // content-driven resize cannot inherit that temporary shift. + private var topEdgeAnchor: CGFloat? + // Registration is main-actor-only; deinit only removes these opaque + // Foundation tokens through NotificationCenter's thread-safe cleanup API. + nonisolated(unsafe) private var windowMoveObserver: NSObjectProtocol? + nonisolated(unsafe) private var hostMoveObserver: NSObjectProtocol? + private weak var hostWindow: NSWindow? + private var lastHostOrigin: NSPoint? + private var isAttachedToHost = false + private var isHostMovePending = false + private var isHostAnchorRefreshScheduled = false + private var isAnchorCorrectionScheduled = false + private var isApplyingFrame = false init(rootView: Content) { - // The root view retains this object through `report`; the window is - // weakly reachable from here only through `window`, so no cycle. + // The presenter retains this wrapper while the window is presented; + // the root view retains the reporter that points back to this owner. let reporter = SizeReporter() let controller = NSHostingController(rootView: CloudSheetContent(content: rootView, report: reporter)) controller.sizingOptions = [] window = NSWindow(contentViewController: controller) - let initialSize = controller.view.fittingSize + // NSHostingController's flexible root view can report its temporary + // attached-sheet proposal (1×0). Measure an unattached hosting view so + // the first window frame is based on the content's intrinsic size. + let initialSize = NSHostingView( + rootView: CloudSheetContent(content: rootView, report: reporter) + ).fittingSize + initialContentSize = Self.rounded(initialSize) if initialSize.width > 0, initialSize.height > 0 { - window.setContentSize(Self.rounded(initialSize)) + window.setContentSize(initialContentSize) } reporter.owner = self + windowMoveObserver = NotificationCenter.default.addObserver( + forName: NSWindow.didMoveNotification, + object: window, + queue: .main + ) { [weak self] _ in + MainActor.assumeIsolated { + guard let self else { return } + if self.isAttachedToHost { + let didRefreshHostAnchor = self.recordAttachedSheetMoveIfHostMoveIsPending() + if didRefreshHostAnchor { + // A host move can arrive while AppKit still exposes a + // transient 1×0 sheet. The later sheet move completes + // the handshake; apply any content size that arrived + // while resizing was blocked. + self.applyPendingContentSize() + } + self.scheduleAttachedSheetAnchorCorrection() + } else { + self.recordFloatingWindowMoveIfStable() + } + } + } + } + + deinit { + if let windowMoveObserver { + NotificationCenter.default.removeObserver(windowMoveObserver) + } + if let hostMoveObserver { + NotificationCenter.default.removeObserver(hostMoveObserver) + } } /// Attaches the sheet to `host`; the size is held until the open /// animation has finished. func beginSheet(on host: NSWindow, completionHandler: ((NSApplication.ModalResponse) -> Void)? = nil) { + hostWindow = host + lastHostOrigin = host.frame.origin + isAttachedToHost = true + isHostMovePending = false + hostMoveObserver = NotificationCenter.default.addObserver( + forName: NSWindow.didMoveNotification, + object: host, + queue: .main + ) { [weak self] _ in + MainActor.assumeIsolated { + self?.recordHostMoveIfStable(host) + } + } isOpening = true host.beginSheet(window, completionHandler: completionHandler) isOpening = false + // Some AppKit versions reset a newly attached sheet to a 1×0 content + // rect while the host is inactive. Restore the measured first layout + // before applying any later geometry report. + restoreInitialContentSizeIfNeeded() applyPendingContentSize() + // AppKit may perform one more sheet-host layout on the next turn and + // reset the frame after beginSheet returns. Reapply after that pass so + // the first geometry report has a usable window to measure against. + DispatchQueue.main.async { [weak self] in + guard let self else { return } + self.restoreInitialContentSizeIfNeeded() + self.topEdgeAnchor = self.topEdgeAnchor ?? self.window.frame.maxY + self.applyPendingContentSize() + } } /// Shows the sheet as a centered floating window when no host is on screen. func orderFrontFloating() { + hostWindow = nil + lastHostOrigin = nil + isAttachedToHost = false isOpening = true window.center() window.makeKeyAndOrderFront(nil) isOpening = false + topEdgeAnchor = window.frame.maxY applyPendingContentSize() } @@ -72,7 +155,7 @@ final class CloudSheetWindow { } private func applyPendingContentSize() { - guard !isOpening, let size = pendingContentSize else { return } + guard !isOpening, !isHostMovePending, let size = pendingContentSize else { return } pendingContentSize = nil let current = window.contentRect(forFrameRect: window.frame).size guard size != current else { return } @@ -80,8 +163,98 @@ final class CloudSheetWindow { let oldFrame = window.frame var frame = window.frameRect(forContentRect: NSRect(origin: .zero, size: size)) frame.origin.x = oldFrame.midX - frame.width / 2 - frame.origin.y = oldFrame.maxY - frame.height + frame.origin.y = (topEdgeAnchor ?? oldFrame.maxY) - frame.height + setFrameInternally(frame) + scheduleAttachedSheetAnchorCorrection() + } + + private func restoreInitialContentSizeIfNeeded() { + guard initialContentSize.width > 1, initialContentSize.height > 1 else { return } + let current = window.contentRect(forFrameRect: window.frame).size + guard current.width <= 1 || current.height <= 1 else { return } + + // An attached sheet hangs from its top edge. setContentSize preserves + // the bottom-left origin, which detaches the sheet from its host when + // repairing AppKit's temporary 1×0 frame. Restore through a frame so + // the top edge remains anchored while the content gets its size back. + let oldFrame = window.frame + var frame = window.frameRect(forContentRect: NSRect(origin: .zero, size: initialContentSize)) + frame.origin.x = oldFrame.midX - frame.width / 2 + frame.origin.y = (topEdgeAnchor ?? oldFrame.maxY) - frame.height + setFrameInternally(frame) + } + + private func setFrameInternally(_ frame: NSRect) { + isApplyingFrame = true window.setFrame(frame, display: window.isVisible, animate: false) + isApplyingFrame = false + } + + private func scheduleAttachedSheetAnchorCorrection() { + guard isAttachedToHost, !isHostMovePending, topEdgeAnchor != nil, !isAnchorCorrectionScheduled else { return } + isAnchorCorrectionScheduled = true + DispatchQueue.main.async { [weak self] in + guard let self else { return } + self.isAnchorCorrectionScheduled = false + guard self.isAttachedToHost, !self.isOpening, !self.isApplyingFrame, + !self.isHostMovePending, + let anchor = self.topEdgeAnchor else { return } + let delta = anchor - self.window.frame.maxY + guard abs(delta) > 0.5 else { return } + var frame = self.window.frame + frame.origin.y += delta + self.setFrameInternally(frame) + } + } + + private func recordFloatingWindowMoveIfStable() { + // An attached sheet's frame can emit didMove after AppKit resizes it + // from the bottom edge. That is an internal layout move, not a new + // anchor; only floating windows can be moved directly by the user. + guard !isAttachedToHost else { return } + recordStableTopEdge() + } + + private func recordHostMoveIfStable(_ host: NSWindow) { + guard isAttachedToHost, hostWindow === host else { return } + guard !isOpening, !isApplyingFrame else { return } + guard host.frame.origin != lastHostOrigin else { return } + lastHostOrigin = host.frame.origin + isHostMovePending = true + scheduleHostAnchorRefresh() + } + + @discardableResult + private func recordAttachedSheetMoveIfHostMoveIsPending() -> Bool { + guard isHostMovePending else { return false } + guard !isOpening, !isApplyingFrame else { return false } + let contentSize = window.contentRect(forFrameRect: window.frame).size + guard contentSize.width > 1, contentSize.height > 1 else { return false } + topEdgeAnchor = window.frame.maxY + isHostMovePending = false + return true + } + + private func scheduleHostAnchorRefresh() { + guard !isHostAnchorRefreshScheduled else { return } + isHostAnchorRefreshScheduled = true + DispatchQueue.main.async { [weak self] in + guard let self else { return } + self.isHostAnchorRefreshScheduled = false + guard self.isAttachedToHost, !self.isOpening, !self.isApplyingFrame else { return } + self.recordAttachedSheetMoveIfHostMoveIsPending() + self.applyPendingContentSize() + } + } + + private func recordStableTopEdge() { + guard !isOpening, !isApplyingFrame else { return } + let contentSize = window.contentRect(forFrameRect: window.frame).size + // During attachment AppKit can briefly publish a 1×0 frame and move + // its bottom edge. It is not a user move and must not replace the + // stable anchor used to restore the initial content size. + guard contentSize.width > 1, contentSize.height > 1 else { return } + topEdgeAnchor = window.frame.maxY } private static func rounded(_ size: NSSize) -> NSSize { @@ -103,12 +276,17 @@ struct CloudSheetContent: View { var body: some View { content - .fixedSize(horizontal: false, vertical: true) + // Sheets in this wrapper all declare a natural width. Measuring + // horizontally as flexible lets an attached sheet's temporary + // 1-point proposal collapse the content to 1×0, so later model + // updates never produce a usable geometry report. Keep both axes + // intrinsic while the wrapper applies the measured size outside + // AppKit's layout pass. + .fixedSize(horizontal: true, vertical: true) .onGeometryChange(for: CGSize.self) { proxy in proxy.size } action: { size in report.owner?.contentIdealSizeChanged(size) } - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top) } } diff --git a/Sources/Cloud/CloudTreeNodeActions.swift b/Sources/Cloud/CloudTreeNodeActions.swift index 174739d79a27..6390fea313e6 100644 --- a/Sources/Cloud/CloudTreeNodeActions.swift +++ b/Sources/Cloud/CloudTreeNodeActions.swift @@ -68,6 +68,9 @@ struct CloudTreeNodeActions { let copyToPasteboard: @MainActor (_ text: String) -> Void /// Copy the machine port's private URL without changing network state. let copyPortLink: @MainActor (_ resource: SurfaceResourceID) -> Void + /// Copy a link to the port that teammates can open after signing in, + /// creating it first when the port has none. + var sharePort: @MainActor (_ resource: SurfaceResourceID) -> Void = { _ in } let refresh: @MainActor () -> Void var discoverPorts: @MainActor (SurfaceMachineID) -> Void = { _ in } /// Starts guest display discovery, which also warms the machine's standby display. @@ -163,9 +166,11 @@ struct CloudTreeNodeActions { _ key: String, _ label: String, _ operation: @escaping @MainActor (SurfaceCatalog) async throws -> Void, - failureDescription: (@MainActor (Error) -> String)? = nil + failureDescription: (@MainActor (Error) -> String)? = nil, + fallbackToUnownedTask: Bool = true ) -> Bool { guard let controller = operationController ?? AppDelegate.shared?.cloudWorkspaceOperationController else { + guard fallbackToUnownedTask else { return false } _ = run(label, operation, failureDescription: failureDescription) return true } @@ -690,6 +695,70 @@ struct CloudTreeNodeActions { operationController: operationController ?? AppDelegate.shared?.cloudWorkspaceOperationController ) actions.openRemoteTerminal = { navigation.open(machine: $0, group: $1, resource: $2, view: $3, openIn: $4) } + actions.sharePort = { resource in + guard let port = resource.forwardedPort else { return } + let store = CloudPortShareStore.shared + let key = CloudPortShareStore.Key(machineID: resource.machine.rawValue, port: port) + guard let operationID = store.beginCreating(key) else { return } + // Making a link can take a while; if something else lands on the + // clipboard meanwhile, don't replace it. The row says the link is + // ready instead, and the next click copies it straight away. + let clipboardAtClick = NSPasteboard.general.changeCount + let operationKey = "cloud-port-share:\(resource.machine.rawValue):\(port)" + let started = runKeyed( + operationKey, + String(localized: "cloudTree.port.share.creating", defaultValue: "Creating link\u{2026}"), + { catalog in + do { + try Task.checkCancellation() + guard let provider = catalog.provider(for: resource.machine) as? CmuxTuiSurfaceProvider, + let client = VMClient.shared else { + throw CloudPortShareFailure.unavailable + } + let publication = try await CloudPortShareService(api: client) + .share(vmID: provider.machineID, port: port, teamID: provider.ownerTeamID) + // Cloud sign-out, team changes, and feature shutdown cancel + // the owning controller task. Do not let a late network + // completion copy the previous account's link. + try Task.checkCancellation() + if NSPasteboard.general.changeCount == clipboardAtClick { + Self.copyToPasteboard(publication.url) + store.set(.copied(publication.accessMode), for: key, operationID: operationID, holdFor: .seconds(2)) + } else { + store.set(.ready, for: key, operationID: operationID, holdFor: .seconds(10)) + } + } catch is CancellationError { + store.clear(key, operationID: operationID) + throw CancellationError() + } catch { + if Task.isCancelled { + store.clear(key, operationID: operationID) + throw CancellationError() + } + store.set(.failed, for: key, operationID: operationID, holdFor: .seconds(4)) + throw error + } + }, + failureDescription: { error in + switch error { + case CloudPortShareError.stillProvisioning: + return String(localized: "cloudTree.port.share.error.timeout", defaultValue: "The link is still being set up. Try sharing again in a minute.") + case VMClientError.notSignedIn, VMClientError.sessionRefreshFailed: + return (error as? LocalizedError)?.errorDescription ?? String(describing: error) + default: + // Server and client errors here are written for the + // CLI ("Run `cmux ...`"); the sidebar gets plain copy. + return String(localized: "cloudTree.port.share.error.unavailable", defaultValue: "The Cloud service couldn't create a link for this port. Try again.") + } + }, + fallbackToUnownedTask: false + ) + if !started { + // No lifecycle owner admitted the work (for example while + // Cloud is being torn down), so do not leave a spinner behind. + store.clear(key, operationID: operationID) + } + } return actions } @MainActor @@ -702,3 +771,8 @@ struct CloudTreeNodeActions { #endif } } + +/// The machine isn't reachable through a Cloud provider right now. +private enum CloudPortShareFailure: Error { + case unavailable +} diff --git a/Sources/Cloud/CloudTreeOutlineView.swift b/Sources/Cloud/CloudTreeOutlineView.swift index b2ae718276be..cd4d9c530c22 100644 --- a/Sources/Cloud/CloudTreeOutlineView.swift +++ b/Sources/Cloud/CloudTreeOutlineView.swift @@ -928,6 +928,9 @@ struct CloudTreeOutlineView: NSViewRepresentable { if resource.id.isForwardedPort, !isLocal { // Copying the private URL never creates a forward. items.append(item(String(localized: "cloudTree.menu.copyPrivateURL", defaultValue: "Copy Private Address URL")) { [nodeActions] in nodeActions.copyPortLink(resource.id) }) + if CloudTreeRowHoverButtons.shareablePort(resource) != nil { + items.append(item(String(localized: "cloudTree.menu.copyShareLink", defaultValue: "Copy Share Link")) { [nodeActions] in nodeActions.sharePort(resource.id) }) + } } else if let portURL { items.append(item(String(localized: "cloudTree.menu.copyLink", defaultValue: "Copy Link")) { [nodeActions] in nodeActions.copyToPasteboard(portURL) }) } else if let port = resource.port, resource.kind == .browser { diff --git a/Sources/Cloud/CloudTreeRowHoverButtons.swift b/Sources/Cloud/CloudTreeRowHoverButtons.swift index 664bed8589d9..ee26f2b5f6b3 100644 --- a/Sources/Cloud/CloudTreeRowHoverButtons.swift +++ b/Sources/Cloud/CloudTreeRowHoverButtons.swift @@ -1,4 +1,5 @@ import CmuxCloud +import CmuxSurfaceCatalogModel import SwiftUI struct CloudTreeRowHoverButtons: View { @@ -136,6 +137,15 @@ struct CloudTreeRowHoverButtons: View { nodeActions.closeTerminal(row.resource.id) } } + case .port(let resource, _, _): + if let port = Self.shareablePort(resource) { + CloudPortShareButton( + key: CloudPortShareStore.Key(machineID: resource.machine.rawValue, port: port), + store: CloudPortShareStore.shared + ) { + nodeActions.sharePort(resource.id) + } + } case .display(let resource, _, let remoteView): if let remoteView, remoteView.isCloudDisplayMembershipView { xmark(String(localized: "cloudTree.menu.removeDisplayFromWorkspace", defaultValue: "Remove from Workspace")) { @@ -164,6 +174,8 @@ struct CloudTreeRowHoverButtons: View { return row.canCreateWorkspacesAndTerminals case .terminal(let row): return !row.resource.machine.isLocal + case .port(let resource, _, _): + return shareablePort(resource) != nil case .display(_, _, let remoteView): return remoteView?.isCloudDisplayMembershipView == true default: @@ -171,11 +183,24 @@ struct CloudTreeRowHoverButtons: View { } } + /// A Cloud machine's forwarded port can be shared; This Mac and SSH hosts can't. + static func shareablePort(_ resource: SurfaceResource) -> Int? { + guard resource.machine.cloudMachineID != nil else { return nil } + return resource.id.forwardedPort + } + /// True when the row's buttons stay visible without hover. Machine rows /// keep + and ⋯ on screen so their actions are discoverable at rest. static func showsAtRest(for kind: CloudTreeNode.Kind) -> Bool { - if case .machine = kind { return true } - return false + switch kind { + case .machine: + return true + case .port(let resource, _, _): + // Sharing is the port row's main action, so it stays discoverable. + return shareablePort(resource) != nil + default: + return false + } } /// The Displays affordance remains visible while guest discovery is pending @@ -203,6 +228,83 @@ struct CloudTreeRowHoverButtons: View { } } +/// Share on a Cloud port row: a spinner while the link is made, a checkmark +/// once it is on the clipboard. +private struct CloudPortShareButton: View { + let key: CloudPortShareStore.Key + let store: CloudPortShareStore + let action: () -> Void + + var body: some View { + let phase = store.phase(for: key) + // No transition: the controls host resizes with the note, and an + // animated swap slides the note out under the row's content. + HStack(spacing: 4) { + if let status = status(phase) { + // The row's content keeps its trailing edge at just below + // required priority, so the controls host shrinks to its + // minimum width; a fixed-size note keeps that minimum honest + // instead of truncating to nothing. + Text(status) + .font(.system(size: 11)) + .foregroundStyle(.secondary) + .lineLimit(1) + .fixedSize() + } + MachinesChromeIconButton( + symbolName: symbolName(phase), + accessibilityLabel: label(phase), + isBusy: phase == .creating, + action: action + ) + .help(label(phase)) + .accessibilityIdentifier("CloudPortShareButton") + } + } + + private func symbolName(_ phase: CloudPortShareStore.Phase?) -> String { + switch phase { + case .copied: return "checkmark" + case .failed: return "exclamationmark.triangle" + case .creating, .ready, nil: return "link" + } + } + + /// The short inline note beside the button while sharing runs and right + /// after the link lands on the clipboard. + private func status(_ phase: CloudPortShareStore.Phase?) -> String? { + switch phase { + case .creating: + return String(localized: "cloudTree.port.share.creating", defaultValue: "Creating link\u{2026}") + case .copied: + return String(localized: "cloudTree.port.share.copied", defaultValue: "Copied to clipboard") + case .ready: + return String(localized: "cloudTree.port.share.ready", defaultValue: "Link ready") + case .failed, nil: + return nil + } + } + + private func label(_ phase: CloudPortShareStore.Phase?) -> String { + switch phase { + case .creating: + return String(localized: "cloudTree.port.share.creating", defaultValue: "Creating link\u{2026}") + case .copied(.team): + return String(localized: "cloudTree.port.share.copiedTeam", defaultValue: "Link copied. Your team can open it after signing in.") + case .copied(.personal): + return String(localized: "cloudTree.port.share.copiedPersonal", defaultValue: "Link copied. Only you can open it.") + case .copied(.public): + return String(localized: "cloudTree.port.share.copiedPublic", defaultValue: "Link copied. Anyone with the link can open it.") + case .ready: + return String(localized: "cloudTree.port.share.readyHelp", defaultValue: "The link is ready. Click to copy it.") + case .failed: + return String(localized: "cloudTree.port.share.failed", defaultValue: "Couldn't create link") + case nil: + return String(localized: "cloudTree.port.shareLink", defaultValue: "Share Link") + } + } +} + /// The My Devices header's "..." menu. Same size, tint and hover fill as the /// Cloud Machines "+" (`MachinesChromeIconButton`), so both headers hover alike. private struct CloudTreeDevicesMenuButton: View { diff --git a/Sources/Cloud/NewMachineSheetPresenter.swift b/Sources/Cloud/NewMachineSheetPresenter.swift index fcb9bcfe011a..c0358f442d9c 100644 --- a/Sources/Cloud/NewMachineSheetPresenter.swift +++ b/Sources/Cloud/NewMachineSheetPresenter.swift @@ -12,6 +12,7 @@ final class NewMachineSheetPresenter: NSObject, NewMachineSheetPresenting { static let shared = NewMachineSheetPresenter() private var sheetWindow: NSWindow? + private var sheetController: CloudSheetWindow? private var hostWindow: NSWindow? private var model: NewMachineModel? private var pendingSelectionID: UUID? @@ -180,6 +181,7 @@ final class NewMachineSheetPresenter: NSObject, NewMachineSheetPresenting { self?.dismiss() } self.model = model + sheetController = sheet sheetWindow = window NotificationCenter.default.addObserver( self, @@ -446,6 +448,7 @@ final class NewMachineSheetPresenter: NSObject, NewMachineSheetPresenting { host.endSheet(window) } window.orderOut(nil) + sheetController = nil sheetWindow = nil hostWindow = nil model = nil diff --git a/cmuxTests/BrowserReplRenderHostTests.swift b/cmuxTests/BrowserReplRenderHostTests.swift index 568c58a7bac9..e965ece65a79 100644 --- a/cmuxTests/BrowserReplRenderHostTests.swift +++ b/cmuxTests/BrowserReplRenderHostTests.swift @@ -28,23 +28,6 @@ struct BrowserReplRenderHostTests { ) } - private func makeWindow() throws -> (NSWindow, NSView) { - let window = NSWindow( - contentRect: NSRect(x: 0, y: 0, width: 480, height: 320), - styleMask: [.titled, .closable], - backing: .buffered, - defer: false - ) - window.makeKeyAndOrderFront(nil) - window.displayIfNeeded() - window.contentView?.layoutSubtreeIfNeeded() - RunLoop.current.run(until: Date().addingTimeInterval(0.05)) - let contentView = try #require(window.contentView) - let anchor = NSView(frame: NSRect(x: 24, y: 24, width: 360, height: 220)) - contentView.addSubview(anchor) - return (window, anchor) - } - private func visibleRenderWindows() -> [NSWindow] { NSApp.windows.filter { $0.identifier?.rawValue == Self.renderWindowIdentifier && $0.isVisible @@ -53,18 +36,10 @@ struct BrowserReplRenderHostTests { } @Test func hiddenDrivenTabRendersOffEveryScreenAndReturnsToItsPane() throws { - let (window, anchor) = try makeWindow() + let (window, anchor, panel, paneHost) = try makePane(key: true) defer { window.orderOut(nil) } - let panel = BrowserPanel( - workspaceId: UUID(), - initialURL: URL(string: "about:blank")!, - isRemoteWorkspace: false - ) let webView = panel.webView defer { BrowserWindowPortalRegistry.detach(webView: webView) } - BrowserWindowPortalRegistry.bind(webView: webView, to: anchor, visibleInUI: true) - BrowserWindowPortalRegistry.synchronizeForAnchor(anchor) - let paneHost = try #require(webView.cmuxBrowserViewportAttachmentSuperview) // A background tab: no pane shows it, so a driving session moves it // into the render window. @@ -107,6 +82,25 @@ struct BrowserReplRenderHostTests { override var isKeyWindow: Bool { reportsKey } } + /// A deterministic ordinary pane window for tests that exercise only the + /// render-host focus transition. Headless runners do not reliably activate + /// a newly-created AppKit window, so its key status is explicit. + private func makeWindow() throws -> (NSWindow, NSView) { + let window = KeyStatusWindow( + contentRect: NSRect(x: 0, y: 0, width: 480, height: 320), + styleMask: [.titled, .closable], + backing: .buffered, + defer: false + ) + window.reportsKey = true + window.orderFront(nil) + window.displayIfNeeded() + let contentView = try #require(window.contentView) + let anchor = NSView(frame: NSRect(x: 24, y: 24, width: 360, height: 220)) + contentView.addSubview(anchor) + return (window, anchor) + } + private func makePane(key: Bool) throws -> (KeyStatusWindow, NSView, BrowserPanel, NSView) { let window = KeyStatusWindow( contentRect: NSRect(x: 0, y: 0, width: 480, height: 320), diff --git a/cmuxTests/NewMachineSheetLayoutTests.swift b/cmuxTests/NewMachineSheetLayoutTests.swift index f7bfc98eec26..85310b5fcc4e 100644 --- a/cmuxTests/NewMachineSheetLayoutTests.swift +++ b/cmuxTests/NewMachineSheetLayoutTests.swift @@ -102,6 +102,19 @@ struct NewMachineSheetLayoutTests { NewMachineSheetPresenter.shared.present(model: model, preferredWindow: host, loadPlanFromCache: false) defer { model.cancel() } let sheet = try #require(host.attachedSheet, "the sheet was not attached to its host window") + // AppKit may finish attaching and restore the initial sheet frame on + // the next main-loop turn. Capture the anchor after that deferred + // pass so later content-driven resizes are compared with the stable + // attached frame rather than the temporary 1×0 frame. + Self.runMainLoopTurns() + let initialTopEdge = sheet.frame.maxY + // Moving the host moves an attached sheet. Its later content-driven + // resizes must follow that new position instead of snapping back to + // the top edge captured at presentation. + host.setFrameOrigin(NSPoint(x: host.frame.minX, y: host.frame.minY - 80)) + Self.runMainLoopTurns() + let movedTopEdge = sheet.frame.maxY + #expect(abs(movedTopEdge - initialTopEdge) > 1, "moving the host did not move the attached sheet") for tick in 0..<12 { let pool = CloudVMResourcePool(poolVcpus: 40, poolMemoryMb: 81920, usedVcpus: 32 + tick % 3, usedMemoryMb: 65536) @@ -118,12 +131,25 @@ struct NewMachineSheetLayoutTests { Self.runMainLoopTurns() } model.selectBaseImage(.machine(model.sourceMachines[3])) - Self.runMainLoopTurns() let ideal = NSHostingView(rootView: NewMachineSheet(model: model)).fittingSize + // The attached sheet's hosting view is not necessarily laid out just + // because the model changed. Drive the same layout/display path used + // by the detached rendering helpers until the async geometry report + // has been applied, or until the bounded test deadline expires. + for _ in 0..<100 { + sheet.contentView?.layoutSubtreeIfNeeded() + sheet.displayIfNeeded() + let content = sheet.contentRect(forFrameRect: sheet.frame).size + if abs(content.height - ceil(ideal.height)) <= 1, abs(content.width - ceil(ideal.width)) <= 1 { + break + } + _ = RunLoop.main.run(mode: .default, before: Date(timeIntervalSinceNow: 0.01)) + } let content = sheet.contentRect(forFrameRect: sheet.frame).size #expect(abs(content.height - ceil(ideal.height)) <= 1, "sheet content \(content) does not fit its content \(ideal)") #expect(abs(content.width - ceil(ideal.width)) <= 1, "sheet content \(content) does not fit its content \(ideal)") + #expect(abs(sheet.frame.maxY - movedTopEdge) <= 1, "sheet top edge moved from \(movedTopEdge) to \(sheet.frame.maxY) after the host moved (initially \(initialTopEdge))") } /// The grid's pop-ups read as one column: each starts at the column's @@ -159,9 +185,12 @@ struct NewMachineSheetLayoutTests { #expect(abs(leading[0] - leading[1]) <= 1, "Base starts at \(leading[0]), Size at \(leading[1])") for (name, popUp) in rows { let width = popUp.convert(popUp.bounds, to: host).width + // AppKit's intrinsicContentSize excludes a few points of the + // menu control's border/accessory; fittingSize is its measured + // natural width after those decorations are included. #expect( - width <= popUp.intrinsicContentSize.width + 1, - "\(name) pop-up is \(width)pt wide; its own width is \(popUp.intrinsicContentSize.width)pt" + width <= popUp.fittingSize.width + 1, + "\(name) pop-up is \(width)pt wide; its fitting width is \(popUp.fittingSize.width)pt" ) } } diff --git a/tests/test_backend_migrations_plan.py b/tests/test_backend_migrations_plan.py index 5dce8417cfad..6be7397e521b 100644 --- a/tests/test_backend_migrations_plan.py +++ b/tests/test_backend_migrations_plan.py @@ -81,6 +81,19 @@ def test_a_pr_that_adds_a_migration_still_lists_its_files(self): self.assertNotEqual(code, 0, log) self.assertNotIn("migrations=false", output) + def test_unfetchable_head_without_migrations_uses_files_api(self): + (self.tmp / "bin/gh").write_text("#!/bin/sh\nprintf 'modified\\twebviews/App.tsx\\t\\n'\n") + code, output, log = self.run_plan("f" * 40) + self.assertEqual(code, 0, log) + self.assertIn("migrations=false", output) + + def test_unfetchable_head_with_migrations_fails_closed(self): + (self.tmp / "bin/gh").write_text("#!/bin/sh\nprintf 'added\\tbackend/db/migrations/0002_more.sql\\t\\n'\n") + code, output, log = self.run_plan("f" * 40) + self.assertNotEqual(code, 0, log) + self.assertIn("migrations=true", output) + self.assertNotIn("migrations=false", output) + if __name__ == "__main__": unittest.main() diff --git a/web/.env.example b/web/.env.example index 041ae661a37f..5528f12b755c 100644 --- a/web/.env.example +++ b/web/.env.example @@ -182,6 +182,9 @@ FREESTYLE_API_KEY= CMUX_VM_PUBLICATION_FORWARD_AUTH_SECRET= # Canonical HTTPS CMUX origin used for protected-domain browser sign-in. CMUX_VM_PUBLICATION_AUTH_ORIGIN=https://cmux.com +# Optional origin Freestyle calls for forward-auth when it can't reach the auth origin, +# e.g. a tunnel to a tailnet-only development stack. Leave unset in production. +CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN= # Zone for generated Cloud VM publication hostnames (.). The CMUX Freestyle # account must own it: verify the zone, CNAME `*` to beta-web.freestyle.sh, delegate # `_acme-challenge` to beta-dns.freestyle.sh, and request its wildcard certificate. diff --git a/web/app/api/vm/publications/routeShared.ts b/web/app/api/vm/publications/routeShared.ts index f1b5d53e55a1..5aba1fd8dc02 100644 --- a/web/app/api/vm/publications/routeShared.ts +++ b/web/app/api/vm/publications/routeShared.ts @@ -121,7 +121,13 @@ export function publicationForwardAuthConfig( ): PublicationForwardAuthConfig | undefined { const serviceToken = environment.CMUX_VM_PUBLICATION_FORWARD_AUTH_SECRET?.trim(); if (!serviceToken) return undefined; - const origin = normalizePublicationAuthOrigin(environment.CMUX_VM_PUBLICATION_AUTH_ORIGIN); + // A development stack the edge cannot reach sets a separate public origin + // for the edge alone; browsers still sign in on the auth origin. A set but + // malformed override fails closed instead of falling back. + const override = environment.CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN?.trim(); + const origin = normalizePublicationAuthOrigin( + override || environment.CMUX_VM_PUBLICATION_AUTH_ORIGIN, + ); return { url: origin ? new URL("/api/freestyle/forward-auth", origin).href : "", serviceToken, diff --git a/web/app/env.ts b/web/app/env.ts index 3f20d81d5174..6a9d27c27477 100644 --- a/web/app/env.ts +++ b/web/app/env.ts @@ -126,7 +126,7 @@ const irohMinterUrl = z.string().url().superRefine((value, context) => { }); } }); -const publicationAuthOrigin = z.string().url().superRefine((value, context) => { +const bareHttpsOrigin = (name: string) => z.string().url().superRefine((value, context) => { let parsed: URL | null = null; try { parsed = new URL(value); @@ -146,10 +146,15 @@ const publicationAuthOrigin = z.string().url().superRefine((value, context) => { context.addIssue({ code: z.ZodIssueCode.custom, message: - "CMUX_VM_PUBLICATION_AUTH_ORIGIN must be a bare https:// origin with no path, query, or credentials", + `${name} must be a bare https:// origin with no path, query, or credentials`, }); } }); +const publicationAuthOrigin = bareHttpsOrigin("CMUX_VM_PUBLICATION_AUTH_ORIGIN"); +const publicationForwardAuthOrigin = z.preprocess( + (value) => typeof value === "string" && value.trim() === "" ? undefined : value, + bareHttpsOrigin("CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN").optional(), +); const irohBindingLimit = z.string().regex(/^[1-9][0-9]{0,3}$/).superRefine((value, context) => { if (Number(value) > 4_096) { context.addIssue({ @@ -334,6 +339,10 @@ export const env = createEnv({ // pushed to Freestyle as the account-wide forward-auth target. It is never // derived from a request; protected publications fail closed without it. CMUX_VM_PUBLICATION_AUTH_ORIGIN: publicationAuthOrigin.optional(), + // Optional origin Freestyle calls for forward-auth when it differs from + // the sign-in origin, e.g. a tunnel to a development stack the edge can't + // reach. Unset in production: the auth origin serves both. + CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN: publicationForwardAuthOrigin.optional(), // Zone generated Cloud VM publication hostnames are minted under // (.). The CMUX Freestyle account must own it: verify the // zone, CNAME `*` to the Freestyle edge, delegate `_acme-challenge`, and @@ -554,6 +563,10 @@ export const env = createEnv({ CMUX_VM_PUBLICATION_AUTH_ORIGIN: trimEnv( process.env.CMUX_VM_PUBLICATION_AUTH_ORIGIN, ), + // Blank (as in .env.example) means unset, not an invalid origin. + CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN: trimEnv( + process.env.CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN, + ) || undefined, CMUX_VM_PUBLICATION_GENERATED_DOMAIN: trimEnv( process.env.CMUX_VM_PUBLICATION_GENERATED_DOMAIN, ), diff --git a/web/tests/vm-publication-workflows.test.ts b/web/tests/vm-publication-workflows.test.ts index e46d35334a2e..dd2a9fdad1b2 100644 --- a/web/tests/vm-publication-workflows.test.ts +++ b/web/tests/vm-publication-workflows.test.ts @@ -1901,6 +1901,20 @@ describe("Cloud VM publication REST adapters", () => { } }); + test("an edge-only forward-auth origin overrides the target and fails closed when malformed", () => { + const secret = "a-secret-long-enough-for-the-provider"; + expect(publicationForwardAuthConfig({ + CMUX_VM_PUBLICATION_FORWARD_AUTH_SECRET: secret, + CMUX_VM_PUBLICATION_AUTH_ORIGIN: "https://cmux-dev.example.ts.net:4252", + CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN: "https://edge-tunnel.example.com", + })).toEqual({ url: "https://edge-tunnel.example.com/api/freestyle/forward-auth", serviceToken: secret }); + expect(publicationForwardAuthConfig({ + CMUX_VM_PUBLICATION_FORWARD_AUTH_SECRET: secret, + CMUX_VM_PUBLICATION_AUTH_ORIGIN: "https://cmux.com", + CMUX_VM_PUBLICATION_FORWARD_AUTH_ORIGIN: "http://edge-tunnel.example.com", + })).toEqual({ url: "", serviceToken: secret }); + }); + test("resolves the requested team before authenticating a publication mutation", async () => { const verified: unknown[] = []; const verify: Parameters[3] = async (_request, options) => {