Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/authenticated-user-storage/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `getAssetsWatchlist` returns the assets-watchlist blob or `null` on 404, mirroring `getNotificationPreferences`.
- `setAssetsWatchlist` writes the full blob and enforces a maximum of `ASSETS_WATCHLIST_MAX_ASSETS` (100) assets before sending the request, via a superstruct `size` constraint on the write-side schema.

### Changed

- **BREAKING:** Add required `agenticCli` field to `NotificationPreferences`, along with the `AgenticCliPreference` type and `NotificationPreferencesSchema` validation for Agentic CLI notification preferences ([#8933](https://github.com/MetaMask/core/pull/8933))

## [2.0.0]

### Changed
Expand Down
1 change: 1 addition & 0 deletions packages/authenticated-user-storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type {
PerpsWatchlistMarkets,
PerpsPreference,
SocialAIPreference,
AgenticCliPreference,
NotificationPreferences,
AssetsWatchlistBlob,
ClientType,
Expand Down
6 changes: 6 additions & 0 deletions packages/authenticated-user-storage/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export type WalletActivityAccount = {
enabled: boolean;
};

export type AgenticCliPreference = {
inAppNotificationsEnabled: boolean;
pushNotificationsEnabled: boolean;
};

export type WalletActivityPreference = {
inAppNotificationsEnabled: boolean;
pushNotificationsEnabled: boolean;
Expand Down Expand Up @@ -109,6 +114,7 @@ export type NotificationPreferences = {
marketing: MarketingPreference;
perps: PerpsPreference;
socialAI: SocialAIPreference;
agenticCli: AgenticCliPreference;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Validation schema missing new agenticCli field

High Severity

The NotificationPreferences type now requires agenticCli, but NotificationPreferencesSchema in validators.ts was not updated to include a corresponding agenticCli field. The assertNotificationPreferences function uses this schema to validate API responses, then asserts the data is NotificationPreferences. This means API data missing agenticCli will pass validation, yet downstream code will trust it's present — causing runtime undefined access errors.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a732e09. Configure here.

};

// ---------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions packages/authenticated-user-storage/src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ const SocialAIPreferenceSchema = type({
mutedTraderProfileIds: array(string()),
});

const AgenticCliPreferenceSchema = type({
inAppNotificationsEnabled: boolean(),
pushNotificationsEnabled: boolean(),
});

const NotificationPreferencesSchema = type({
walletActivity: WalletActivityPreferenceSchema,
marketing: MarketingPreferenceSchema,
perps: PerpsPreferenceSchema,
socialAI: SocialAIPreferenceSchema,
agenticCli: AgenticCliPreferenceSchema,
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export const MOCK_NOTIFICATION_PREFERENCES: NotificationPreferences = {
'e8f2a1b3-5c4d-4e6f-8a9b-2c3d4e5f6a7b',
],
},
agenticCli: {
inAppNotificationsEnabled: true,
pushNotificationsEnabled: false,
},
};

export const MOCK_ASSETS_WATCHLIST_BLOB: AssetsWatchlistBlob = {
Expand Down
4 changes: 4 additions & 0 deletions packages/notification-services-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `DEFAULT_AGENTIC_CLI_PREFERENCES` and initialize `agenticCli` when building fresh notification preferences via `NotificationServicesController` ([#8933](https://github.com/MetaMask/core/pull/8933))

## [24.1.2]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from './mocks/mock-feature-announcements';
import { createMockNotificationEthSent } from './mocks/mock-raw-notifications';
import {
DEFAULT_AGENTIC_CLI_PREFERENCES,
DEFAULT_PERPS_PREFERENCES,
DEFAULT_SOCIAL_AI_PREFERENCES,
NotificationServicesController,
Expand Down Expand Up @@ -105,6 +106,10 @@ const prefsFromAddresses = (
pushNotificationsEnabled: true,
mutedTraderProfileIds: [],
},
agenticCli: {
inAppNotificationsEnabled: true,
pushNotificationsEnabled: true,
},
});

const prefsFromAddressesWithMarketingInAppNotifications = (
Expand Down Expand Up @@ -565,6 +570,7 @@ describe('NotificationServicesController', () => {
},
perps: { ...DEFAULT_PERPS_PREFERENCES },
socialAI: { ...DEFAULT_SOCIAL_AI_PREFERENCES },
agenticCli: { ...DEFAULT_AGENTIC_CLI_PREFERENCES },
});
expect(mockEnablePushNotifications).toHaveBeenCalledWith([
ADDRESS_1.toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
AgenticCliPreference,
AuthenticatedUserStorageServiceGetNotificationPreferencesAction,
AuthenticatedUserStorageServicePutNotificationPreferencesAction,
NotificationPreferences,
Expand Down Expand Up @@ -244,6 +245,15 @@ export const DEFAULT_SOCIAL_AI_PREFERENCES: Required<SocialAIPreference> = {
mutedTraderProfileIds: [],
};

/**
* Hardcoded default Agentic CLI notification preferences. Applied when
* notification preferences are initialized for the first time.
*/
export const DEFAULT_AGENTIC_CLI_PREFERENCES: AgenticCliPreference = {
inAppNotificationsEnabled: true,
pushNotificationsEnabled: true,
};

/**
* Builds wallet-activity preferences from the keyring's current accounts.
*
Expand Down Expand Up @@ -325,6 +335,7 @@ const buildFreshPreferences = (
},
perps: { ...DEFAULT_PERPS_PREFERENCES },
socialAI: { ...DEFAULT_SOCIAL_AI_PREFERENCES },
agenticCli: { ...DEFAULT_AGENTIC_CLI_PREFERENCES },
});

const MESSENGER_EXPOSED_METHODS = [
Expand Down
1 change: 1 addition & 0 deletions packages/notification-services-controller/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * as NotificationServicesController from './NotificationServicesController';
export * as NotificationServicesPushController from './NotificationServicesPushController';
export {
DEFAULT_AGENTIC_CLI_PREFERENCES,
DEFAULT_PERPS_PREFERENCES,
DEFAULT_SOCIAL_AI_PREFERENCES,
} from './NotificationServicesController';
Loading