Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(editor): defaults that look good without touching anything

EtienneLescot2ee1a978965c
diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.ts
index 4179d54d9..fc8ba4085 100644
--- a/electron/ai-edition/agent-tools.test.ts
+++ b/electron/ai-edition/agent-tools.test.ts
@@ -684,11 +684,30 @@ describe("executeAgentTool", () => {
endMs: 3000,
type: "text",
textContent: "Look here",
- position: { x: 20, y: 80 },
+ // x/y are the text's centre: a 30x20 box centred on (20, 80).
+ position: { x: 5, y: 70 },
});
expect(() => documentSchema.parse(result.document)).not.toThrow();
});
+ it("addAnnotation centres the text on a dark plate by default, and keeps it in frame", () => {
+ const centred = executeAgentTool(
+ fixtureDocument(),
+ "addAnnotation",
+ JSON.stringify({ startSec: 1, endSec: 3, text: "Hi" }),
+ ).document?.annotations.at(-1);
+ expect(centred).toMatchObject({
+ position: { x: 35, y: 40 },
+ style: { backgroundColor: "rgba(0, 0, 0, 0.7)" },
+ });
+ const corner = executeAgentTool(
+ fixtureDocument(),
+ "addAnnotation",
+ JSON.stringify({ startSec: 1, endSec: 3, text: "Hi", x: 100, y: 0 }),
+ ).document?.annotations.at(-1);
+ expect(corner).toMatchObject({ position: { x: 70, y: 0 } });
+ });
+
it("snapshot exposes clips/trims/effects as virtual-time groups with a time-base note", () => {
const withEffects = executeAgentTool(
fixtureDocument(),
diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.ts
index e90fb9feb..3ffc9b215 100644
--- a/electron/ai-edition/agent-tools.ts
+++ b/electron/ai-edition/agent-tools.ts
@@ -16,6 +16,7 @@
// described are gone (see `MUTATING_TOOL_NAMES`).
import { z } from "zod";
+import { DEFAULT_TEXT_PLATE } from "../../src/lib/ai-edition/annotations/background";
import {
collapseTracksToPills,
patchAudioTrack,
@@ -512,6 +513,9 @@ export const setSpeedArgs = z.object({
speed: speedSchema.optional(),
});
+/** A new text annotation's box, in frame percentages: the editor's own size for one. */
+const ANNOTATION_BOX = { width: 30, height: 20 } as const;
+
export const addAnnotationArgs = z.object({
startSec: secondsSchema,
endSec: secondsSchema,
@@ -1919,11 +1923,23 @@ export function executeAgentTool(
type: "text" as const,
content: parsed.data.text,
textContent: parsed.data.text,
- position: { x: parsed.data.x, y: parsed.data.y },
- size: { width: 30, height: 20 },
+ // x/y name the text's centre, which is what "default centre" always promised: the
+ // position is the box's top-left corner, so {50, 50} dropped the text into the
+ // bottom-right quarter. Kept whole inside the frame.
+ position: {
+ x: Math.min(
+ 100 - ANNOTATION_BOX.width,
+ Math.max(0, parsed.data.x - ANNOTATION_BOX.width / 2),
+ ),
+ y: Math.min(
+ 100 - ANNOTATION_BOX.height,
+ Math.max(0, parsed.data.y - ANNOTATION_BOX.height / 2),
+ ),
+ },
+ size: { ...ANNOTATION_BOX },
style: {
color: "#ffffff",
- backgroundColor: "transparent",
+ backgroundColor: DEFAULT_TEXT_PLATE,
fontSize: 32,
fontFamily: "Inter",
fontWeight: "bold" as const,
diff --git a/electron/ai-edition/deep-agent/service.ts b/electron/ai-edition/deep-agent/service.ts
index 51eade3e5..64bcef03b 100644
--- a/electron/ai-edition/deep-agent/service.ts
+++ b/electron/ai-edition/deep-agent/service.ts
@@ -172,7 +172,7 @@ export const TOOL_DESCRIPTIONS: Record<string, string> = {
setSpeed:
"Move, resize, or change the multiplier of an existing speed region by id (virtual-timeline seconds). Only the fields you pass are changed.",
addAnnotation:
- "Add a text annotation over a span of the edited timeline (virtual seconds). x/y are frame percentages (0–100, default centre). Use for callouts and labels.",
+ "Add a text annotation over a span of the edited timeline (virtual seconds). x/y place the text's centre, in frame percentages (0–100, default the frame's centre); the box stays inside the frame. It is drawn on a dark plate so it reads on any footage. Use for callouts and labels.",
setAnnotation:
"Move, resize, or edit the text of an existing annotation by id (virtual-timeline seconds). Only the fields you pass are changed.",
addCameraFullscreen:
diff --git a/src/components/video-editor/editorDefaults.ts b/src/components/video-editor/editorDefaults.ts
index dba8525dd..299dada30 100644
--- a/src/components/video-editor/editorDefaults.ts
+++ b/src/components/video-editor/editorDefaults.ts
@@ -1,5 +1,6 @@
import { DEFAULT_CURSOR_THEME_ID } from "@/lib/cursor/cursorThemes";
import type { ExportFormat, ExportQuality, GifFrameRate, GifSizePreset } from "@/lib/exporter";
+import { DEFAULT_PROJECT_APPEARANCE } from "@/lib/projectDefaults";
import { DEFAULT_WALLPAPER } from "@/lib/wallpaper";
import type { AspectRatio } from "@/utils/aspectRatioUtils";
import {
@@ -37,12 +38,13 @@ export const DEFAULT_EDITOR_APPEARANCE_SETTINGS: {
motionBlurAmount: number;
borderRadius: number;
} = {
- // Keep in sync with `DEFAULT_EDITOR_SETTINGS` (lib/ai-edition/store/editorSettings.ts),
- // which is what the mounted v4 shell reads — see the rationale there.
- shadowIntensity: 0.2,
- showBlur: false,
- motionBlurAmount: 0.2,
- borderRadius: 40,
+ // The project defaults the v4 shell reads (`DEFAULT_PROJECT_APPEARANCE`), not a copy of them:
+ // this is what the CLI and a v2 project file fall back to, and a copy kept "in sync" by hand
+ // was one change away from rendering a different look there.
+ shadowIntensity: DEFAULT_PROJECT_APPEARANCE.shadowIntensity,
+ showBlur: DEFAULT_PROJECT_APPEARANCE.showBlur,
+ motionBlurAmount: DEFAULT_PROJECT_APPEARANCE.motionBlurAmount,
+ borderRadius: DEFAULT_PROJECT_APPEARANCE.borderRadius,
};
export const DEFAULT_EDITOR_LAYOUT_SETTINGS: {
@@ -51,7 +53,7 @@ export const DEFAULT_EDITOR_LAYOUT_SETTINGS: {
cropRegion: typeof DEFAULT_CROP_REGION;
wallpaper: string;
} = {
- padding: 50,
+ padding: DEFAULT_PROJECT_APPEARANCE.padding,
// What a v2 project file means when it states no ratio. Every such file predates Auto, so
// the answer stays 16:9 for good, as the v8 upgrader pins it for documents. New projects
// state their ratio instead (see CliRecordRunner).
diff --git a/src/lib/ai-edition/annotations/background.ts b/src/lib/ai-edition/annotations/background.ts
index ade92d56c..9ccd7d527 100644
--- a/src/lib/ai-edition/annotations/background.ts
+++ b/src/lib/ai-edition/annotations/background.ts
@@ -11,8 +11,16 @@ import { textForPlate } from "@/lib/ai-edition/textContrast";
type AnnotationStyle = AxcutAnnotationRegion["style"];
-/** Couleur d'un premier allumage, quand l'annotation n'a jamais eu de fond. */
-export const DEFAULT_TEXT_BACKGROUND = "#000000";
+/**
+ * La plaque d'une annotation neuve : noire à 70 %. Un texte blanc sans plaque ni contour
+ * disparaissait sur toute page claire, soit la moitié des enregistrements d'écran. `rgba()` et
+ * non un hex à 8 chiffres : c'est la forme que le compositeur lit (`parse_hex`), comme pour les
+ * sous-titres.
+ */
+export const DEFAULT_TEXT_PLATE = "rgba(0, 0, 0, 0.7)";
+
+/** Couleur d'un premier allumage, quand l'annotation n'a jamais eu de fond : la plaque par défaut. */
+export const DEFAULT_TEXT_BACKGROUND = DEFAULT_TEXT_PLATE;
export function hasTextBackground(style: AnnotationStyle): boolean {
const color = style.backgroundColor;
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index 19462058d..27eb35f9c 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -2,6 +2,7 @@
import { act, renderHook, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { I18nProvider } from "@/contexts/I18nContext";
+import { DEFAULT_TEXT_PLATE } from "../annotations/background";
import type { AxcutDocument } from "../schema";
import { axcutSchemaVersion } from "../schema";
import { useProjectStore } from "./projectStore";
@@ -717,6 +718,20 @@ describe("useTimeline.addAnnotation", () => {
id: (annotations[0] as { id: string }).id,
});
});
+
+ it("centres the new text box and puts it on a dark plate that reads on any page", async () => {
+ const { result } = renderTimeline();
+ await act(async () => {
+ await result.current.addAnnotation();
+ });
+ const [annotation] = useProjectStore.getState().document?.annotations ?? [];
+ const { position, size } = annotation as {
+ position: { x: number; y: number };
+ size: { width: number; height: number };
+ };
+ expect([position.x + size.width / 2, position.y + size.height / 2]).toEqual([50, 50]);
+ expect(annotation.style.backgroundColor).toBe(DEFAULT_TEXT_PLATE);
+ });
});
describe("useTimeline zoom modifiers (rotation + focus mode)", () => {
@@ -959,6 +974,8 @@ describe("useTimeline is not re-rendered by playhead ticks", () => {
expect(useProjectStore.getState().document?.zoomRanges.at(-1)).toMatchObject({
startMs: 4200,
endMs: 6200,
+ // Framing what the pointer does, not the middle of the screen.
+ focusMode: "auto",
});
});
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index ea6955948..e4aa812e2 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -12,6 +12,7 @@ import type {
Rotation3DPreset,
} from "@/components/video-editor/types";
import { useScopedT } from "@/contexts/I18nContext";
+import { DEFAULT_TEXT_PLATE } from "../annotations/background";
import {
collapseTracksToPills,
patchAudioTrack,
@@ -340,8 +341,10 @@ export function useTimeline() {
startMs: timeMs,
endMs,
depth: 3,
+ // Auto: a zoom added with Z frames what the pointer is doing, like the ones
+ // placed at import. The centre is its fallback where no pointer was recorded.
focus: { cx: 0.5, cy: 0.5 },
- focusMode: "manual" as const,
+ focusMode: "auto" as const,
},
],
document.timeline.clips,
@@ -446,11 +449,13 @@ export function useTimeline() {
// `content || textContent` and seeding both would just duplicate it.
content: ts("annotation.defaultText"),
textContent: "",
- position: { x: 50, y: 50 },
+ // Centred: the position is the box's top-left corner, so {50, 50} dropped the text
+ // into the bottom-right quarter.
+ position: { x: 35, y: 40 },
size: { width: 30, height: 20 },
style: {
color: "#ffffff",
- backgroundColor: "transparent",
+ backgroundColor: DEFAULT_TEXT_PLATE,
fontSize: 32,
fontFamily: "Inter",
fontWeight: "bold",
diff --git a/src/lib/projectDefaults.ts b/src/lib/projectDefaults.ts
index 33d241a61..4108852f9 100644
--- a/src/lib/projectDefaults.ts
+++ b/src/lib/projectDefaults.ts
@@ -212,7 +212,9 @@ export const DEFAULT_PROJECT_APPEARANCE: ProjectAppearanceDefaults = {
// Auto: the frame follows the recording, its crop, the camera layout and the padding.
// Documents from before it stored no ratio and read 16:9; the v8 upgrader pins that.
aspectRatio: "auto",
- shadowIntensity: 0.2,
+ // 0.2 peaked at 9% opacity: a shadow nobody could see. 0.6 is 27%, the card lifts off the
+ // wallpaper without a halo.
+ shadowIntensity: 0.6,
showBlur: false,
motionBlurAmount: 0.2,
// On: it only acts on tilted zooms, where the blur already scales with the real angle.
@@ -230,7 +232,9 @@ export const DEFAULT_PROJECT_APPEARANCE: ProjectAppearanceDefaults = {
webcamWallpaper: "/wallpapers/wallpaper11.jpg",
webcamBlurIntensity: 0.5,
cursor: {
- size: 3,
+ // 1.5 draws a 41 px arrow in a 1080p export, about twice the system one, which reads at a
+ // glance. 3 drew it at 82 px, a quarter of the screen's height at the top of its range.
+ size: 1.5,
smoothing: 0.67,
motionBlur: 0.35,
// A light tap: 2.5 squashed the arrow to 40% and threw it to 140% in 260 ms on every click.