Captions take a cut's own words; AGENTS.md: captions and titles through Captions and Region, never a typed top

An edit holding several cuts has one words.json, so Captions had no words for each cut and agents wrote their own
captions at a typed top, in the app's UI zones.
This commit is contained in:
shinyobjectz committed 2026-12-05 08:30:39 -08:00
1 parent 98beb04318
commit 6ed150d21f
3 files changed
+24 -5

No files matched your search

+3 -2
View File
@@ -104,8 +104,9 @@ measured on the take, never a guess. <Audio src startFrom endAt volume={n | (f)
it as \`raea guide sound\` says; narration is <Speech text start> from raea/speech. <Mix lufs ceiling> masters the sound.
Words: useWords() -> [{text, from, to}] (frames, the cuts' words), word("phrase") -> the frame it's said,
findPhrase(words, "phrase", {occurrence, edge: "start" | "end"}).
Placement: <Region name="top" | "bottom" | "center" | "auto" | "full"> keeps a part in a band clear of the face and
the platforms' buttons; useRegion() gives its box.
Placement: <Captions said?> (said: a cut's own words, when the edit holds several cuts) captions in the brand's style;
titles go in <Region name="top" | "bottom" | "center" | "auto" | "full">. Both keep clear of the face and the app's
buttons; never type a text's top or left.
Composition: registerRoot(() => <Composition id component width height fps durationInFrames />).
Not there: React hooks come from "react" (useMemo, useState), not from raea.
`;
+14 -1
View File
@@ -2,7 +2,7 @@
// "3D in the same tree", "Toon surfaces and ink outlines", "The camera's lens", "Motion blur", "Page layers under and
// over the 3D", "Games: state from input, frame by frame").
import { beforeEach, describe, expect, test } from "bun:test";
import { Audio, Region, lyria, proofBoxes, sao, useGameEvents, useGameState, useInput, useRegion } from "../src";
import { Audio, Captions, Region, lyria, proofBoxes, sao, useGameEvents, useGameState, useInput, useRegion } from "../src";
import { Canvas3D, Cylinder, Fisheye, LensDistortion, Model, MotionBlur, Sphere } from "../src/3d";
import { DirectionalLight, Mesh, MeshStandardMaterial, MeshToonMaterial, PointLight } from "@raea/render/three";
// the retired three.js shapes, compared against (M5: no longer exported from raea)
@@ -299,3 +299,16 @@ test("an input changed far back refolds from a let-go state correctly", () => {
for (let g = 0; g < 2999; g++) s = step(s, { keys: input[g]?.keys ?? [] }, g);
expect(got).toBe(s);
});
describe("Captions", () => {
test("a cut's own words (said) caption it inside the app's zones, when the edit's words are another cut's", () => {
const said = [{ text: "So", from: 0, to: 6 }, { text: "fresh.", from: 7, to: 20 }];
const html = renderFrame(<Captions said={said} />, { ...base, frame: 3, words: [{ text: "other", from: 0, to: 30 }] });
expect(html).toContain('data-raea-role="caption"');
expect(html).toContain("So");
expect(html).not.toContain("other");
// the bottom band ends 420 px over the bottom, and its right side keeps the buttons' 140
expect(html).toContain("width:875px");
expect(html).toContain('data-band-bottom="1500"');
});
});
+7 -2
View File
@@ -11,6 +11,10 @@ import { useWords } from "./words";
export interface CaptionsProps {
/** the band they sit in (Region): "bottom" by default, "top" when something owns the bottom */
region?: RegionName;
/** the cut's words, in frames on its clock, when the edit's own (useWords, from the words.json `raea cut` writes) aren't
* this cut's: an edit holding several cuts passes each its words (12-05: agents with six cuts in one edit wrote their
* own captions at a typed top, in the app's zones, for want of this) */
said?: readonly TimelineWord[];
/** the most words a caption holds (3) */
words?: number;
/** a pause longer than this many frames starts a new caption (8) */
@@ -55,10 +59,11 @@ const spell = (fix: Record<string, string> | undefined, text: string) => {
};
/** Captions of everything said in the edit, in the brand's caption style, in a safe band. */
export function Captions({ region = "bottom", words: max = 3, pause = 8, fix, size = 84, accent = true, style, className, children }: CaptionsProps) {
export function Captions({ region = "bottom", said, words: max = 3, pause = 8, fix, size = 84, accent = true, style, className, children }: CaptionsProps) {
const f = useCurrentFrame();
const { width } = useClockState("Captions").config;
const groups = groupWords(useWords(), max, pause);
const own = useWords();
const groups = groupWords([...(said ?? own)], max, pause);
const i = captionAt(groups, f, pause);
const g = i < 0 ? null : groups[i].map((w) => ({ ...w, text: spell(fix, w.text) }));
const saying = g ? g.findIndex((w) => f >= w.from && f < Math.max(w.to, w.from + 4)) : -1;