Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
refactor: schema region consolidation + playback cap + deep-agent fold
Etienne Lescot83b9aa1058b9
diff --git a/electron/ai-edition/deep-agent/agent-provider-capabilities.test.ts b/electron/ai-edition/deep-agent/agent-provider-capabilities.test.tsindex 0b6581ed4..d9a6c306e 100644--- a/electron/ai-edition/deep-agent/agent-provider-capabilities.test.ts+++ b/electron/ai-edition/deep-agent/agent-provider-capabilities.test.ts@@ -1,13 +1,13 @@// Covers the reasoning-effort matrix that survived the llm-call.ts deletion.-// The deleted top-level agent-provider-capabilities.ts had the only tests for-// this logic; these keep the per-provider wiring pinned.+// The capability helpers now live in chat-model.ts (folded from+// agent-provider-capabilities.ts); these keep the per-provider wiring pinned.import { describe, expect, it } from "vitest";import {buildLangChainReasoningOptions,getReasoningCapability,normalizeReasoningEffortForCapability,-} from "./agent-provider-capabilities";+} from "./chat-model";describe("getReasoningCapability", () => {it("turns reasoning off for non-reasoning OpenAI models", () => {diff --git a/electron/ai-edition/deep-agent/agent-provider-capabilities.ts b/electron/ai-edition/deep-agent/agent-provider-capabilities.tsdeleted file mode 100644index fde62ca7e..000000000--- a/electron/ai-edition/deep-agent/agent-provider-capabilities.ts+++ /dev/null@@ -1,257 +0,0 @@-// ponytail: port of axcut's agent-provider-capabilities.ts. Drives the-// per-provider reasoning-effort wiring (OpenAI uses `reasoning.effort`,-// Anthropic uses `thinking` blocks, OpenRouter uses `modelKwargs.reasoning`,-// Google uses `thinkingConfig`). Lives behind createOpenScreenChatModel.--import { getProviderDefinition, type ProviderDefinition } from "../provider-registry";--export type AgentReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";--export const AGENT_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [- "none",- "minimal",- "low",- "medium",- "high",- "xhigh",-];--export interface ReasoningCapability {- supported: boolean;- efforts: readonly AgentReasoningEffort[];- defaultEffort?: AgentReasoningEffort;- strategy?:- | "custom-openai-account"- | "openai-responses"- | "anthropic-thinking"- | "minimax-thinking"- | "openrouter-reasoning"- | "google-thinking";-}--export interface LangChainReasoningOptions {- reasoning?: { effort: "low" | "medium" | "high" };- thinking?: Record<string, unknown>;- outputConfig?: Record<string, unknown>;- thinkingConfig?: Record<string, unknown>;- modelKwargs?: Record<string, unknown>;- useResponsesApi?: boolean;-}--const OPENAI_REASONING_EFFORTS: readonly AgentReasoningEffort[] = ["none", "low", "medium", "high"];-const ANTHROPIC_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [- "none",- "low",- "medium",- "high",- "xhigh",-];-const OPENROUTER_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [- "none",- "low",- "medium",- "high",-];-const GOOGLE_REASONING_EFFORTS: readonly AgentReasoningEffort[] = ["none", "low", "medium", "high"];--// Every branch here compares against canonical registry ids —-// createOpenScreenChatModel normalizes the provider before calling in.-export function getReasoningCapability(provider: string, model?: string): ReasoningCapability {- const def: ProviderDefinition | undefined = getProviderDefinition(provider);- const normalizedModel = normalizeModelName(model);-- if (- (provider === "openai" || provider === "openai-compatible") &&- isOpenAIReasoningModel(normalizedModel)- ) {- return {- supported: true,- efforts: OPENAI_REASONING_EFFORTS,- defaultEffort: "medium",- strategy: "openai-responses",- };- }- if (def?.id === "anthropic" && isAnthropicReasoningModel(normalizedModel)) {- return {- supported: true,- efforts: ANTHROPIC_REASONING_EFFORTS,- defaultEffort: "medium",- strategy: "anthropic-thinking",- };- }- if (provider === "minimax" || provider === "minimax-token-plan") {- // MiniMax's thinking block is binary — `{type: "adaptive"}` (on) or- // `{type: "disabled"}` (off, ignored on M2.x which is always-on) — no- // budget_tokens tiers like native Anthropic. Any non-"none" effort- // just turns it on; see buildLangChainReasoningOptions below.- return {- supported: true,- efforts: ANTHROPIC_REASONING_EFFORTS,- defaultEffort: "medium",- strategy: "minimax-thinking",- };- }- if (provider === "openrouter" && isOpenRouterReasoningModel(normalizedModel)) {- return {- supported: true,- efforts: OPENROUTER_REASONING_EFFORTS,- defaultEffort: "medium",- strategy: "openrouter-reasoning",- };- }- if (provider === "google" && isGeminiThinkingModel(normalizedModel)) {- return {- supported: true,- efforts: GOOGLE_REASONING_EFFORTS,- defaultEffort: "medium",- strategy: "google-thinking",- };- }- return { supported: false, efforts: ["none"] };-}--export function normalizeReasoningEffortForCapability(- effort: AgentReasoningEffort | undefined,- capability: ReasoningCapability,-): AgentReasoningEffort | undefined {- if (!capability.supported) return undefined;- if (!effort) return capability.defaultEffort;- if (capability.efforts.includes(effort)) return effort;- if (effort === "minimal" && capability.efforts.includes("low")) return "low";- if (effort === "xhigh" && capability.efforts.includes("high")) return "high";- return capability.defaultEffort;-}--export function buildLangChainReasoningOptions(- provider: string,- model: string | undefined,- effort: AgentReasoningEffort | undefined,-): LangChainReasoningOptions {- const capability = getReasoningCapability(provider, model);- const normalizedEffort = normalizeReasoningEffortForCapability(effort, capability);- if (!capability.supported || !normalizedEffort || normalizedEffort === "none") {- return {};- }-- switch (capability.strategy) {- case "openai-responses":- return {- reasoning: { effort: toOpenAIReasoningEffort(normalizedEffort) },- useResponsesApi: true,- };- case "anthropic-thinking":- return buildAnthropicReasoningOptions(model, normalizedEffort);- case "minimax-thinking":- // No "none" case needed — normalizedEffort === "none" already- // short-circuits to {} above, which omits `thinking` (= off).- return { thinking: { type: "adaptive" } };- case "openrouter-reasoning":- return {- modelKwargs: {- reasoning: { effort: toOpenAIReasoningEffort(normalizedEffort) },- include_reasoning: true,- },- };- case "google-thinking":- return {- thinkingConfig: {- includeThoughts: true,- thinkingLevel: toGoogleThinkingLevel(normalizedEffort),- thinkingBudget: toGoogleThinkingBudget(normalizedEffort),- },- };- default:- return {};- }-}--export function shouldDisableModelStreamingForToolCalling(- provider: string,- model?: string,-): boolean {- return provider === "google" && normalizeModelName(model).startsWith("gemini-3");-}--function buildAnthropicReasoningOptions(- model: string | undefined,- effort: AgentReasoningEffort,-): LangChainReasoningOptions {- if (isAnthropicAdaptiveThinkingModel(model)) {- return {- thinking: { type: "adaptive", display: "summarized" },- outputConfig: { effort: toAnthropicEffort(effort) },- };- }- return {- thinking: {- type: "enabled",- budget_tokens: toAnthropicBudgetTokens(effort),- display: "summarized",- },- };-}--function isOpenAIReasoningModel(model: string): boolean {- return /^(o\d|o\d-|o\d\.|gpt-5|gpt-5-|gpt-5\.)/.test(model);-}--function isAnthropicReasoningModel(model: string): boolean {- return /^claude-(opus|sonnet|haiku)-4/.test(model);-}--function isAnthropicAdaptiveThinkingModel(model: string | undefined): boolean {- if (!model) return false;- return /^claude-(opus|sonnet)-4-[67]/.test(model);-}--function isGeminiThinkingModel(model: string): boolean {- return model.startsWith("gemini-2.5") || model.startsWith("gemini-3");-}--function isOpenRouterReasoningModel(model: string): boolean {- // OpenRouter slugs are `vendor/model`, and both vendor matchers are- // anchored at the start — so the prefix has to come off first or- // `openai/gpt-5` never matches.- if (isOpenAIReasoningModel(stripVendorPrefix(model, "openai/"))) return true;- if (isAnthropicReasoningModel(stripVendorPrefix(model, "anthropic/"))) return true;- return /deepseek-r1/i.test(model) || /qwen.*thinking/i.test(model) || /grok-4/i.test(model);-}--function stripVendorPrefix(model: string, prefix: string): string {- return model.startsWith(prefix) ? model.slice(prefix.length) : model;-}--function toOpenAIReasoningEffort(effort: AgentReasoningEffort): "low" | "medium" | "high" {- if (effort === "high" || effort === "xhigh") return "high";- if (effort === "medium") return "medium";- return "low";-}--function toAnthropicEffort(effort: AgentReasoningEffort): "low" | "medium" | "high" | "xhigh" {- if (effort === "high" || effort === "xhigh") return effort;- if (effort === "medium") return "medium";- return "low";-}--function toAnthropicBudgetTokens(effort: AgentReasoningEffort): number {- if (effort === "xhigh") return 16_000;- if (effort === "high") return 10_000;- if (effort === "medium") return 4_000;- return 1_024;-}--function toGoogleThinkingLevel(effort: AgentReasoningEffort): "LOW" | "MEDIUM" | "HIGH" {- if (effort === "high" || effort === "xhigh") return "HIGH";- if (effort === "medium") return "MEDIUM";- return "LOW";-}--function toGoogleThinkingBudget(effort: AgentReasoningEffort): number {- if (effort === "high" || effort === "xhigh") return 8_192;- if (effort === "medium") return 4_096;- return 1_024;-}--function normalizeModelName(model?: string): string {- return model?.trim().toLowerCase() || "";-}diff --git a/electron/ai-edition/deep-agent/chat-model.ts b/electron/ai-edition/deep-agent/chat-model.tsindex 5845905b3..037343262 100644--- a/electron/ai-edition/deep-agent/chat-model.ts+++ b/electron/ai-edition/deep-agent/chat-model.ts@@ -5,16 +5,277 @@//// The openai-oauth (Codex) and copilot-proxy branches were removed in 1.8.0// along with their providers — see the note in provider-registry.ts.+//+// ponytail: the per-provider reasoning-effort capability table (was+// ./agent-provider-capabilities.ts) is only consumed by createOpenScreenChatModel,+// so it lives here as a top section. The deep-agent runtime wrapper+// (./service.ts) stays separate because it owns a different concern — the+// LangGraph thread + tool graph, not the chat-model factory.import { ChatAnthropic } from "@langchain/anthropic";import type { BaseChatModel } from "@langchain/core/language_models/chat_models";import { ChatMistralAI } from "@langchain/mistralai";import { ChatOpenAI } from "@langchain/openai";-import { normalizeProviderId } from "../provider-registry";import {- buildLangChainReasoningOptions,- shouldDisableModelStreamingForToolCalling,-} from "./agent-provider-capabilities";+ getProviderDefinition,+ normalizeProviderId,+ type ProviderDefinition,+} from "../provider-registry";++// --- per-provider reasoning-effort capability table -----------------------++export type AgentReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";++export const AGENT_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [+ "none",+ "minimal",+ "low",+ "medium",+ "high",+ "xhigh",+];++export interface ReasoningCapability {+ supported: boolean;+ efforts: readonly AgentReasoningEffort[];+ defaultEffort?: AgentReasoningEffort;+ strategy?:+ | "custom-openai-account"+ | "openai-responses"+ | "anthropic-thinking"+ | "minimax-thinking"+ | "openrouter-reasoning"+ | "google-thinking";+}++export interface LangChainReasoningOptions {+ reasoning?: { effort: "low" | "medium" | "high" };+ thinking?: Record<string, unknown>;+ outputConfig?: Record<string, unknown>;+ thinkingConfig?: Record<string, unknown>;+ modelKwargs?: Record<string, unknown>;+ useResponsesApi?: boolean;+}++const OPENAI_REASONING_EFFORTS: readonly AgentReasoningEffort[] = ["none", "low", "medium", "high"];+const ANTHROPIC_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [+ "none",+ "low",+ "medium",+ "high",+ "xhigh",+];+const OPENROUTER_REASONING_EFFORTS: readonly AgentReasoningEffort[] = [+ "none",+ "low",+ "medium",+ "high",+];+const GOOGLE_REASONING_EFFORTS: readonly AgentReasoningEffort[] = ["none", "low", "medium", "high"];++// Every branch here compares against canonical registry ids —+// createOpenScreenChatModel normalizes the provider before calling in.+export function getReasoningCapability(provider: string, model?: string): ReasoningCapability {+ const def: ProviderDefinition | undefined = getProviderDefinition(provider);+ const normalizedModel = normalizeModelName(model);++ if (+ (provider === "openai" || provider === "openai-compatible") &&+ isOpenAIReasoningModel(normalizedModel)+ ) {+ return {+ supported: true,+ efforts: OPENAI_REASONING_EFFORTS,+ defaultEffort: "medium",+ strategy: "openai-responses",+ };+ }+ if (def?.id === "anthropic" && isAnthropicReasoningModel(normalizedModel)) {+ return {+ supported: true,+ efforts: ANTHROPIC_REASONING_EFFORTS,+ defaultEffort: "medium",+ strategy: "anthropic-thinking",+ };+ }+ if (provider === "minimax" || provider === "minimax-token-plan") {+ // MiniMax's thinking block is binary — `{type: "adaptive"}` (on) or+ // `{type: "disabled"}` (off, ignored on M2.x which is always-on) — no+ // budget_tokens tiers like native Anthropic. Any non-"none" effort+ // just turns it on; see buildLangChainReasoningOptions below.+ return {+ supported: true,+ efforts: ANTHROPIC_REASONING_EFFORTS,+ defaultEffort: "medium",+ strategy: "minimax-thinking",+ };+ }+ if (provider === "openrouter" && isOpenRouterReasoningModel(normalizedModel)) {+ return {+ supported: true,+ efforts: OPENROUTER_REASONING_EFFORTS,+ defaultEffort: "medium",+ strategy: "openrouter-reasoning",+ };+ }+ if (provider === "google" && isGeminiThinkingModel(normalizedModel)) {+ return {+ supported: true,+ efforts: GOOGLE_REASONING_EFFORTS,+ defaultEffort: "medium",+ strategy: "google-thinking",+ };+ }+ return { supported: false, efforts: ["none"] };+}++export function normalizeReasoningEffortForCapability(+ effort: AgentReasoningEffort | undefined,+ capability: ReasoningCapability,+): AgentReasoningEffort | undefined {+ if (!capability.supported) return undefined;+ if (!effort) return capability.defaultEffort;+ if (capability.efforts.includes(effort)) return effort;+ if (effort === "minimal" && capability.efforts.includes("low")) return "low";+ if (effort === "xhigh" && capability.efforts.includes("high")) return "high";+ return capability.defaultEffort;+}++export function buildLangChainReasoningOptions(+ provider: string,+ model: string | undefined,+ effort: AgentReasoningEffort | undefined,+): LangChainReasoningOptions {+ const capability = getReasoningCapability(provider, model);+ const normalizedEffort = normalizeReasoningEffortForCapability(effort, capability);+ if (!capability.supported || !normalizedEffort || normalizedEffort === "none") {+ return {};+ }++ switch (capability.strategy) {+ case "openai-responses":+ return {+ reasoning: { effort: toOpenAIReasoningEffort(normalizedEffort) },+ useResponsesApi: true,+ };+ case "anthropic-thinking":+ return buildAnthropicReasoningOptions(model, normalizedEffort);+ case "minimax-thinking":+ // No "none" case needed — normalizedEffort === "none" already+ // short-circuits to {} above, which omits `thinking` (= off).+ return { thinking: { type: "adaptive" } };+ case "openrouter-reasoning":+ return {+ modelKwargs: {+ reasoning: { effort: toOpenAIReasoningEffort(normalizedEffort) },+ include_reasoning: true,+ },+ };+ case "google-thinking":+ return {+ thinkingConfig: {+ includeThoughts: true,+ thinkingLevel: toGoogleThinkingLevel(normalizedEffort),+ thinkingBudget: toGoogleThinkingBudget(normalizedEffort),+ },+ };+ default:+ return {};+ }+}++export function shouldDisableModelStreamingForToolCalling(+ provider: string,+ model?: string,+): boolean {+ return provider === "google" && normalizeModelName(model).startsWith("gemini-3");+}++function buildAnthropicReasoningOptions(+ model: string | undefined,+ effort: AgentReasoningEffort,+): LangChainReasoningOptions {+ if (isAnthropicAdaptiveThinkingModel(model)) {+ return {+ thinking: { type: "adaptive", display: "summarized" },+ outputConfig: { effort: toAnthropicEffort(effort) },+ };+ }+ return {+ thinking: {+ type: "enabled",+ budget_tokens: toAnthropicBudgetTokens(effort),+ display: "summarized",+ },+ };+}++function isOpenAIReasoningModel(model: string): boolean {+ return /^(o\d|o\d-|o\d\.|gpt-5|gpt-5-|gpt-5\.)/.test(model);+}++function isAnthropicReasoningModel(model: string): boolean {+ return /^claude-(opus|sonnet|haiku)-4/.test(model);+}++function isAnthropicAdaptiveThinkingModel(model: string | undefined): boolean {+ if (!model) return false;+ return /^claude-(opus|sonnet)-4-[67]/.test(model);+}++function isGeminiThinkingModel(model: string): boolean {+ return model.startsWith("gemini-2.5") || model.startsWith("gemini-3");+}++function isOpenRouterReasoningModel(model: string): boolean {+ // OpenRouter slugs are `vendor/model`, and both vendor matchers are+ // anchored at the start — so the prefix has to come off first or+ // `openai/gpt-5` never matches.+ if (isOpenAIReasoningModel(stripVendorPrefix(model, "openai/"))) return true;+ if (isAnthropicReasoningModel(stripVendorPrefix(model, "anthropic/"))) return true;+ return /deepseek-r1/i.test(model) || /qwen.*thinking/i.test(model) || /grok-4/i.test(model);+}++function stripVendorPrefix(model: string, prefix: string): string {+ return model.startsWith(prefix) ? model.slice(prefix.length) : model;+}++function toOpenAIReasoningEffort(effort: AgentReasoningEffort): "low" | "medium" | "high" {+ if (effort === "high" || effort === "xhigh") return "high";+ if (effort === "medium") return "medium";+ return "low";+}++function toAnthropicEffort(effort: AgentReasoningEffort): "low" | "medium" | "high" | "xhigh" {+ if (effort === "high" || effort === "xhigh") return effort;+ if (effort === "medium") return "medium";+ return "low";+}++function toAnthropicBudgetTokens(effort: AgentReasoningEffort): number {+ if (effort === "xhigh") return 16_000;+ if (effort === "high") return 10_000;+ if (effort === "medium") return 4_000;+ return 1_024;+}++function toGoogleThinkingLevel(effort: AgentReasoningEffort): "LOW" | "MEDIUM" | "HIGH" {+ if (effort === "high" || effort === "xhigh") return "HIGH";+ if (effort === "medium") return "MEDIUM";+ return "LOW";+}++function toGoogleThinkingBudget(effort: AgentReasoningEffort): number {+ if (effort === "high" || effort === "xhigh") return 8_192;+ if (effort === "medium") return 4_096;+ return 1_024;+}++function normalizeModelName(model?: string): string {+ return model?.trim().toLowerCase() || "";+}++// --- chat-model factory ----------------------------------------------------export interface OpenScreenChatModelConfig {provider: string;@@ -107,8 +368,7 @@ export async function createOpenScreenChatModel(): Promise<BaseChatModel> {// Canonicalise once, here: stored configs can still carry historical// aliases (`claude`, `gemini`, `anthropic-proxy`), and every provider- // comparison below — and in agent-provider-capabilities — is an exact- // match against a registry id.+ // comparison below is an exact match against a registry id.const config: OpenScreenChatModelConfig = {...input,provider: normalizeProviderId(input.provider) ?? input.provider,diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsxindex f7e9cb17f..41f03e515 100644--- a/src/components/ai-edition/v4/FloatingInspector.tsx+++ b/src/components/ai-edition/v4/FloatingInspector.tsx@@ -367,8 +367,8 @@ const SPEED_PRESETS = [1, ...SPEED_OPTIONS.map((option) => option.speed)].sort((* (`settings.speed.customPlaybackSpeed` / `maxSpeedError` / `previewFrameSteppingHint`, shipped* in all 13 locales) but no longer any control for: the V4 shell replaced the panel that hosted* it with a preset-only `<select>` capped at 3×, while the underlying capability goes to- * `MAX_PLAYBACK_SPEED` (100×). Only the control was missing, so this rewires it rather than- * adding anything new.+ * `MAX_PLAYBACK_SPEED` (16×, the native HTMLMediaElement ceiling). Only the control was+ * missing, so this rewires it rather than adding anything new.*/export function SpeedControl({region,diff --git a/src/components/ai-edition/v4/SpeedControl.test.tsx b/src/components/ai-edition/v4/SpeedControl.test.tsxindex c510227d7..05d68be42 100644--- a/src/components/ai-edition/v4/SpeedControl.test.tsx+++ b/src/components/ai-edition/v4/SpeedControl.test.tsx@@ -32,11 +32,11 @@ describe("SpeedControl", () => {it("commits a free-typed speed above the preset ceiling", () => {// The regression this control exists for: the V4 shell only offered presets up to 3×,- // while the underlying capability reaches 100×.+ // while the underlying capability reaches 16× (the native HTMLMediaElement ceiling).const { updateSpeedValue, field } = renderControl(1);- fireEvent.change(field, { target: { value: "25" } });+ fireEvent.change(field, { target: { value: "10" } });fireEvent.blur(field);- expect(updateSpeedValue).toHaveBeenCalledWith("sp1", 25);+ expect(updateSpeedValue).toHaveBeenCalledWith("sp1", 10);});it("commits on Enter as well as on blur, and only once", () => {@@ -53,7 +53,7 @@ describe("SpeedControl", () => {fireEvent.change(field, { target: { value: "500" } });fireEvent.blur(field);expect(updateSpeedValue).not.toHaveBeenCalled();- expect(toastError).toHaveBeenCalledWith("speed.maxSpeedError:100");+ expect(toastError).toHaveBeenCalledWith("speed.maxSpeedError:16");});it("ignores an unparseable draft without touching the region", () => {diff --git a/src/components/video-editor/customPlaybackSpeed.test.ts b/src/components/video-editor/customPlaybackSpeed.test.tsindex eb14cf16e..f15dbde8d 100644--- a/src/components/video-editor/customPlaybackSpeed.test.ts+++ b/src/components/video-editor/customPlaybackSpeed.test.ts@@ -45,26 +45,25 @@ describe("parseCustomPlaybackSpeedInput", () => {});it("accepts the maximum editor speed", () => {- expect(parseCustomPlaybackSpeedInput("100")).toEqual({+ expect(parseCustomPlaybackSpeedInput("16")).toEqual({status: "valid",- draft: "100",- speed: 100,+ draft: "16",+ speed: 16,});});- it("accepts high speeds that exceed the native preview rate", () => {- // 16.1× was rejected under the old 16× cap; it must now be valid.+ it("rejects speeds that exceed the native preview rate", () => {+ // 16.1× exceeds Chromium's playbackRate ceiling, so the editor rejects it.expect(parseCustomPlaybackSpeedInput("16.1")).toEqual({- status: "valid",+ status: "too-fast",draft: "16.1",- speed: 16.1,});});it("rejects speeds above the editor maximum", () => {- expect(parseCustomPlaybackSpeedInput("100.1")).toEqual({+ expect(parseCustomPlaybackSpeedInput("50")).toEqual({status: "too-fast",- draft: "100.1",+ draft: "50",});});});diff --git a/src/components/video-editor/types.ts b/src/components/video-editor/types.tsindex aaeac5333..b62c10a1c 100644--- a/src/components/video-editor/types.ts+++ b/src/components/video-editor/types.ts@@ -390,10 +390,14 @@ export const DEFAULT_CROP_REGION: CropRegion = {export type PlaybackSpeed = number;export const MIN_PLAYBACK_SPEED = 0.1;-export const MAX_PLAYBACK_SPEED = 100;// Chromium hard-caps HTMLMediaElement.playbackRate at 16 (setting more throws// NotSupportedError). At or below this, preview plays natively; above it, preview// frame-steps by seeking and audio export uses an offline pitch-preserved stretch.+// ponytail: the editor cap and the native preview cap are the same number —+// everything above this is the export path's stretch, and the editor's input+// parser shouldn't accept speeds the preview cannot render. A 50× entry now+// clamps to 16, not 100.+export const MAX_PLAYBACK_SPEED = 16;export const MAX_NATIVE_PLAYBACK_RATE = 16;export function clampPlaybackSpeed(speed: number): PlaybackSpeed {diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.tsindex a10b718ab..5595f5454 100644--- a/src/lib/ai-edition/schema/index.ts+++ b/src/lib/ai-edition/schema/index.ts@@ -33,6 +33,20 @@ import { anchorRegionsWithDerivedMs } from "../timeline/timelineMap";// `AspectRatio` union without a runtime bridge.export const axcutSchemaVersion = 6;+// ponytail: every region schema shares the same monotonicity rule+// (end >= start) with the same error shape. Factor the refine so the+// five call sites stay declarative; the message + path stay tied to+// the field names (e.g. `endSec >= startSec`, `endMs >= startMs`).+const endGteStart = <T extends z.ZodObject<z.ZodRawShape>>(+ schema: T,+ endKey: keyof T["shape"] & string,+ startKey: keyof T["shape"] & string,+) =>+ schema.refine((data) => (data[endKey] as number) >= (data[startKey] as number), {+ message: `${endKey} must be greater than or equal to ${startKey}`,+ path: [endKey],+ });+export const isoDateSchema = z.string().datetime({ offset: true });export const wordSchema = z@@ -160,44 +174,41 @@ export const clipSchema = zpath: ["sourceEndSec"],});-export const gapSchema = z- .object({+export const gapSchema = endGteStart(+ z.object({id: z.string().min(1),timelineStartSec: z.number().nonnegative(),timelineEndSec: z.number().nonnegative(),reason: z.string().default(""),- })- .refine((data) => data.timelineEndSec >= data.timelineStartSec, {- message: "timelineEndSec must be greater than or equal to timelineStartSec",- path: ["timelineEndSec"],- });+ }),+ "timelineEndSec",+ "timelineStartSec",+);-export const rangeSchema = z- .object({+export const rangeSchema = endGteStart(+ z.object({startSec: z.number().nonnegative(),endSec: z.number().nonnegative(),reason: z.string().default(""),- })- .refine((data) => data.endSec >= data.startSec, {- message: "endSec must be greater than or equal to startSec",- path: ["endSec"],- });+ }),+ "endSec",+ "startSec",+);// ponytail: trimRanges reference asset source-time (not timeline). trimRegions// in v2 are the inverse — a skip = the region inside the source we DON'T keep.-export const trimRangeSchema = z- .object({+export const trimRangeSchema = endGteStart(+ z.object({id: z.string().min(1),assetId: z.string().min(1),startSec: z.number().nonnegative(),endSec: z.number().nonnegative(),reason: z.string().default(""),origin: z.enum(["system", "agent", "user"]),- })- .refine((data) => data.endSec >= data.startSec, {- message: "endSec must be greater than or equal to startSec",- path: ["endSec"],- });+ }),+ "endSec",+ "startSec",+);export const timelineSchema = z.preprocess(// Back-compat: the field was renamed skipRanges → trimRanges. Old persisted@@ -353,8 +364,8 @@ const clipAnchorShape = {sourceEndSec: z.number().nonnegative().optional(),};-export const annotationRegionSchema = z- .object({+export const annotationRegionSchema = endGteStart(+ z.object({id: z.string().min(1),startMs: z.number().nonnegative(),endMs: z.number().nonnegative(),@@ -376,14 +387,13 @@ export const annotationRegionSchema = zannotationSource: z.literal("auto-caption").optional(),figureData: figureDataSchema,blurData: blurDataSchema,- })- .refine((data) => data.endMs >= data.startMs, {- message: "endMs must be greater than or equal to startMs",- path: ["endMs"],- });+ }),+ "endMs",+ "startMs",+);-export const zoomRegionSchema = z- .object({+export const zoomRegionSchema = endGteStart(+ z.object({id: z.string().min(1),startMs: z.number().nonnegative(),endMs: z.number().nonnegative(),@@ -404,11 +414,10 @@ export const zoomRegionSchema = zrotationPreset: z.enum(["iso", "left", "right"]).optional(),customScale: z.number().positive().optional(),source: z.enum(["auto", "manual"]).optional(),- })- .refine((data) => data.endMs >= data.startMs, {- message: "endMs must be greater than or equal to startMs",- path: ["endMs"],- });+ }),+ "endMs",+ "startMs",+);// Legacy OpenScreen appearance / export settings that the v3 schema doesn't// normalize into the timeline / assets model. They are applied at export time