Skip to content

feat: hide controls the API key cannot use - #358

Merged
4 commits merged into
mainfrom
feat/hide-controls-the-key-cannot-use
Nov 13, 2026
Merged

4 commits merged into
mainfrom
feat/hide-controls-the-key-cannot-use

Conversation

@nofuturekid

@nofuturekid nofuturekid commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

A key that lacks the permission for an action is no longer offered the button for it (#315).

  • Hidden controls, one note. With access Denied (from the capability probe of ADR-0047), the Docker, VMs and Array tabs and the container, VM and notification sheets hide Start, Stop, Restart, Resume, Update, Update all, Pause, Reboot, Reset, Force stop, Start/Stop array, the parity buttons, Archive, Unarchive, Archive all, Delete and Delete all archived, and show one "View only" note in their place that names the missing permission (for example "Needs DOCKER:UPDATE_ANY") with a "Which permissions?" link to the README table (#api-key-permissions). The texts are the ones of the design. Notifications are split: a key that may archive but not delete keeps exactly the archive buttons, and the note says "This API key can't delete notifications."
  • Unknown stays open. Only Access.Denied hides a control. While detection runs, when it failed, or for a role NOVA does not know, every screen looks as before. This is tested in pairs (Denied vs Unknown vs Allowed) on every surface.
  • Refused actions explain themselves. For FORBIDDEN the snackbar now reads "Action failed: your API key isn't allowed to do this (it needs DOCKER:UPDATE_ANY)" (permission from KeyAction.forOperation), for UNAUTHENTICATED "…the server didn't accept the API key". The server's own text stays on ActionFailedException.detail.
  • Add server: Test uses the probe. Ping (__typename) is answered for any key, so Test used to say "Connected" for a wrong key. Test now runs version + me: a rejected key fails ("The server didn't accept this API key"); an accepted key shows "Connected · Unraid 7.4.0 · API 4.37.11" and "View only key: NOVA will hide controls", "Full control" or "Can control: Docker, VMs"; a too-old API gets the design's sentence. A refused me says nothing about control. Certificate handling (untrusted/changed certificate dialog) still works through the probe (tested). query Ping is removed. The API Key field gets "A key with the VIEWER role is enough to see everything. Controls need more permissions." and a "Which permissions?" link (Document the minimal API key permissions for each feature #316).
  • Overview follow-up from the PR-2 review. When every domain failed, the Overview now passes the failure reason to ErrorState (same texts as the tabs; a connection problem wins over other reasons). Its offline rule, and so the needs-attention card, is now decided by ErrorReason.isConnectionProblem: Docker or VMs switched off no longer hides the card. The Containers and Virtual machines cards show "—" instead of "0 running · all healthy" / "0 configured" while their data is unknown (Needs attention card never appears when VMs or Docker are switched off #356).
  • Demo. The demo keeps reporting every control as allowed. A test derives each surface's Access from the demo's capabilities exactly as MainScreen does and checks that no note shows and no button is missing.

Closes #315
Closes #316
Closes #356

Shared files touched, and the region

  • MainScreen.kt: the capabilities collection after displayThresholds, plus one control = / update = / delete = argument at each tab and sheet call site. Nothing else.
  • UnraidRepository.kt: only testConnection (now testOutcomeOf(probeCapabilities(client))) and the removed PingQuery import.
  • ResponseClassifier.kt: ActionFailedException (new detail), checkActionResponse / orThrow (refusal wording), TestOutcome.Ok, new TestControl and testOutcomeOf.
  • CapabilityProbe.kt: ProbeOutcome carries the transport cause and the server's failureText of a failed detection (needed so Test can still show the certificate dialog and real errors). Error.code() is now internal.
  • DockerTab.kt, ContainerDetailSheet.kt, VmsTab.kt, VmDetailSheet.kt, ArrayTab.kt, NotificationsSheet.kt: new parameters with the default Access.Unknown and the button rows only. In ContainerDetailSheet.kt the actions block gets one extra else if (control == Denied) branch; the Start/Resume lines are untouched.
  • AddEditServerSheet.kt: the Test result state and panel, the key hint and link.
  • OverviewTab.kt: the all-failed branch and the offline rule (two small internal functions).
  • queries.graphql (removed Ping), HANDOFF.md (one file-list entry), README.md (two sentences that said buttons are refused / "a later version will hide them"), CHANGELOG.md.
  • New: ui/components/ViewOnlyNote.kt.

Not touched: Settings screen and data/alerts, ApolloClientFactory and the response classifier's redirect handling, UnraidRepository.unpause/resume and the Docker container sheet's Resume line, DomainState.kt, SnapshotStates.kt, schema.graphqls, the top bar region, .github/, version, ADRs.

Deliberately left out

  • Hiding the Overview or the logs: they have no actions.
  • A "detecting" delay before showing buttons (design risk 4): not added; only check it on the device.
  • Role-less keys and the "scoped key sees every screen" check of Document the minimal API key permissions for each feature #316 are still unverified on a real server (README says so).
  • Network-speed probe, version floors, background work: unchanged.

Tests

New: ViewOnlyControlsTest (Robolectric: Denied/Unknown/Allowed per surface, notification split, demo hides nothing), TestConnectionOutcomeTest (wrong key fails, view only, full, partial, unknown, too old, unreachable, certificate dialog, server text), ActionRefusalTest (live FORBIDDEN body names the permission; every operation names its own KeyAction), OverviewFailureTest (reason shown, card kept with Docker/VMs off, hidden when unreachable or key rejected).

./scripts/local-ci.sh: passed (636 unit tests, 0 failed, 0 skipped).

Device acceptance (read-only key, then admin key)

  1. VIEWER key: Docker, VMs and Array tabs show no action buttons and one "View only" note each; open a container, a VM and the notifications sheet: no actions, one note each; the note is read as one item by TalkBack; "Which permissions?" opens the README section.
  2. Docker update banner still says "N containers have updates" without "Tap to update all".
  3. Add server sheet, Test with the VIEWER key: "Connected · Unraid 7.4.0 · API 4.37.11" and "View only key: NOVA will hide controls"; with a wrong key: fails.
  4. Pull to refresh and bringing the app to the foreground keep the notes; watch for a brief flash of buttons at app start (design risk 4).
  5. ADMIN key (look only, press nothing): buttons are back, no notes, Test shows "Full control".
  6. Demo server: every button present, no note.

🤖 Generated with Claude Code

@nofuturekid
nofuturekid force-pushed the feat/hide-controls-the-key-cannot-use branch from 8d5eac6 to dfa17c2 Compare November 13, 2026 21:04
@nofuturekid nofuturekid added this to the 0.1.49 milestone Nov 13, 2026
nofuturekid and others added 4 commits November 13, 2026 22:31
The Resume button on a paused container sent the start mutation, which
Docker refuses ("cannot start a paused container, try unpause instead"),
so the container stayed paused. A paused container now gets the existing
UnpauseContainer mutation (docker.unpause, available since API 4.29.0, so
on every supported server and without a capability floor); a stopped
container still gets start.

The choice is made once, in UnraidRepository.startContainer(client, id,
paused), the same seam as restartContainer. The Docker tab row and the
container sheet both go through MainViewModel.startContainer(Container).

The demo follows the repository surface: UnraidGateway.startContainer
takes the same flag, and the demo model refuses start on a paused
container like Docker does, so the demo no longer hides the bug.

Closes #345
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ain http

The foreground clients followed redirects, and OkHttp keeps the x-api-key
header when it does, so a 3xx answer moved the key to whatever Location
named: another host, or http after the user entered https. For the
WebSocket the handshake was followed and the key then went out in
connection_init to the new host.

No client that carries the key follows a redirect any more (ADR-0051).
A redirect is reported as the new reason Redirected, naming the target
origin ("The server redirects to https://... Edit the server and enter
that address."), in the tabs, in the Add server sheet's Test and in the
action message. It is no connection problem, so the pill does not say
Offline. Unraid answers http requests with 302 when SSL is Yes or Strict.

Closes #354

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A key without the permission for an action no longer gets the button for it.
The Docker, VMs and Array tabs and the container, VM and notification sheets
hide Start, Stop, Restart, Update, parity, Archive and Delete controls when the
capability probe says the key lacks DOCKER, VMS, ARRAY or NOTIFICATIONS
UPDATE_ANY / DELETE_ANY, and show one "View only" note that names the missing
permission, with a link to the README table. Unknown access keeps every button
as before, and a refused action now says which permission it needed instead of
"Forbidden resource".

The Add server Test button now uses the capability probe instead of Ping, which
the server answers for any key: a rejected key fails the test, and an accepted
one reports the Unraid and API version and what the key can do. The API Key field
gets a hint and a "Which permissions?" link.

The Overview shows the failure reason of a total failure like the tabs do, and
only a connection problem (unreachable server, rejected key) marks it offline and
hides the needs-attention card.

Closes #315
Closes #316

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ion card with services off

The Containers and Virtual machines cards turned an unknown list (not loaded,
turned off, not allowed, offline) into "0 running", "all healthy" and
"0 configured". They now show the same dash as the other Overview cards; a real
empty list still reads 0. The figures moved into OverviewFigures.kt so they can
be unit-tested.

Regression tests for #356: the Needs attention card stays with VMs or Docker
switched off or forbidden for the key, and the cards render dashes while their
data is unknown. ErrorReasonTest now also classifies the Docker-off answer
through the real Docker query.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid
nofuturekid force-pushed the feat/hide-controls-the-key-cannot-use branch from cf43b99 to 9792740 Compare November 13, 2026 21:43
nofuturekid added a commit that referenced this pull request Nov 13, 2026
#358 moved the Add server sheet's Test onto the capability probe, whose
failure path never called redirectMessage(): a 3xx answer showed the generic
"Http request failed with status code 302" instead of the sentence ADR-0051
documents. testOutcomeOf now prefers the redirect message when the probe's
failure carries the HTTP exception. Tests: a 302 with a target and one
without go through the real probe; the classifier test no longer claims to
cover Test. ADR-0048's last sentence pointed at in-app clients that follow
redirects; since ADR-0051 they do not.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid nofuturekid closed this pull request by merging all changes into main in deded38 Nov 13, 2026
@nofuturekid
nofuturekid deleted the feat/hide-controls-the-key-cannot-use branch November 13, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant