Skip to content
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d211bce
Add TemporalSpan model
horatiualmasan Jul 7, 2026
0c66a38
update
horatiualmasan Jul 7, 2026
3e04899
fix
horatiualmasan Jul 7, 2026
bd48016
try eager load
horatiualmasan Jul 7, 2026
f668678
fix warning
horatiualmasan Jul 7, 2026
f3956d1
Add video annotation from activitynet
horatiualmasan Jul 8, 2026
07ddf00
remove not needed joins
horatiualmasan Jul 8, 2026
37441f5
Merge branch 'horatiu-lig-9805-import-activitynet-style-event-annotat…
horatiualmasan Jul 8, 2026
ebe86db
simplify
horatiualmasan Jul 8, 2026
84a4063
Merge branch 'main' into horatiu-lig-9805-import-activitynet-style-ev…
horatiualmasan Jul 15, 2026
47ec651
fix merge
horatiualmasan Jul 15, 2026
9f97a84
add example sctipt
horatiualmasan Jul 15, 2026
d95200c
format
horatiualmasan Jul 15, 2026
6a243bd
update
horatiualmasan Jul 15, 2026
1a24532
Merge branch 'main' into horatiu-lig-9805-import-activitynet-style-ev…
horatiualmasan Jul 15, 2026
d32cbe4
Consider also own annotations for video filter
horatiualmasan Jul 16, 2026
3acc186
Merge branch 'horatiu-lig-9805-import-activitynet-style-event-annotat…
horatiualmasan Jul 16, 2026
bdc02d2
fix merge error
horatiualmasan Jul 16, 2026
a9d31fd
Add useVideoPlayback hook with tests
horatiualmasan Jul 16, 2026
5a07a5b
Wire custom control bar into VideoPlayer
horatiualmasan Jul 16, 2026
ebad55a
Use custom player in VideoDetails with deep-link start time
horatiualmasan Jul 16, 2026
1d6d5ae
Add presentation-only VideoControls component
horatiualmasan Jul 16, 2026
2cdba41
format
horatiualmasan Jul 16, 2026
9f287db
Add Storybook stories for VideoControls
horatiualmasan Jul 16, 2026
2dc2a47
Add useVideoPlayback hook with tests
horatiualmasan Jul 16, 2026
7dede03
Wire custom control bar into VideoPlayer
horatiualmasan Jul 16, 2026
ecef795
Use custom player in VideoDetails with deep-link start time
horatiualmasan Jul 16, 2026
e2a18ce
format
horatiualmasan Jul 16, 2026
8395952
fix error in test stub
horatiualmasan Jul 16, 2026
f8ef40d
Merge branch 'horatiu-lig-9807-show-event-bars-on-the-timeline.d' of …
horatiualmasan Jul 16, 2026
0f2b999
Add video event model (toVideoEvents, assignEventLanes)
horatiualmasan Jul 16, 2026
8e2426e
Add VideoEventTimeline component
horatiualmasan Jul 16, 2026
cdbf3e5
Wire event bar into VideoPlayer, VideoControls and VideoDetails
horatiualmasan Jul 16, 2026
717ebf2
add AnnotationType.CLASSIFICATION
horatiualmasan Jul 17, 2026
b8ada23
Merge branch 'horatiu-lig-9807-show-event-bars-on-the-timeline-3-even…
horatiualmasan Jul 17, 2026
becf8d5
Merge branch 'horatiu-lig-9807-show-event-bars-on-the-timeline-3-even…
horatiualmasan Jul 17, 2026
21d02b9
update
horatiualmasan Jul 17, 2026
c56018e
Merge branch 'horatiu-lig-9807-show-event-bars-on-the-timeline-3-even…
horatiualmasan Jul 17, 2026
78259f4
Edit video events in the timeline
horatiualmasan Jul 17, 2026
52da034
fix
horatiualmasan Jul 17, 2026
7b41439
Add new video events
horatiualmasan Jul 17, 2026
16d0d0b
Delete video event
horatiualmasan Jul 17, 2026
8c5ed52
Merge branch 'main' into horatiu-lig-10189-edit-events-3
LeonardoRosaa Jul 22, 2026
3cec246
fix bad merge
LeonardoRosaa Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@
component: VideoControls,
tags: ['autodocs']
});
<<<<<<< HEAD
</script>

