Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
077a586
feat: enable controllers per stream in the controller panel
anderson-oki Oct 11, 2026
2701600
refactor: tighten the per-stream controller model and monitor seams
anderson-oki Oct 11, 2026
b46eed7
Merge commit 'a6c662480f2c4fcbd83353acc4941311fe35cc0e' into sheldon/…
sheldon Oct 11, 2026
84f1a40
feat: tile stream windows and add borderless full screen behind the c…
sheldon Oct 11, 2026
b48f6b7
feat: give each stream window its own controllers and let pads play o…
sheldon Oct 11, 2026
1e2513d
feat: add Stream > Detach New Session to stream a second account in i…
sheldon Oct 11, 2026
a8a5bfa
fix: keep the Detach window from covering the main window during add …
sheldon Oct 11, 2026
e47c6bb
Merge main into sheldon/dual-instance-couch-coop
sheldon Oct 25, 2026
413e92e
fix(deps): cap swift-collections below 1.7 so tests load on macOS 26
sheldon Oct 25, 2026
75b7292
merge: cap swift-collections below 1.7 so tests load on macOS 26
sheldon Oct 25, 2026
2206695
docs: move swift-collections cap rationale from Package.swift to README
sheldon Oct 25, 2026
8417932
merge: move swift-collections cap rationale to the README
sheldon Oct 25, 2026
b33133f
test: stop the close-guard test from ending the test host on macOS 26
sheldon Oct 25, 2026
c2eb3b9
test: stop the close-guard test from ending the test host on macOS 26
sheldon Oct 25, 2026
94253ca
Merge branch 'sheldon/fix-close-guard-test-ends-test-host' into sheld…
sheldon Oct 25, 2026
0cacb27
fix: don't treat a move before the first tile lands as the reader tak…
sheldon Oct 25, 2026
7a36e91
feat: let couch co-op tiles sit below the menu bar or fill the screen…
sheldon Oct 25, 2026
9623318
Merge branch 'main' into sheldon/dual-instance-couch-coop
anderson-oki Oct 25, 2026
580a24d
fix: isolate couch co-op account services and detached actions
anderson-oki Oct 25, 2026
3e67b97
fix: harden couch co-op input and window transitions
anderson-oki Oct 25, 2026
fef6abe
Merge branch 'main' of https://github.com/OpenCloudGaming/OpenNOW-Mac…
sheldon Oct 25, 2026
e12d89d
fix: retile the remaining co-op windows when one is taken by the read…
sheldon Oct 25, 2026
e25c0ff
Merge branch 'sheldon/dual-instance-couch-coop' of https://github.com…
sheldon Oct 25, 2026
bdc86da
test: cover retiling when a tiled window is taken by the reader or go…
sheldon Oct 25, 2026
60884b6
fix: send an account switch to sign-in when its saved tokens are reje…
sheldon Oct 26, 2026
48d04f8
fix: drop the rejected client token before the refresh-token fallback…
sheldon Oct 26, 2026
bf18bdc
fix: reconcile latest PR 82 account and window changes
anderson-oki Oct 26, 2026
194fff8
Merge branch 'main' into sheldon/dual-instance-couch-coop
sheldon Oct 27, 2026
f8db633
fix: stop the refresh-token fallback from acting on another account a…
sheldon Oct 28, 2026
98c11dc
fix: treat a 400 invalid_grant as a rejected grant, and drop explanat…
sheldon Oct 28, 2026
35e5442
fix: bring the Jarvis auth service and account restore back under the…
sheldon Oct 28, 2026
49723fa
fix: integrate latest PR 82 auth and rendering updates
anderson-oki Oct 28, 2026
977eefc
Merge branch 'main' into sheldon/dual-instance-couch-coop
anderson-oki Oct 29, 2026
4f4dfa1
Merge branch 'main' into sheldon/dual-instance-couch-coop
anderson-oki Oct 29, 2026
fd870cb
fix: integrate PR 82 microphone startup and release updates
anderson-oki Oct 29, 2026
cb27dcb
refactor: clarify PR 82 account and stream code
anderson-oki Oct 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions App/OPNMainAccountActions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import Foundation
import SwiftData

@MainActor
final class OPNMainAccountActions {
static let shared = OPNMainAccountActions()

struct Target {
let identifier: PersistentIdentifier
let accountID: String
let email: String
let userID: String
let providerID: String

init(account: LoginAccount) {
identifier = account.persistentModelID
accountID = account.stableAccountID
email = account.email
userID = account.userId
providerID = account.providerIdpId
}
}

enum Request {
case addAccount
case reauthenticate(Target)
case signOut(Target)
case forget(Target)
}

private weak var login: LoginViewModel?
private var pendingRequests: [Request] = []
private let confirmation: OPNConfirmationPresentation
private let handoff: OPNMainWindowAccountHandoff

private enum ActionError: Error {
case missingContext
}

init(confirmation: OPNConfirmationPresentation = .shared, handoff: OPNMainWindowAccountHandoff = .shared) {
self.confirmation = confirmation
self.handoff = handoff
}

@discardableResult
func bind(login: LoginViewModel) -> Task<Void, Never> {
self.login = login
let queuedRequests = pendingRequests
pendingRequests.removeAll()
return Task {
for request in queuedRequests {
await perform(request, login: login)
}
}
}

func unbind(login: LoginViewModel) {
guard self.login === login else { return }
self.login = nil
}

@discardableResult
func request(_ request: Request) -> Task<Void, Never>? {
guard let login else {
pendingRequests.append(request)
return nil
}
return Task { await perform(request, login: login) }
}

private func perform(_ request: Request, login: LoginViewModel) async {
do {
try reload(login: login)
} catch {
showFailure("Saved accounts could not be loaded. Try again.")
return
}
switch request {
case .addAccount:
login.beginAddAccount()
case .reauthenticate(let target):
guard let account = resolve(target, login: login) else { return }
login.dismissAccountChooser()
login.beginReauthentication(for: account)
case .signOut(let target):
guard let account = resolve(target, login: login) else { return }
login.validationMessage = ""
await login.signOutAccount(account)
finishMutation(login: login)
case .forget(let target):
guard let account = resolve(target, login: login) else { return }
login.validationMessage = ""
login.forgetAccount(account)
finishMutation(login: login)
}
}

private func reload(login: LoginViewModel) throws {
guard let modelContext = login.modelContext else { throw ActionError.missingContext }
login.update(
modelContext: modelContext,
accounts: try modelContext.fetch(FetchDescriptor<LoginAccount>()),
sessions: try modelContext.fetch(FetchDescriptor<LoginSession>()),
devices: try modelContext.fetch(FetchDescriptor<LoginDeviceRegistration>())
)
}

private func resolve(_ target: Target, login: LoginViewModel) -> LoginAccount? {
guard let account = login.accounts.first(where: {
$0.persistentModelID == target.identifier && $0.stableAccountID == target.accountID
&& $0.email == target.email && $0.userId == target.userID && $0.providerIdpId == target.providerID
}) else {
showFailure("This saved account changed or was removed. Choose the account again before continuing.")
return nil
}
return account
}

private func finishMutation(login: LoginViewModel) {
guard login.validationMessage.isEmpty else {
showFailure(login.validationMessage)
return
}
endHandoff()
}

private func showFailure(_ message: String) {
confirmation.present(
.init(
eyebrow: "ACCOUNT",
title: "Account action unavailable",
message: message,
actions: [OPNConfirmationAction("CLOSE") { [weak confirmation] in confirmation?.dismiss() }]
),
onDismiss: { [weak self] in self?.endHandoff() }
)
handoff.begin(from: nil)
}

private func endHandoff() {
guard login?.signInRequest == nil else { return }
handoff.end()
}
}
15 changes: 15 additions & 0 deletions App/OPNReportIssueCommands.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SwiftUI

struct OPNReportIssueCommands: Commands {
@FocusedValue(\.opnReportIssuePresentation) private var presentation

var body: some Commands {
CommandGroup(replacing: .help) {
Button {
(presentation ?? .shared).present(context: .appEnvironment())
} label: {
Label("Report an Issue…", systemImage: "exclamationmark.bubble")
}
}
}
}
12 changes: 9 additions & 3 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ The screen renders at 100 % interface scale like every other transient splash.
### Confirmation Modal (`OPNConfirmationModal`)

The app-shell replacement for the native `.confirmationDialog` and `.alert`, which render rounded
macOS system chrome. Raised through the `opnConfirmation` modifier and rendered once at the app root
macOS system chrome. Raised through the `opnConfirmation` modifier and rendered once at its window root
by `OPNConfirmationOverlay` — above the update prompt, below the splash — so it covers the whole
surface even when the page that raised it lives inside a scroll view. Full-cover Scrim behind a
centered panel following the modal spec (Panel background, 1px Stroke Regular, 2px accent top bar,
Expand All @@ -1336,10 +1336,16 @@ actions trailing. Actions are `OPNConfirmationAction`s in visual order: `.cancel
centered panel springs up from 0.96 scale with a fade. Reduce Motion collapses both to a plain
cross-fade.

Detached catalogs own a separate confirmation and report presenter through `DetachedSessionModalHost`.
The host injects these references into its descendants and the focused scene's Help command; it never
observes the main window's shared requests. Confirmation modifiers dismiss only their own request, so
an unrelated page disappearing cannot clear another page's dialog. Main-window update prompts keep
their existing host and ordering.

### Report an Issue Modal (`OPNReportIssueModal`)

The two-channel support form, raised through `OPNReportIssuePresentation.shared.present(context:)`
and rendered once at the app root by `OPNReportIssueOverlay` — above the update prompt, below the
The two-channel support form, raised through the window's `OPNReportIssuePresentation.present(context:)`
(the shared presenter in the main window) and rendered once at that window root by `OPNReportIssueOverlay` — above the update prompt, below the
confirmation modal — so it covers the whole surface even when the page that raised it lives inside a
scroll view. It reuses the confirmation modal's shell exactly (Panel background, 1px Stroke Regular,
2px accent top bar, modal shadow #000000 @ 0.58 radius 28 y 20, App Bar header with a 10pt bold
Expand Down
27 changes: 19 additions & 8 deletions GFN/Jarvis/JarvisAuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,25 @@ public actor JarvisAuthService<Transport: JarvisHTTPTransport> {
}
guard isSessionRefreshable else { throw JarvisAuthError.noRefreshMechanism }
if !session.clientToken.isEmpty {
let initiating = session
let body = JarvisOAuthRequestFactory.clientTokenGrantBody(clientToken: session.clientToken, userId: session.userId, configuration: configuration)
let refreshed = merge(saved: session, refreshed: try await requestSession(body: body, operation: .getSessionToken))
let enriched = try await ensureClientToken(refreshed)
setSessionInMemory(enriched)
try await persistSessionIfAutomatic(enriched)
telemetry.recordCounter(name: "jarvis.auth.refresh.count", attributes: ["outcome": "success", "grant_type": "client_token"])
span.finish(success: true)
return enriched
do {
let refreshed = merge(saved: session, refreshed: try await requestSession(body: body, operation: .getSessionToken))
let enriched = try await ensureClientToken(refreshed)
setSessionInMemory(enriched)
try await persistSessionIfAutomatic(enriched)
telemetry.recordCounter(name: "jarvis.auth.refresh.count", attributes: ["outcome": "success", "grant_type": "client_token"])
span.finish(success: true)
return enriched
} catch let error as JarvisAuthError where error.category == .authorization && !session.refreshToken.isEmpty {
Comment thread
sheldon marked this conversation as resolved.
Resolved
guard session.userId == initiating.userId, session.refreshToken == initiating.refreshToken else {
throw CancellationError()
}
telemetry.recordCounter(name: "jarvis.auth.refresh.count", attributes: ["outcome": "fallback", "grant_type": "client_token"])
session.clientToken = ""
session.clientTokenExpiry = 0
session.clientTokenExpiryLength = 0
}
}
let refreshed = try await refreshWithOAuthToken()
telemetry.recordCounter(name: "jarvis.auth.refresh.count", attributes: ["outcome": "success", "grant_type": "refresh_token"])
Expand Down Expand Up @@ -523,7 +534,7 @@ extension JarvisAuthService {
}

guard response.statusCode == 200 else {
let error = JarvisAuthError.httpStatus(response.statusCode)
let error = JarvisAuthError.rejectedGrant(statusCode: response.statusCode, body: data) ?? JarvisAuthError.httpStatus(response.statusCode)
telemetry.recordError(error, operation: operation, attributes: ["status_code": String(response.statusCode), "category": error.category.rawValue])
throw error
}
Expand Down
7 changes: 7 additions & 0 deletions GFN/Jarvis/JarvisService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ public enum JarvisAuthError: LocalizedError, Equatable, Sendable {
}
}

static func rejectedGrant(statusCode: Int, body: Data) -> JarvisAuthError? {
guard statusCode == 400,
let json = try? JSONSerialization.jsonObject(with: body) as? [String: Any],
json["error"] as? String == "invalid_grant" else { return nil }
return .oauthError("invalid_grant")
}

public static func transportFailure(_ error: Error) -> JarvisAuthError {
let nsError = error as NSError
let category: JarvisAuthFailureCategory
Expand Down
16 changes: 16 additions & 0 deletions Model/Stream/ControllerBindingOutputLedger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ struct ControllerBindingOutputLedger {
}
}

mutating func releaseHeldOutputs(timestamp: MediaTimestamp) -> [UserInputEvent] {
var releaseEvents: [UserInputEvent] = []
for keyCode in keys.keys.sorted() {
guard let ownerDeviceID = keys[keyCode]?.keys.sorted(by: { $0.rawValue < $1.rawValue }).first else { continue }
releaseEvents.append(.keyboard(KeyboardEvent(deviceID: ownerDeviceID, keyCode: keyCode, scanCode: keyCode,
modifiers: [], isPressed: false, timestamp: timestamp)))
}
for mouseButton in mouseButtons.keys.sorted(by: { $0.rawValue < $1.rawValue }) {
guard let ownerDeviceID = mouseButtons[mouseButton]?.sorted(by: { $0.rawValue < $1.rawValue }).first else { continue }
releaseEvents.append(.mouse(.button(deviceID: ownerDeviceID, button: mouseButton, isPressed: false, timestamp: timestamp)))
}
keys.removeAll()
mouseButtons.removeAll()
return releaseEvents
}

private mutating func keyboardEvents(for event: KeyboardEvent) -> [UserInputEvent] {
let previous = keys
let previousModifiers = modifiers
Expand Down
7 changes: 5 additions & 2 deletions Model/Stream/ControllerMappingFocusPolicy.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
enum ControllerMappingFocusPolicy {
/// Mappings follow the frontmost stream, except that couch co-op lets a pad keep playing its own
/// stream while another window has the focus. The overlay and remote-input gates still apply.
static func allowsMappings(appIsActive: Bool, windowIsKey: Bool,
remoteInputEnabled: Bool, overlayCapturesInput: Bool) -> Bool {
appIsActive && windowIsKey && remoteInputEnabled && !overlayCapturesInput
remoteInputEnabled: Bool, overlayCapturesInput: Bool,
allowsBackgroundPads: Bool = false) -> Bool {
((appIsActive && windowIsKey) || allowsBackgroundPads) && remoteInputEnabled && !overlayCapturesInput
}
}
10 changes: 9 additions & 1 deletion Model/Stream/StreamingTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,18 @@ extension StreamLaunchConfiguration {
/// What the catalog said about HDR for the store edition this launch picked. Client-side only:
/// it describes the launch to this app, not to the vendor.
static let hdrCatalogSupportKey = "hdrCatalogSupport"
/// The stable id of the account that owns the session, so per-account choices made before the
/// stream existed (which controllers it plays with) find their way to it.
static let owningAccountIDKey = "owningAccountID"

var owningAccountDisplayName: String {
(metadata[Self.owningAccountDisplayNameKey] ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
}

var owningAccountID: String {
(metadata[Self.owningAccountIDKey] ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
}

/// The catalog's HDR answer as the stream profile should read it. A store-launcher session
/// starts the game through the store's own launcher, so the catalog's per-edition answer does
/// not describe what will run and is not applied.
Expand All @@ -70,9 +77,10 @@ extension StreamLaunchConfiguration {
/// by, whose game it is, and which game's mappings it uses. The id has to come from the session
/// that owns the launch - the stream surface registers its commands under the configuration's id,
/// so a different one here would leave every targeted control reaching nothing.
func snapshottingSession(id: UUID, ownerDisplayName: String, mappingGameIdentity: String) -> StreamLaunchConfiguration {
func snapshottingSession(id: UUID, ownerDisplayName: String, ownerAccountID: String, mappingGameIdentity: String) -> StreamLaunchConfiguration {
var metadata = metadata
metadata[Self.owningAccountDisplayNameKey] = ownerDisplayName
metadata[Self.owningAccountIDKey] = ownerAccountID
metadata[Self.mappingGameIdentityKey] = mappingGameIdentity
return StreamLaunchConfiguration(
id: id,
Expand Down
17 changes: 11 additions & 6 deletions OPN/Core/OPNDlssPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ extension OPNStreamPreferences {
storage.synchronize()
}

/// The entitlements the launch path filters against, remembered so a session request does not
/// need a subscription fetch on its own path.
/// The active browsing account's presentation mirror. Launches carry their own snapshot.
public static func loadDlssEntitlements() -> DlssEntitlements {
guard let dictionary = storage.object(forKey: k.dlssEntitlements) as? [String: Any] else { return .none }
dlssEntitlements(from: storage.object(forKey: k.dlssEntitlements) as? [String: Any] ?? [:])
}

static func dlssEntitlements(from dictionary: [String: Any]) -> DlssEntitlements {
return DlssEntitlements(
superResolution: capability(from: dictionary, key: "superResolution"),
frameGeneration: capability(from: dictionary, key: "frameGeneration"),
Expand All @@ -28,14 +30,17 @@ extension OPNStreamPreferences {
}

public static func saveDlssEntitlements(_ entitlements: DlssEntitlements) {
let dictionary: [String: Any] = [
storage.set(dlssEntitlementsDictionary(entitlements), forKey: k.dlssEntitlements)
storage.synchronize()
}

static func dlssEntitlementsDictionary(_ entitlements: DlssEntitlements) -> [String: Any] {
[
"superResolution": capabilityDictionary(entitlements.superResolution),
"frameGeneration": capabilityDictionary(entitlements.frameGeneration),
"rayReconstruction": capabilityDictionary(entitlements.rayReconstruction),
"frameGenerationMultipliers": entitlements.frameGenerationMultipliers,
]
storage.set(dictionary, forKey: k.dlssEntitlements)
storage.synchronize()
}

/// Signing out drops the stored entitlements, so a later launch cannot ask for an override the
Expand Down
Loading
Loading