Skip to content

feat: add an admin-configurable site banner - #2257

Merged
netomi merged 17 commits into
mainfrom
gnugomez/main/allow-admins-to-edit-banner
Oct 10, 2026
Merged

netomi merged 17 commits into
mainfrom
gnugomez/main/allow-admins-to-edit-banner

Conversation

@gnugomez

Copy link
Copy Markdown
Member

This is an start to have the banner as part of the runtime settings.

Resolves #2256

@gnugomez
gnugomez requested review from autumnfound, cstamas and netomi and a balanced review from Copilot September 28, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Public-setting exposure, stale active clients, and non-atomic or conflicting updates must be addressed.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Adds an admin-configurable runtime site banner while preserving page-settings overrides.

Changes:

  • Adds banner persistence, validation, and a public settings API.
  • Adds admin editing, preview, severity, dismissal reset, and runtime rendering.
  • Adds frontend and server test coverage.
File Description
webui/​test/​unit/​pages/​admin-dashboard/​settings.spec.tsx Tests banner administration.
webui/​test/​unit/​layout/​app-layout.spec.tsx Tests banner fallback precedence.
webui/​test/​unit/​components/​registry-banner.spec.tsx Tests rendering and dismissal.
webui/​src/​pages/​admin-dashboard/​use-settings.ts Invalidates public settings.
webui/​src/​pages/​admin-dashboard/​settings.tsx Integrates banner settings.
webui/​src/​pages/​admin-dashboard/​settings-switch.tsx Adds reusable setting switch.
webui/​src/​pages/​admin-dashboard/​settings-section.tsx Adds settings grouping.
webui/​src/​pages/​admin-dashboard/​settings-item.tsx Reuses the shared switch.
webui/​src/​pages/​admin-dashboard/​settings-banner-item.tsx Adds banner editor and preview.
webui/​src/​layout/​app-layout.tsx Adds runtime banner fallback.
webui/​src/​index.ts Exports banner APIs.
webui/​src/​extension-registry-types.ts Defines banner settings types.
webui/​src/​extension-registry-service.ts Fetches public site settings.
webui/​src/​components/​use-site-settings.ts Adds settings query hook.
webui/​src/​components/​registry-banner.tsx Renders configured banners.
webui/​src/​components/​banner.tsx Exports banner props.
webui/​CHANGELOG.md Documents the feature.
server/​src/​test/​java/​org/​eclipse/​openvsx/​settings/​SettingsValidatorTest.java Tests validation rules.
server/​src/​test/​java/​org/​eclipse/​openvsx/​settings/​SettingsServiceTest.java Tests persistence behavior.
server/​src/​test/​java/​org/​eclipse/​openvsx/​settings/​SettingsAPITest.java Tests the public endpoint.
server/​src/​test/​java/​org/​eclipse/​openvsx/​json/​SettingsJsonTest.java Tests settings serialization.
server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​SettingsValidator.java Validates banner values.
server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​SettingsService.java Manages and publishes settings.
server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​SettingsCache.java Caches typed settings.
server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​SettingsAPI.java Exposes public site settings.
server/​src/​main/​java/​org/​eclipse/​openvsx/​json/​SettingsJson.java Defines settings payload fields.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The public endpoint can expose future private settings, and locale-sensitive validation permits inconsistent executable-scheme checks.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (3)

@netomi

netomi commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

hmm, I do not like the idea that we start adding a SettingsAPI right now. Just wrap that into the existing version endpoint as an optional field.

also its not clear to me how the banner-dismiss-id is generated. I tested it out by updating the text but it kept the same. My expectation would be that the id is derived from the text, we might even add a field in the settings to add a custom prefix / suffix to the id.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The admin settings contract has a breaking readOnly key rename, and the severity selector lacks an accessible group name.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Add an accessible name to the severity button group

webui/​src/​pages/​admin-dashboard/​settings-banner-item.tsx:116

The exclusive severity group has no accessible name, so assistive technology exposes an unlabeled group containing generic “Info” and “Warning” buttons. Add an aria-label such as “Banner severity” (or associate a visible label) with the group.

@gnugomez
gnugomez force-pushed the gnugomez/main/allow-admins-to-edit-banner branch from e3d474b to 4d9c466 Compare September 29, 2026 08:03
@gnugomez
gnugomez force-pushed the gnugomez/main/allow-admins-to-edit-banner branch from ace229a to 19f5389 Compare September 29, 2026 15:40
@cstamas
cstamas requested a balanced review from Copilot October 1, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Runtime severity handling can crash the admin page, banner propagation exceeds its stated latency, and distributed invalidation lacks direct coverage.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity · 2 Low severity

