Add Prototype Banner settings panel - #2644
Draft
yuechao-qin wants to merge 3 commits into
Draft
Conversation
Banner content comes from the backend instead of a frontend deploy. Banners
are stored in user settings under the `system:web_ui/banners` key as a
newest-first list of `{iso_timestamp: banner_text}`.
Settings -> Prototype Banner (below AI Configuration) saves a new banner,
shows the latest one, and lists the full history. Writes go through
`PATCH /api/users/me/settings`, reads through `GET /api/users/me/settings`.
Prototype scope: `/api/users/me/settings` keys the row by the authenticated
caller, so a banner is visible only to the person who saved it. A
server-pinned route reading the same key for `system:web_ui` makes it global
without client changes beyond the URL.
Requested by Yue Chao Qin <yuechao.qin@shopify.com>
Co-authored-by: Yue Chao Qin <yuechao.qin@shopify.com>
Adds hook-level tests for the settings read/write (query params, both payload shapes, read-modify-write) and panel tests for latest/history rendering, save, error and refresh. Keys history rows by index too, since two banners can share a timestamp. Assisted-By: devx/18a6bbd2-5972-4e08-ad51-c91f9713b20c
The settings endpoint can hand a value back as a JSON string; the tour and onboarding readers already parse before validating. Without it the panel shows no history and, worse, the read-modify-write save overwrites the whole history with a single entry. Assisted-By: devx/18a6bbd2-5972-4e08-ad51-c91f9713b20c
🎩 PreviewA preview build has been created at: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves banner text from the backend instead of a frontend deploy, as a prototype: Settings → Prototype Banner saves a banner, shows the latest one, and lists the history.
Banners live in user settings under one key,
system:web_ui/banners, as a newest-first list of{iso_timestamp: text}. No backend change and no migration —user_idis just a string column, so the namespace is the virtual user.How it works
sequenceDiagram participant P as Prototype Banner panel participant H as usePrototypeBanners / useSavePrototypeBanner participant A as /api/users/me/settings P->>H: save("runs are delayed") H->>A: GET ?setting_names=system:web_ui/banners A-->>H: current list (object or JSON string) H->>H: parse, prepend {now: text}, sort newest-first H->>A: PATCH { settings: { "system:web_ui/banners": [...] } } H-->>P: new list → latest + historySave is read-modify-write because the settings
PATCHmerges top-level keys only; a blind write would drop banners saved elsewhere. The stored value is parsed when it comes back as a JSON string, the same waytourCompletion.tsandonboardingProgress.tsdo it.Prototype scope
/api/users/me/settingskeys the row by the authenticated caller, so a banner is visible only to the person who saved it. Making it global needs a server-pinned/api/system_settingsroute reading the same key forsystem:web_ui— no client change beyond the URL. The panel is intentionally ungated, so it shows for every user.Original patch by River; tests and the JSON-string fix added on top.