<script>
=======

>>>>>>> main
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
// The bar owns no state; the Playground wires local state so the scrubber
// and transport buttons actually respond.
let currentTimeS = $state(15);
let durationS = $state(120);
let isPlaying = $state(false);
let isMuted = $state(true);
let isFullscreen = $state(false);
<<<<<<< HEAD
=======

// Separate state for the short-clip story so its arrow-key stepping is
// independent of the Playground.
let shortCurrentTimeS = $state(0);
>>>>>>> main
</script>

<!-- Rendered on a dark backdrop since the bar is designed to overlay a video. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import { useCreateAnnotation } from '$lib/hooks/useCreateAnnotation/useCreateAnnotation';
import { useCreateLabel } from '$lib/hooks/useCreateLabel/useCreateLabel';
import { useSelectClassDialog } from '$lib/hooks/useSelectClassDialog/useSelectClassDialog';
import { useDeleteAnnotation } from '$lib/hooks/useDeleteAnnotation/useDeleteAnnotation';
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import { routeHelpers } from '$lib/routes';
Expand Down Expand Up @@ -55,6 +56,7 @@
const { updateAnnotations } = useUpdateAnnotationsMutation({ collectionId: eventCollectionId });
const { createAnnotation } = useCreateAnnotation({ collectionId: eventCollectionId });
const { createLabel } = useCreateLabel({ collectionId: eventCollectionId });
const { deleteAnnotation } = useDeleteAnnotation({ collectionId: eventCollectionId });
const annotationLabels = useAnnotationLabels(() => ({ collectionId: eventCollectionId }));

const {
Expand Down Expand Up @@ -118,6 +120,17 @@
}
}

async function handleEventDelete(event: VideoEvent) {
try {
await deleteAnnotation(event.id);
onVideoUpdate();
toast.success('Event deleted');
} catch (error) {
toast.error('Failed to delete event. Please try again.');
console.error('Error deleting event:', error);
}
}

const {
currentFrame,
frames: videoFrames,
Expand Down Expand Up @@ -255,6 +268,7 @@
editableEvents={$isEditingMode}
onEventResize={handleEventResize}
onEventAdd={handleEventAdd}
onEventDelete={handleEventDelete}
videoProps={{
muted: true,
class: 'object-contain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ vi.mock('$lib/hooks/useCreateLabel/useCreateLabel', () => ({
vi.mock('$lib/hooks/useAnnotationLabels/useAnnotationLabels', () => ({
useAnnotationLabels: vi.fn(() => ({ data: [] }))
}));
vi.mock('$lib/hooks/useDeleteAnnotation/useDeleteAnnotation', () => ({
useDeleteAnnotation: vi.fn(() => ({ deleteAnnotation: vi.fn() }))
}));

import VideoDetails from './VideoDetails.svelte';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
]);

const singleEvent = makeEvents([['Sprint', 3, 14]]);
</script>

<script>
let playheadTimeS = $state(6);
</script>

Expand Down Expand Up @@ -82,7 +79,6 @@
currentTimeS: 5
}}
/>

<Story
name="NoHeader"
args={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* />
* ```
*/
import { Plus } from '@lucide/svelte';
import { Plus, Trash2 } from '@lucide/svelte';
import { cn } from '$lib/utils/shadcn.js';
import { assignEventLanes, type VideoEvent } from '$lib/utils';

Expand All @@ -45,6 +45,8 @@
onResize?: (event: VideoEvent, startTimeS: number, endTimeS: number) => void;
/** Called with a default span when the user requests a new event. */
onAddEvent?: (startTimeS: number, endTimeS: number) => void;
/** Called when the user deletes an event via its trash affordance. */
onDelete?: (event: VideoEvent) => void;
/** Heading shown above the timeline. */
title?: string;
/** Whether to render the title/count header above the track. */
Expand All @@ -61,6 +63,7 @@
editable = false,
onResize,
onAddEvent,
onDelete,
title = 'Events',
showHeader = true,
class: className
Expand Down Expand Up @@ -228,7 +231,7 @@
)}
{@const timeRange = `${formatTime(span.startTimeS)}–${formatTime(span.endTimeS)}`}
<div
class="absolute"
class="group absolute"
style={`left: ${leftPercent}%; width: ${widthPercent}%; top: ${
event.lane * (LANE_HEIGHT_PX + LANE_GAP_PX)
}px; height: ${LANE_HEIGHT_PX}px;`}
Expand All @@ -244,6 +247,21 @@
<span class="truncate">{event.label}</span>
</button>

{#if editable && onDelete}
<button
type="button"
class="absolute right-2.5 top-1/2 z-30 flex -translate-y-1/2 items-center rounded bg-black/60 p-1 text-white opacity-0 transition-opacity hover:bg-black/80 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100"
aria-label={`Delete ${event.label}`}
data-testid="delete-event-button"
onclick={(e) => {
e.stopPropagation();
onDelete?.(event);
}}
>
<Trash2 class="size-3.5" />
</button>
{/if}

{#if editable}
{#each ['start', 'end'] as const as edge (edge)}
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,33 @@ describe('VideoEventTimeline', () => {
// A 1s span can't start at 10s in a 10s video, so it is shifted back to end at 10s.
expect(onAddEvent).toHaveBeenCalledWith(9, 10);
});

it('shows the delete button only when editable with an onDelete handler', () => {
const { queryByTestId, rerender } = render(VideoEventTimeline, {
props: { events: [makeEvent({ id: 'a' })], durationS: 10, onDelete: vi.fn() }
});
expect(queryByTestId('delete-event-button')).toBeFalsy();

rerender({
events: [makeEvent({ id: 'a' })],
durationS: 10,
editable: true,
onDelete: vi.fn()
});
expect(queryByTestId('delete-event-button')).toBeTruthy();
});

it('calls onDelete without seeking when the trash button is clicked', async () => {
const onDelete = vi.fn();
const onSeek = vi.fn();
const event = makeEvent({ id: 'a', label: 'Clip' });
const { getByTestId } = render(VideoEventTimeline, {
props: { events: [event], durationS: 10, editable: true, onDelete, onSeek }
});

await fireEvent.click(getByTestId('delete-event-button'));
expect(onDelete).toHaveBeenCalledWith(expect.objectContaining({ id: 'a' }));
// The bar's seek click must not fire when deleting.
expect(onSeek).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@

/** Called with a default span when the user adds a new event. */
onEventAdd?: (startTimeS: number, endTimeS: number) => void;

/** Called when the user deletes an event. */
onEventDelete?: (event: VideoEvent) => void;
}

let {
Expand All @@ -90,7 +93,8 @@
durationS,
editableEvents = false,
onEventResize,
onEventAdd
onEventAdd,
onEventDelete
}: VideoPlayerProps = $props();

const defaultVideoProps: HTMLVideoAttributes = {
Expand Down Expand Up @@ -224,6 +228,7 @@
editable={editableEvents}
onResize={onEventResize}
onAddEvent={onEventAdd}
onDelete={onEventDelete}
showHeader={false}
/>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,28 @@ describe('VideoPlayer', () => {
expect(getByTestId('video-event-timeline')).toBeTruthy();
expect(getByTestId('add-event-button')).toBeTruthy();
});

it('renders a delete affordance on events in edit mode', () => {
const { getByTestId } = render(VideoPlayer, {
props: {
src: 'test-video.mp4',
durationS: 10,
editableEvents: true,
onEventDelete: () => {},
events: [
{
id: 'e1',
annotationCollectionId: 'coll-1',
label: 'Jump',
startTimeS: 2,
endTimeS: 4,
color: 'rgba(10, 20, 30, 0.7)',
contrastColor: 'rgba(245, 235, 225, 0.7)'
}
]
}
});

expect(getByTestId('delete-event-button')).toBeTruthy();
});
});
Loading