Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

refactor: clean semantic studio interactions

kashorinc5e591227036
diff --git a/packages/ranking/src/fragment.ts b/packages/ranking/src/fragment.ts
index 7eeb23bf..e53034d2 100644
--- a/packages/ranking/src/fragment.ts
+++ b/packages/ranking/src/fragment.ts
@@ -135,7 +135,7 @@ export function createRankingFragment(
? rankingProducers.appendColumnCandidate
: rankingProducers.appendTriggeredCandidate,
inputs: {
- set: candidates, spec: resolvedSpec, semantic: input("semantic"),
+ set: candidates, spec: resolvedSpec,
window: operation(windowId),
},
result: { kind: "output", name: "set" },
diff --git a/packages/studio/src/style.css b/packages/studio/src/style.css
index 74b7d5e4..119fd568 100644
--- a/packages/studio/src/style.css
+++ b/packages/studio/src/style.css
@@ -4,7 +4,6 @@
--panel: #141518;
--panel-raised: #1a1b1f;
--field: #222429;
- --hover: #292b31;
--lane: #0c0d10;
--line: #26282d;
--line-strong: #33363c;
@@ -12,39 +11,45 @@
--text-2: #a4a7ae;
--text-3: #6f737c;
/* Replace this ramp as one unit when Hypit's interaction identity changes. */
- --brand-200: #f8b6c4;
- --brand-400: #ee647c;
- --brand-500: #e83f5f;
- --brand-600: #c92d4c;
+ --brand-200: #f8c1ce;
+ --brand-400: #ed7898;
+ --brand-500: #e3406a;
+ --brand-600: #b52b4d;
--brand-soft: color-mix(in srgb, var(--brand-500) 14%, transparent);
--brand-foreground: var(--text);
--interaction-accent: var(--brand-500);
--interaction-pressed: var(--brand-600);
- --danger: #d33944;
- /* Track family is data encoding, deliberately separated from the brand hue. */
- --component: #ae5528;
- --component-rail: #ff9661;
- /* Ranking reveal windows are component structure, not imported media. */
- --ranking-reveal: #874721;
+ --danger: #c00015;
+ /* Track families occupy fixed hue slots; variants stay on their family's hue. */
+ --component: #ac571d;
+ --component-rail: #ff9858;
+ /* Ranking reveal is a darker component variant, not a new family. */
+ --ranking-reveal: #7b3702;
--ranking-reveal-rail: #e7834c;
--audio: #38853e;
--audio-rail: #75d079;
- --speech: #008882;
- --speech-rail: #00d5cd;
- --speech-deep: #071f1d;
- /* Semantic ruler: a restrained teal depth ramp, not the bright family rail. */
- --semantic-segment: #355f5a;
- --semantic-word: #2a504c;
- --semantic-marker: #21423f;
- --semantic-current: #43847b;
- --media: #007bb2;
- --media-rail: #38c5ff;
- --text-track: #5c69bc;
- --text-rail: #9caeff;
- --caption: #8e57a5;
- --caption-rail: #db98f9;
- --visual: #69737d;
- --visual-rail: #adb9c5;
+ --speech: #008889;
+ --speech-rail: #00d4d5;
+ /* Semantic ruler: brightness separates content from its own band; hue marks state. */
+ --semantic-segment: #417370;
+ --semantic-word: #005551;
+ /* Author intent uses a gold annotation hue; brand pink stays in the chrome. */
+ --semantic-intent: #a28b2b;
+ /* Same perceived active level as a selected/covered semantic cell. */
+ --semantic-current: #009f98;
+ /* Ordered marker depth: one hue, decreasing lightness. */
+ --intent-depth-0: #dfca7d;
+ --intent-depth-1: #c0aa54;
+ --intent-depth-2: #a28b2b;
+ --intent-depth-3: #846d00;
+ --media: #1777b8;
+ --media-rail: #58c0ff;
+ --text-track: #6f63b8;
+ --text-rail: #b3a6ff;
+ --caption: #995398;
+ --caption-rail: #ea93e8;
+ --visual: #6a737c;
+ --visual-rail: #aeb9c4;
--timeline-label-width: 152px;
--source-width: 350px;
--workspace-width: 300px;
@@ -76,7 +81,10 @@ html, body, #app {
}
body { cursor: default; }
button, [role="button"] { font: inherit; }
-button { cursor: pointer; }
+/* Keep ordinary content on one neutral pointer. The two explicit geometry
+ affordances below are the only exceptions: panel boundaries and item
+ boundaries have a real spatial adjustment meaning. */
+#app, #app * { cursor: default !important; }
button:focus-visible, textarea:focus-visible {
outline: 1px solid var(--interaction-accent);
outline-offset: -1px;
@@ -90,7 +98,6 @@ button:focus-visible, textarea:focus-visible {
background: rgba(255, 255, 255, .16);
background-clip: padding-box;
}
-*::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .26); }
*::-webkit-scrollbar-corner, *::-webkit-resizer { background: transparent; }
.icon, .pane-icon { display: block; width: 16px; height: 16px; flex: none; }
@@ -211,7 +218,6 @@ button:focus-visible, textarea:focus-visible {
background: transparent;
color: var(--text-3);
}
-.icon-button:hover, .tool-button:hover { background: var(--hover); color: var(--text); }
.tool-button.active { background: var(--brand-soft); color: var(--interaction-accent); }
.tool-button.active:active { color: var(--interaction-pressed); }
@@ -239,7 +245,6 @@ button:focus-visible, textarea:focus-visible {
background: #141518;
font: 11px/19px var(--font-mono);
user-select: text;
- cursor: text;
}
.code-editor {
display: none;
@@ -257,7 +262,6 @@ button:focus-visible, textarea:focus-visible {
tab-size: 2;
caret-color: var(--interaction-accent);
user-select: text;
- cursor: text;
white-space: pre;
}
.code.is-editing .code-scroll { display: none; }
@@ -271,33 +275,19 @@ button:focus-visible, textarea:focus-visible {
text-align: right;
user-select: none;
}
-.code-line.bound { cursor: pointer; }
-.code-line.bound:hover { background: rgba(255, 255, 255, .025); }
-.code-line .gutter-bar {
- position: absolute;
- top: 2px;
- bottom: 2px;
- width: 2px;
- border-radius: 1px;
- background: var(--tone, #fff);
- opacity: .68;
- pointer-events: none;
-}
-.code-line.bound:hover .gutter-bar { opacity: 1; }
-.code-line.bound:hover .line-number { color: var(--tone, var(--text-2)); }
-.code-line code { flex: none; padding-right: 12px; color: #9b9fa8; font: inherit; white-space: pre; }
-.tok-header, .tok-comment { color: #5e626b; font-style: italic; }
-.tok-punct { color: #777b84; }
-.tok-tag { color: #7da5dc; }
-.tok-attr { color: #b391c6; }
-.tok-string { color: #7db08c; }
-.tok-reference { color: #d58b78; }
-.tok-marker { color: #76b7c4; font-weight: 500; cursor: pointer; }
-.tok-role { color: #c987a2; }
-.tone-0 { --tone: #77a6c7; }
-.tone-1 { --tone: #6fae9d; }
-.tone-2 { --tone: #ad946b; }
-.tone-3 { --tone: #a582b3; }
+.code-line code { flex: none; padding-right: 12px; color: #bebebe; font: inherit; white-space: pre; }
+.tok-header, .tok-comment { color: #4e5358; font-style: italic; }
+.tok-punct { color: #686c71; }
+.tok-tag { color: #6896c6; }
+.tok-attr { color: #8f83b7; }
+.tok-string { color: #76aa80; }
+.tok-reference { color: #e18f7a; }
+.tok-marker { color: var(--intent-depth-1); font-weight: 500; }
+.tok-role { color: #ca84b3; }
+.tone-0 { --tone: var(--intent-depth-0); }
+.tone-1 { --tone: var(--intent-depth-1); }
+.tone-2 { --tone: var(--intent-depth-2); }
+.tone-3 { --tone: var(--intent-depth-3); }
.tok-marker.tone-0, .tok-marker.tone-1, .tok-marker.tone-2, .tok-marker.tone-3 {
color: var(--tone);
background: transparent;
@@ -305,7 +295,7 @@ button:focus-visible, textarea:focus-visible {
.range-canvas { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.spoken { position: absolute; z-index: 0; border-radius: 2px; background: color-mix(in srgb, var(--speech) 18%, transparent); pointer-events: none; }
.range-element { fill: rgba(255, 255, 255, .035); stroke: rgba(255, 255, 255, .64); stroke-width: 1; }
-.range-binding { fill: transparent; stroke: var(--tone, var(--interaction-accent)); stroke-width: 1; }
+.range-binding { fill: transparent; stroke: var(--tone, var(--intent-depth-2)); stroke-width: 1; }
/* Preview */
.stage { height: 100%; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
@@ -362,7 +352,6 @@ button:focus-visible, textarea:focus-visible {
background: transparent;
color: #b6b9c0;
}
-.stage-bar button:hover { background: var(--hover); color: #fff; }
.stage-bar button[data-play] { width: 30px; height: 30px; color: #f0f1f3; }
.stage-mute { margin-left: 5px; }
@@ -527,7 +516,6 @@ button:focus-visible, textarea:focus-visible {
overflow: hidden;
border-bottom: 1px solid var(--line);
background: #111216;
- cursor: pointer;
}
.tick {
position: absolute;
@@ -571,16 +559,16 @@ button:focus-visible, textarea:focus-visible {
.tick-last { padding-right: 4px; padding-left: 0; border-right: 1px solid #45484e; border-left: 0; transform: translateX(-100%); }
.lanes { min-height: 0; cursor: default; }
.lane { position: relative; min-height: 0; overflow: hidden; border-bottom: 1px solid #191b1f; background: var(--lane); }
-.semantic-lane { min-height: 0; background: var(--speech-deep); }
+.semantic-lane { min-height: 0; background: var(--lane); }
.semantic-band {
position: absolute;
right: 0;
left: 0;
height: var(--semantic-band-height);
overflow: hidden;
- background: var(--speech-deep);
+ background: var(--lane);
}
-.semantic-band-marker { border-bottom: 0; }
+.semantic-band-intent { border-bottom: 0; }
.lane-attached {
border-left: 0;
background: var(--lane);
@@ -613,11 +601,14 @@ button:focus-visible, textarea:focus-visible {
--semantic-cell: var(--semantic-word);
}
.semantic-selection {
- --semantic-cell: var(--semantic-marker);
- box-shadow: none;
+ --semantic-cell: var(--semantic-intent);
+ color: #fff;
}
-.semantic-segment.selected { z-index: 4; box-shadow: 0 0 0 var(--timeline-selection-stroke) var(--timeline-selection-color); }
-.semantic-segment.live { filter: brightness(1.08); }
+.semantic-cell.selected,
+.semantic-cell.live { z-index: 4; filter: brightness(1.22); }
+.semantic-segment.selected { box-shadow: none; }
+.semantic-segment.live.selected { filter: brightness(1.22); }
+.semantic-moment.selected { z-index: 4; filter: brightness(1.22); }
.semantic-segment-label {
flex: 1 1 auto;
min-width: 0;
@@ -632,7 +623,7 @@ button:focus-visible, textarea:focus-visible {
display: block;
overflow: hidden;
text-overflow: ellipsis;
- color: #eef0f3;
+ color: #fff;
font-size: 11px;
font-weight: 500;
white-space: nowrap;
@@ -654,12 +645,14 @@ button:focus-visible, textarea:focus-visible {
height: 14px;
transform: translateX(-7px) rotate(45deg);
border-radius: 0;
- background: var(--semantic-current);
- box-shadow: none;
+ padding: 0;
+ border: 0;
+ background: var(--semantic-intent);
}
+.semantic-moment:focus-visible { outline: 0; }
.track-label-semantic::before {
border-radius: 0;
- background: var(--speech-deep);
+ background: #181a1f;
}
.label-hidden .semantic-word-label,
.label-hidden .semantic-segment-label,
@@ -675,7 +668,6 @@ button:focus-visible, textarea:focus-visible {
font-size: 11px;
line-height: 17px;
}
-.track-fold:hover { background: #303238; color: #fff; }
.track-label-attached {
padding: 0 15px;
background: transparent;
@@ -703,7 +695,6 @@ button:focus-visible, textarea:focus-visible {
transition: transform 100ms ease;
}
.attachment-fold.expanded::before { transform: rotate(45deg) translate(-1px, -1px); }
-.attachment-fold:hover { background: transparent; }
.clip {
--track: var(--visual);
--item-head: color-mix(in srgb, var(--track) 58%, var(--lane));
@@ -718,6 +709,7 @@ button:focus-visible, textarea:focus-visible {
display: block;
padding: 0;
border: 0;
+ border-bottom: 1px solid color-mix(in srgb, var(--track) 48%, var(--lane));
border-radius: var(--timeline-item-radius);
background: var(--item-body);
box-shadow: none;
@@ -725,6 +717,22 @@ button:focus-visible, textarea:focus-visible {
text-align: left;
cursor: default;
}
+/* The edge affordance is intentionally visual-only for now. Actual trim and
+ writeback remain disabled until their SVML mapping is implemented. */
+#app .clip::before,
+#app .clip::after {
+ content: "";
+ position: absolute;
+ z-index: 8;
+ top: 0;
+ bottom: 0;
+ width: 6px;
+ pointer-events: auto;
+ background: transparent;
+ cursor: ew-resize !important;
+}
+#app .clip::before { left: 0; }
+#app .clip::after { right: 0; }
.clip.selected {
z-index: 4;
overflow: visible;
@@ -915,7 +923,6 @@ button:focus-visible, textarea:focus-visible {
width: 100%;
height: 14px;
background: transparent;
- cursor: pointer;
}
.zoom::before {
content: "";
@@ -934,20 +941,17 @@ button:focus-visible, textarea:focus-visible {
min-width: 14px;
border-radius: 2px;
background: #3a3e46;
- cursor: grab;
transition: background 80ms ease;
}
/* The control remains easy to acquire without making its visible rail fat. */
.zoom-window::before { content: ""; position: absolute; inset: -5px 0; }
-.zoom-window:hover { background: #464b54; }
-.zoom-window:active { background: #505660; cursor: grabbing; }
+.zoom-window:active { background: #505660; }
.zoom-grip {
position: absolute;
z-index: 1;
top: -5px;
width: 12px;
height: 14px;
- cursor: ew-resize;
}
.zoom-grip-start { left: -5px; }
.zoom-grip-end { right: -5px; }
@@ -955,10 +959,9 @@ button:focus-visible, textarea:focus-visible {
/* Resizers and errors */
.handle { position: relative; z-index: 20; background: #0c0d0f; touch-action: none; }
.handle::after { content: ""; position: absolute; background: transparent; }
-.handle:hover::after, .handle:focus-visible::after { background: var(--interaction-accent); }
-.handle-column { width: 8px; cursor: col-resize; }
+#app .handle-column { width: 8px; cursor: col-resize !important; }
.handle-column::after { top: 0; bottom: 0; left: 3px; width: 1px; }
-.handle-row { height: 8px; cursor: row-resize; }
+#app .handle-row { height: 8px; cursor: row-resize !important; }
.handle-row::after { right: 0; left: 0; top: 3px; height: 1px; }
.failure {
position: absolute;
diff --git a/packages/studio/src/ui/code.ts b/packages/studio/src/ui/code.ts
index e1eac3c8..84018de9 100644
--- a/packages/studio/src/ui/code.ts
+++ b/packages/studio/src/ui/code.ts
@@ -1,6 +1,6 @@
import type { Range, StudioSnapshot } from "../shared.js";
import { icon, setIcon } from "./icons.js";
-import { markerTones } from "./markers.js";
+import { intentTones } from "./markers.js";
import { tokenizeSvml } from "./syntax.js";
import type { Token } from "./syntax.js";
@@ -9,7 +9,7 @@ const SVG_NS = "http://www.w3.org/2000/svg";
export type Highlight = {
readonly range: Range;
/**
- * `element` outlines the authored tag, `binding` the Script marker, and
+ * `element` outlines the authored tag, `binding` the author's intent, and
* `onscreen` a tag that is merely drawn at this frame rather than chosen.
*/
readonly tone: "element" | "binding" | "onscreen";
@@ -64,15 +64,8 @@ function roundedRangePath(points: readonly { x: number; y: number }[], radius =
}).join(" ")} Z`;
}
-/**
- * The gutter holds one bar per nesting level. `GUTTER_LEFT` is where the
- * outermost bar starts, past the right edge of a three-digit line number.
- */
-const GUTTER_LEFT = 27;
-const GUTTER_STEP = 3;
-const GUTTER_LEVELS = 4;
-/** Where a range outline may begin: clear of every bar the gutter can hold. */
-const GUTTER_TEXT = GUTTER_LEFT + GUTTER_STEP * GUTTER_LEVELS + 2;
+/** Keep source-range outlines clear of the line-number column. */
+const RANGE_LEFT = 41;
export function createCodePane(): CodePane {
const element = document.createElement("section");
@@ -229,9 +222,8 @@ export function createCodePane(): CodePane {
const end = caret(item.range.end, "end");
if (start === undefined || end === undefined) continue;
const lineHeight = start.height || Number.parseFloat(getComputedStyle(scroll).lineHeight) || 20;
- // The outline's left edge sits clear of the gutter bars rather than over
- // the first characters of the code.
- const left = GUTTER_TEXT;
+ // The outline starts at the code column rather than over the line number.
+ const left = RANGE_LEFT;
const right = width - 10;
const startX = Math.max(left, start.x - 3);
const endX = Math.max(left, end.x + 3);
@@ -272,7 +264,7 @@ export function createCodePane(): CodePane {
editingRevision = snapshot.revision;
}
const tokens: readonly Token[] = tokenizeSvml(source);
- const tones = markerTones(snapshot);
+ const tones = intentTones(snapshot);
lines = [];
const fragment = document.createDocumentFragment();
let offset = 0;
@@ -330,57 +322,6 @@ export function createCodePane(): CodePane {
offset = lineEnd + 1;
}
- // Mark every line that can be clicked, at the level it belongs to. Only a
- // small part of a Source binds to anything, so what is clickable has to be
- // visible standing still rather than discovered by sweeping the pointer
- // over it — and a Script range is as clickable as an authored element.
- const clickable: { range: Range; tone: number | undefined }[] = [];
- for (const segment of snapshot.script?.segments ?? []) {
- clickable.push({ range: segment.range, tone: tones.get(segment.id) });
- }
- for (const selection of snapshot.script?.selections ?? []) {
- clickable.push({
- range: { start: selection.open.start, end: selection.close.end },
- tone: tones.get(selection.id),
- });
- }
- for (const track of snapshot.tracks) {
- for (const clip of track.clips) {
- if (clip.elementRange === undefined) continue;
- clickable.push({ range: clip.elementRange, tone: tones.get(clip.authoredId) });
- }
- }
- for (const line of lines) {
- // Widest first: a bar per level the line sits inside, laid left to
- // right so the enclosing pair stays visible beside the nested one
- // instead of being covered by it.
- // Several clips can be drawn from one tag - a Caption Track is one tag
- // and a dozen cues - and a bar per clip would say the line is nested a
- // dozen deep. One bar per distinct range is what nesting means.
- const distinct = new Map<string, { range: Range; tone: number | undefined }>();
- for (const item of clickable) {
- if (line.end < item.range.start || line.start > item.range.end) continue;
- const key = `${item.range.start}:${item.range.end}`;
- if (!distinct.has(key)) distinct.set(key, item);
- }
- const covering = [...distinct.values()]
- .sort((left, right) =>
- (right.range.end - right.range.start) - (left.range.end - left.range.start))
- .slice(0, GUTTER_LEVELS);
- if (covering.length === 0) continue;
- line.element.classList.add("bound");
- // The tightest range is what the line means, so the line-number hover
- // colour still follows the innermost level.
- const innermost = covering[covering.length - 1]!;
- if (innermost.tone !== undefined) line.element.classList.add(`tone-${innermost.tone}`);
- for (const [level, item] of covering.entries()) {
- const bar = document.createElement("span");
- bar.className = item.tone === undefined ? "gutter-bar" : `gutter-bar tone-${item.tone}`;
- bar.style.left = `${GUTTER_LEFT + level * GUTTER_STEP}px`;
- line.element.append(bar);
- }
- }
-
scroll.replaceChildren(canvas, fragment);
draw();
},
diff --git a/packages/studio/src/ui/icons.ts b/packages/studio/src/ui/icons.ts
index c9c8a652..e864e6a5 100644
--- a/packages/studio/src/ui/icons.ts
+++ b/packages/studio/src/ui/icons.ts
@@ -23,6 +23,8 @@ const paths: Readonly<Record<string, string>> = {
video: '<rect x="3" y="5" width="14" height="14" rx="2"/><path d="m17 10 4-2v8l-4-2v-4Z"/>',
text: '<path d="M5 5h14M12 5v14M8 19h8"/>',
captions: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M7 11h4M13 11h4M7 15h3M12 15h5"/>',
+ link: '<path d="m9 15 6-6"/><path d="M7.5 17.5h-1a4 4 0 0 1 0-8h3"/><path d="M16.5 6.5h1a4 4 0 0 1 0 8h-3"/>',
+ moment: '<path d="m12 3 3 9-3 9-3-9 3-9Z"/>',
component: '<rect x="4" y="4" width="6" height="6" rx="1"/><rect x="14" y="4" width="6" height="6" rx="1"/><rect x="4" y="14" width="6" height="6" rx="1"/><rect x="14" y="14" width="6" height="6" rx="1"/>',
layers: '<path d="m12 3 9 5-9 5-9-5 9-5Z"/><path d="m3 12 9 5 9-5M3 16l9 5 9-5"/>',
ranking: '<path d="M5 19V9h4v10M10 19V5h4v14M15 19v-7h4v7M3 19h18"/>',
diff --git a/packages/studio/src/ui/main.ts b/packages/studio/src/ui/main.ts
index 5ef30a46..d0db58b5 100644
--- a/packages/studio/src/ui/main.ts
+++ b/packages/studio/src/ui/main.ts
@@ -3,7 +3,7 @@ import { createCodePane } from "./code.js";
import { setIcon } from "./icons.js";
import { createHandle } from "./resize.js";
import type { Highlight } from "./code.js";
-import { liveRanges, markerTones, spanAtOffset } from "./markers.js";
+import { intentAtOffset, intentTones, liveRanges, spanAtOffset } from "./markers.js";
import { clipAtOffset, createStore } from "./selection.js";
import { createStage } from "./stage.js";
import { createTimeline } from "./timeline.js";
@@ -201,6 +201,59 @@ function renderSemanticInspector(snapshot: StudioSnapshot, segmentId: string): v
]));
}
+function renderSemanticSelectionInspector(snapshot: StudioSnapshot, selectionId: string): void {
+ const selection = snapshot.semantic.selections.find((item) => item.id === selectionId);
+ if (selection === undefined) { inspector.replaceChildren(); return; }
+ const fps = snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;
+ const durationFrames = selection.endFrameExclusive - selection.startFrame;
+ const source = snapshot.script?.selections.find((item) => item.id === selectionId);
+ const hero = document.createElement("div");
+ hero.className = "selection-hero";
+ hero.innerHTML = `
+ <span class="selection-icon" data-selection-icon></span>
+ <div class="selection-title"><strong></strong><small></small></div>
+ <span class="selection-kind">Selection</span>`;
+ setIcon(hero.querySelector("[data-selection-icon]")!, "link");
+ hero.querySelector("strong")!.textContent = selection.id;
+ hero.querySelector("small")!.textContent = "Author intent";
+ inspector.replaceChildren(hero,
+ group("Timing", [
+ property("Start", `${selection.startFrame}f`, "property-number"),
+ property("End", `${selection.endFrameExclusive}f`, "property-number"),
+ property("Duration", `${durationFrames}f`, "property-number"),
+ property("Seconds", `${(durationFrames / fps).toFixed(2)}s`, "property-number"),
+ ]),
+ ...(source === undefined ? [] : [group("Source", [
+ property("Range", `${source.open.start}–${source.close.end}`, "property-wide property-code"),
+ ])]),
+ );
+}
+
+function renderSemanticMomentInspector(snapshot: StudioSnapshot, momentId: string): void {
+ const moment = snapshot.semantic.moments.find((item) => item.id === momentId);
+ if (moment === undefined) { inspector.replaceChildren(); return; }
+ const fps = snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;
+ const source = snapshot.script?.moments.find((item) => item.id === momentId);
+ const hero = document.createElement("div");
+ hero.className = "selection-hero";
+ hero.innerHTML = `
+ <span class="selection-icon" data-selection-icon></span>
+ <div class="selection-title"><strong></strong><small></small></div>
+ <span class="selection-kind">Moment</span>`;
+ setIcon(hero.querySelector("[data-selection-icon]")!, "moment");
+ hero.querySelector("strong")!.textContent = moment.id;
+ hero.querySelector("small")!.textContent = "Author intent";
+ inspector.replaceChildren(hero,
+ group("Timing", [
+ property("Frame", `${moment.frame}f`, "property-number"),
+ property("Seconds", `${(moment.frame / fps).toFixed(2)}s`, "property-number"),
+ ]),
+ ...(source === undefined ? [] : [group("Source", [
+ property("Range", `${source.range.start}–${source.range.end}`, "property-wide property-code"),
+ ])]),
+ );
+}
+
// The word being spoken at the playhead, which is the point of carrying token
// timings at all: it ties the Script text to the frame on screen.
store.subscribe(({ snapshot, playhead }) => {
@@ -218,19 +271,27 @@ store.subscribe(({ snapshot, selection, playhead }) => {
const chosenSegment = selection.kind === "semantic-segment"
? snapshot.semantic.segments.find((item) => item.id === selection.segmentId)
: undefined;
+ const chosenSelection = selection.kind === "semantic-selection"
+ ? snapshot.semantic.selections.find((item) => item.id === selection.selectionId)
+ : undefined;
+ const chosenMoment = selection.kind === "semantic-moment"
+ ? snapshot.semantic.moments.find((item) => item.id === selection.momentId)
+ : undefined;
// Rebuilding this every frame of playback would be DOM churn for no change.
- const describes = `${snapshot.revision}:${chosen?.id ?? chosenSegment?.id ?? ""}`;
+ const describes = `${snapshot.revision}:${selection.kind}:${chosen?.id ?? chosenSegment?.id ?? chosenSelection?.id ?? chosenMoment?.id ?? ""}`;
if (describes !== described) {
described = describes;
if (chosenSegment !== undefined) renderSemanticInspector(snapshot, chosenSegment.id);
+ else if (chosenSelection !== undefined) renderSemanticSelectionInspector(snapshot, chosenSelection.id);
+ else if (chosenMoment !== undefined) renderSemanticMomentInspector(snapshot, chosenMoment.id);
else renderInspector(snapshot, chosen?.id);
}
// Every Selection the playhead is inside is outlined, not only what was
// clicked, and not only what has a clip. A Selection inside another Selection
// is still inside it, so the enclosing pair stays outlined while the inner one
- // is — that nesting is the whole point of the markers.
- const tones = markerTones(snapshot);
+ // is — that nesting is the whole point of the authored intents.
+ const tones = intentTones(snapshot);
const live = store.clipsAt(playhead.frame);
const highlights: Highlight[] = liveRanges(snapshot, playhead.frame).map((selection) => ({
range: selection.range,
@@ -248,21 +309,32 @@ store.subscribe(({ snapshot, selection, playhead }) => {
if (chosenSegment?.range !== undefined) {
highlights.push({ range: chosenSegment.range, tone: "element" });
}
+ const sourceSelection = chosenSelection === undefined
+ ? undefined
+ : snapshot.script?.selections.find((item) => item.id === chosenSelection.id);
+ const sourceMoment = chosenMoment === undefined
+ ? undefined
+ : snapshot.script?.moments.find((item) => item.id === chosenMoment.id);
+ const chosenIntentRange = sourceSelection === undefined
+ ? sourceMoment?.range
+ : { start: sourceSelection.open.start, end: sourceSelection.close.end };
+ if (chosenIntentRange !== undefined) highlights.push({ range: chosenIntentRange, tone: "binding" });
// Scroll only when the selection actually moved, and never toward the pane
// the author is pointing at: following the playhead every frame would drag
// the source out from under whoever is reading it.
const focused = chosen === undefined && chosenSegment === undefined
+ && chosenSelection === undefined && chosenMoment === undefined
? ""
- : `${snapshot.revision}:${chosen?.id ?? chosenSegment?.id}`;
+ : `${snapshot.revision}:${selection.kind}:${chosen?.id ?? chosenSegment?.id ?? chosenSelection?.id ?? chosenMoment?.id}`;
const moved = focused.length > 0 && focused !== scrolledTo;
scrolledTo = focused;
code.highlight(highlights, moved && origin !== "code");
});
// Clicking a marked region in the source selects what it binds and looks at the
-// instant it covers. The lines that bind something carry a coloured gutter bar,
-// so what is clickable is visible standing still.
+// instant it covers. The source token and range overlay carry that relationship;
+// the line-number gutter stays quiet.
code.element.addEventListener("click", (event) => {
if ((event.target as HTMLElement | null)?.closest("button, textarea") !== null) return;
const state = store.current();
@@ -273,6 +345,15 @@ code.element.addEventListener("click", (event) => {
store.clearSelection();
return;
}
+ const intent = intentAtOffset(state.snapshot, offset);
+ if (intent?.kind === "selection") {
+ store.selectSemanticSelection(intent.id, "code");
+ return;
+ }
+ if (intent?.kind === "moment") {
+ store.selectSemanticMoment(intent.id, "code");
+ return;
+ }
const clip = clipAtOffset(state.snapshot, offset);
// A click inside marked prose lands inside the innermost marker written there,
diff --git a/packages/studio/src/ui/markers.ts b/packages/studio/src/ui/markers.ts
index b4d47dc1..bbdd5683 100644
--- a/packages/studio/src/ui/markers.ts
+++ b/packages/studio/src/ui/markers.ts
@@ -1,51 +1,51 @@
import type { Range, StudioSnapshot } from "../shared.js";
/** How many distinct depth tones the stylesheet defines. */
-export const MARKER_TONES = 4;
+export const INTENT_TONES = 4;
/**
- * A tone per Script marker, shared by the code pane, the timeline and the box
+ * A tone per authored intent, shared by the code pane, the timeline and the box
* drawn over the picture.
*
- * Markers are coloured by **nesting depth**, not by identity. Depth is the only
+ * Author intents are coloured by **nesting depth**, not by identity. Depth is the only
* difference between two Selections that means anything — an inner one is a
- * narrower claim about the same speech — so two markers at the same depth read
+ * narrower claim about the same speech — so two intents at the same depth read
* the same, and an inner pair reads as sitting inside its outer pair rather than
* as an unrelated thing.
*
- * The three panes have to agree, or the colour would carry no meaning: a marker
+ * The three panes have to agree, or the colour would carry no meaning: an intent
* pair in the prose and the clip it binds are the same fact seen twice.
*/
-export function markerTones(snapshot: StudioSnapshot): ReadonlyMap<string, number> {
+export function intentTones(snapshot: StudioSnapshot): ReadonlyMap<string, number> {
const tones = new Map<string, number>();
for (const segment of snapshot.script?.segments ?? []) {
- tones.set(segment.id, segment.depth % MARKER_TONES);
+ tones.set(segment.id, segment.depth % INTENT_TONES);
}
for (const selection of snapshot.script?.selections ?? []) {
- tones.set(selection.id, selection.depth % MARKER_TONES);
+ tones.set(selection.id, selection.depth % INTENT_TONES);
}
// A Moment marks an instant, so it sits at whatever level it was written in
// rather than enclosing anything. One level in from its Segment is honest.
- for (const moment of snapshot.script?.moments ?? []) tones.set(moment.id, 1 % MARKER_TONES);
+ for (const moment of snapshot.script?.moments ?? []) tones.set(moment.id, 1 % INTENT_TONES);
// A clip is coloured by what placed it, so a cutaway and the words that call
- // for it read as one thing. But several clips can share one marker - the rows
+ // for it read as one thing. But several clips can share one intent - the rows
// of a board do - and colouring them alike would say they are the same clip.
- // Siblings therefore step through the tones from their marker's own.
+ // Siblings therefore step through the tones from their intent's own.
const seen = new Map<string, number>();
let spare = 0;
for (const track of snapshot.tracks) {
for (const clip of track.clips) {
if (tones.has(clip.authoredId)) continue;
- const marker = clip.markerId === undefined ? undefined : tones.get(clip.markerId);
- if (marker === undefined) {
+ const intent = clip.markerId === undefined ? undefined : tones.get(clip.markerId);
+ if (intent === undefined) {
// Nothing said to put this here, so it takes the next tone along.
- tones.set(clip.authoredId, spare % MARKER_TONES);
+ tones.set(clip.authoredId, spare % INTENT_TONES);
spare += 1;
continue;
}
const index = seen.get(clip.markerId!) ?? 0;
seen.set(clip.markerId!, index + 1);
- tones.set(clip.authoredId, (marker + index) % MARKER_TONES);
+ tones.set(clip.authoredId, (intent + index) % INTENT_TONES);
}
}
return tones;
@@ -109,7 +109,7 @@ export function liveRanges(snapshot: StudioSnapshot, frame: number): readonly Sc
* The tightest Script range written around a source offset.
*
* Clicking marked prose should land inside the thing that was clicked, and the
- * innermost marker is the most specific claim there. Resolving to a clip alone
+ * innermost intent is the most specific claim there. Resolving to a clip alone
* would send a click on `@amount` to whatever encloses it, because a marker that
* places nothing still means something.
*/
@@ -119,3 +119,34 @@ export function spanAtOffset(snapshot: StudioSnapshot, offset: number): ScriptSp
.sort((left, right) =>
(left.range.end - left.range.start) - (right.range.end - right.range.start))[0];
}
+
+/**
+ * The authored intent under a source cursor. Unlike a rendered clip, this is
+ * an author entity in its own right: clicking a Selection or Moment in prose
+ * must select that marker, even when it has no consumer and therefore no clip.
+ */
+export type SourceIntent =
+ | { readonly kind: "selection"; readonly id: string; readonly range: Range }
+ | { readonly kind: "moment"; readonly id: string; readonly range: Range };
+
+export function intentAtOffset(snapshot: StudioSnapshot, offset: number): SourceIntent | undefined {
+ const intents: SourceIntent[] = [
+ ...(snapshot.script?.selections ?? []).map((selection) => ({
+ kind: "selection" as const,
+ id: selection.id,
+ range: { start: selection.open.start, end: selection.close.end },
+ })),
+ ...(snapshot.script?.moments ?? []).map((moment) => ({
+ kind: "moment" as const,
+ id: moment.id,
+ range: moment.range,
+ })),
+ ];
+ return intents
+ .filter((intent) => offset >= intent.range.start && offset <= intent.range.end)
+ .sort((left, right) => {
+ const span = (item: SourceIntent): number => item.range.end - item.range.start;
+ const width = span(left) - span(right);
+ return width !== 0 ? width : left.kind === "moment" ? -1 : 1;
+ })[0];
+}
diff --git a/packages/studio/src/ui/overlay.ts b/packages/studio/src/ui/overlay.ts
index fadaf8a7..1019cfaa 100644
--- a/packages/studio/src/ui/overlay.ts
+++ b/packages/studio/src/ui/overlay.ts
@@ -1,5 +1,5 @@
import type { Clip, StudioSnapshot } from "../shared.js";
-import { markerTones } from "./markers.js";
+import { intentTones } from "./markers.js";
import type { Store } from "./selection.js";
const SVG_NS = "http://www.w3.org/2000/svg";
@@ -95,7 +95,7 @@ export function createOverlay(store: Store, measure: Measure): Overlay {
live = store.clipsAt(frame);
if (selected === undefined) return;
- const tones = markerTones(snapshot);
+ const tones = intentTones(snapshot);
const tone = tones.get(selected.authoredId);
const onScreen = frame >= selected.startFrame && frame < selected.endFrameExclusive;
const box = drawnBox(selected);
diff --git a/packages/studio/src/ui/selection.ts b/packages/studio/src/ui/selection.ts
index 11d868e0..3da75a52 100644
--- a/packages/studio/src/ui/selection.ts
+++ b/packages/studio/src/ui/selection.ts
@@ -10,7 +10,9 @@ export type Origin = "timeline" | "code" | "video";
export type Selection =
| { readonly kind: "none" }
| { readonly kind: "clip"; readonly clipId: string; readonly origin: Origin }
- | { readonly kind: "semantic-segment"; readonly segmentId: string; readonly origin: Origin };
+ | { readonly kind: "semantic-segment"; readonly segmentId: string; readonly origin: Origin }
+ | { readonly kind: "semantic-selection"; readonly selectionId: string; readonly origin: Origin }
+ | { readonly kind: "semantic-moment"; readonly momentId: string; readonly origin: Origin };
export type Playhead = { readonly frame: number; readonly origin: Origin | "play" };
@@ -31,6 +33,10 @@ export type Store = {
select(clipId: string, origin: Origin): void;
/** Select one authored SemanticTake without moving the playhead. */
selectSemanticSegment(segmentId: string, origin: Origin): void;
+ /** Select one authored Selection marker without moving the playhead. */
+ selectSemanticSelection(selectionId: string, origin: Origin): void;
+ /** Select one authored Moment marker without moving the playhead. */
+ selectSemanticMoment(momentId: string, origin: Origin): void;
/** Select and seek to the clip start, used by source navigation. */
selectClip(clipId: string, origin: Origin): void;
/**
@@ -47,7 +53,7 @@ export type Store = {
/**
* The clip an author is pointing at in the source text.
*
- * A Script marker wins over the element that binds it: `@claim … @/claim` sits
+ * A Script intent wins over the element that binds it: `@claim … @/claim` sits
* inside the `<script>` element, so without that preference every click in the
* prose would select the Speech Take instead of the B-roll. Ties break toward
* the tightest range, which is the most specific thing under the cursor.
@@ -108,6 +114,14 @@ export function createStore(): Store {
&& !snapshot.semantic.segments.some((segment) => segment.id === held.segmentId)) {
selection = { kind: "none" };
}
+ if (held.kind === "semantic-selection"
+ && !snapshot.semantic.selections.some((item) => item.id === held.selectionId)) {
+ selection = { kind: "none" };
+ }
+ if (held.kind === "semantic-moment"
+ && !snapshot.semantic.moments.some((item) => item.id === held.momentId)) {
+ selection = { kind: "none" };
+ }
playhead = { frame: clamp(playhead.frame), origin: playhead.origin };
emit();
},
@@ -122,6 +136,16 @@ export function createStore(): Store {
selection = { kind: "semantic-segment", segmentId, origin };
emit();
},
+ selectSemanticSelection(selectionId, origin) {
+ if (snapshot?.semantic.selections.some((item) => item.id === selectionId) !== true) return;
+ selection = { kind: "semantic-selection", selectionId, origin };
+ emit();
+ },
+ selectSemanticMoment(momentId, origin) {
+ if (snapshot?.semantic.moments.some((item) => item.id === momentId) !== true) return;
+ selection = { kind: "semantic-moment", momentId, origin };
+ emit();
+ },
selectClip(clipId, origin) {
const clip = clips().find((item) => item.id === clipId);
if (clip === undefined) return;
diff --git a/packages/studio/src/ui/timeline.ts b/packages/studio/src/ui/timeline.ts
index 6f727d94..8b6d6d93 100644
--- a/packages/studio/src/ui/timeline.ts
+++ b/packages/studio/src/ui/timeline.ts
@@ -195,7 +195,13 @@ export function createTimeline(store: Store): Timeline {
) !== null;
pointerDownX = event.clientX;
pointerArmed = true;
- try { lanes.setPointerCapture(event.pointerId); } catch { /* pointer remains local */ }
+ // Let semantic children receive their native click. Capturing every
+ // pointer here retargets the later click to `.lanes`, which made segment
+ // and selection buttons appear to be dead zones. Blank-space scrubbing
+ // still uses capture so it can continue outside the lane.
+ if (!pointerDownOnItem) {
+ try { lanes.setPointerCapture(event.pointerId); } catch { /* pointer remains local */ }
+ }
if (!pointerDownOnItem) {
store.clearSelection();
store.seek(frameAt(event.clientX), "timeline");
@@ -402,7 +408,7 @@ export function createTimeline(store: Store): Timeline {
kind: "segment" | "word" | "selection" | "moment";
}[] = [];
- const bands = ["segment", "word", "marker"] as const;
+ const bands = ["segment", "word", "intent"] as const;
for (const [index, kind] of bands.entries()) {
const band = document.createElement("div");
band.className = `semantic-band semantic-band-${kind}`;
@@ -411,7 +417,7 @@ export function createTimeline(store: Store): Timeline {
}
const segmentBand = lane.querySelector<HTMLElement>(".semantic-band-segment")!;
const wordBand = lane.querySelector<HTMLElement>(".semantic-band-word")!;
- const markerBand = lane.querySelector<HTMLElement>(".semantic-band-marker")!;
+ const intentBand = lane.querySelector<HTMLElement>(".semantic-band-intent")!;
for (const segment of snapshot.semantic.segments) {
const from = place(segment.startFrame, snapshot.space.frameCount, zoom.window());
@@ -441,9 +447,11 @@ export function createTimeline(store: Store): Timeline {
segmentDuration.textContent = `${segment.endFrameExclusive - segment.startFrame}f`;
head.append(segmentLabel, segmentDuration);
node.append(head);
- node.addEventListener("pointerdown", (event) => {
+ node.addEventListener("click", (event) => {
+ event.stopPropagation();
if ((event.target as Element).closest(".semantic-word") !== null) return;
store.selectSemanticSegment(segment.id, "timeline");
+ store.seek(segment.startFrame, "timeline");
});
node.addEventListener("dblclick", (event) => {
event.stopPropagation();
@@ -464,8 +472,7 @@ export function createTimeline(store: Store): Timeline {
const wordFrom = place(token.startFrame, snapshot.space.frameCount, zoom.window());
const wordTo = place(token.endFrameExclusive, snapshot.space.frameCount, zoom.window());
if (wordTo <= 0 || wordFrom >= 1) continue;
- const word = document.createElement("button");
- word.type = "button";
+ const word = document.createElement("span");
word.className = "semantic-cell semantic-word";
word.dataset.semanticToken = token.id;
word.style.left = `${wordFrom * 100}%`;
@@ -478,8 +485,8 @@ export function createTimeline(store: Store): Timeline {
const widthPx = Math.max(0, wordTo - wordFrom) * laneWidth;
word.classList.toggle("label-hidden",
measuredText(token.text, "500 11px -apple-system, system-ui, Segoe UI, sans-serif") + 18 > widthPx);
- word.addEventListener("pointerdown", () => {
- store.selectSemanticSegment(token.segmentId, "timeline");
+ word.addEventListener("click", (event) => {
+ event.stopPropagation();
store.seek(token.startFrame, "timeline");
});
nextSemanticNodes.push({ node: word, id: token.id, start: token.startFrame, end: token.endFrameExclusive, kind: "word" });
@@ -489,8 +496,11 @@ export function createTimeline(store: Store): Timeline {
const from = place(selection.startFrame, snapshot.space.frameCount, zoom.window());
const to = place(selection.endFrameExclusive, snapshot.space.frameCount, zoom.window());
if (to <= 0 || from >= 1) continue;
- const node = document.createElement("span");
+ const node = document.createElement("button");
+ node.type = "button";
node.className = "semantic-cell semantic-selection";
+ node.tabIndex = 0;
+ node.setAttribute("aria-label", `Selection ${selection.id}`);
node.style.left = `${from * 100}%`;
node.style.width = `max(2px, calc(${Math.max(0, to - from) * 100}% - ${itemMetrics.gapPx}px))`;
node.title = `${selection.id} · ${selection.startFrame}-${selection.endFrameExclusive}f`;
@@ -504,17 +514,29 @@ export function createTimeline(store: Store): Timeline {
const selectionWidthPx = Math.max(0, to - from) * laneWidth;
node.classList.toggle("label-hidden",
measuredText(selection.id, "500 11px -apple-system, system-ui, Segoe UI, sans-serif") + 18 > selectionWidthPx);
- markerBand.append(node);
+ node.addEventListener("click", (event) => {
+ event.stopPropagation();
+ store.selectSemanticSelection(selection.id, "timeline");
+ store.seek(selection.startFrame, "timeline");
+ });
+ intentBand.append(node);
nextSemanticNodes.push({ node, id: selection.id, start: selection.startFrame, end: selection.endFrameExclusive, kind: "selection" });
}
for (const moment of snapshot.semantic.moments) {
const at = place(moment.frame, snapshot.space.frameCount, zoom.window());
if (at < 0 || at > 1) continue;
- const node = document.createElement("span");
+ const node = document.createElement("button");
+ node.type = "button";
node.className = "semantic-moment";
+ node.tabIndex = 0;
+ node.setAttribute("aria-label", `Moment ${moment.id}`);
node.style.left = `${at * 100}%`;
node.title = `${moment.id} · ${moment.frame}f`;
- markerBand.append(node);
+ node.addEventListener("click", (event) => {
+ event.stopPropagation();
+ store.selectSemanticMoment(moment.id, "timeline");
+ });
+ intentBand.append(node);
nextSemanticNodes.push({ node, id: moment.id, start: moment.frame, end: moment.frame + 1, kind: "moment" });
}
rows.append(lane);
@@ -680,10 +702,18 @@ export function createTimeline(store: Store): Timeline {
item.node.classList.toggle("live", head.frame >= item.start && head.frame < item.end);
}
for (const item of semanticNodes) {
- item.node.classList.toggle("live", item.kind === "segment" && head.frame >= item.start && head.frame < item.end);
+ item.node.classList.toggle("live",
+ (item.kind === "segment" || item.kind === "selection")
+ && head.frame >= item.start && head.frame < item.end);
item.node.classList.toggle("current", item.kind === "word" && head.frame >= item.start && head.frame < item.end);
- item.node.classList.toggle("selected", item.kind === "segment"
- && selection.kind === "semantic-segment" && selection.segmentId === item.id);
+ const selected = (item.kind === "segment"
+ && selection.kind === "semantic-segment" && selection.segmentId === item.id)
+ || (item.kind === "selection"
+ && selection.kind === "semantic-selection" && selection.selectionId === item.id)
+ || (item.kind === "moment"
+ && selection.kind === "semantic-moment" && selection.momentId === item.id);
+ item.node.classList.toggle("selected", selected);
+ if (item.kind !== "word") item.node.setAttribute("aria-pressed", String(selected));
}
};