Skip to content

feat(settings): add an administrator_shield switch to hide the elevation badge - #1084

Open
Sakyvo wants to merge 1 commit into
Kuddev:release/auto-2.6.2from
Sakyvo:administrator-shield-official
Open

Sakyvo wants to merge 1 commit into
Kuddev:release/auto-2.6.2from
Sakyvo:administrator-shield-official

Conversation

@Sakyvo

@Sakyvo Sakyvo commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Why

An elevated Windows session marks every local tab with a shield in front of the program icon (from #436). The marker is useful when you launch Pebrel as administrator on purpose, but there is no way to turn it off — a user who always runs elevated sees the shield on every tab, forever, with no setting to hide it.

What it does

Adds a Show administrator shield switch to Settings → Appearance → Interface, directly after Show tab close buttons.

  • administrator_shield is a new preference in nebula_settings, default on, so nothing changes for anyone who does not touch it.
  • The badge decision is now a single pure function, shows_administrator_badge(enabled, elevated, inherits_host_token), so the switch, the elevation query and the per-pane host-token inheritance are checked in one place. Sidebar rows and top tabs both read the result through TabPresentation.local_administrator, so one switch hides the marker everywhere.
  • Turning the switch off hides the marker only. The session keeps its rights; the shield is an indicator, not a control.
  • The switch participates in the existing dirty-value reset (↶) and in the settings reset, like every other boolean row.
  • The switch is shown on every platform, not only Windows. It is inert where elevation is not supported, which matches how other platform-specific switches are presented; gating the row by cfg would make the settings page differ between platforms for no gain.

UI strings were added to en-US and zh-CN only; the other catalogs keep falling back to English.

Verification

  • cargo check -p nebula --bin pebrel --features gpui-shell passes on this branch.
  • cargo test -p nebula-settings passes (114 tests), including a new administrator_shield_defaults_to_shown_and_round_trips covering the default, =0, =1, invalid input, and reset-to-default.
  • python scripts/check_architecture.py passes with no errors on this branch.
  • Not verified here: the rendered badge disappearing in a real elevated window. Test processes cannot be elevated, which is exactly why the decision is a parameterised function; the visual check needs a manual run as administrator.

Notes

  • nebula_settings/src/lib.rs was at 1998 lines and the new field would cross the 2000-line budget, so its unit tests move to nebula_settings/src/tests.rs in the same commit. No test body changed; lib.rs drops to 1416 lines. Happy to split this differently if you would rather see a separate commit for the move.
  • A CHANGELOG entry is included under Unreleased (Added / 新增), leaving the released 2.6.1 section untouched.
  • The switch has no keybinding and no CLI flag; it is a persisted preference only.

@Sakyvo
Sakyvo requested a review from Kuddev as a code owner November 21, 2026 09:25
@Sakyvo

Sakyvo commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Base note: this targets
elease/auto-2.6.2\ rather than \main\ because \main\ has renamed the crates to \pebrel_\ while this patch is written against the
ebula_
\ layout. The touched files are byte-identical between \�2.6.1\ and
elease/auto-2.6.2, so it applies cleanly. The CHANGELOG entry sits under a new ## Unreleased\ section so the released 2.6.1 notes stay untouched.

Note on size: 656/590 lines look large, but 584/590 of those are the #[cfg(test)] mod tests\ block moved verbatim from
ebula_settings/src/lib.rs\ into
ebula_settings/src/tests.rs\ to stay inside the 2000-line per-file budget. The actual feature is roughly 60 lines.

@Sakyvo
Sakyvo force-pushed the administrator-shield-official branch from 37abe3b to 8484c07 Compare November 21, 2026 09:33
…ion badge

An elevated Windows session marks every local tab with a shield before the
program icon, and the badge could not be turned off. Add a
`administrator_shield` preference (default on, current behaviour unchanged)
and surface it as "Show administrator shield" in Appearance -> Interface,
right after the tab close button.

The badge decision now lives in one pure function,
`shows_administrator_badge(enabled, elevated, inherits_host_token)`, so the
switch, the elevation query and the per-pane host-token inheritance are all
checked in one place; sidebar rows and top tabs reuse that computation through
`TabPresentation.local_administrator`. Turning the switch off hides the marker
only: the session keeps its rights.

Move the `nebula_settings` unit tests into `src/tests.rs` so `lib.rs` stays
under the 2000-line budget; no test body changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant