Repository navigation
fix(auth): use native branding for server names - #126
Conversation
📝 WalkthroughWalkthroughThe app now resolves server names from native branding, falls back to the health endpoint when needed, and refreshes names during active-server transitions. tvOS control advertisements also track name changes. Tests cover fallback behavior and stale asynchronous responses. ChangesServer identity resolution
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ContentView
participant AuthService
participant ServerIdentityResolver
participant BrandingEndpoint
participant HealthEndpoint
participant ServerRegistry
participant TVControlReceiver
ContentView->>AuthService: Activate or refresh server
AuthService->>ServerIdentityResolver: Fetch server name
ServerIdentityResolver->>BrandingEndpoint: Request native branding
BrandingEndpoint-->>ServerIdentityResolver: Usable or blank server_name
ServerIdentityResolver->>HealthEndpoint: Request health when branding is unusable
HealthEndpoint-->>ServerIdentityResolver: Legacy server_name
ServerIdentityResolver-->>AuthService: Resolved name or nil
AuthService->>ServerRegistry: Update active server name
ServerRegistry-->>TVControlReceiver: Active display name changes
TVControlReceiver->>TVControlReceiver: Restart advertisement
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Auth/AuthService.swift`:
- Around line 121-132: Add focused tests for AuthService.refreshActiveServerName
covering both a normal active-server name update and a delayed response for
server A after switching to server B; verify the stale response does not update
server B, while the active response updates its matching registry entry.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e9e5414f-2795-4b85-b2a2-626a0b6c44b7
📒 Files selected for processing (6)
iosApp/Tests/ServerIdentityResolverTests.swiftiosApp/iosApp/ContentView.swiftiosApp/iosApp/Networking/ServerIdentityResolver.swiftiosApp/iosApp/Networking/ServerRegistry.swiftiosApp/iosApp/Screens/Auth/AuthModels.swiftiosApp/iosApp/Screens/Auth/AuthService.swift
| /// Refreshes the active registry entry from the server's native branding. | ||
| /// The identity check prevents a slow response from one server renaming a | ||
| /// different server after the user switches destinations. | ||
| func refreshActiveServerName() async { | ||
| guard let server = ServerRegistry.shared.activeServer else { return } | ||
| let serverId = server.id | ||
| guard let name = await serverIdentityResolver.fetchServerName(serverURL: server.url), | ||
| ServerRegistry.shared.activeServerId == serverId else { | ||
| return | ||
| } | ||
| ServerRegistry.shared.updateFetchedName(for: serverId, fetchedName: name) | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Add refresh-path identity-guard coverage.
The supplied tests cover resolver responses only. They do not exercise refreshActiveServerName(), its registry update, or its stale-server guard.
Add a focused test that delays a refresh for server A, switches to server B, then verifies that the delayed result cannot change server B. Also test a normal active-server refresh.
As per coding guidelines, “for shared-logic changes, add focused tests only for critical or high-risk behavior.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@iosApp/iosApp/Screens/Auth/AuthService.swift` around lines 121 - 132, Add
focused tests for AuthService.refreshActiveServerName covering both a normal
active-server name update and a delayed response for server A after switching to
server B; verify the stale response does not update server B, while the active
response updates its matching registry entry.
Source: Coding guidelines
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8804c7489a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return name | ||
| } | ||
|
|
||
| if let health: HealthStatus = try? await httpClient.getUnauthenticated( |
There was a problem hiding this comment.
Restrict health fallback to unsupported branding endpoints
When a current server's branding request transiently fails with a timeout, 5xx, or malformed response, try? collapses that failure and this unconditional fallback accepts /health.server_name. Because that health field is the Jellyfin compatibility label this change is intended to avoid, refreshActiveServerName() can then overwrite a previously correct native name with the wrong product name. Fall back only when branding is definitively unsupported, such as a 404, and preserve the existing name for transient or decoding failures.
Useful? React with 👍 / 👎.
| // queued and must perform no work for the stale destination. | ||
| guard await HTTPClient.shared.waitForRequestDispatchOpen() else { return } | ||
| guard !Task.isCancelled else { return } | ||
| await AuthService.shared.refreshActiveServerName() |
There was a problem hiding this comment.
Clear server-scoped state before refreshing the name
When the destination's branding or health endpoint is slow, awaiting this best-effort refresh delays the rest of the server-change task by one or two network timeouts. During that delay, OverlayPrefsStore still has the previous server's hydrated values because overlayPrefs.clear() has not run, so views rebuilt for the new server can render the old server's preferences and may temporarily ignore the destination server's overlay kill switch. Perform the boundary reset before waiting for the display-name refresh, or run the refresh independently of the required cleanup.
Useful? React with 👍 / 👎.
| ServerRegistry.shared.activeServerId == serverId else { | ||
| return | ||
| } | ||
| ServerRegistry.shared.updateFetchedName(for: serverId, fetchedName: name) |
There was a problem hiding this comment.
Republish the tvOS identity after updating the name
On tvOS, when activation replaces a stale fetchedName with native branding, this line only updates the registry. TVMainTabView starts TVControlReceiver on the activeServerId change before the asynchronous refresh finishes, and TVControlReceiver.start returns at TVControlReceiver.swift:68 whenever the listener already advertises that server ID without comparing its advertised name. The Bonjour TXT record therefore keeps the old health-derived name, so iPhone remote discovery continues showing it until the listener is recreated; refresh the advertisement or make the receiver observe name changes after a successful update.
Useful? React with 👍 / 👎.
- Only fall back to the legacy health server name when branding returns 404 (or a blank name); other failures keep the stored name so transient errors can't resurface the Jellyfin-compat label - Run refreshActiveServerName after server-scoped state clearing in ContentView, fire-and-forget, so a slow server never delays the diagnostics reset and token/overlay switch - Restart the tvOS control listener when the advertised server name changes for the same server id - Add a test covering the stale-server identity guard via a minimal AuthService injection seam Implemented by OpenAI Codex (gpt-5.6-sol), reviewed and verified locally. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Pushed 67767f8 addressing the review findings:
Verified: focused identity tests 6/6 passing, iOS and tvOS simulator builds succeed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67767f87f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if listener != nil, | ||
| advertisedServerId == serverId, | ||
| advertisedServerName == serverName { |
There was a problem hiding this comment.
Refresh the advertisement without stopping control
When the asynchronous branding refresh changes the active server’s saved name while a phone is controlling the TV, the new name comparison makes start(router:) fall through to stop(). That method calls closeActiveSession(sendClose: false), so merely updating the Bonjour TXT name disconnects the active remote-control session and cancels any in-progress handoff. Rebuild only the listener advertisement, as refreshAdvertisement() does, while preserving the accepted session.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Control/tvOS/TVControlReceiver.swift`:
- Line 125: Update refreshAdvertisement() where advertisedServerName is assigned
to reuse the same fallback resolver as start(router:), preserving the
server.displayName fallback when effectiveServerName is unavailable instead of
hardcoding "Silo".
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ebff79b-f704-4012-bed6-9ab5d6d57a46
📒 Files selected for processing (7)
iosApp/Tests/ServerIdentityResolverTests.swiftiosApp/iosApp/ContentView.swiftiosApp/iosApp/Control/tvOS/TVControlReceiver.swiftiosApp/iosApp/Networking/HTTPClient.swiftiosApp/iosApp/Networking/ServerIdentityResolver.swiftiosApp/iosApp/Screens/Auth/AuthService.swiftiosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
🚧 Files skipped from review as they are similar to previous changes (3)
- iosApp/iosApp/ContentView.swift
- iosApp/iosApp/Networking/ServerIdentityResolver.swift
- iosApp/iosApp/Screens/Auth/AuthService.swift
| listener.start(queue: .main) | ||
| self.listener = listener | ||
| advertisedServerId = serverId | ||
| advertisedServerName = serverName |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve the URL fallback during listener refresh.
start(router:) uses server.displayName when effectiveServerName is unavailable. refreshAdvertisement() uses "Silo" instead. After an advertisement refresh, line 125 can cache "Silo" and publish the wrong Bonjour server name.
Use the same fallback resolver in both paths.
Proposed fix
- let serverName = RemotePlaybackIdentityManager.shared.effectiveServerName ?? "Silo"
+ let serverName = RemotePlaybackIdentityManager.shared.effectiveServerName
+ ?? ServerRegistry.shared.activeServer?.displayName
+ ?? "Silo"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| advertisedServerName = serverName | |
| let serverName = RemotePlaybackIdentityManager.shared.effectiveServerName | |
| ?? ServerRegistry.shared.activeServer?.displayName | |
| ?? "Silo" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@iosApp/iosApp/Control/tvOS/TVControlReceiver.swift` at line 125, Update
refreshAdvertisement() where advertisedServerName is assigned to reuse the same
fallback resolver as start(router:), preserving the server.displayName fallback
when effectiveServerName is unavailable instead of hardcoding "Silo".
Problem
The Apple client saves and displays
GET /api/v1/health.server_name. That field is currently backed by the Jellyfin compatibility setting, so an iOS or tvOS client can show “StreamApp” even when Jellyfin compatibility is disabled.Fixes #125.
Related to Silo-Server/silo-server#553.
Approach
GET /api/v1/theme/brandingendpoint.GET /api/v1/healthfor older servers.Validation
xcodegen generateServerIdentityResolverTests— 3 tests passedSiloTVbuild succeededRisk
Low. Both identity requests are public, best-effort reads. Existing servers remain compatible through the health fallback, and failures retain the existing URL display name.
AI use
Implemented and validated with Codex on behalf of the repository maintainer.
Summary by CodeRabbit
New Features
Bug Fixes