From 2d304adf154a35550f7d29bd95211bcd6bd373f8 Mon Sep 17 00:00:00 2001 From: pengx17 Date: Tue, 1 Apr 2025 14:19:29 +0000 Subject: [PATCH] fix(electron): incorrect app allow list logic for recording (#11368) --- .../src/app/effects/recording.ts | 4 +- .../electron/src/main/recording/feature.ts | 10 +- .../component/src/ui/lottie/transcribe.json | 96 +++---------------- 3 files changed, 21 insertions(+), 89 deletions(-) diff --git a/packages/frontend/apps/electron-renderer/src/app/effects/recording.ts b/packages/frontend/apps/electron-renderer/src/app/effects/recording.ts index f5d764690..4cb92294b 100644 --- a/packages/frontend/apps/electron-renderer/src/app/effects/recording.ts +++ b/packages/frontend/apps/electron-renderer/src/app/effects/recording.ts @@ -68,14 +68,14 @@ export function setupRecordingEvents(frameworkProvider: FrameworkProvider) { (async () => { // name + timestamp(readable) + extension const attachmentName = - (status.appName ?? 'System Audio') + ' ' + timestamp + '.webm'; + (status.appName ?? 'System Audio') + ' ' + timestamp + '.opus'; // add size and sourceId to the attachment later const attachmentId = doc.addBlock( 'affine:attachment', { name: attachmentName, - type: 'audio/webm', + type: 'audio/opus', }, noteId ); diff --git a/packages/frontend/apps/electron/src/main/recording/feature.ts b/packages/frontend/apps/electron/src/main/recording/feature.ts index fe06b4b49..6104975f7 100644 --- a/packages/frontend/apps/electron/src/main/recording/feature.ts +++ b/packages/frontend/apps/electron/src/main/recording/feature.ts @@ -16,7 +16,7 @@ import { Subject, throttleTime, } from 'rxjs'; -import { map, shareReplay } from 'rxjs/operators'; +import { filter, map, shareReplay } from 'rxjs/operators'; import { isMacOS, shallowEqual } from '../../shared/utils'; import { beforeAppQuit } from '../cleanup'; @@ -157,7 +157,8 @@ function setupNewRunningAppGroup() { groupStream$.pipe( distinctUntilChanged((prev, curr) => prev.isRunning === curr.isRunning) ) - ) + ), + filter(group => isAppNameAllowed(group.name)) ); appGroups$.value.forEach(group => { @@ -391,8 +392,7 @@ function getAllApps(): TappableAppInfo[] { v !== null && !v.bundleIdentifier.startsWith('com.apple') && !v.bundleIdentifier.startsWith('pro.affine') && - v.processId !== process.pid && - isAppNameAllowed(v.name) + v.processId !== process.pid ); return filteredApps; } @@ -604,7 +604,7 @@ export async function readyRecording(id: number, buffer: Buffer) { const filepath = path.join( SAVED_RECORDINGS_DIR, - `${recordingStatus.appGroup?.bundleIdentifier ?? 'unknown'}-${recordingStatus.id}-${recordingStatus.startTime}.webm` + `${recordingStatus.appGroup?.bundleIdentifier ?? 'unknown'}-${recordingStatus.id}-${recordingStatus.startTime}.opus` ); await fs.writeFile(filepath, buffer); diff --git a/packages/frontend/component/src/ui/lottie/transcribe.json b/packages/frontend/component/src/ui/lottie/transcribe.json index f487e910f..2ab451216 100644 --- a/packages/frontend/component/src/ui/lottie/transcribe.json +++ b/packages/frontend/component/src/ui/lottie/transcribe.json @@ -1,8 +1,8 @@ { "v": "5.12.1", "fr": 60, - "ip": 0, - "op": 106, + "ip": 35, + "op": 64, "w": 24, "h": 24, "nm": "light", @@ -113,18 +113,6 @@ "t": 5, "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] }, - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 10, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 95, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, { "t": 101, "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] @@ -264,18 +252,6 @@ "t": 5, "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] }, - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 10, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 95, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, { "t": 101, "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] @@ -433,19 +409,8 @@ { "ty": "fl", "c": { - "a": 1, - "k": [ - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 95, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, - { - "t": 101, - "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] - } - ], + "a": 0, + "k": [0.478431373835, 0.478431373835, 0.478431373835, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -598,19 +563,8 @@ { "ty": "fl", "c": { - "a": 1, - "k": [ - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 95, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - }, - { - "t": 101, - "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] - } - ], + "a": 0, + "k": [0.478431373835, 0.478431373835, 0.478431373835, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -840,7 +794,7 @@ "ty": "fl", "c": { "a": 0, - "k": [0.117647058824, 0.588235294118, 0.921568627451, 1], + "k": [0.478431402468, 0.478431402468, 0.478431402468, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -1070,7 +1024,7 @@ "ty": "fl", "c": { "a": 0, - "k": [0.117647058824, 0.588235294118, 0.921568627451, 1], + "k": [0.478431402468, 0.478431402468, 0.478431402468, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -1300,7 +1254,7 @@ "ty": "fl", "c": { "a": 0, - "k": [0.117647058824, 0.588235294118, 0.921568627451, 1], + "k": [0.478431402468, 0.478431402468, 0.478431402468, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -1530,7 +1484,7 @@ "ty": "fl", "c": { "a": 0, - "k": [0.117647058824, 0.588235294118, 0.921568627451, 1], + "k": [0.478431402468, 0.478431402468, 0.478431402468, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -1683,19 +1637,8 @@ { "ty": "fl", "c": { - "a": 1, - "k": [ - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 5, - "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] - }, - { - "t": 10, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - } - ], + "a": 0, + "k": [0.478431373835, 0.478431373835, 0.478431373835, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 }, @@ -1848,19 +1791,8 @@ { "ty": "fl", "c": { - "a": 1, - "k": [ - { - "i": { "x": [0.833], "y": [0.833] }, - "o": { "x": [0.167], "y": [0.167] }, - "t": 5, - "s": [0.478431373835, 0.478431373835, 0.478431373835, 1] - }, - { - "t": 10, - "s": [0.117647059262, 0.588235318661, 0.921568632126, 1] - } - ], + "a": 0, + "k": [0.478431373835, 0.478431373835, 0.478431373835, 1], "ix": 4 }, "o": { "a": 0, "k": 100, "ix": 5 },