Skip to content

feat(locallibrary): let a plugin ask for more of an account, and say when accounts sign themselves out - #340

Merged
botandbang merged 12 commits into
mainfrom
bnb/account-ensure
Nov 2, 2026
Merged

botandbang merged 12 commits into
mainfrom
bnb/account-ensure

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

Stacked on #339. A plugin's optional scopes had no way to be asked for at the moment a command needs them, and nothing said when an account would stop working.

Added:

  • accounts/ensure {type, scopes, access?} in the plugin protocol (part of the accounts feature, so no protocol bump) and Host::ensure_account in the SDK. It answers granted and declined scope names, never a token.
  • The host answers it: a scope the manifest doesn't ask for is refused; one already given and granted is granted; one the user declined before is declined; otherwise it asks. A terminal (not --json, --yes or watch) and the player ask, signing in again when the account lacks the service scope; with nobody to ask, it fails with the action that gives it.
  • locallibrary account says when each account signs itself out (a token that doesn't refresh, or a refresh token the service says expires), and publishing, the access prompt and the player warn in an account's last 2 days, offering to sign in again.

How it was tested

  • An SDK round trip for accounts/ensure, a hegel property that ensure answers granted or declined and never a token (with an asker that allows, declines or partly grants, and with none), a CLI property that a terminal asks and --json errors with an action, a player test, and a property that tokens last as the service says. Each new test was broken once to see it fail.
  • Locally: fmt, clippy (workspace and the CLI's CI forms), ast-grep, docs/rpc current, full nextest 4094/4096 (the props_edit failure test(locallibrary): leave blank names out of the edit model's playlist lookups #334 fixes, and a flaky account property whose cause is fixed in its own PR). Hegel coverage 95.56 / 94.10 / 93.63.

Checklist

  • Tests cover the change
  • For locallibrary: apps/locallibrary/CHANGELOG.md has a line under Unreleased
  • The READMEs, docs/ and --help still say what the code does (apps/locallibrary/docs/rpc/ too)

@botandbang
botandbang requested a review from bnb as a code owner October 30, 2026 22:05
@github-actions github-actions Bot added documentation Improvements or additions to documentation locallibrary locallibrary and the loclib-* crates locallibrary: cli The locallibrary command line locallibrary: player The terminal player and its waveforms locallibrary: sidecar The JSON-RPC sidecar and the api module it serves locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary: publishing The Atmosphere account, and the sets and profile published to it tests Tests, fixtures and test harnesses labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Size

Compared with main. KiB are 1,024 bytes.

This pull request main Change
Client JavaScript 729.1 KiB 729.1 KiB 0 B (0%)
Client JavaScript, brotli 245.7 KiB 245.7 KiB 0 B (0%)
Client CSS 91.9 KiB 91.9 KiB 0 B (0%)
Client CSS, brotli 13.2 KiB 13.2 KiB 0 B (0%)

# Conflicts:
#	apps/locallibrary/CHANGELOG.md
#	apps/locallibrary/src/output.rs
#	apps/locallibrary/src/tui/app.rs
#	apps/locallibrary/src/tui/mod.rs
#	crates/loclib-plugin/src/lib.rs
@bnb
bnb added this pull request to stack #354 November 1, 2026 16:21
bnb
bnb previously approved these changes Nov 1, 2026
Comment thread apps/locallibrary/src/browser.rs Fixed
bnb
bnb previously approved these changes Nov 1, 2026
bnb
bnb previously approved these changes Nov 1, 2026
# Conflicts:
#	crates/locallibrary/src/plugin/accounts/shared.rs
bnb
bnb previously approved these changes Nov 1, 2026
Base automatically changed from bnb/account-escalation to main November 2, 2026 03:33
@botandbang
botandbang dismissed bnb’s stale review November 2, 2026 03:33

The merge-base changed after approval.

bnb
bnb previously approved these changes Nov 2, 2026
@botandbang

Copy link
Copy Markdown
Contributor Author

Closing and reopening so CI runs against current main. Branch unchanged.

@botandbang botandbang closed this Nov 2, 2026
@botandbang botandbang reopened this Nov 2, 2026
@botandbang botandbang closed this Nov 2, 2026
@botandbang botandbang reopened this Nov 2, 2026
…l draws

The profile bar test compared the "sign in again by" span's colour with the theme's warning as
plain RGB. The bar draws it through the theme, which gives RGB only on a terminal that says it
takes 24-bit colour (COLORTERM, or a known TERM_PROGRAM) and an xterm-256 index otherwise, so the
test passed in a truecolor terminal and failed on CI's runners. It now compares with what
theme::fg gives for the warning colour, and passes with and without COLORTERM and with NO_COLOR.
bnb
bnb previously approved these changes Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Rust coverage

From run 184. Both are held to the thresholds in .cargo/config.toml.

Tests Lines Functions Regions
All 97.36% (86903/89261) 96.48% (14070/14583) 95.6% (191811/200636)
Hegel property tests alone 95.36% (85118/89261) 94.08% (13719/14583) 93.41% (187421/200636)

@botandbang
botandbang added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
… runs

`Asked`, the ways a_plugin_wanting_more_of_an_account_asks_only_in_a_terminal runs echo's
`ensure`, was compiled on every platform, but its one test is `#[cfg(unix)]`, so on Windows it
was never used and clippy's `-D warnings` stopped the merge queue's other-os job. It now has the
same `#[cfg(unix)]` as its test.
@botandbang
botandbang added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 02060d1 Nov 2, 2026
35 checks passed
@botandbang
botandbang deleted the bnb/account-ensure branch November 2, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation locallibrary: cli The locallibrary command line locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: player The terminal player and its waveforms locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary: publishing The Atmosphere account, and the sets and profile published to it locallibrary: sidecar The JSON-RPC sidecar and the api module it serves locallibrary locallibrary and the loclib-* crates tests Tests, fixtures and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants