Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Guard failed capture shutdown and address dashboard review feedback

webadderallef4ca060689e
diff --git a/electron/native/ScreenCaptureKitRecorder.lifecycle.test.ts b/electron/native/ScreenCaptureKitRecorder.lifecycle.test.ts
new file mode 100644
index 00000000..0d29d986
--- /dev/null
+++ b/electron/native/ScreenCaptureKitRecorder.lifecycle.test.ts
@@ -0,0 +1,94 @@
+import { spawnSync } from "node:child_process";
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+
+// Exercise the production service and stdin reader in a real Swift process.
+// Only the device backend is simulated: CI must not request screen/mic access.
+describe.skipIf(process.platform !== "darwin")("recorder process lifecycle", () => {
+ let directory: string;
+ let executable: string;
+ beforeAll(() => {
+ directory = mkdtempSync(join(tmpdir(), "recordly-lifecycle-"));
+ executable = join(directory, "helper");
+ const source = readFileSync(
+ new URL("./ScreenCaptureKitRecorder.swift", import.meta.url),
+ "utf8",
+ );
+ const service = source.slice(
+ source.indexOf("final class RecorderService"),
+ source.indexOf("guard CommandLine.arguments.count"),
+ );
+ const commands = source.slice(
+ source.indexOf("let service = RecorderService()"),
+ source.indexOf("if !service.waitUntilFinished()"),
+ );
+ writeFileSync(
+ join(directory, "main.swift"),
+ `
+import Foundation
+final class ScreenCaptureRecorder {
+ var output = ""
+ func startCapture(configJSON: String) async throws {
+ try await Task.sleep(nanoseconds: 50_000_000)
+ if configJSON == "fail" { throw NSError(domain: "startup", code: 1) }
+ output = configJSON
+ try "recording".write(toFile: output, atomically: true, encoding: .utf8)
+ }
+ func stopCapture() async throws -> String {
+ print("BACKEND_STOP")
+ fflush(stdout)
+ if output.isEmpty { throw NSError(domain: "inactive", code: 2) }
+ try "finalized".write(toFile: output, atomically: true, encoding: .utf8)
+ return output
+ }
+ func pauseCapture() async -> Bool { true }
+ func resumeCapture() async -> Bool { true }
+}
+${service}
+${commands}
+let success = service.waitUntilFinished()
+// Keep the process alive long enough to expose a queued second group release.
+Thread.sleep(forTimeInterval: 0.2)
+exit(success ? 0 : 1)
+`,
+ );
+ const build = spawnSync(
+ "swiftc",
+ [
+ "-module-cache-path",
+ join(directory, "cache"),
+ join(directory, "main.swift"),
+ "-o",
+ executable,
+ ],
+ { encoding: "utf8", timeout: 60_000 },
+ );
+ expect(build.status, build.stderr).toBe(0);
+ }, 60_000);
+ afterAll(() => {
+ if (directory) rmSync(directory, { recursive: true, force: true });
+ });
+
+ it.each([
+ "",
+ "stop\n",
+ "pause\nresume\n",
+ "stop\nstop\n",
+ ])("finalizes once with stdin %j", (input) => {
+ const output = join(directory, "recording");
+ const result = spawnSync(executable, [output], { input, encoding: "utf8", timeout: 5_000 });
+ expect(result.status, result.stderr).toBe(0);
+ expect(result.stdout.match(/BACKEND_STOP/g)).toHaveLength(1);
+ expect(readFileSync(output, "utf8")).toBe("finalized");
+ });
+
+ it.each(["", "stop\n"])("exits cleanly after failed startup with stdin %j", (input) => {
+ const result = spawnSync(executable, ["fail"], { input, encoding: "utf8", timeout: 5_000 });
+ expect(result.signal, result.stderr).toBeNull();
+ expect(result.status, result.stderr).toBe(1);
+ expect(result.stderr).toContain("Error starting capture");
+ expect(result.stdout).not.toContain("BACKEND_STOP");
+ });
+});
diff --git a/electron/native/ScreenCaptureKitRecorder.swift b/electron/native/ScreenCaptureKitRecorder.swift
index d47e1605..002b1a67 100644
--- a/electron/native/ScreenCaptureKitRecorder.swift
+++ b/electron/native/ScreenCaptureKitRecorder.swift
@@ -958,6 +958,8 @@ final class RecorderService {
private let queue = DispatchQueue(label: "recordly.screencapturekit.commands")
private let completionGroup = DispatchGroup()
private var succeeded = true
+ // Accessed only by serialized command operations.
+ private var captureStarted = false
private func enqueue(_ operation: @escaping () async -> Void) {
queue.async {
@@ -975,6 +977,7 @@ final class RecorderService {
enqueue {
do {
try await self.recorder.startCapture(configJSON: configJSON)
+ self.captureStarted = true
} catch {
self.succeeded = false
fputs("Error starting capture: \(error.localizedDescription)\n", stderr)
@@ -986,6 +989,9 @@ final class RecorderService {
func stop() {
enqueue {
+ // Failed startup already releases completionGroup. EOF must not do it again.
+ guard self.captureStarted else { return }
+ self.captureStarted = false
do {
let outputPath = try await self.recorder.stopCapture()
print("Recording stopped. Output path: \(outputPath)")
diff --git a/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper b/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper
index 54b450ce..54835c5a 100755
Binary files a/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper and b/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper differ
diff --git a/electron/native/bin/darwin-x64/recordly-screencapturekit-helper b/electron/native/bin/darwin-x64/recordly-screencapturekit-helper
index 0bd08966..1a05cf27 100755
Binary files a/electron/native/bin/darwin-x64/recordly-screencapturekit-helper and b/electron/native/bin/darwin-x64/recordly-screencapturekit-helper differ
diff --git a/src/components/video-editor/ShortcutsConfigDialog.tsx b/src/components/video-editor/ShortcutsConfigDialog.tsx
index 15e33d54..11b49a45 100644
--- a/src/components/video-editor/ShortcutsConfigDialog.tsx
+++ b/src/components/video-editor/ShortcutsConfigDialog.tsx
@@ -153,7 +153,11 @@ export function ShortcutsConfigDialog() {
type="button"
variant="secondary"
size="sm"
- aria-label={`Change ${SHORTCUT_LABELS[action]} shortcut`}
+ aria-label={
+ isCapturing
+ ? `${SHORTCUT_LABELS[action]}: ${t("shortcutsConfig.pressAKey")}`
+ : `Change ${SHORTCUT_LABELS[action]} shortcut, currently ${formatBinding(draft[action], isMac)}`
+ }
onClick={() => {
setConflict(null);
setCaptureFor(isCapturing ? null : action);
diff --git a/src/components/video-editor/dashboard/DashboardGrid.tsx b/src/components/video-editor/dashboard/DashboardGrid.tsx
index f191a158..d14d271c 100644
--- a/src/components/video-editor/dashboard/DashboardGrid.tsx
+++ b/src/components/video-editor/dashboard/DashboardGrid.tsx
@@ -35,6 +35,7 @@ export function DashboardGrid({
selected,
openEntry,
query,
+ hasActiveFilters,
setQuery,
run,
}: Pick<
@@ -62,6 +63,7 @@ export function DashboardGrid({
| "selected"
| "openEntry"
| "query"
+ | "hasActiveFilters"
| "setQuery"
| "run"
>) {
@@ -115,7 +117,7 @@ export function DashboardGrid({
</ul>
) : (
<div className="flex h-64 flex-col items-center justify-center gap-3 text-sm text-muted-foreground">
- {!isRaw && !query ? (
+ {!isRaw && !hasActiveFilters ? (
<span aria-hidden="true" className="text-4xl">
🦗
</span>
@@ -127,12 +129,14 @@ export function DashboardGrid({
? rawLoading
? "Loading recordings…"
: rawError ||
- (query ? "No matching raw files" : "No raw recordings yet")
- : query
+ (hasActiveFilters
+ ? "No matching raw files"
+ : "No raw recordings yet")
+ : hasActiveFilters
? "No matching projects"
: "It's looking empty in here..."}
</p>
- {!isRaw && !query && (
+ {!isRaw && !hasActiveFilters && (
<RecordNewButton busy={busy} run={run} first className="mt-2" />
)}
{isRaw && rawError && (
diff --git a/src/components/video-editor/dashboard/useDashboardModel.ts b/src/components/video-editor/dashboard/useDashboardModel.ts
index bbe10635..840a8c8d 100644
--- a/src/components/video-editor/dashboard/useDashboardModel.ts
+++ b/src/components/video-editor/dashboard/useDashboardModel.ts
@@ -121,6 +121,8 @@ export function useDashboardModel({
toggleSelected,
assignFolder,
query,
+ hasActiveFilters:
+ Boolean(query.trim()) || period !== "all" || folders.some((f) => f.id === section),
setQuery,
period,
setPeriod,
diff --git a/tests/ui/project-dashboard.spec.ts b/tests/ui/project-dashboard.spec.ts
index e5dc5fdb..8a046619 100644
--- a/tests/ui/project-dashboard.spec.ts
+++ b/tests/ui/project-dashboard.spec.ts
@@ -470,6 +470,7 @@ test("Solar navigation selection, circular initials, and Raw sources are consist
await scene.click();
await expect(scene).toBeChecked();
await expect(videos).toHaveAttribute("aria-expanded", "false");
+ await expect(page.getByRole("complementary", { name: "Clips" })).toHaveCount(0);
const homeButton = page.getByRole("button", { name: "Home", exact: true });
await expect(homeButton.locator("svg")).toHaveAttribute("data-icon-style", "bold");
await homeButton.click();
@@ -717,16 +718,21 @@ test("sidebar cards, separate Import, and shortcut settings use the dashboard fl
await home.getByRole("button", { name: "Customize", exact: true }).click();
const shortcuts = page.getByRole("dialog", { name: "Keyboard Shortcuts", exact: true });
await expect(shortcuts).toBeVisible();
- const change = shortcuts.getByRole("button", { name: "Change Add Zoom shortcut", exact: true });
+ const change = shortcuts.getByRole("button", { name: /^Change Add Zoom shortcut, currently / });
await change.click();
+ await expect(shortcuts.getByRole("button", { name: /^Add Zoom: / })).toHaveAccessibleName(
+ /press.*key/i,
+ );
await page.keyboard.press("j");
await expect(change).toHaveText("J");
+ await expect(change).toHaveAccessibleName("Change Add Zoom shortcut, currently J");
await shortcuts.getByRole("button", { name: "Save", exact: true }).scrollIntoViewIfNeeded();
await page.screenshot({ path: "test-results/dashboard-shortcuts.png", animations: "disabled" });
await shortcuts.getByRole("button", { name: "Save", exact: true }).click();
await expect(shortcuts).not.toBeVisible();
await home.getByRole("button", { name: "Customize", exact: true }).click();
await expect(change).toHaveText("J");
+ await expect(change).toHaveAccessibleName("Change Add Zoom shortcut, currently J");
await page.setViewportSize({ width: 800, height: 600 });
await expect(shortcuts.getByRole("button", { name: "Save", exact: true })).toBeInViewport();
await expect(
@@ -737,3 +743,23 @@ test("sidebar cards, separate Import, and shortcut settings use the dashboard fl
animations: "disabled",
});
});
+
+test("empty filtered libraries do not prompt for a first recording", async ({ page }) => {
+ await installDesktopBridge(page);
+ await page.addInitScript(() => {
+ window.electronAPI.getCurrentVideoPath = async () => ({ success: false });
+ });
+ await page.goto("/?windowType=editor");
+ const home = page.getByRole("dialog", { name: "Projects dashboard" });
+ const first = home.getByRole("button", { name: "Record your first video", exact: true });
+ await expect(first).toBeVisible();
+ await home.getByRole("button", { name: "Last 7 days", exact: true }).click();
+ await expect(home.getByText("No matching projects", { exact: true })).toBeVisible();
+ await expect(first).toHaveCount(0);
+ await home.getByRole("button", { name: "All", exact: true }).click();
+ await expect(first).toBeVisible();
+ await home.getByRole("button", { name: "New folder", exact: true }).click();
+ await home.getByRole("button", { name: "Untitled folder", exact: true }).click();
+ await expect(home.getByText("No matching projects", { exact: true })).toBeVisible();
+ await expect(first).toHaveCount(0);
+});