Skip to content

fix(requests): re-check the requests capability when the app returns to the foreground - #560

Closed
Rhainland wants to merge 3 commits into
Silo-Server:mainfrom
Rhainland:fix/requests-status-refresh-on-resume
Closed

Rhainland wants to merge 3 commits into
Silo-Server:mainfrom
Rhainland:fix/requests-status-refresh-on-resume

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: Silo-Server/silo-server#1201
Validation tasks: unblocks #338 C3, #339 C3

The Android apps check whether the server has Requests on only at startup and on a server or profile switch. When an admin turns requests off while the app is in the background, the profile-menu entry, the search "Available to request" section and any open Requests screen stay until the app restarts, and search shows "The requests capability is disabled by an administrator." This change re-checks when the app returns to the foreground, and the phone app closes open Requests screens once the server answers that they are off.

Approach

The existing foreground hook (ForegroundAccessCheck) now also re-checks Requests, once the shell's own first check has answered and while signed in. On phone, Requests screens on top of the back stack pop back to whatever opened them on an answered "unavailable", never while the answer is unknown. Android TV already left its Requests tab when it disappears. This mirrors Apple, which re-checks on every foreground.

Stacked on #558 (merge that first).

Validation

  • Phone emulator against a local server, before and after: with the hub open, turning requests off and returning to the app now closes the hub and removes the menu entry and search section; turning them back on restores them. Android TV leaves its Requests tab the same way.
  • :shared, :androidApp and :androidTvApp unit tests: pass, except ReflowStyleTest ("line height flows from settings"), which fails the same way on main.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-560/

Risks

One extra status request each time the app returns to the foreground.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code (Bash, file edits, subagents), GitHub CLI (gh), Playwright, Xcode xcodebuild/simctl, Maestro, Android emulator/adb
  • Model(s): Claude Opus 5.5 (claude-opus-5-5)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: A separate Claude Code review pass (medium) covered every branch of the Requests validation fixes across silo-server, silo-apple and silo-android. Its findings (a commit message that misdescribed the unfollow response, a tablet layout that hid the title) were fixed. This was an AI self-review; no independent human review is claimed.

The 1.0 Requests acceptance criteria keep request administration
(approve, decline, retry, limits, auto-approve) in web admin, and the
native validation tasks say not to expose it on native clients. The
Android apps still offered it: an Approvals screen and summary cards on
phone, approval and failed-request rows on TV, and Approve, Decline, and
Retry on the request detail pages of both.

This removes that surface and the code behind it: the admin request
endpoints in RequestsApi and their models, the admin capability probe
and canModerate in RequestsFeatureStore, RequestApprovalsViewModel, the
moderation state in RequestDetailViewModel and RequestDetailCache, and
the requests/approvals route. Users keep requesting titles, cancelling
their own pending requests, and following request status.

Without the moderation lookup, the detail page's own create or cancel
broadcast could reach its listener after the action finished and trigger
a second read; the page now ignores the broadcast of its own action.

A source guard test fails if Android code calls the admin request
endpoints or brings the moderation surface back. AGENTS.md, FEATURES.md,
and README.md now say request administration stays in web admin.
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3ced3e5-b6fd-4414-82bd-f5f0c80f325b
📥 Commits

Reviewing files that changed from the base of the PR and between 726684d and 779d7ce.

📒 Files selected for processing (38)
  • AGENTS.md
  • FEATURES.md
  • README.md
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/requests/RequestRouter.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/requests/RequestUi.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/RequestsRouteVisibility.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/Routes.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/MyRequestsScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/RequestApprovalsScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/RequestComponents.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/RequestDetailScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/RequestRows.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/requests/RequestsScreen.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/RequestsRouteVisibilityTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/di/AndroidTvModule.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/requests/TvRequestComponents.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/requests/TvRequestDetailScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/requests/TvRequestsPage.kt
  • shared/src/androidUnitTest/kotlin/org/siloserver/silo/network/api/NoNativeRequestModerationSourceTest.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/di/RepositoryModule.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/feature/RequestsFeatureStore.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/request/RequestDisplayState.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/request/RequestModels.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/request/RequestMutations.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/network/api/RequestsApi.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/ForegroundAccessCheck.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/RequestDetailCache.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/RequestsRepository.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/viewmodel/RequestApprovalsViewModel.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/viewmodel/RequestDetailViewModel.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/viewmodel/RequestsViewModels.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/model/feature/RequestsFeatureStoreTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/network/apiv2/RequestsV2Test.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/repository/RequestsRepositoryTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/viewmodel/RequestDetailStatusTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/viewmodel/RequestsViewModelTest.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added bug Something isn't working priority: P2 Limited scope, workaround exists, or polish stacked Stacked on another open PR or branch labels Oct 12, 2026
