Skip to content

Auth/pm 19877/notification processing #15611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

Patrick-Pimentel-Bitwarden
Copy link
Contributor

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden commented Jul 14, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-19877

📔 Objective

These changes lay the foundation and support it in the platform domain to do operating system notifications.

  • Renamed notification service to server-notification service.
  • Created an actions service to provide the ability to open the popup.
  • Renamed isViewOpen to clearer isPopupOpen for a clearer api.
  • Made marks to deprecate the openPopup as it's moving to a new service.
  • Created system notification service.

📸 Screenshots

Open Popup

The actions service working in Chrome. Code that demonstrated this was removed.

Chrome.Working.mov

System Notifications

The notifications service working in Chrome. Code that demonstrated this was removed.

Chrome.Notifications.Working.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Jul 15, 2025

Logo
Checkmarx One – Scan Summary & Detailsbf4f04db-ce55-4ab6-80e4-ab092530cae3

Great job, no security vulnerabilities found in this Pull Request

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

❌ Patch coverage is 14.54545% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.83%. Comparing base (fe1c040) to head (0d1d08b).
⚠️ Report is 22 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tifications/browser-system-notification.service.ts 14.81% 23 Missing ⚠️
...er/src/platform/actions/browser-actions.service.ts 21.05% 15 Missing ⚠️
apps/browser/src/background/main.background.ts 23.07% 10 Missing ⚠️
apps/browser/src/popup/services/services.module.ts 0.00% 6 Missing ⚠️
...ations/unsupported-system-notifications.service.ts 0.00% 6 Missing ⚠️
apps/web/src/app/app.component.ts 0.00% 4 Missing ⚠️
libs/angular/src/services/jslib-services.module.ts 0.00% 4 Missing ⚠️
apps/browser/src/background/idle.background.ts 0.00% 3 Missing ⚠️
apps/browser/src/background/runtime.background.ts 0.00% 3 Missing ⚠️
...form/notifications/system-notifications-service.ts 0.00% 3 Missing ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15611      +/-   ##
==========================================
+ Coverage   37.59%   37.83%   +0.23%     
==========================================
  Files        3322     3316       -6     
  Lines       94923    94081     -842     
  Branches    14361    14253     -108     
==========================================
- Hits        35687    35596      -91     
+ Misses      57738    56986     -752     
- Partials     1498     1499       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ntation - Minor changes to popup logic and removed content in login component.
…ntation - Trying to have the notification present to prompt the browser extension to popup
…ntation - Giving up on safari. Getting the code ready for review now.
Comment on lines +22 to +26
"build:nonprod:chrome": "cross-env npm run build:chrome",
"build:nonprod:edge": "cross-env npm run build:edge",
"build:nonprod:firefox": "cross-env npm run build:firefox",
"build:nonprod:opera": "cross-env npm run build:opera",
"build:nonprod:safari": "cross-env npm run build:safari",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added these to prevent the minification of the source code when being built. Is there a better way to do this or is this okay?

Copy link
Member

Choose a reason for hiding this comment

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

These aren't doing anything special than running their underlying command unless I am missing something?

switch (this.platformUtilsService.getDevice()) {
case DeviceType.ChromeExtension:
chrome.notifications.create(createInfo.id, {
iconUrl: "https://avatars.githubusercontent.com/u/15990069?s=200",
Copy link
Contributor Author

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden Jul 23, 2025

Choose a reason for hiding this comment

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

This is a placeholder for a bitwarden icon in the notification. Justin could you provide some guidance on how I could reference an image here for the notification? I imagine referencing an asset would probably be better.

…tation - Fixed renaming of private member variable notificationsService to serverNotificationsService.
…ntation - Removed unnecessary private member variable.
Comment on lines +22 to +26
"build:nonprod:chrome": "cross-env npm run build:chrome",
"build:nonprod:edge": "cross-env npm run build:edge",
"build:nonprod:firefox": "cross-env npm run build:firefox",
"build:nonprod:opera": "cross-env npm run build:opera",
"build:nonprod:safari": "cross-env npm run build:safari",
Copy link
Member

Choose a reason for hiding this comment

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

These aren't doing anything special than running their underlying command unless I am missing something?

@@ -27,6 +32,15 @@
"dist:firefox:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:firefox",
"dist:opera:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:opera",
"dist:safari:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:safari",
"dist:chrome:nonprod": "npm run build:nonprod:chrome && mkdir -p dist && ./scripts/compress.sh dist-chrome.zip",
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case for doing a non-prod dist build over doing the npm run build:watch:{chrome|firefox|edge|opera|safari} those should have source maps and auto recompile when you make changes.

@@ -9,7 +9,7 @@ import {
VaultTimeoutSettingsService,
VaultTimeoutStringType,
} from "@bitwarden/common/key-management/vault-timeout";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/notifications";
Copy link
Member

Choose a reason for hiding this comment

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

We should change the import location as well.

Suggested change
import { ServerNotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";

Comment on lines +1139 to +1143
if ((isChrome || isFirefox) && !isSafari) {
this.systemNotificationService = new BrowserSystemNotificationService(
this.logService,
this.platformUtilsService,
);
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if a more direct heuristic would work here instead? Like "notifications" in chrome. If ever possible I prefer to not rely on direct client type checks and instead rely on the more core system being requested.

If we can't do that though I don't see the value in having the !isSafari check. the isChrome || isFirefox is enough to know that Safari won't use the supported version.

Copy link
Member

Choose a reason for hiding this comment

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

There should still be a . before the service in the file name instead of a -.

Copy link
Member

Choose a reason for hiding this comment

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

Same here with . before service instead of -.


export type SystemNotificationEvent = {
id: string;
type: ButtonActionsKeys;
Copy link
Member

Choose a reason for hiding this comment

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

I'm leaning towards not having any type now that I've read the docs a bit more. I think the id can be used well enough and it plays nicer with a recommendation I have about changing the listeners later on.

*/
export abstract class SystemNotificationsService {
abstract notificationClicked$: Observable<SystemNotificationEvent>;
abstract create(createInfo: SystemNotificationCreateInfo): Promise<undefined>;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should return the notification id back to them that way if they left it off they will get the one that was automatically generated for them?

};

export type SystemNotificationCreateInfo = {
id: string;
Copy link
Member

Choose a reason for hiding this comment

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

This can be optional right?

Copy link

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.

2 participants