Open (5)

Comment thread webui/CHANGELOG.md Resolved
netomi and others added 7 commits October 8, 2026 08:13
Fold the max-extension-size setting into the per-setting bean design
as MaxExtensionSizeSetting. WritableSetting#writesUnchanged lets it
keep writing a value equal to the configured default, so an admin can
still pin it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Fall back to info for a stored severity the banner has no variant for,
poll the site settings every minute to match the endpoint's cache, fix
the changelog issue link, and cover SettingsUpdateChannel.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SettingsJson, served by both the admin and the public settings
endpoints, now uses camelCase like every other DTO. The stored
setting keys stay kebab-case and are translated in SettingsJson.
The public endpoint returns SettingsJson instead of a raw map.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SettingsService takes PublishingConfig directly instead of going
through MaxExtensionSizeSetting#getCeiling, as it did on main.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SiteSettingsJson carries only the banner properties, so an admin-only
setting cannot reach /api/-/settings by being added to SettingsJson,
and the public schema no longer lists fields it never populates.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The web UI polls at the same interval, so a poll is not answered from
the browser cache.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread webui/src/extension-registry-types.ts Resolved
Write every row an update carries, since the snapshot it is compared
against can be stale on this node. Keep the guaranteed admin settings
fields required in the TypeScript types. Seed the public settings
from the update response instead of refetching an endpoint a browser
or CDN may still hold a cached copy of.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Multi-row saves are non-atomic, unchanged legacy size values can block unrelated updates, and admin routes omit the site-wide banner.

1 open finding
3 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Skip unchanged max-size validation during settings saves

server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​MaxExtensionSizeSetting.java:71

SettingsService validates every registered setting on every save, but this implementation rejects even when the max-size value is unchanged. If the configured override ceiling is lowered below an already stored default, admins can no longer change the banner or read-only flag until they also change the size; the previous implementation validated only when maxExtensionSize was present. Follow WritableSetting.validate’s contract and skip these checks when value equals current.

Medium severity Mount RegistryBanner in the admin dashboard layout

webui/​src/​layout/​app-layout.tsx:110

