Compare commits

...

12 Commits

Author SHA1 Message Date
Claude 8b8885d0b7 fix(cuesheet): align lazy cell placeholder with its editor
Two regressions from the lazy text-cell placeholders:
- single-line placeholders centered their text in the full (possibly tall)
  cell, so the text jumped upward when the top-aligned editor mounted. Keep
  the glyph in a 2rem band at the top (scoped to editable cells via a
  `topAligned` prop so the time/duration delay indicator is unaffected).
- multi-line placeholders only grew to their content height, so a short note
  in a row made tall by another column was not fully clickable. Use
  `min-height: 100%` so the placeholder fills the cell (and still grows with
  content, no clipping).

Verified by measuring text/editor positions: single-line jump ~0px; all text
placeholders fill the cell and the whole area is clickable. Cuesheet e2e (4/4).
2026-06-21 06:19:29 +00:00
Claude dd8cfef4de test(cuesheet): isolate empty-state rundown locator for retries
The 'background edit from empty state' test matched the rundown row by the
shared prefix '0 empty-'. Each Playwright retry creates another empty-<ts>
rundown, so on retry the locator resolved to multiple rows and failed with a
strict-mode violation — preventing the (pre-existing, timing-related) flake
from ever self-healing. Scope the locator to the unique name the test just
created so each attempt is independent and retries can recover.
2026-06-20 07:18:55 +00:00
Claude bdd4f75c4a Merge remote-tracking branch 'origin/master' into claude/cuesheet-scroll-perf-7nogws 2026-06-20 07:06:18 +00:00
Claude 3a740ec713 style(cuesheet): satisfy oxfmt formatter for EditableCell 2026-06-20 06:38:30 +00:00
Claude dcdfd9ca85 fix(cuesheet): restore keyboard focus flow for lazy text cells
The lazy editor (Exp A) unmounts on exit, so the editor's own deferred
focus-return (useReactiveTextInput) targeted a detached node and focus was
lost to <body>, breaking table keyboard navigation after submit/escape.

Return focus to the parent cell deterministically in a layout effect once the
display element is back in the DOM (rather than a setTimeout that races the
next keypress), mirroring the time/duration cells.

Update the e2e tests to the lazy interaction model (click the cell to open the
on-demand editor, assert it unmounts on exit) — matching the existing timer
cell test. Verified end-to-end: 202-cuesheet (3/3) and 206-url-preset (5/5).
2026-06-19 06:23:51 +00:00
Alex Christoffer Rasmussen b946b245c2 feat: create the first event from the cuesheet (#2105)
* feat: create the first event from the cuesheet

* chore: cleanup css

* test: cuesheet beckground edit from empty state

* feat: only show +event button when user is in edit mode and have full write perms
2026-06-17 22:31:13 +02:00
Claude d17a7e9321 chore(cuesheet): remove temporary first-render metrics scaffold
The metrics scaffold has served its purpose: it proved the lazy text-cell
editor change (Exp A) and ruled out the colour-precompute and lazy-autosize
candidates. Removing it entirely:
- restores AutoTextarea/Tooltip/useReactiveTextInput/EventRow/CuesheetTable
  to their original (uninstrumented) form
- deletes common/devtools/cuesheet-metrics

Keeps the validated Exp A optimization (lazy editor mounting). Verified:
typecheck, lint, 181 unit tests, and production build all pass; no scaffold
references remain in the bundle.
2026-06-16 05:40:59 +00:00
Claude c960a983a0 perf(cuesheet): lazily mount text-cell editors (Exp A) — validated win
Render a lightweight, focusable TextLikeInput for cue/title/note/custom cells
and only mount the real input/textarea editor (with reactive-input hooks and
autosize) on click/focus, mirroring the existing time/duration cells.

Measured baseline vs Exp A at CPU 4x (median of 3, ~1140 row mounts):
- longFrames 201 -> 127 (-37%), maxFrameMs 517 -> 417 (-19%)
- longtask total 58.9s -> 30.7s (-48%), EventRow.mount avg 179 -> 146ms (-18%)
- cell.autosize and cell.reactiveInputInit eliminated from the scroll path
- per-row re-renders 4648 -> 3048 (-34%): stable display height, no virtuoso churn
  (the opposite of the reverted lazy-autosize Exp B, which doubled re-renders)

Editing verified end-to-end: click mounts+focuses the editor, edits persist,
editor unmounts back to the display on commit. TextLikeInput now fills its cell
so the whole cell is clickable to edit.
2026-06-16 05:32:11 +00:00
Claude 7498abb326 perf(cuesheet): revert lazy-autosize (Exp B) — metrics show it regresses
Measured baseline vs lazy-autosize at CPU 4x (median of 3, ~1140 row mounts):
- cell.autosize eliminated (15.2s -> 0) BUT
- EventRow.mount avg +39% (179 -> 248ms), longtask +32%, longFrames 201->219,
  and per-row re-renders ~2x (getVisibleCells renders 4648 -> 8902).
Deferring autosize destabilises virtuoso row-height measurement (rows=1
textareas), causing more re-render churn, and collapses note display.
Net negative — not merged. Keeping instrumented baseline.
2026-06-15 20:59:33 +00:00
Claude a0d72d1776 perf(cuesheet): add result capture + candidate lazy-autosize (Exp B, under measurement)
- Scaffold: snapshot()/getResults() so the benchmark returns structured
  metrics for automated before/after capture (PERF-METRICS).
- Candidate Exp B: defer AutoTextarea autosize() off the mount path to
  focus-time, removing the per-row forced reflows during scroll. Under
  evaluation against the metrics.
2026-06-15 20:46:54 +00:00
Claude eab63e838d perf(cuesheet): add temporary first-render metrics scaffold
Adds a dev-only, self-contained instrumentation module under
common/devtools/cuesheet-metrics to measure the first-render (mount) cost
of virtualised cuesheet rows, so scroll-performance changes can be backed
by before/after numbers.

- Console-only API on window.__cuesheetPerf (deterministic scroll benchmark
  + manual start/stop), gated by isDev && ?perf=1, runtime-inert in prod.
- Whole-row mount probe plus per-subsystem attribution: colour calc,
  getVisibleCells, AutoTextarea autosize, Tooltip portal mount,
  useReactiveTextInput hotkey-handler init; FPS/long-frame timing.
- All edits to existing files tagged // PERF-METRICS for a one-pass teardown.

Temporary: to be deleted once the optimizations are proven.
2026-06-15 20:17:01 +00:00
Carlos Valente c238147b75 chore: bump node version 2026-06-11 18:58:00 +02:00
12 changed files with 256 additions and 45 deletions
+1 -1
View File
@@ -1 +1 @@
v22.22.2
v22.22.3
@@ -8,9 +8,12 @@
padding-top: 10vh;
}
.empty {
width: 100%;
opacity: 0.8;
.inline {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin-top: 1em;
}
.text {
@@ -1,18 +1,33 @@
import EmptyImage from '../../../assets/images/empty.svg?react';
import { SupportedEntry } from 'ontime-types';
import { IoAdd } from 'react-icons/io5';
import { useTranslation } from '../../../translation/TranslationProvider';
import Button from '../buttons/Button';
import Empty from './Empty';
import style from './EmptyTableBody.module.scss';
interface EmptyTableBodyProps {
text: string;
handleAddNew?: (type: SupportedEntry) => void;
}
export default function EmptyTableBody({ text }: EmptyTableBodyProps) {
export default function EmptyTableBody({ handleAddNew }: EmptyTableBodyProps) {
const { getLocalizedString } = useTranslation();
const text = getLocalizedString('common.no_data');
return (
<tbody className={style.emptyContainer}>
<tr>
<td colSpan={99} className={style.emptyCell}>
<EmptyImage className={style.empty} />
{text && <span className={style.text}>{text}</span>}
<Empty injectedStyles={{ marginTop: '5vh' }} />
<span className={style.text}>{text}</span>
{handleAddNew && (
<div className={style.inline}>
<Button onClick={() => handleAddNew(SupportedEntry.Event)} variant='primary' size='large'>
<IoAdd />
Create Event
</Button>
</div>
)}
</td>
</tr>
</tbody>
@@ -157,7 +157,7 @@ export default function ManageRundowns() {
</td>
<td>
<DropdownMenu
render={<IconButton variant='ghosted-white' />}
render={<IconButton variant='ghosted-white' data-testId='rundown_menu' />}
items={[
{
type: 'item',
@@ -1,6 +1,6 @@
import { useTableNav } from '@table-nav/react';
import { ColumnDef, Table, getCoreRowModel, useReactTable } from '@tanstack/react-table';
import { OntimeEntry, TimeField, isOntimeDelay, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
import { OntimeEntry, SupportedEntry, TimeField, isOntimeDelay, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
import { ComponentProps, ReactNode, memo, useCallback, useEffect, useMemo, useRef } from 'react';
import {
ContextProp,
@@ -20,6 +20,7 @@ import { usePersistedRundownOptions } from '../../../features/rundown/rundown.op
import { useEventSelection } from '../../../features/rundown/useEventSelection';
import { AppMode } from '../../../ontimeConfig';
import { usePersistedCuesheetOptions } from '../cuesheet.options';
import { useCuesheetPermissions } from '../useTablePermissions';
import { CuesheetHeader, SortableCuesheetHeader } from './cuesheet-table-elements/CuesheetHeader';
import DelayRow from './cuesheet-table-elements/DelayRow';
import EventRow from './cuesheet-table-elements/EventRow';
@@ -62,7 +63,8 @@ export default function CuesheetTable({
insertElement,
}: CuesheetTableProps) {
const { flatRundown, status, selectedEventId } = source;
const { updateEntry, updateTimer } = useEntryActionsContext();
const { updateEntry, updateTimer, addEntry } = useEntryActionsContext();
const canCreateEntries = useCuesheetPermissions((state) => state.canCreateEntries) && cuesheetMode === AppMode.Edit;
const useOptions = tableRoot === 'editor' ? usePersistedRundownOptions : usePersistedCuesheetOptions;
const optionsStore = useOptions();
@@ -202,8 +204,9 @@ export default function CuesheetTable({
listeners,
rows,
table,
handleAddNew: canCreateEntries ? (type: SupportedEntry) => addEntry({ type }) : undefined,
}),
[columnSizeVars, cursor, listeners, rows, table],
[columnSizeVars, cursor, listeners, rows, table, addEntry, canCreateEntries],
);
const computeItemKey = useCallback((_: number, item: ExtendedEntry) => item.id, []);
@@ -273,10 +276,13 @@ interface CuesheetVirtuosoContext {
listeners: ReturnType<typeof useTableNav>['listeners'];
rows: ReturnType<Table<ExtendedEntry>['getRowModel']>['rows'];
table: Table<ExtendedEntry>;
handleAddNew?: (type: SupportedEntry) => void;
}
const EmptyPlaceholder = memo(function EmptyPlaceholder() {
return <EmptyTableBody text='No data in rundown' />;
const EmptyPlaceholder = memo(function EmptyPlaceholder({
context,
}: TableProps & ContextProp<CuesheetVirtuosoContext>) {
return <EmptyTableBody handleAddNew={context.handleAddNew} />;
});
const CuesheetTableElement = memo(function CuesheetTableElement({
@@ -0,0 +1,101 @@
import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';
import MultiLineCell from './MultiLineCell';
import SingleLineCell from './SingleLineCell';
import TextLikeInput from './TextLikeInput';
interface EditableCellProps {
initialValue: string;
multiline?: boolean;
fieldId?: string;
fieldLabel?: string;
handleUpdate: (newValue: string) => void;
}
interface FocusableEditor {
focus: () => void;
select?: () => void;
}
interface FocusableDisplay {
focusParentElement: () => void;
}
/**
* Lazily mounts the text editor for a cell.
*
* Mounting an `<input>`/`<textarea>` editor (with its reactive-input hooks and autosize) for every
* cell is expensive when many rows mount at once during virtualised scroll. While the cell is not
* being edited we render a lightweight, focusable display element and only mount the real editor
* when the user clicks/focuses the cell — mirroring how the time/duration cells already behave.
*
* On exit we return focus to the parent cell (through the display element, in a layout effect once
* it is back in the DOM) so the table keyboard navigation keeps working — the editor is unmounted
* by then, so we cannot rely on its own ref.
*/
function EditableCell({ initialValue, multiline, fieldId, fieldLabel, handleUpdate }: EditableCellProps) {
const [isEditing, setIsEditing] = useState(false);
const wasEditing = useRef(false);
const editorRef = useRef<FocusableEditor | null>(null);
const displayRef = useRef<FocusableDisplay | null>(null);
useLayoutEffect(() => {
if (isEditing) {
// focus the editor once it mounts on entering edit mode
editorRef.current?.focus();
editorRef.current?.select?.();
} else if (wasEditing.current) {
// returning from edit: hand focus back to the cell so table keyboard navigation continues
displayRef.current?.focusParentElement();
}
wasEditing.current = isEditing;
}, [isEditing]);
const enterEdit = useCallback(() => setIsEditing(true), []);
const exitEdit = useCallback(() => setIsEditing(false), []);
const onSubmit = useCallback(
(newValue: string) => {
setIsEditing(false);
handleUpdate(newValue);
},
[handleUpdate],
);
if (!isEditing) {
return (
<TextLikeInput
ref={displayRef}
onClick={enterEdit}
onFocus={enterEdit}
multiline={multiline}
topAligned
aria-label={fieldLabel ? `${fieldLabel} cell` : undefined}
>
{initialValue}
</TextLikeInput>
);
}
return multiline ? (
<MultiLineCell
ref={editorRef}
initialValue={initialValue}
fieldId={fieldId}
fieldLabel={fieldLabel}
handleUpdate={onSubmit}
handleCancelUpdate={exitEdit}
/>
) : (
<SingleLineCell
ref={editorRef}
initialValue={initialValue}
fieldId={fieldId}
fieldLabel={fieldLabel}
handleUpdate={onSubmit}
handleCancelUpdate={exitEdit}
/>
);
}
export default memo(EditableCell);
@@ -1,4 +1,4 @@
import { memo, useCallback, useRef } from 'react';
import { forwardRef, memo, useCallback, useImperativeHandle, useRef } from 'react';
import { AutoTextarea } from '../../../../common/components/input/auto-textarea/AutoTextarea';
import useReactiveTextInput from '../../../../common/components/input/text-input/useReactiveTextInput';
@@ -8,19 +8,36 @@ interface MultiLineCellProps {
fieldId?: string;
fieldLabel?: string;
handleUpdate: (newValue: string) => void;
handleCancelUpdate?: () => void;
}
export default memo(MultiLineCell);
function MultiLineCell({ initialValue, fieldId, fieldLabel, handleUpdate }: MultiLineCellProps) {
const MultiLineCell = forwardRef(function MultiLineCell(
{ initialValue, fieldId, fieldLabel, handleUpdate, handleCancelUpdate }: MultiLineCellProps,
inputRef,
) {
const ref = useRef<HTMLTextAreaElement | null>(null);
const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]);
const { value, onChange, onBlur, onKeyDown } = useReactiveTextInput(initialValue, submitCallback, ref, {
submitOnCtrlEnter: true,
allowKeyboardNavigation: true,
onCancelUpdate: handleCancelUpdate,
});
// expose focus to the parent so the editor can be focused when mounted on demand
useImperativeHandle(
inputRef,
() => ({
focus() {
ref.current?.focus();
},
select() {
ref.current?.select();
},
}),
[ref],
);
return (
<AutoTextarea
inputref={ref}
@@ -36,4 +53,6 @@ function MultiLineCell({ initialValue, fieldId, fieldLabel, handleUpdate }: Mult
aria-label={fieldLabel ? `${fieldLabel} editor` : undefined}
/>
);
}
});
export default memo(MultiLineCell);
@@ -1,6 +1,8 @@
/* element matching input styles */
.textInput {
height: 2rem;
width: 100%;
height: 100%;
min-height: 2rem;
background-color: transparent;
border-radius: $component-border-radius-md;
text-wrap: nowrap;
@@ -32,4 +34,21 @@
background-color: $gray-1100;
cursor: text;
}
// single-line placeholder: keep the glyph in a 2rem band at the top of the cell so it lines up
// with the editor (which mounts top-aligned) and does not jump when the cell is taller than 2rem
&.topAligned:not(.multiline) {
align-items: flex-start;
line-height: 2rem;
}
&.multiline {
height: auto;
min-height: 100%; // fill the cell so the whole area is clickable (grows with content)
text-wrap: wrap;
white-space: break-spaces;
overflow: hidden;
align-items: flex-start;
padding-top: 0.25em;
}
}
@@ -8,11 +8,23 @@ interface TextLikeInputProps extends HTMLAttributes<HTMLSpanElement> {
offset?: 'over' | 'under' | 'muted' | null;
muted?: boolean;
disabled?: boolean;
multiline?: boolean;
/** keep the content at the top of the cell (matches an editor that mounts top-aligned) */
topAligned?: boolean;
}
const TextLikeInput = forwardRef(
(
{ offset, muted, disabled, children, className, ...elementProps }: PropsWithChildren<TextLikeInputProps>,
{
offset,
muted,
disabled,
multiline,
topAligned,
children,
className,
...elementProps
}: PropsWithChildren<TextLikeInputProps>,
textRef,
) => {
const ref = useRef<HTMLDivElement | null>(null);
@@ -21,6 +33,8 @@ const TextLikeInput = forwardRef(
offset && style[offset],
muted && style.muted,
disabled && style.disabled,
multiline && style.multiline,
topAligned && style.topAligned,
className,
]);
@@ -9,12 +9,11 @@ import { formatDuration, formatTime } from '../../../../common/utils/time';
import { AppMode } from '../../../../ontimeConfig';
import { getCuesheetColumnAccessPolicy } from '../../cuesheet.policies';
import DurationInput from './DurationInput';
import EditableCell from './EditableCell';
import EditableImage from './EditableImage';
import FlagCell from './FlagCell';
import GhostedText from './GhostedText';
import MultiLineCell from './MultiLineCell';
import MutedText from './MutedText';
import SingleLineCell from './SingleLineCell';
import TimeInput from './TimeInput';
function getColumnLabel(column: CellContext<ExtendedEntry, unknown>['column']): string {
@@ -151,7 +150,8 @@ function MakeMultiLineField({ row, column, table }: CellContext<ExtendedEntry, u
}
return (
<MultiLineCell
<EditableCell
multiline
initialValue={initialValue as string}
fieldId={column.id}
fieldLabel={getColumnLabel(column)}
@@ -198,7 +198,7 @@ function MakeSingleLineField({ row, column, table }: CellContext<ExtendedEntry,
}
return (
<SingleLineCell
<EditableCell
initialValue={initialValue as string}
fieldId={column.id}
fieldLabel={getColumnLabel(column)}
@@ -238,7 +238,8 @@ function MakeCustomField({ row, column, table }: CellContext<ExtendedEntry, unkn
}
return (
<MultiLineCell
<EditableCell
multiline
initialValue={initialValue}
fieldId={column.id}
fieldLabel={getColumnLabel(column)}
+47 -15
View File
@@ -57,46 +57,78 @@ test('cuesheet datagrid keeps keyboard focus flow while editing text cells', asy
const firstEvent = page.getByTestId('cuesheet-event').first();
await expect(firstEvent).toBeVisible();
const cueCell = firstEvent.getByTestId('cuesheet-cell-cue');
const titleCell = firstEvent.getByTestId('cuesheet-cell-title');
const noteCell = firstEvent.getByTestId('cuesheet-cell-note');
const cueEditor = firstEvent.getByTestId('cuesheet-editor-cue');
const titleEditor = firstEvent.getByTestId('cuesheet-editor-title');
const noteEditor = firstEvent.getByTestId('cuesheet-editor-note');
/**
* 1. focus a cell in the datagrid single line text
* submitting the data returns the focus to the parent
* 1. clicking a single line text cell opens the editor (mounted on demand)
* submitting with Enter closes the editor and returns focus to the parent cell
*/
await titleEditor.click();
await titleCell.click();
await expect(titleEditor).toBeFocused();
const updatedTitle = `focus-title-${Date.now()}`;
await titleEditor.fill(updatedTitle);
await titleEditor.press('Enter');
await expect(titleEditor).not.toBeFocused();
await expect(titleEditor).toHaveValue(updatedTitle);
await expect(titleEditor).toHaveCount(0);
await expect(titleCell).toContainText(updatedTitle);
await expect(titleCell).toBeFocused();
/**
* 2. navigate and modify multiline text cell
* 2. navigate to the multiline text cell with the keyboard and open it with Enter
* submitting works with ctrl/cmd + enter and the focus returns to the parent
*/
await page.keyboard.press('ArrowRight');
await expect(noteCell).toBeFocused();
await page.keyboard.press('Enter');
await expect(noteEditor).toBeFocused();
const updatedNote = `focus-note-${Date.now()}`;
await noteEditor.fill(updatedNote);
await noteEditor.press('ControlOrMeta+Enter');
await expect(noteEditor).not.toBeFocused();
await expect(noteEditor).toHaveValue(updatedNote);
await expect(noteEditor).toHaveCount(0);
await expect(noteCell).toContainText(updatedNote);
await expect(noteCell).toBeFocused();
/**
* 2. navigate and modify single line text cell again
* pressing escape cancels the edit and the focus returns to the parent
* 3. navigating back returns focus to the title cell
* opening the cue cell and pressing escape cancels the edit and reverts the value
*/
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('Enter');
await expect(titleEditor).toBeFocused();
await expect(titleCell).toBeFocused();
await cueCell.click();
await expect(cueEditor).toBeFocused();
const cueBeforeCancel = await cueEditor.inputValue();
await cueEditor.click();
await cueEditor.fill(`${cueBeforeCancel} temporary`);
await cueEditor.press('Escape');
await expect(cueEditor).not.toBeFocused();
await expect(cueEditor).toHaveValue(cueBeforeCancel);
await expect(cueEditor).toHaveCount(0);
await expect(cueCell).toContainText(cueBeforeCancel);
await expect(cueCell).toBeFocused();
});
test('cuesheet background edit from empty state', async ({ page }) => {
// create an empty rundown
await page.goto('/editor');
await page.getByRole('button', { name: 'Toggle settings' }).click();
await page.getByRole('button', { name: 'Manage rundowns' }).click();
await page.getByRole('button', { name: 'New' }).nth(1).click();
const emptyName = `empty-${Date.now()}`;
await page.getByRole('textbox', { name: 'Rundown title' }).fill(emptyName);
await page.getByRole('button', { name: 'Create rundown' }).click();
// edit it in the cuesheet (scope to the rundown we just created so retries stay isolated)
await page.getByRole('row', { name: emptyName }).getByTestId('rundown_menu').click();
await page.getByText('Edit in cuesheet').click();
// expect to see and empty screen
await expect(page.getByRole('button', { name: 'Create Event' })).toBeVisible();
// create 1 event
await page.getByRole('button', { name: 'Create Event' }).click();
// and expect to find it
await expect(page.getByTestId('cuesheet-event')).toBeVisible();
});
+4 -3
View File
@@ -231,9 +231,10 @@ test.describe('Sharing from cuesheet', () => {
// Verify that the title is visible and editable
await expect(page.getByTestId('cuesheet-event').getByRole('cell', { name: 'title' })).toBeVisible();
const titleEditor = page.getByTestId('cuesheet-event').getByTestId('cuesheet-editor-title');
await titleEditor.click();
await expect(titleEditor).toBeEditable();
// the editor mounts on demand: clicking the cell opens it
const firstEvent = page.getByTestId('cuesheet-event').first();
await firstEvent.getByTestId('cuesheet-cell-title').click();
await expect(firstEvent.getByTestId('cuesheet-editor-title')).toBeEditable();
// other elements are not there
await expect(page.getByRole('cell', { name: 'Duration' })).toBeHidden();