Repository: toeverything/AFFiNE
Pull request #12530: fix(electron): optimize meeting privacy settings
Author: login: pengx17
Labels: name: mod:i18n
description: Related to i18n
name: app:electron
description: Related to electron app
name: app:core
Created: 2025-05-26T07:22:07Z | Merged: 2025-05-27T11:21:30Z



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for requesting screen recording permission on macOS alongside microphone permission.
  - Introduced a "Permission issues" section in meeting privacy settings with a button to restart the app for refreshing permissions.
- **Improvements**
  - Unified permission handling for screen and microphone settings, streamlining user interactions.
  - Added localized strings to improve clarity on permission issues and app restart guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/packages/frontend/apps/electron/src/main/recording/feature.ts b/packages/frontend/apps/electron/src/main/recording/feature.ts
index d5926cd71766e..649d7980106eb 100644
--- a/packages/frontend/apps/electron/src/main/recording/feature.ts
+++ b/packages/frontend/apps/electron/src/main/recording/feature.ts
@@ -471,6 +471,21 @@ function setupMediaListeners() {
   );
 }
 
+function askForScreenRecordingPermission() {
+  if (!isMacOS()) {
+    return false;
+  }
+  try {
+    const ShareableContent = require('@affine/native').ShareableContent;
+    // this will trigger the permission prompt
+    new ShareableContent();
+    return true;
+  } catch (error) {
+    logger.error('failed to ask for screen recording permission', error);
+  }
+  return false;
+}
+
 // will be called when the app is ready or when the user has enabled the recording feature in settings
 export function setupRecordingFeature() {
   if (!MeetingsSettingsState.value.enabled || !checkCanRecordMeeting()) {
@@ -788,10 +803,15 @@ export const checkMeetingPermissions = () => {
   ) as Record<(typeof mediaTypes)[number], boolean>;
 };
 
-export const askForMeetingPermission = async (type: 'microphone') => {
+export const askForMeetingPermission = async (
+  type: 'microphone' | 'screen'
+) => {
   if (!isMacOS()) {
     return false;
   }
+  if (type === 'screen') {
+    return askForScreenRecordingPermission();
+  }
   return systemPreferences.askForMediaAccess(type);
 };
 
diff --git a/packages/frontend/apps/electron/src/main/recording/index.ts b/packages/frontend/apps/electron/src/main/recording/index.ts
index 3a98935256341..20dc99de1f863 100644
--- a/packages/frontend/apps/electron/src/main/recording/index.ts
+++ b/packages/frontend/apps/electron/src/main/recording/index.ts
@@ -77,18 +77,17 @@ export const recordingHandlers = {
   checkMeetingPermissions: async () => {
     return checkMeetingPermissions();
   },
-  askForMeetingPermission: async (_, type: 'microphone') => {
+  askForMeetingPermission: async (_, type: 'screen' | 'microphone') => {
     return askForMeetingPermission(type);
   },
   showRecordingPermissionSetting: async (_, type: 'screen' | 'microphone') => {
-    const urlMap = {
-      screen: 'Privacy_ScreenCapture',
-      microphone: 'Privacy_Microphone',
-    };
     if (isMacOS()) {
-      return shell.openExternal(
-        `x-apple.systempreferences:com.apple.preference.security?${urlMap[type]}`
-      );
+      const urlMap = {
+        screen: 'Privacy_ScreenCapture',
+        microphone: 'Privacy_Microphone',
+      };
+      const url = `x-apple.systempreferences:com.apple.preference.security?${urlMap[type]}`;
+      return shell.openExternal(url);
     }
     // this only available on MacOS
     return false;
diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx
index bae5bec61035e..d6ba6fa6a587e 100644
--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx
+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx
@@ -1,4 +1,5 @@
 import {
+  Button,
   IconButton,
   Menu,
   MenuItem,
@@ -11,6 +12,7 @@ import {
   SettingWrapper,
 } from '@affine/component/setting-components';
 import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
+import { DesktopApiService } from '@affine/core/modules/desktop-api';
 import { MeetingSettingsService } from '@affine/core/modules/media/services/meeting-settings';
 import type { MeetingSettingsSchema } from '@affine/electron/main/shared-state-schema';
 import { Trans, useI18n } from '@affine/i18n';
@@ -133,6 +135,7 @@ const PermissionSettingRow = ({
 const MeetingsSettingsMain = () => {
   const t = useI18n();
   const meetingSettingsService = useService(MeetingSettingsService);
+  const desktopApiService = useService(DesktopApiService);
   const settings = useLiveData(meetingSettingsService.settings$);
   const [recordingFeatureAvailable, setRecordingFeatureAvailable] =
     useState(false);
@@ -175,26 +178,22 @@ const MeetingsSettingsMain = () => {
     [meetingSettingsService]
   );
 
-  const handleOpenScreenRecordingPermissionSetting =
-    useAsyncCallback(async () => {
-      await meetingSettingsService.showRecordingPermissionSetting('screen');
-    }, [meetingSettingsService]);
-
-  const handleOpenMicrophoneRecordingPermissionSetting =
-    useAsyncCallback(async () => {
-      const result =
-        await meetingSettingsService.askForMeetingPermission('microphone');
-      if (!result) {
-        await meetingSettingsService.showRecordingPermissionSetting(
-          'microphone'
-        );
-      }
-    }, [meetingSettingsService]);
+  const handleOpenPermissionSetting = useAsyncCallback(
+    async (type: 'screen' | 'microphone') => {
+      await meetingSettingsService.askForMeetingPermission(type);
+      await meetingSettingsService.showRecordingPermissionSetting(type);
+    },
+    [meetingSettingsService]
+  );
 
   const handleOpenSavedRecordings = useAsyncCallback(async () => {
     await meetingSettingsService.openSavedRecordings();
   }, [meetingSettingsService]);
 
+  const handleRestartApp = useAsyncCallback(async () => {
+    await desktopApiService.handler.ui.restartApp();
+  }, [desktopApiService]);
+
   return (
     <div className={styles.meetingWrapper}>
       <SettingHeader
@@ -304,8 +303,8 @@ const MeetingsSettingsMain = () => {
               descriptionKey="com.affine.settings.meetings.privacy.screen-system-audio-recording.description"
               permissionSettingKey="com.affine.settings.meetings.privacy.screen-system-audio-recording.permission-setting"
               hasPermission={permissions?.screen || false}
-              onOpenPermissionSetting={
-                handleOpenScreenRecordingPermissionSetting
+              onOpenPermissionSetting={() =>
+                handleOpenPermissionSetting('screen')
               }
             />
             <PermissionSettingRow
@@ -313,11 +312,23 @@ const MeetingsSettingsMain = () => {
               descriptionKey="com.affine.settings.meetings.privacy.microphone.description"
               permissionSettingKey="com.affine.settings.meetings.privacy.microphone.permission-setting"
               hasPermission={permissions?.microphone || false}
-              onOpenPermissionSetting={
-                handleOpenMicrophoneRecordingPermissionSetting
+              onOpenPermissionSetting={() =>
+                handleOpenPermissionSetting('microphone')
               }
             />
           </SettingWrapper>
+          <SettingWrapper>
+            <SettingRow
+              name={t['com.affine.settings.meetings.privacy.issues']()}
+              desc={t[
+                'com.affine.settings.meetings.privacy.issues.description'
+              ]()}
+            >
+              <Button onClick={handleRestartApp}>
+                {t['com.affine.settings.meetings.privacy.issues.restart']()}
+              </Button>
+            </SettingRow>
+          </SettingWrapper>
         </>
       )}
     </div>
diff --git a/packages/frontend/core/src/modules/media/services/meeting-settings.ts b/packages/frontend/core/src/modules/media/services/meeting-settings.ts
index 2e8b49ac8a8b6..01a0aff33b139 100644
--- a/packages/frontend/core/src/modules/media/services/meeting-settings.ts
+++ b/packages/frontend/core/src/modules/media/services/meeting-settings.ts
@@ -130,7 +130,7 @@ export class MeetingSettingsService extends Service {
     );
   }
 
-  async askForMeetingPermission(type: 'microphone') {
+  async askForMeetingPermission(type: 'microphone' | 'screen') {
     return this.desktopApiService?.handler.recording.askForMeetingPermission(
       type
     );
diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.ts
index a7a315340de58..8eecc451b09ea 100644
--- a/packages/frontend/i18n/src/i18n.gen.ts
+++ b/packages/frontend/i18n/src/i18n.gen.ts
@@ -5598,6 +5598,18 @@ export function useAFFiNEI18N(): {
       * `Click to allow`
       */
     ["com.affine.settings.meetings.privacy.microphone.permission-setting"](): string;
+    /**
+      * `Permission issues`
+      */
+    ["com.affine.settings.meetings.privacy.issues"](): string;
+    /**
+      * `Permissions are granted but the status isn't updated? Restart the app to refresh permissions.`
+      */
+    ["com.affine.settings.meetings.privacy.issues.description"](): string;
+    /**
+      * `Restart App`
+      */
+    ["com.affine.settings.meetings.privacy.issues.restart"](): string;
     /**
       * `Do nothing`
       */
diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json
index f17b57b5afda1..b1eadc8b0b98b 100644
--- a/packages/frontend/i18n/src/resources/en.json
+++ b/packages/frontend/i18n/src/resources/en.json
@@ -1398,6 +1398,9 @@
   "com.affine.settings.meetings.privacy.microphone": "Microphone",
   "com.affine.settings.meetings.privacy.microphone.description": "The Meeting feature requires permission to be used.",
   "com.affine.settings.meetings.privacy.microphone.permission-setting": "Click to allow",
+  "com.affine.settings.meetings.privacy.issues": "Permission issues",
+  "com.affine.settings.meetings.privacy.issues.description": "Permissions are granted but the status isn't updated? Restart the app to refresh permissions.",
+  "com.affine.settings.meetings.privacy.issues.restart": "Restart App",
   "com.affine.settings.meetings.record.recording-mode.none": "Do nothing",
   "com.affine.settings.meetings.record.recording-mode.auto-start": "Auto start recording",
   "com.affine.settings.meetings.record.recording-mode.prompt": "Show a recording prompt",


Reviews:
user: login: graphite-app[bot]
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-26T07:23:30Z
user: login: forehalo
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-26T08:39:14Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>♻️ Duplicate comments (2)</summary><blockquote>

<details>
<summary>packages/frontend/apps/electron/src/main/recording/feature.ts (1)</summary><blockquote>

`474-487`: **Consider using ES6 import syntax for consistency.**

The function correctly implements screen recording permission request logic, but it uses the `require()` pattern that was previously flagged for consistency issues.



The implementation should use ES6 import syntax to match the codebase standards:

```diff
-function askForScreenRecordingPermission() {
-  if (!isMacOS()) {
-    return false;
-  }
-  try {
-    const ShareableContent = require('@affine/native').ShareableContent;
-    // this will trigger the permission prompt
-    new ShareableContent();
-    return true;
-  } catch (error) {
-    logger.error('failed to ask for screen recording permission', error);
-  }
-  return false;
-}
+function askForScreenRecordingPermission() {
+  if (!isMacOS()) {
+    return false;
+  }
+  try {
+    // this will trigger the permission prompt
+    new ShareableContent();
+    return true;
+  } catch (error) {
+    logger.error('failed to ask for screen recording permission', error);
+  }
+  return false;
+}
```

Note: You'll need to update the existing import at line 7 to import the actual `ShareableContent` class instead of just the type.

</blockquote></details>
<details>
<summary>packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx (1)</summary><blockquote>

`181-187`: **Consider preserving previous behavior by conditionally opening settings.**

The current implementation unconditionally opens system settings after requesting permissions, which may provide a suboptimal user experience when permissions are already granted.



As suggested in the previous review, consider only opening settings when permission is denied:

```diff
-  const handleOpenPermissionSetting = useAsyncCallback(
-    async (type: 'screen' | 'microphone') => {
-      await meetingSettingsService.askForMeetingPermission(type);
-      await meetingSettingsService.showRecordingPermissionSetting(type);
-    },
-    [meetingSettingsService]
-  );
+  const handleOpenPermissionSetting = useAsyncCallback(
+    async (type: 'screen' | 'microphone') => {
+      const result = await meetingSettingsService.askForMeetingPermission(type);
+      if (!result) {
+        await meetingSettingsService.showRecordingPermissionSetting(type);
+      }
+    },
+    [meetingSettingsService]
+  );
```

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>packages/frontend/i18n/src/resources/en.json (1)</summary><blockquote>

`1391-1391`: **Nit: refine the description text for clarity**  
The current phrase reads as a question; consider rephrasing for grammatical consistency, e.g.:  
"Permissions are granted, but the status isn't updated. Restart the app to refresh permissions."

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between bfe743b68bbce3bf3b4c4ea4756f7ef2a4436db0 and 701c18d5246d9e1455c1fdd24439ce86c669c873.

</details>

<details>
<summary>📒 Files selected for processing (6)</summary>

* `packages/frontend/apps/electron/src/main/recording/feature.ts` (2 hunks)
* `packages/frontend/apps/electron/src/main/recording/index.ts` (1 hunks)
* `packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx` (5 hunks)
* `packages/frontend/core/src/modules/media/services/meeting-settings.ts` (1 hunks)
* `packages/frontend/i18n/src/i18n.gen.ts` (1 hunks)
* `packages/frontend/i18n/src/resources/en.json` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>packages/frontend/apps/electron/src/main/recording/feature.ts (1)</summary><blockquote>

<details>
<summary>packages/frontend/core/src/modules/media/services/meeting-settings.ts (1)</summary>

* `askForMeetingPermission` (133-137)

</details>

</blockquote></details>
<details>
<summary>packages/frontend/apps/electron/src/main/recording/index.ts (2)</summary><blockquote>

<details>
<summary>packages/frontend/core/src/modules/media/services/meeting-settings.ts (1)</summary>

* `askForMeetingPermission` (133-137)

</details>
<details>
<summary>packages/frontend/apps/electron/src/main/recording/feature.ts (1)</summary>

* `askForMeetingPermission` (806-816)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (81)</summary>

* GitHub Check: Frontend Copilot E2E Test (4, 8)
* GitHub Check: Frontend Copilot E2E Test (8, 8)
* GitHub Check: Frontend Copilot E2E Test (6, 8)
* GitHub Check: Frontend Copilot E2E Test (5, 8)
* GitHub Check: Frontend Copilot E2E Test (3, 8)
* GitHub Check: Frontend Copilot E2E Test (7, 8)
* GitHub Check: Frontend Copilot E2E Test (2, 8)
* GitHub Check: Frontend Copilot E2E Test (1, 8)
* GitHub Check: Cloud E2E Test 4/6
* GitHub Check: Cloud E2E Test 6/6
* GitHub Check: Cloud E2E Test 5/6
* GitHub Check: Cloud E2E Test 3/6
* GitHub Check: Server Copilot Api Test
* GitHub Check: Cloud Desktop E2E Test
* GitHub Check: Cloud E2E Test 1/6
* GitHub Check: Cloud E2E Test 2/6
* GitHub Check: Server Test (6, 8)
* GitHub Check: Server Test (7, 8)
* GitHub Check: Server Test (4, 8)
* GitHub Check: Server Test (3, 8)
* GitHub Check: Server Test (5, 8)
* GitHub Check: Server Test (2, 8)
* GitHub Check: Server Test (1, 8)
* GitHub Check: Server Test (0, 8)
* GitHub Check: Check Git Status
* GitHub Check: Server Test with Elasticsearch
* GitHub Check: Server E2E Test
* GitHub Check: Unit Test (4)
* GitHub Check: Unit Test (5)
* GitHub Check: Unit Test (1)
* GitHub Check: Unit Test (3)
* GitHub Check: Unit Test (2)
* GitHub Check: Native Unit Test
* GitHub Check: test-build-mobile-app / build-ios-web
* GitHub Check: test-build-mobile-app / build-android-web
* GitHub Check: fuzzing
* GitHub Check: y-octo binding test on x86_64-apple-darwin
* GitHub Check: y-octo binding test on aarch64-pc-windows-msvc
* GitHub Check: E2E Test (7)
* GitHub Check: E2E Test (8)
* GitHub Check: E2E Test (9)
* GitHub Check: y-octo binding test on x86_64-pc-windows-msvc
* GitHub Check: Run native tests
* GitHub Check: E2E Test (1)
* GitHub Check: E2E Test (10)
* GitHub Check: E2E Test (6)
* GitHub Check: E2E Test (2)
* GitHub Check: loom thread test
* GitHub Check: E2E BlockSuite Cross Browser Test (1, firefox)
* GitHub Check: E2E Test (3)
* GitHub Check: E2E Test (5)
* GitHub Check: E2E Test (4)
* GitHub Check: E2E BlockSuite Cross Browser Test (2, webkit)
* GitHub Check: E2E BlockSuite Test (9)
* GitHub Check: E2E BlockSuite Cross Browser Test (1, chromium)
* GitHub Check: E2E BlockSuite Cross Browser Test (2, chromium)
* GitHub Check: Build AFFiNE native (x86_64-pc-windows-msvc)
* GitHub Check: E2E BlockSuite Cross Browser Test (2, firefox)
* GitHub Check: E2E BlockSuite Cross Browser Test (1, webkit)
* GitHub Check: E2E BlockSuite Test (10)
* GitHub Check: E2E BlockSuite Test (2)
* GitHub Check: Build AFFiNE native (aarch64-pc-windows-msvc)
* GitHub Check: E2E BlockSuite Test (3)
* GitHub Check: E2E BlockSuite Test (5)
* GitHub Check: E2E BlockSuite Test (4)
* GitHub Check: E2E BlockSuite Test (6)
* GitHub Check: E2E BlockSuite Test (7)
* GitHub Check: E2E BlockSuite Test (8)
* GitHub Check: E2E Mobile Test (2)
* GitHub Check: E2E BlockSuite Test (1)
* GitHub Check: E2E Mobile Test (5)
* GitHub Check: E2E Mobile Test (3)
* GitHub Check: E2E Mobile Test (4)
* GitHub Check: E2E Mobile Test (1)
* GitHub Check: Build @affine/electron renderer
* GitHub Check: Analyze (typescript, blocksuite)
* GitHub Check: Analyze (typescript, affine)
* GitHub Check: Typecheck
* GitHub Check: Analyze (javascript, affine)
* GitHub Check: Lint
* GitHub Check: Analyze (javascript, blocksuite)

</details>

<details>
<summary>🔇 Additional comments (8)</summary><blockquote>

<details>
<summary>packages/frontend/i18n/src/resources/en.json (1)</summary>

`1390-1392`: **Add new localization entries for meeting privacy permission issues**  
The keys follow the established naming convention and the labels/messages clearly guide the user to restart the app when permissions are out of sync.

</details>
<details>
<summary>packages/frontend/core/src/modules/media/services/meeting-settings.ts (1)</summary>

`133-137`: **LGTM! Clean expansion of permission types.**

The method signature correctly expands to support both 'microphone' and 'screen' permission types, maintaining type safety while enabling the new screen recording permission functionality. The implementation properly forwards the permission type to the underlying handler.

</details>
<details>
<summary>packages/frontend/apps/electron/src/main/recording/index.ts (2)</summary>

`80-82`: **LGTM! Consistent type expansion for unified permission handling.**

The handler correctly expands to support both 'screen' and 'microphone' permission types, maintaining consistency with the frontend service changes and enabling the new screen recording permission functionality.

---

`84-94`: **LGTM! Improved code organization and readability.**

The refactoring moves the URL mapping logic inside the macOS platform check, making the code more organized and explicit. The separate URL construction improves readability while maintaining the same functionality.

</details>
<details>
<summary>packages/frontend/apps/electron/src/main/recording/feature.ts (1)</summary>

`806-816`: **LGTM! Clean implementation of unified permission handling.**

The function correctly handles both screen and microphone permission types with appropriate delegation to the specific handlers.

</details>
<details>
<summary>packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx (3)</summary>

`193-195`: **LGTM! Simple and clean restart functionality.**

The restart app handler is correctly implemented with proper async handling and dependency injection.

---

`306-308`: **LGTM! Proper unification of permission handlers.**

The inline arrow functions correctly pass the permission types to the unified handler, maintaining clean separation between screen and microphone permissions.




Also applies to: 315-317

---

`320-331`: **LGTM! Well-structured restart UI section.**

The new restart functionality is properly integrated with localization and provides a clear user action for permission-related issues.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-27T03:46:51Z
user: login: forehalo
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-27T10:57:19Z

Review comments:
diff_hunk: @@ -471,6 +471,21 @@ function setupMediaListeners() {
   );
 }
 
+function askForScreenRecordingPermission() {
+  if (!isMacOS()) {
+    return false;
+  }
+  try {
+    const ShareableContent = require('@affine/native').ShareableContent;
path: packages/frontend/apps/electron/src/main/recording/feature.ts
user: login: graphite-app[bot]
body: Consider using ES6 import syntax instead of CommonJS `require()` for consistency with the codebase's module system. The current implementation:

```js
const ShareableContent = require('@affine/native').ShareableContent;
```

Could be replaced with:

```js
import { ShareableContent } from '@affine/native';
```

This would align with modern JavaScript practices and maintain consistency with the rest of the codebase.
```suggestion
    import { ShareableContent } from '@affine/native';
```
  

*Spotted by [Diamond](https://app.graphite.dev/diamond/?org=toeverything&ref=ai-review-comment) (based on [custom rules](https://app.graphite.dev/diamond/?org=toeverything&ref=ai-review-comment&view=settings))*<i class='graphite__hidden'><br /><br />Is this helpful? React 👍 or 👎 to let us know.</i>
created_at: 2025-05-26T07:23:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -175,21 +175,13 @@ const MeetingsSettingsMain = () => {
     [meetingSettingsService]
   );
 
-  const handleOpenScreenRecordingPermissionSetting =
-    useAsyncCallback(async () => {
-      await meetingSettingsService.showRecordingPermissionSetting('screen');
-    }, [meetingSettingsService]);
-
-  const handleOpenMicrophoneRecordingPermissionSetting =
-    useAsyncCallback(async () => {
-      const result =
-        await meetingSettingsService.askForMeetingPermission('microphone');
-      if (!result) {
-        await meetingSettingsService.showRecordingPermissionSetting(
-          'microphone'
-        );
-      }
-    }, [meetingSettingsService]);
+  const handleOpenPermissionSetting = useAsyncCallback(
+    async (type: 'screen' | 'microphone') => {
+      await meetingSettingsService.askForMeetingPermission(type);
+      await meetingSettingsService.showRecordingPermissionSetting(type);
+    },
+    [meetingSettingsService]
+  );
path: packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx
user: login: graphite-app[bot]
body: The current implementation unconditionally opens system settings after requesting permissions. Consider preserving the previous behavior by only opening settings when permission is denied:

```typescript
async (type: 'screen' | 'microphone') => {
  const result = await meetingSettingsService.askForMeetingPermission(type);
  if (!result) {
    await meetingSettingsService.showRecordingPermissionSetting(type);
  }
}
```

This approach provides a better user experience by avoiding unnecessary navigation to system settings when permissions are already granted.
```suggestion
  const handleOpenPermissionSetting = useAsyncCallback(
    async (type: 'screen' | 'microphone') => {
      const result = await meetingSettingsService.askForMeetingPermission(type);
      if (!result) {
        await meetingSettingsService.showRecordingPermissionSetting(type);
      }
    },
    [meetingSettingsService]
  );
```
  

*Spotted by [Diamond](https://app.graphite.dev/diamond/?org=toeverything&ref=ai-review-comment)*<i class='graphite__hidden'><br /><br />Is this helpful? React 👍 or 👎 to let us know.</i>
created_at: 2025-05-26T07:23:29Z
author_association: CONTRIBUTOR
diff_hunk: @@ -5558,6 +5558,18 @@ export function useAFFiNEI18N(): {
       * `Click to allow`
       */
     ["com.affine.settings.meetings.privacy.microphone.permission-setting"](): string;
+    /**
+      * `Permission issues`
+      */
+    ["com.affine.settings.meetings.privacy.issues"](): string;
+    /**
+      * `Permissions are granted but the status isn't updated? Restart the app to refresh permissions.`
+      */
+    ["com.affine.settings.meetings.privacy.issues.description"](): string;
+    /**
+      * `Restart App`
+      */
+    ["com.affine.settings.meetings.privacy.issues.restart"](): string;
path: packages/frontend/i18n/src/i18n.gen.ts
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Verify new localization keys and maintain ordering.**

The three added keys for meeting-privacy issues look correct, but please ensure they are defined in all locale resource files (e.g., `en.json`, other languages) and double-check that their text matches the JSDoc descriptions here. Additionally, consider keeping these entries alphabetically sorted within `i18n.gen.ts` for easier maintenance.

---

🏁 Script executed:

```shell
#!/bin/bash
# Verify presence of new i18n keys in resource files
rg -n '"com.affine.settings.meetings.privacy.issues(\.description|\.restart)?":' packages/frontend/i18n/src/resources
```

Length of output: 569

---

🏁 Script executed:

```shell
#!/bin/bash
# Verify the new i18n keys exist in every locale JSON
for file in packages/frontend/i18n/src/resources/*.json; do
  echo "Checking ${file##*/}:"
  grep -n '"com.affine.settings.meetings.privacy.issues"' "$file" \
    || echo "  ✗ Missing key: com.affine.settings.meetings.privacy.issues"
  grep -n '"com.affine.settings.meetings.privacy.issues.description"' "$file" \
    || echo "  ✗ Missing key: com.affine.settings.meetings.privacy.issues.description"
  grep -n '"com.affine.settings.meetings.privacy.issues.restart"' "$file" \
    || echo "  ✗ Missing key: com.affine.settings.meetings.privacy.issues.restart"
done
```

Length of output: 20781

---



</details>

**Add missing i18n keys to all locale files and keep entries sorted**

Although the three new keys are present in en.json, they’re currently missing from every other JSON in packages/frontend/i18n/src/resources. Please add these entries (with appropriate translations) to each locale file:

  • com.affine.settings.meetings.privacy.issues  
  • com.affine.settings.meetings.privacy.issues.description  
  • com.affine.settings.meetings.privacy.issues.restart  

Also, ensure the definitions in i18n.gen.ts remain alphabetically ordered.

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In packages/frontend/i18n/src/i18n.gen.ts around lines 5561 to 5572, the three
new i18n keys for meeting privacy issues are correctly added but missing from
all locale JSON resource files except en.json. Add these keys with appropriate
translations to every locale JSON file in packages/frontend/i18n/src/resources,
ensuring the keys are included exactly as named. Also, verify that the entries
in i18n.gen.ts remain alphabetically sorted for easier maintenance.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-27T03:46:50Z
author_association: CONTRIBUTOR

PR comments:
user: login: coderabbitai[bot]
created_at: 2025-05-26T07:22:21Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

The changes introduce explicit handling for screen recording permissions on macOS, unify permission request logic for screen and microphone, and add UI and localization for resolving permission issues by restarting the app. The permission request logic and UI are refactored for clarity, and new localized strings are added for user guidance.

## Changes

| File(s)                                                                                       | Change Summary                                                                                                    |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| .../electron/src/main/recording/feature.ts                                                   | Added `askForScreenRecordingPermission`, updated `askForMeetingPermission` to support 'screen' type.             |
| .../electron/src/main/recording/index.ts                                                     | Updated handler signatures to accept 'screen' or 'microphone'; reorganized permission URL mapping logic.         |
| .../core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx                      | Unified permission handling, added restart app UI/button, refactored callbacks, injected `DesktopApiService`.    |
| .../core/src/modules/media/services/meeting-settings.ts                                      | Expanded `askForMeetingPermission` method to accept 'screen' or 'microphone'.                                    |
| .../i18n/src/i18n.gen.ts                                                                     | Added three new translation keys for meeting privacy permission issues and restart guidance.                      |
| .../i18n/src/resources/en.json                                                               | Added English localization strings for permission issues and restart app button.                                  |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant UI (MeetingsSettingsMain)
    participant MeetingSettingsService
    participant DesktopApiService
    participant ElectronMain

    User->>UI (MeetingsSettingsMain): Clicks permission setting button (screen/microphone)
    UI (MeetingsSettingsMain)->>MeetingSettingsService: askForMeetingPermission(type)
    MeetingSettingsService->>DesktopApiService: handler.recording.askForMeetingPermission(type)
    DesktopApiService->>ElectronMain: askForMeetingPermission(type)
    ElectronMain-->>DesktopApiService: Returns permission result
    DesktopApiService-->>MeetingSettingsService: Returns result
    MeetingSettingsService-->>UI (MeetingsSettingsMain): Returns result
    UI (MeetingsSettingsMain)->>DesktopApiService: handler.recording.showRecordingPermissionSetting(type)
    DesktopApiService->>ElectronMain: showRecordingPermissionSetting(type)
    ElectronMain-->>DesktopApiService: Opens system settings
```

```mermaid
sequenceDiagram
    participant User
    participant UI (MeetingsSettingsMain)
    participant DesktopApiService

    User->>UI (MeetingsSettingsMain): Clicks "Restart App" button
    UI (MeetingsSettingsMain)->>DesktopApiService: restartApp()
    DesktopApiService-->>UI (MeetingsSettingsMain): App restarts
```

## Suggested reviewers

- forehalo

## Poem

> A bunny hops to fix the screen,  
> Permissions clear, the code is clean.  
> With restart now just one click away,  
> Troubles vanish, bright as day.  
> Strings are added, logic neat—  
> This fluffy patch is quite a treat!  
> 🐇✨

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 701c18d5246d9e1455c1fdd24439ce86c669c873 and 4ad008f7122be663ff17a4b431e390015fe24ee7.

</details>

<details>
<summary>📒 Files selected for processing (6)</summary>

* `packages/frontend/apps/electron/src/main/recording/feature.ts` (2 hunks)
* `packages/frontend/apps/electron/src/main/recording/index.ts` (1 hunks)
* `packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx` (5 hunks)
* `packages/frontend/core/src/modules/media/services/meeting-settings.ts` (1 hunks)
* `packages/frontend/i18n/src/i18n.gen.ts` (1 hunks)
* `packages/frontend/i18n/src/resources/en.json` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (5)</summary>

* packages/frontend/apps/electron/src/main/recording/index.ts
* packages/frontend/apps/electron/src/main/recording/feature.ts
* packages/frontend/core/src/modules/media/services/meeting-settings.ts
* packages/frontend/i18n/src/resources/en.json
* packages/frontend/i18n/src/i18n.gen.ts

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (80)</summary>

* GitHub Check: Server Copilot Api Test
* GitHub Check: Cloud E2E Test 4/6
* GitHub Check: Frontend Copilot E2E Test (8, 8)
* GitHub Check: Cloud Desktop E2E Test
* GitHub Check: Frontend Copilot E2E Test (7, 8)
* GitHub Check: Frontend Copilot E2E Test (4, 8)
* GitHub Check: Cloud E2E Test 6/6
* GitHub Check: Frontend Copilot E2E Test (2, 8)
* GitHub Check: Frontend Copilot E2E Test (1, 8)
* GitHub Check: Server Test (3, 8)
* GitHub Check: Frontend Copilot E2E Test (3, 8)
* GitHub Check: Cloud E2E Test 3/6
* GitHub Check: Frontend Copilot E2E Test (5, 8)
* GitHub Check: Cloud E2E Test 1/6
* GitHub Check: Server Test (2, 8)
* GitHub Check: Frontend Copilot E2E Test (6, 8)
* GitHub Check: Server Test (6, 8)
* GitHub Check: Cloud E2E Test 5/6
* GitHub Check: Cloud E2E Test 2/6
* GitHub Check: Server Test (7, 8)
* GitHub Check: Server Test (0, 8)
* GitHub Check: Server Test (4, 8)
* GitHub Check: Server Test (5, 8)
* GitHub Check: Server Test (1, 8)
* GitHub Check: Check Git Status
* GitHub Check: Server E2E Test
* GitHub Check: Server Test with Elasticsearch
* GitHub Check: Unit Test (5)
* GitHub Check: Unit Test (4)
* GitHub Check: Unit Test (2)
* GitHub Check: Unit Test (1)
* GitHub Check: Unit Test (3)
* GitHub Check: test-build-mobile-app / build-android-web
* GitHub Check: test-build-mobile-app / build-ios-web
* GitHub Check: loom thread test
* GitHub Check: y-octo binding test on x86_64-pc-windows-msvc
* GitHub Check: fuzzing
* GitHub Check: E2E BlockSuite Test (9)
* GitHub Check: E2E Test (10)
* GitHub Check: y-octo binding test on aarch64-pc-windows-msvc
* GitHub Check: E2E Test (4)
* GitHub Check: E2E BlockSuite Test (8)
* GitHub Check: E2E BlockSuite Test (4)
* GitHub Check: E2E Test (7)
* GitHub Check: E2E BlockSuite Test (1)
* GitHub Check: Run native tests
* GitHub Check: y-octo binding test on x86_64-apple-darwin
* GitHub Check: E2E BlockSuite Test (10)
* GitHub Check: E2E BlockSuite Test (6)
* GitHub Check: E2E BlockSuite Test (3)
* GitHub Check: E2E Test (3)
* GitHub Check: E2E BlockSuite Test (2)
* GitHub Check: E2E Test (1)
* GitHub Check: E2E BlockSuite Test (7)
* GitHub Check: E2E Test (6)
* GitHub Check: E2E Test (5)
* GitHub Check: E2E BlockSuite Test (5)
* GitHub Check: E2E Test (2)
* GitHub Check: Build @affine/electron renderer
* GitHub Check: Build AFFiNE native (x86_64-pc-windows-msvc)
* GitHub Check: E2E Mobile Test (4)
* GitHub Check: E2E Test (9)
* GitHub Check: E2E Mobile Test (5)
* GitHub Check: Build AFFiNE native (aarch64-pc-windows-msvc)
* GitHub Check: E2E Test (8)
* GitHub Check: Typecheck
* GitHub Check: E2E BlockSuite Cross Browser Test (2, webkit)
* GitHub Check: E2E Mobile Test (1)
* GitHub Check: E2E BlockSuite Cross Browser Test (2, firefox)
* GitHub Check: E2E BlockSuite Cross Browser Test (1, firefox)
* GitHub Check: Analyze (typescript, blocksuite)
* GitHub Check: E2E BlockSuite Cross Browser Test (1, chromium)
* GitHub Check: E2E Mobile Test (2)
* GitHub Check: Analyze (typescript, affine)
* GitHub Check: E2E Mobile Test (3)
* GitHub Check: E2E BlockSuite Cross Browser Test (1, webkit)
* GitHub Check: Analyze (javascript, blocksuite)
* GitHub Check: E2E BlockSuite Cross Browser Test (2, chromium)
* GitHub Check: Lint
* GitHub Check: Analyze (javascript, affine)

</details>

<details>
<summary>🔇 Additional comments (5)</summary><blockquote>

<details>
<summary>packages/frontend/core/src/desktop/dialogs/setting/general-setting/meetings/index.tsx (5)</summary>

`2-2`: **LGTM: Import additions are correctly used.**

The new imports for `Button` and `DesktopApiService` are properly utilized in the component.



Also applies to: 15-15

---

`138-138`: **LGTM: Service injection follows established patterns.**

The `DesktopApiService` injection is consistent with the component's architecture.

---

`193-195`: **LGTM: Restart app functionality is well implemented.**

The async callback properly handles the restart app functionality with correct dependencies.

---

`306-308`: **Clean usage of unified permission handler.**

The inline arrow functions properly utilize the unified `handleOpenPermissionSetting` function with appropriate permission types. However, these inherit the unconditional system settings opening behavior noted in the unified function.



Also applies to: 315-317

---

`320-331`: **Excellent addition for resolving permission issues.**

The new privacy issues section provides a user-friendly way to resolve permission problems through app restart. The implementation follows established UI patterns and uses proper localization.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJB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WwW3W2kyfFkhqjkyaem7k8HJvBVfkrVHVYU3qw1MUk1Qa6MnSz8PEvSJixQP+jwY26pC/bOZpTq8eDMrxbQxoJmlmtmjm2Grm43CGo+KGi3JGhG2NahlGsgF3WW+0zBFhqsgAbQVqrsdpVtrpdobvdoZJbu4OiAAF0vUuAzbKhYV2HOG+xuHyBeGAbXbgLG6Pbm6DaNBfbRRJpRHxHdK/xpH7SOGHblaFG66SL+Gm69aNH27tVdGch9GpGqyWHXcQNQa4LyHEKQ1qHUKfCNQH4EKGGhBEBMgyLs9KK885J54SNLy9QPRybj6GYBQqo7p2AagbIzQOZmExKtQiRKgjwhsDp/GXZ4g59qjDg/oBarGP6URvI0Bkw95FL3B8k0mBqXyMhbYXY5lflI7b6RbvabbERNSbiApWivAXwAotH/bUn2F0RkQfY7IS6FUDR5ADhIBY6rpBg9te7k6IJsdTtvJlwesRLEwJnwIApYkhMARbHE7yTrnAsfDi6o72Qx6EhWlJ66bZ6OYiqV7uqcDYsv62TGrSrix/62rf6wYbzF6erEdIGBqoyLzibvMoXuq9VYX+rpB4VqDdkIWKxEnT6iggjJGqgp6yH7rIbHrH0fH4M/GLIXoI0MANBgmoUoK3c84DBe4jUNMh4y5c9Cxq5OBp5Z4aLVml5241A15u5N4OWC4J4+hqdVhEBqcCDLw6BqdfCN4t5OW5hLgZgGA4baBtwAAWAANloAAE4SAZgjXThTh9XYhuRjgjWjXzhzXpxYaTWGATWTW3XYa5hzhNWZWIBIAjXDRLhLhYbYg5gThjgDhvXzgTF5g0AjWBAXWZgSBXXw2ZhTgJwnWSEFh2XOWsJ1AFXaAlWVWzRaBqcd79AgA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=toeverything/AFFiNE&utm_content=12530):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR
user: login: pengx17
created_at: 2025-05-26T07:22:26Z
body: * **#12530** <a href="https://app.graphite.dev/github/pr/toeverything/AFFiNE/12530?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a> 👈 <a href="https://app.graphite.dev/github/pr/toeverything/AFFiNE/12530?utm_source=stack-comment-view-in-graphite" target="_blank">(View in Graphite)</a>
* **#12527** <a href="https://app.graphite.dev/github/pr/toeverything/AFFiNE/12527?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a>
* `canary`
<hr />

## How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:
- <kbd>merge</kbd> - adds this PR to the back of the merge queue
- <kbd>hotfix</kbd> - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using [this link](https://app.graphite.dev/invite/github/toeverything?ref=merge-queue-instructions-in-stack-comment&prId=12530).

<h2></h2>
<sub>

An organization admin has enabled the [Graphite Merge Queue](https://graphite.dev/docs/graphite-merge-queue) in this repository.

</sub>

<sub>

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

</sub>

<h2></h2>

This stack of pull requests is managed by <a href="https://graphite.dev?utm-source=stack-comment"><b>Graphite</b></a>. Learn more about <a href="https://stacking.dev/?utm_source=stack-comment">stacking</a>.
<!-- Current dependencies on/for this PR: -->
author_association: COLLABORATOR
user: login: codecov[bot]
created_at: 2025-05-26T07:29:27Z
body: ## [Codecov](https://app.codecov.io/gh/toeverything/AFFiNE/pull/12530?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 55.63%. Comparing base [(`d6476db`)](https://app.codecov.io/gh/toeverything/AFFiNE/commit/d6476db64d0cff6c97ee5987b761091db1bc5f7f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything) to head [(`4ad008f`)](https://app.codecov.io/gh/toeverything/AFFiNE/commit/4ad008f7122be663ff17a4b431e390015fe24ee7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything).
> Report is 1 commits behind head on canary.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           canary   #12530      +/-   ##
==========================================
- Coverage   55.64%   55.63%   -0.01%     
==========================================
  Files        2650     2650              
  Lines      124366   124366              
  Branches    19682    19681       -1     
==========================================
- Hits        69198    69192       -6     
- Misses      52899    52903       +4     
- Partials     2269     2271       +2     
```

| [Flag](https://app.codecov.io/gh/toeverything/AFFiNE/pull/12530/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything) | Coverage Δ | |
|---|---|---|
| [server-test](https://app.codecov.io/gh/toeverything/AFFiNE/pull/12530/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything) | `79.07% <ø> (-0.01%)` | :arrow_down: |
| [unittest](https://app.codecov.io/gh/toeverything/AFFiNE/pull/12530/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything) | `31.60% <ø> (-0.01%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/toeverything/AFFiNE/pull/12530?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toeverything).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: graphite-app[bot]
created_at: 2025-05-27T10:57:20Z
body: ### Merge activity

* **May 27, 10:57 AM UTC**: `pengx17` added this pull request to the [Graphite merge queue](https://app.graphite.dev/merges?org=toeverything&repo=AFFiNE).
* **May 27, 11:21 AM UTC**: Merged by the [Graphite merge queue](https://app.graphite.dev/merges?org=toeverything&repo=AFFiNE).

author_association: CONTRIBUTOR