@Rhainland
Rhainland force-pushed the fix/requests-status-refresh-on-resume branch 2 times, most recently from c7f1db3 to cf5e637 Compare October 12, 2026 22:47
Removing the requests/approvals destination left no destination for a
back stack saved by an older build, and Navigation throws when it
restores an entry whose destination is missing. Register a hidden
redirect to Requests, like the existing admin and card overlays
aliases, so such a restore lands on Requests. It renders nothing and
offers no moderation.

The source guard allows only the alias's two lines in AppNavigation.kt.
…to the foreground

Requests entry points must disappear when the server turns requests off
(1.0 Requests AC7). Both shells probed /api/v2/requests/status only when
the server or profile changed, so an admin who turned requests off while
the app was in the background left the profile menu, search results, the
TV Requests tab, and any open Requests screen in place until a restart or
profile switch.

The foreground access check that runs when the app returns from the
background (phone and TV, process ON_START, skipped on the first start)
now also re-probes the requests capability, as the Apple clients do on
every foreground. The probe runs only after the shell's own probe for the
current session has answered and only while signed in, and it keeps the
store's generation guard against server and profile switches.

On phone, an open Requests screen (hub, My Requests, request
detail) now closes back to whatever opened it once a probe answers that
requests are unavailable, matching how the TV shell leaves its Requests
tab. A Requests screen restored before the first probe answers waits for
that answer.
@Rhainland
Rhainland force-pushed the fix/requests-status-refresh-on-resume branch from cf5e637 to 779d7ce Compare October 12, 2026 22:56
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Rhainland Rhainland mentioned this pull request Oct 13, 2026
3 tasks done
Quick104 added a commit that referenced this pull request Nov 15, 2026
…ts off (#855)

* fix(requests): re-check the requests capability when the app returns to the foreground

Requests entry points must disappear when the server turns requests off
(1.0 Requests AC7). Both shells probed /api/v2/requests/status only when
the server or profile changed, so an admin who turned requests off while
the app was in the background left the profile menu, search results, the
TV Requests tab, and any open Requests screen in place until a restart or
profile switch.

The foreground access check that runs when the app returns from the
background (phone and TV, process ON_START, skipped on the first start)
now also re-probes the requests capability, as the Apple clients do on
every foreground. The probe runs only after the shell's own probe for the
current session has answered and only while signed in, and it keeps the
store's generation guard against server and profile switches.

On phone, an open Requests screen (hub, My Requests, request
detail) now closes back to whatever opened it once a probe answers that
requests are unavailable, matching how the TV shell leaves its Requests
tab. A Requests screen restored before the first probe answers waits for
that answer.

(cherry picked from commit 779d7ce)

* fix(requests): close request screens whenever the server turns requests off

Builds on the foreground re-check from #560 so the Android apps match the
Apple apps (Silo-Server/silo-apple#748):

- A requests call the server refuses as requests-off (capability_disabled,
  capability_not_configured, capability_unsupported, permission_denied)
  reads the status again, so an app that stays in the foreground notices.
- Screens close only on an answered "unavailable" (isKnownUnavailable),
  never on a failed status read, and an older answer can't overwrite a
  newer one.
- Phone: the Discover row See all page closes with the other request
  screens.
- TV: request detail closes too, and the Requests page and detail pop back
  to what opened them, like Back, instead of a state-saving pop to Home
  that left Requests in the opening tab's saved stack.
- A failed token read in the foreground check no longer escapes its scope.

Closes #854

* fix(requests): re-check on return to the foreground while the first probe is out

The foreground check skipped until the shell's first status read had
answered. If the app went to the background while that read was out, and
it had read the status before requests were turned off, its stale
"available" stood until the next refusal or foreground return. Skip only
until the session's first probe has started.

* fix(requests): keep the library and Requests foreground checks independent

A failed library check no longer cancels the Requests status check that
runs beside it on return to the foreground. Also correct the TV entry
point in the README and FEATURES exposure notes: Requests opens from the
profile menu, not a top-bar tab.

* fix(requests): re-check on return to the foreground before the shell's first probe

A phone restored onto a Requests screen after process death never shows the
tab screen that starts the shell's status probe, so the foreground check
skipped every return and the screen stayed open after requests were turned
off. The foreground check already asks the server only while someone is
signed in, and the store discards answers from before a server or profile
switch, so it now probes without waiting for the shell.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Rhainland <[email protected]>
Co-authored-by: Quick <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@Quick104

Copy link
Copy Markdown
Contributor

This PR is superseded: #855 (98d0771) cherry-picked its commit onto main with authorship kept, and built the remaining Requests-off handling on top. The PR it was stacked on, #558, merged as c73770f. Main already has everything this branch changes: ForegroundAccessCheck re-checks Requests on return to the foreground, and the phone closes Requests screens through RequestsRouteVisibility once isKnownUnavailable is set. I recommend closing it.

This PR closes no issues. Silo-Server/silo-server#1201 is only linked as related and stays open as the v1 Requests tracker. Thank you for the work, @Rhainland.

@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Nov 19, 2026
@Quick104 Quick104 closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. stacked Stacked on another open PR or branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants