You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XAML: extract a shared dismissible-notification helper #213
Three notification modules implement the same "show a notification with a Don't show again action, persist the dismissal in globalState" pattern with near-identical code:
src/xaml/csharpDevKitNotification.ts
src/xaml/degradedNotification.ts
src/xaml/projectRestoreNotification.ts
Each has its own state key handling, its own dismissal action wiring, and its own test file covering the same mechanics. A fourth such notification would mean a fourth copy.
Suggested work:
Extract a shared helper (e.g. showDismissibleNotification({ key, message, actions, memento })) that owns the globalState read/write and the "Don't show again" action.
Reduce the three modules to their message/action specifics.
Collapse the duplicated portions of the corresponding tests.
Implemented in PR #50 (1fd5dc5), but scoped differently than described here. Two corrections to the premise, since they changed what was worth building.
projectRestoreNotification.ts does not belong in this list. It has no persisted dismissal, no globalState key, and no "Don't Show Again" action. It gates on a session-scoped Set of already-prompted project paths, which is deliberate: a restore prompt should return after a reload if packages are still missing. There is nothing to share, and folding it in would have meant giving it a persistence concept it should not have.
degradedNotification.ts shares the flag but not the notification. It does persist a dismissal for the missing-runtime case, but the surrounding shape is different: a multi-action model (url / command / fallbackCommand / commandArg / showOutput) and suppression driven by cause transitions rather than dismissal alone. A generic showDismissibleNotification({ key, message, actions, memento }) would not have fit it, so the two call sites would have diverged immediately.
So the shared part is narrower than the issue assumed: it is the persisted flag, not the presentation. What was actually duplicated is the globalState.get<boolean>(key, false) / globalState.update(key, true) pair, inlined at four sites in xamlLanguageService.ts, plus an ?? false / ?? Promise.resolve() fallback repeated wherever the ExtensionContext was optional.
The fix extracts notificationDismissal(key, store) returning { isDismissed, dismiss() }, with a DismissalStore interface that globalState satisfies structurally, and routes the Dev Kit recommendation and the degraded runtime warning through it. Both keep their own message and action handling.
One thing worth flagging for anyone adding tests here: test:unit lists test files explicitly rather than globbing, so a new test file runs zero tests until it is added to that list. The new file initially passed silently for exactly that reason. Extension suite is 1,119 passing (was 1,114).
A fourth instance of the full pattern does exist, in extension.ts (winapp.manifestEditorNotificationDismissed), but it predates this PR and was left alone to keep the diff scoped.
Activity
Share the persisted notification-dismissal flag
chiaramooney commentedon Sep 8, 2026
Implemented in PR #50 (
1fd5dc5), but scoped differently than described here. Two corrections to the premise, since they changed what was worth building.projectRestoreNotification.tsdoes not belong in this list. It has no persisted dismissal, noglobalStatekey, and no "Don't Show Again" action. It gates on a session-scopedSetof already-prompted project paths, which is deliberate: a restore prompt should return after a reload if packages are still missing. There is nothing to share, and folding it in would have meant giving it a persistence concept it should not have.degradedNotification.tsshares the flag but not the notification. It does persist a dismissal for the missing-runtime case, but the surrounding shape is different: a multi-action model (url/command/fallbackCommand/commandArg/showOutput) and suppression driven by cause transitions rather than dismissal alone. A genericshowDismissibleNotification({ key, message, actions, memento })would not have fit it, so the two call sites would have diverged immediately.So the shared part is narrower than the issue assumed: it is the persisted flag, not the presentation. What was actually duplicated is the
globalState.get<boolean>(key, false)/globalState.update(key, true)pair, inlined at four sites inxamlLanguageService.ts, plus an?? false/?? Promise.resolve()fallback repeated wherever theExtensionContextwas optional.The fix extracts
notificationDismissal(key, store)returning{ isDismissed, dismiss() }, with aDismissalStoreinterface thatglobalStatesatisfies structurally, and routes the Dev Kit recommendation and the degraded runtime warning through it. Both keep their own message and action handling.One thing worth flagging for anyone adding tests here:
test:unitlists test files explicitly rather than globbing, so a new test file runs zero tests until it is added to that list. The new file initially passed silently for exactly that reason. Extension suite is 1,119 passing (was 1,114).A fourth instance of the full pattern does exist, in
extension.ts(winapp.manifestEditorNotificationDismissed), but it predates this PR and was left alone to keep the diff scoped.