Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: preserve timeline library across breakpoints (#5424)

[._.]/ Adam Eivy7f0d2b3309a0
diff --git a/client/src/pages/VideoTimelineEditor.jsx b/client/src/pages/VideoTimelineEditor.jsx
index aa07b4786d..103d89be19 100644
--- a/client/src/pages/VideoTimelineEditor.jsx
+++ b/client/src/pages/VideoTimelineEditor.jsx
@@ -67,6 +67,10 @@ const LIBRARY_TABS = [
{ id: 'audio', label: 'Audio', Icon: Music },
];
+const desktopTimelineLayout = () => (
+ typeof window === 'undefined' || window.matchMedia('(min-width: 64rem)').matches
+);
+
// One accessor per lane, so adding a lane doesn't mean a fourth branch in
// every ternary chain that needs "the entries for this lane".
const laneEntries = (lanes, lane) => {
@@ -109,23 +113,12 @@ export default function VideoTimelineEditor() {
const [playing, setPlaying] = useState(false);
const [muted, setMuted] = useState(false);
const [renderJobId, setRenderJobId] = useState(null);
- const [isDesktop, setIsDesktop] = useState(() => (
- typeof window === 'undefined' || window.innerWidth >= 1024
- ));
- const [showLibrary, setShowLibrary] = useState(() => (
- typeof window === 'undefined' || window.innerWidth >= 1024
- ));
+ const [showLibrary, setShowLibrary] = useState(desktopTimelineLayout);
const [libraryTab, setLibraryTab] = useState('clips');
// Local input draft. Editing the canonical state on every keystroke makes the
// rename onBlur-vs-canonical comparison always-equal.
const [nameDraft, setNameDraft] = useState('');
- useEffect(() => {
- const updateLayout = () => setIsDesktop(window.innerWidth >= 1024);
- window.addEventListener('resize', updateLayout);
- return () => window.removeEventListener('resize', updateLayout);
- }, []);
-
const videoRef = useRef(null);
const lastSrcRef = useRef('');
// The video.onloadedmetadata callback fires async after a src swap. Reading
@@ -698,7 +691,10 @@ export default function VideoTimelineEditor() {
const laneWidth = Math.max(240, total * pxPerSec);
const playheadSec = Math.min(t, total);
const libraryPanel = showLibrary ? (
- <div className="bg-port-card/50 border border-port-border rounded-lg p-2 max-h-[600px] overflow-y-auto">
+ <div
+ id="timeline-library"
+ className="order-2 lg:order-1 bg-port-card/50 border border-port-border rounded-lg p-2 max-h-[600px] overflow-y-auto"
+ >
<div className="flex gap-1 mb-2" role="tablist" aria-label="Clip library">
{LIBRARY_TABS.map(({ id, label, Icon }) => (
<button
@@ -801,6 +797,8 @@ export default function VideoTimelineEditor() {
<button
type="button"
onClick={() => setShowLibrary((v) => !v)}
+ aria-expanded={showLibrary}
+ aria-controls="timeline-library"
className="px-2 py-1.5 text-xs text-gray-400 hover:text-white border border-port-border rounded-md"
>
{showLibrary ? 'Hide library' : 'Show library'}
@@ -820,11 +818,8 @@ export default function VideoTimelineEditor() {
<div className={`grid grid-cols-1 ${
showLibrary ? 'lg:grid-cols-[260px_1fr_240px]' : 'lg:grid-cols-[1fr_240px]'
} gap-3 min-h-[400px]`}>
- {/* Left rail — library */}
- {showLibrary && isDesktop && libraryPanel}
-
{/* Center — preview + tracks */}
- <div className="space-y-3 min-w-0">
+ <div className="order-1 lg:order-2 space-y-3 min-w-0">
{/* The preview adopts the CANONICAL render canvas, not a fixed 16:9
box — overlay x/y/width are normalized against that canvas, so a
portrait or square project would otherwise place them somewhere
@@ -998,11 +993,12 @@ export default function VideoTimelineEditor() {
</div>
</div>
- {/* On mobile the library follows the workspace in both visual and focus order. */}
- {showLibrary && !isDesktop && libraryPanel}
+ {/* The library follows the workspace in DOM/focus order on mobile, then
+ moves into the desktop grid's left rail without remounting. */}
+ {libraryPanel}
{/* Right rail — inspector */}
- <div className="bg-port-card/50 border border-port-border rounded-lg p-3 space-y-3">
+ <div className="order-3 bg-port-card/50 border border-port-border rounded-lg p-3 space-y-3">
<div className="text-xs uppercase text-gray-500 tracking-wide">Inspector</div>
{!selected && (
diff --git a/client/src/pages/VideoTimelineEditor.test.jsx b/client/src/pages/VideoTimelineEditor.test.jsx
index 39f77e948e..7f22f7bcbf 100644
--- a/client/src/pages/VideoTimelineEditor.test.jsx
+++ b/client/src/pages/VideoTimelineEditor.test.jsx
@@ -67,6 +67,12 @@ const bedEntry = { assetKind: 'music', assetFile: 'bed.mp3', startSec: 0, offset
beforeEach(() => {
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1024 });
+ window.matchMedia = vi.fn((query) => ({
+ matches: query === '(min-width: 64rem)' && window.innerWidth >= 1024,
+ media: query,
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ }));
toastError.mockClear();
api.project = project();
api.history = [{ id: CLIP_A, prompt: 'A dramatic sunrise', filename: 'a.mp4', thumbnail: 'a.jpg', width: 1920, height: 1080, fps: 24, numFrames: 96 }];
@@ -161,14 +167,20 @@ describe('workspace layout — mobile library regression (#5424)', () => {
const workspace = screen.getByRole('button', { name: 'Play' }).parentElement?.parentElement;
const inspector = screen.getByText('Inspector').parentElement;
expect(screen.queryByRole('tablist', { name: 'Clip library' })).not.toBeInTheDocument();
+ expect(showLibrary).toHaveAttribute('aria-expanded', 'false');
+ expect(showLibrary).toHaveAttribute('aria-controls', 'timeline-library');
expect(workspace?.parentElement).toHaveClass('lg:grid-cols-[1fr_240px]');
+ expect(workspace).toHaveClass('order-1', 'lg:order-2');
expect(workspace?.compareDocumentPosition(inspector) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(showLibrary);
const library = screen.getByRole('tablist', { name: 'Clip library' }).parentElement;
expect(screen.getByRole('button', { name: 'Hide library' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Hide library' })).toHaveAttribute('aria-expanded', 'true');
expect(workspace?.parentElement).toHaveClass('lg:grid-cols-[260px_1fr_240px]');
+ expect(library).toHaveAttribute('id', 'timeline-library');
+ expect(library).toHaveClass('order-2', 'lg:order-1');
expect(workspace?.compareDocumentPosition(library) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Add to timeline' }));
@@ -176,22 +188,22 @@ describe('workspace layout — mobile library regression (#5424)', () => {
screen.getByRole('button', { name: 'Remove A dramatic sunrise from timeline' }),
).toBeInTheDocument());
+ const mountedLibrary = library;
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1024 });
fireEvent(window, new Event('resize'));
- await waitFor(() => {
- const desktopLibrary = screen.getByRole('tablist', { name: 'Clip library' }).parentElement;
- expect(desktopLibrary?.compareDocumentPosition(workspace) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
- });
+ expect(screen.getByRole('tablist', { name: 'Clip library' }).parentElement).toBe(mountedLibrary);
});
- it('keeps the desktop library visible in the original left-rail order', async () => {
+ it('keeps the desktop library visible in the original left-rail grid position', async () => {
await renderEditor();
const library = screen.getByRole('tablist', { name: 'Clip library' }).parentElement;
const workspace = screen.getByRole('button', { name: 'Play' }).parentElement?.parentElement;
expect(screen.getByRole('button', { name: 'Hide library' })).toBeInTheDocument();
expect(workspace?.parentElement).toHaveClass('lg:grid-cols-[260px_1fr_240px]');
- expect(library?.compareDocumentPosition(workspace) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(workspace).toHaveClass('order-1', 'lg:order-2');
+ expect(library).toHaveClass('order-2', 'lg:order-1');
+ expect(workspace?.compareDocumentPosition(library) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Hide library' }));
expect(workspace?.parentElement).toHaveClass('lg:grid-cols-[1fr_240px]');