RegistryBanner is only mounted inside AppLayout, but Main renders /admin/** through the separate AdminDashboard route (webui/src/main.tsx:123-133). Consequently the configured “every page” banner is absent throughout the admin dashboard—including the Settings page whose mutation now seeds this query cache. Mount the banner at a layout level shared by both route trees (while preserving the page-settings override), or add equivalent handling to the admin layout.

🧠 Review effort: Balanced

A multi-row save was committed row by row, so a reader could see a
mixed state, and a failure part way left the update half applied.
SettingsCache#setAll upserts every row at once; the cache is cleared
and the other nodes told only after it returns. The write-order
handling in BannerSetting existed for the per-row commits and goes.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unchanged invalid size settings can block unrelated saves, while stale snapshots and cache normalization can violate banner dismissal and public API semantics.

0 open findings

1 resolved since last review
Previously missed (3)

In code that hasn't changed since last review

Medium severity Validate only settings changed in partial updates

server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​MaxExtensionSizeSetting.java:71

validate runs for every registered setting, including settings omitted from this request. Because this implementation always checks the resolved value, lowering max-override-size below an already-stored default makes every unrelated banner/read-only save fail until the size is edited. Preserve partial-update behavior by skipping validation when this setting did not change, as required by WritableSetting.validate and already done by BannerSetting.

Medium severity Avoid stale snapshots when generating banner dismiss tokens

server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​SettingsService.java:121

Using the minute-cached snapshot here can defeat the server-side “new banner gets a fresh dismiss token” guarantee. For example, after node A clears a message, an admin can read that state from A and submit a new message to node B whose snapshot still contains the old message; dismissIdFor then keeps the old token, so everyone who dismissed the old banner also misses the replacement. Merge token-generating updates against an uncached/current database snapshot in the write transaction (or otherwise make the rotation independent of this stale snapshot).

Medium severity Preserve absent defaults in admin and public settings responses

webui/​src/​pages/​admin-dashboard/​use-settings.ts:41

The admin response contains resolved defaults, whereas the public endpoint intentionally publishes only rows actually stored. Thus, enabling a banner whose severity was never written seeds bannerSeverity: 'info' here, but the next /api/-/settings poll removes that property. This violates SiteSettings' documented absence semantics and makes the exported useSiteSettings result change shape without a settings change. Seed from the previous public value plus the submitted patch, or make the endpoint consistently return resolved defaults.

🧠 Review effort: Balanced

netomi and others added 2 commits October 10, 2026 13:19
A default stored above a ceiling lowered since stays in force until
edited, and no longer blocks saving an unrelated setting. The banner
card now says it is not shown in the admin dashboard.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A save merged against the node-local snapshot, which another node may
already have invalidated, so a new banner could keep the old dismiss
token. It now reads the rows from the store. A published banner also
carries all four properties with defaults filled in, matching what the
admin page seeds after a save.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@netomi

netomi commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the four findings Copilot listed as previously missed:

  • Unchanged max-size validation (28db574): MaxExtensionSizeSetting#validate now returns early when the value equals the current one, so lowering ovsx.publishing.max-override-size below a stored default no longer blocks saving the banner or read-only mode. A changed size is still checked against the ceiling.
  • Banner in the admin dashboard (28db574): not changing this, the banner is intentionally not shown there. The banner card now says "on every page except the admin dashboard".
  • Stale snapshot for dismiss tokens (6fe6311): updateFromJson merges against SettingsCache#load(), which reads the store directly, instead of the node-local cached snapshot. A banner that is new no longer keeps the old dismiss token because this node had not yet seen another node's clear. Two admins saving at the same instant can still race; that would need a lock and is out of scope here.
  • Seeded vs polled shape (6fe6311): a published banner now always carries all four properties, with defaults filled in (severity info, empty dismiss id). The public endpoint therefore matches what the admin page seeds after a save, and SiteSettings is either complete or empty.

Tests were added or updated for each; the stale-snapshot and unchanged-validation tests fail without their fix.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The renderer ignores an explicit disabled flag, and valid Markdown autolinks are rejected as HTML.

0 open findings

Previously missed (2)

In code that hasn't changed since last review

Medium severity Allow valid Markdown autolinks in banner messages

server/​src/​main/​java/​org/​eclipse/​openvsx/​settings/​BannerSetting.java:116

This pattern rejects valid Markdown autolinks such as <https://status.example.org> and <[email protected]> because it treats the first letter after < as an HTML tag opener, even though the UI and API advertise Markdown support. Distinguish actual HTML tokens from Markdown autolinks (for example via parser token inspection) before rejecting the message.

Medium severity Require bannerEnabled before displaying the banner

webui/​src/​components/​registry-banner.tsx:39

bannerEnabled is never consulted, so a response containing { bannerEnabled: false, bannerMessage: "..." } still opens the banner. This also contradicts the defensive handling described above for responses from unknown registries. Require the enabled flag as well as a non-empty message.

🧠 Review effort: Balanced

Banner messages may contain autolinks such as <https://status.example.org>,
which are Markdown rather than HTML; an autolink to a javascript:,
vbscript: or data: destination is still refused. RegistryBanner now
also requires bannerEnabled before opening.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@netomi

netomi commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the two findings Copilot listed as previously missed in its latest review (1d16e4e):

  • Markdown autolinks: the HTML check treated any < followed by a letter as a tag, so <https://status.example.org> and <[email protected]> were refused. Autolinks are now let through; real tags (<a href=...>, <img ...>, <script>, </b>) are still rejected. Because an autolink no longer trips the HTML check, the executable-link rule now also covers <javascript:...>, <vbscript:...> and <data:...>, case-insensitively.
  • bannerEnabled in RegistryBanner: the banner now requires bannerEnabled === true as well as a non-empty message, so a response carrying a message with the switch off no longer opens it. The new spec fails without the check.

Tests were added for both.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It combines a settings persistence refactor, distributed cache invalidation, a public API, and new frontend behavior requiring final human validation.

0 open findings

🧠 Review effort: Balanced

@netomi
netomi merged commit 3791977 into main Oct 10, 2026
6 checks passed
@netomi
netomi deleted the gnugomez/main/allow-admins-to-edit-banner branch October 10, 2026 13:45
gnugomez added a commit that referenced this pull request Oct 15, 2026
When we introduced the per-setting beans in #2257 the idea was to have the settings open for extension and closed for modification, so adding a setting never touches `SettingsService`. We deprecated `isReadOnly()` on the service back then, but the max extension size that came in with #2287 ended up doing exactly the opposite and added `getMaxExtensionSize()` to the service, so we had one getter deprecated and another one alive, and both settings reading the cache from the same bean that encodes and validates them.

This settles that. A setting bean only knows how to encode and decode its rows, and a setting the server needs at runtime gets its own reader (`ReadOnlyMode`, `ExtensionSizeLimitService`) that asks the service for the current value through a package-private `current(setting)`. Everything else injects the reader, the setting beans, their keys and the cache are package-private now, and the getters on the service are gone.

We're also taking the json mapping out of the service. It returns `SettingRows` now and `SettingsJsonMapper`, next to the beans since it's the only place that can see the keys, does the mapping for `AdminAPI` and `SettingsAPI`, so the DTOs don't name any setting codec anymore.

Assisted-By: anthropic:claude-fable-5
gnugomez added a commit that referenced this pull request Oct 15, 2026
When we introduced the per-setting beans in #2257 the idea was to have the settings open for extension and closed for modification, so adding a setting never touches `SettingsService`. We deprecated `isReadOnly()` on the service back then, but the max extension size that came in with #2287 ended up doing exactly the opposite and added `getMaxExtensionSize()` to the service, so we had one getter deprecated and another one alive, and both settings reading the cache from the same bean that encodes and validates them.

This settles that. A setting bean only knows how to encode and decode its rows, and a setting the server needs at runtime gets its own reader (`ReadOnlyMode`, `ExtensionSizeLimitService`) that asks the service for the current value through a package-private `current(setting)`. Everything else injects the reader, the setting beans, their keys and the cache are package-private now, and the getters on the service are gone.

We're also taking the json mapping out of the service. It returns `SettingRows` now and `SettingsJsonMapper`, next to the beans since it's the only place that can see the keys, does the mapping for `AdminAPI` and `SettingsAPI`, so the DTOs don't name any setting codec anymore.

Assisted-By: anthropic:claude-fable-5
netomi added a commit that referenced this pull request Oct 16, 2026
* chore: read site settings through per-setting reader beans

When we introduced the per-setting beans in #2257 the idea was to have the settings open for extension and closed for modification, so adding a setting never touches `SettingsService`. We deprecated `isReadOnly()` on the service back then, but the max extension size that came in with #2287 ended up doing exactly the opposite and added `getMaxExtensionSize()` to the service, so we had one getter deprecated and another one alive, and both settings reading the cache from the same bean that encodes and validates them.

This settles that. A setting bean only knows how to encode and decode its rows, and a setting the server needs at runtime gets its own reader (`ReadOnlyMode`, `ExtensionSizeLimitService`) that asks the service for the current value through a package-private `current(setting)`. Everything else injects the reader, the setting beans, their keys and the cache are package-private now, and the getters on the service are gone.

We're also taking the json mapping out of the service. It returns `SettingRows` now and `SettingsJsonMapper`, next to the beans since it's the only place that can see the keys, does the mapping for `AdminAPI` and `SettingsAPI`, so the DTOs don't name any setting codec anymore.

Assisted-By: anthropic:claude-fable-5

* chore: rename ReadOnlyMode to ReadOnlyModeService

* chore: update ReadOnlyMode references to ReadOnlyModeService

* chore: let a setting read its own value from the settings store

A setting the server consults exposes its own accessor over the cached
snapshot, so the reader beans go, SettingsCache becomes the public
SettingsStore, and each consulted setting moves into a package of its own.

* chore: read settings through their own accessors

The previous commit captured only the file moves. This is the change
itself: ReadOnlySetting.isEnabled() and MaxExtensionSizeSetting.getValue()
over the public SettingsStore, the reader beans and SettingsService.current
removed, callers injecting the setting, and the tests using the key
constants.

* chore: keep the settings in one package and guard every *API mutation

Move the settings out of the readonly and extensionsize subpackages back
into settings, which shrinks the change and lets SettingsStore stay
package-private.

ReadOnlyEndpointAspect only matched RegistryAPI, UserAPI and the admin
package, so the TrustedPublishingAPI mutations ran in read-only mode.
Match every class named *API instead, and add a test that every
@MutatingOperation is guarded.

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

* docs: add a changelog entry for the read-only trusted publishing fix

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

---------

Co-authored-by: Thomas Neidhart <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Enable admin UI to set up a banner notice

3 participants