Skip to content
Open
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
29 changes: 18 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ vite.config.js
vite.config.d.ts

# Native capture build artifacts
electron/native/wgc-capture/build/
electron/native/cursor-monitor/build/
electron/native/gpu-export-probe/build/
electron/native/nvidia-cuda-compositor/build/
electron/native/bin/*/whisper-*
electron/native/bin/*/whisper-runtime.json

# Local debug helpers
tmp-*.ps1
.tmp-*.ps1
gpu-export-probe.mp4
electron/native/wgc-capture/build/
electron/native/cursor-monitor/build/
electron/native/gpu-export-probe/build/
electron/native/nvidia-cuda-compositor/build/
electron/native/bin/*/whisper-*
electron/native/bin/*/whisper-runtime.json

# Bundled caption models (downloaded at postinstall)
/models/

# Local debug helpers
tmp-*.ps1
.tmp-*.ps1
gpu-export-probe.mp4

# 开发日志内部版(不公开)
dev_docs/articles/internal/
dev_docs/.drafts/
14 changes: 14 additions & 0 deletions dev_docs/INDEX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cc-Recordly-cn — 开发日志
> Build in public 系列

## 文章
| 日期 | 标题 | 类型 |
|------|------|------|

Comment on lines +4 to +7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Surround the table with blank lines.

Add a blank line before and after the table to satisfy Markdown linting rule MD058.

Proposed fix
 ## 文章
+
 | 日期 | 标题 | 类型 |
 |------|------|------|
+
 
 ## 命令
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## 文章
| 日期 | 标题 | 类型 |
|------|------|------|
## 文章
| 日期 | 标题 | 类型 |
|------|------|------|
🧰 Tools
🪛 markdownlint-cli2 (0.23.0)

[warning] 5-5: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dev_docs/INDEX.md` around lines 4 - 7, Add blank lines immediately before and
after the Markdown table under the “文章” heading in INDEX.md, preserving the
table contents and formatting while satisfying MD058.

Source: Linters/SAST tools

## 命令
```bash
journal push # 生成草稿
journal status # 查看状态
journal sync # 同步到全局
journal search # 全局搜索
```
Binary file added dev_docs/journal.db
Binary file not shown.
28 changes: 20 additions & 8 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
{
"from": "public/wallpapers",
"to": "assets/wallpapers"
},
{
"from": "models",
"to": "assets/models"
}
],
"publish": [
Expand All @@ -53,15 +57,23 @@
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"target": [
{
"target": "dmg",
"arch": ["x64", "arm64"]
},
{
"target": "zip",
"arch": ["x64", "arm64"]
}
{
"target": "dmg",
"arch": ["x64", "arm64"]
},
{
"target": "zip",
"arch": ["x64", "arm64"]
}
],
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"target": [
{
"target": "dir",
"arch": ["arm64"]
}
],
Comment on lines 57 to +76

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Duplicate mac keys clobber the dmg/zip targets.

entitlements, entitlementsInherit, and target are each declared twice in the mac block. With last-key-wins JSON parsing, the effective target becomes only [{ "target": "dir", "arch": ["arm64"] }], silently dropping the dmg/zip (x64 + arm64) distributables from release builds. Merge into a single target array.

🛠️ Proposed fix
   "mac": {
     "hardenedRuntime": true,
     "entitlements": "build/entitlements.mac.plist",
     "entitlementsInherit": "build/entitlements.mac.inherit.plist",
     "target": [
-        {
-            "target": "dmg",
-            "arch": ["x64", "arm64"]
-        },
-        {
-            "target": "zip",
-            "arch": ["x64", "arm64"]
-        }
-    ],
-    "entitlements": "build/entitlements.mac.plist",
-    "entitlementsInherit": "build/entitlements.mac.inherit.plist",
-	"target": [
-		{
-			"target": "dir",
-			"arch": ["arm64"]
-		}
-	],
+        { "target": "dmg", "arch": ["x64", "arm64"] },
+        { "target": "zip", "arch": ["x64", "arm64"] },
+        { "target": "dir", "arch": ["arm64"] }
+    ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"target": [
{
"target": "dmg",
"arch": ["x64", "arm64"]
},
{
"target": "zip",
"arch": ["x64", "arm64"]
}
{
"target": "dmg",
"arch": ["x64", "arm64"]
},
{
"target": "zip",
"arch": ["x64", "arm64"]
}
],
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"target": [
{
"target": "dir",
"arch": ["arm64"]
}
],
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"target": [
{ "target": "dmg", "arch": ["x64", "arm64"] },
{ "target": "zip", "arch": ["x64", "arm64"] },
{ "target": "dir", "arch": ["arm64"] }
],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@electron-builder.json5` around lines 57 - 76, Remove the duplicate mac
configuration keys and merge the entries into one mac block: retain the
entitlements settings once, and combine the dmg and zip targets for x64/arm64
with the dir target for arm64 in a single target array.

"icon": "icons/icons/mac/icon.icns",
"artifactName": "${productName}-${arch}.${ext}",
"extendInfo": {
Expand Down
22 changes: 17 additions & 5 deletions electron/electron-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,21 +673,32 @@ interface Window {
canceled?: boolean;
error?: string;
}>;
getWhisperSmallModelStatus: () => Promise<{
// ── Multi-model API ─────────────────────────────────────────────
getAvailableModels: () => Promise<
Array<{
id: string;
name: string;
engine: string;
sizeLabel?: string;
languages: string[];
description: string;
}>
>;
getModelStatus: (modelId: string) => Promise<{
success: boolean;
exists: boolean;
path?: string | null;
error?: string;
}>;
downloadWhisperSmallModel: () => Promise<{
downloadModel: (modelId: string) => Promise<{
success: boolean;
path?: string;
alreadyDownloaded?: boolean;
error?: string;
}>;
deleteWhisperSmallModel: () => Promise<{ success: boolean; error?: string }>;
onWhisperSmallModelDownloadProgress: (
deleteModel: (modelId: string) => Promise<{ success: boolean; error?: string }>;
onModelDownloadProgress: (
callback: (state: {
modelId: string;
status: "idle" | "downloading" | "downloaded" | "error";
progress: number;
path?: string | null;
Expand All @@ -698,6 +709,7 @@ interface Window {
videoPath: string;
whisperExecutablePath?: string;
whisperModelPath: string;
modelId?: string;
language?: string;
}) => Promise<{
success: boolean;
Expand Down
55 changes: 55 additions & 0 deletions electron/ipc/captions/engine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { CaptionModel } from "./models";

/**
* Result from caption generation.
*/
export interface CaptionWordPayload {
text: string;
startMs: number;
endMs: number;
}

export interface CaptionCuePayload {
id: string;
text: string;
startMs: number;
endMs: number;
words?: CaptionWordPayload[];
}

export interface GenerateCaptionResult {
success: boolean;
cues: CaptionCuePayload[];
message?: string;
error?: string;
}

/**
* Options passed to an engine for caption generation.
*/
export interface GenerateCaptionOptions {
/** Path to the pre-extracted 16kHz mono WAV file */
audioPath: string;
/** Absolute path to the downloaded model file */
modelPath: string;
/** The model metadata */
model: CaptionModel;
/** Language hint (BCP-47 code or "auto") */
language?: string;
/** Temp directory for intermediate files */
tempDir: string;
}

/**
* Abstract engine interface.
* Each engine (whisper, sensevoice) implements this.
*/
export interface CaptionEngine {
readonly engineType: string;

/**
* Run caption generation.
* Receives fully resolved paths — no model resolution needed.
*/
generate(options: GenerateCaptionOptions): Promise<GenerateCaptionResult>;
}
47 changes: 47 additions & 0 deletions electron/ipc/captions/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ export async function resolveCaptionAudioCandidates(videoPath: string) {
candidates.push({ path: normalizedCandidatePath, label });
};

// Companion audio (mic/system) should be tried FIRST - they have the best audio quality
const videoDir = path.dirname(videoPath);
const videoExt = path.extname(videoPath);
const videoBase = path.basename(videoPath, videoExt);
pushCandidate(path.join(videoDir, `${videoBase}.mic.wav`), "microphone");
pushCandidate(path.join(videoDir, `${videoBase}.system.wav`), "system audio");

pushCandidate(videoPath, "recording");

const requestedRecordingSession = await resolveRecordingSession(videoPath);
Expand Down Expand Up @@ -190,8 +197,47 @@ export async function generateAutoCaptionsFromVideo(options: {
videoPath: string;
whisperExecutablePath?: string;
whisperModelPath: string;
modelId?: string;
language?: string;
}) {
// ── Engine dispatch: SenseVoice ──────────────────────────────────────
if (options.modelId) {
const { getModelById } = await import("./models");
const model = getModelById(options.modelId);
if (model?.engine === "sensevoice") {
const { SenseVoiceEngine } = await import("./sensevoice");
const engine = new SenseVoiceEngine();
const ffmpegPath = getFfmpegBinaryPath();
const tempDir = app.getPath("temp");
const wavPath = path.join(tempDir, `sensevoice-${Date.now()}.wav`);

// Use the same audio extraction as whisper path
const audioSource = await extractCaptionAudioSource({
videoPath: options.videoPath,
ffmpegPath,
wavPath,
});

const result = await engine.generate({
audioPath: wavPath,
modelPath: options.whisperModelPath,
model,
language: options.language,
tempDir,
});

if (!result.success) {
await fs.rm(wavPath, { force: true }).catch(() => undefined);
throw new Error(result.error || "SenseVoice caption generation failed.");
}

await fs.rm(wavPath, { force: true }).catch(() => undefined);

return { success: true, cues: result.cues, audioSourceLabel: audioSource.label };
Comment on lines +210 to +236

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

SenseVoice temp WAV can leak on unexpected throw.

Cleanup of wavPath only runs after a successful/failed result, but if extractCaptionAudioSource or engine.generate throws, the temp WAV is never removed. The whisper path guards this with finally; wrap the SenseVoice extraction/generation in try/finally for parity. Minor: the sensevoice-${Date.now()}.wav name (line 212) can collide under concurrent runs — the whisper path appends a random suffix.

🧰 Tools
🪛 ast-grep (0.44.1)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFile, spawnSync } from "node:child_process";
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@electron/ipc/captions/generate.ts` around lines 210 - 236, Wrap the
SenseVoice extraction and generation flow in a try/finally block so wavPath is
removed for both expected failures and unexpected throws, while preserving the
existing result handling and return values. Also update the wavPath filename
construction to include a random suffix, matching the whisper path and
preventing concurrent-run collisions.

}
}

// ── Engine: whisper.cpp (default) ────────────────────────────────────
const ffmpegPath = getFfmpegBinaryPath();
const normalizedVideoPath = normalizeVideoSourcePath(options.videoPath);
if (!normalizedVideoPath) {
Expand Down Expand Up @@ -292,6 +338,7 @@ export async function generateAutoCaptionsFromVideo(options: {
}

return {
success: true,
cues: cuesToReturn,
audioSourceLabel: audioSource.label,
};
Expand Down
Loading