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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: refresh linked storyboard changes in open pipeline views
[._.]/ Adam Eivy85be462458e2
diff --git a/client/src/components/pipeline/stages/StoryboardsStage.jsx b/client/src/components/pipeline/stages/StoryboardsStage.jsxindex 9d2929b962..c450dc04e7 100644--- a/client/src/components/pipeline/stages/StoryboardsStage.jsx+++ b/client/src/components/pipeline/stages/StoryboardsStage.jsx@@ -38,11 +38,14 @@ import {updatePipelineShotsFromBoard,} from '../../../services/api';import useUniverse from '../../../hooks/useUniverse';+import { useSocketResource } from '../../../hooks/useSocketResource';import { matchCharactersInText } from '../../../lib/scenePrompt';import MediaJobThumb from '../MediaJobThumb';import ImagePromptCandidates, { PromptCountInput } from '../ImagePromptCandidates';import { genConfigToImageOptions, genConfigToRefineOptions, IMAGE_PROMPT_COUNT_DEFAULT } from './VisualGenSettings';+const STORYBOARD_CHANGE_EVENTS = ['storyboard:changed'];+export default function StoryboardsStage({ issue, series, onStageUpdate, actionsGated = false }) {const navigate = useNavigate();const stage = issue.stages?.storyboards || { status: 'empty', scenes: [] };@@ -138,15 +141,15 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions};// The linked board is a copy: panels edited there wait here, per shot, until Update.- const [boardChanges, setBoardChanges] = useState(null);+ const { data: boardChanges, updateData: setBoardChanges } = useSocketResource(+ ({ signal }) => getPipelineStoryboardChanges(issue.id, { silent: true, signal }),+ {+ events: STORYBOARD_CHANGE_EVENTS,+ resourceKey: JSON.stringify([issue.id, issue.updatedAt]),+ matchesEvent: event => !boardChanges?.boardId || event?.id === boardChanges.boardId,+ },+ );const [updatingFromBoard, setUpdatingFromBoard] = useState(null);- useEffect(() => {- let live = true;- getPipelineStoryboardChanges(issue.id, { silent: true })- .then((res) => { if (live) setBoardChanges(res); })- .catch(() => {});- return () => { live = false; };- }, [issue.id, issue.updatedAt]);const changedShots = useMemo(() => new Map((boardChanges?.changed || []).map((c) => [c.shotId, c])), [boardChanges]);const boardLocked = stage.locked === true;const updateFromBoard = async (shotId = null) => {diff --git a/client/src/components/pipeline/stages/StoryboardsStage.test.jsx b/client/src/components/pipeline/stages/StoryboardsStage.test.jsxindex f734fed307..931b5a2af2 100644--- a/client/src/components/pipeline/stages/StoryboardsStage.test.jsx+++ b/client/src/components/pipeline/stages/StoryboardsStage.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi } from 'vitest';-import { fireEvent, render, screen } from '@testing-library/react';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';import { MemoryRouter, Route, Routes } from 'react-router';const api = vi.hoisted(() => ({@@ -13,7 +13,18 @@ vi.mock('../../../services/api', () => {'extractPipelineStoryboardScenes', 'createBlankSketch'];return { ...api, ...Object.fromEntries(rest.map((name) => [name, vi.fn()])) };});-vi.mock('../../../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn() } }));+const socket = vi.hoisted(() => {+ const handlers = new Map();+ return {+ emit: (event, payload) => { for (const handler of handlers.get(event) || []) handler(payload); },+ on: vi.fn((event, handler) => {+ if (!handlers.has(event)) handlers.set(event, new Set());+ handlers.get(event).add(handler);+ }),+ off: vi.fn((event, handler) => handlers.get(event)?.delete(handler)),+ };+});+vi.mock('../../../services/socket', () => ({ default: socket }));vi.mock('../../../hooks/useUniverse', () => ({ default: () => [null] }));vi.mock('../MediaJobThumb', () => ({ default: () => null }));vi.mock('../../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));@@ -59,4 +70,25 @@ describe('StoryboardsStage', () => {expect(screen.queryByText(/Storyboard changed/)).not.toBeInTheDocument();expect(onStageUpdate).toHaveBeenCalledWith('storyboards', saved.stages.storyboards, saved);});++ it('shows edits from the linked storyboard while the pipeline stays open, then applies the update response', async () => {+ const withShot = { ...issue, stages: { storyboards: { status: 'edited', scenes: [{ ...issue.stages.storyboards.scenes[0], shots: [{ id: 'shot-01', description: 'Wide of the lab', durationSeconds: 5 }] }] } } };+ const unchanged = { boardId: 'sb-1', locked: false, changed: [] };+ api.getPipelineStoryboardChanges.mockResolvedValueOnce(unchanged).mockResolvedValueOnce({+ ...unchanged, changed: [{ sceneId: 'scene-01', shotId: 'shot-01', panelId: 'panel-1', fields: ['description'] }],+ });+ const saved = { ...withShot, stages: { storyboards: { ...withShot.stages.storyboards, scenes: [{ ...withShot.stages.storyboards.scenes[0], shots: [{ id: 'shot-01', description: 'Edited in another tab', durationSeconds: 5 }] }] } } };+ api.updatePipelineShotsFromBoard.mockResolvedValue({ updated: 1, issue: saved, ...unchanged });+ render(<MemoryRouter><StoryboardsStage issue={withShot} series={null} onStageUpdate={vi.fn()} /></MemoryRouter>);+ await waitFor(() => expect(api.getPipelineStoryboardChanges).toHaveBeenCalledTimes(1));+ await act(async () => { socket.emit('storyboard:changed', { id: 'sb-other' }); });+ expect(api.getPipelineStoryboardChanges).toHaveBeenCalledTimes(1);+ await act(async () => { socket.emit('storyboard:changed', { id: 'sb-1' }); });++ expect(await screen.findByText('Storyboard changed: action')).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Update' }));+ expect(await screen.findByDisplayValue('Edited in another tab')).toBeInTheDocument();+ expect(screen.queryByText(/Storyboard changed/)).not.toBeInTheDocument();+ expect(api.getPipelineStoryboardChanges).toHaveBeenCalledTimes(2);+ });});diff --git a/server/services/socket.js b/server/services/socket.jsindex cf16206a8f..fdd2b82f43 100644--- a/server/services/socket.js+++ b/server/services/socket.js@@ -395,6 +395,8 @@ function setupRecordEventForwarding() {ioInstance?.emit('creative-director:project:changed', { id: recordId });} else if (recordKind === 'creativeCommission') {ioInstance?.emit('commission:changed', { id: recordId });+ } else if (recordKind === 'storyboard') {+ ioInstance?.emit('storyboard:changed', { id: recordId });}};recordEvents.on('updated', forward);diff --git a/server/services/socket.test.js b/server/services/socket.test.jsindex a7277530b4..10a1d48b31 100644--- a/server/services/socket.test.js+++ b/server/services/socket.test.js@@ -417,11 +417,14 @@ describe('socket.js — initSocket', () => {initSocket(io);});- it('forwards bounded project and commission invalidations from structural and local-only writes', () => {+ it('forwards bounded project, commission and storyboard invalidations from structural and local-only writes', () => {emitRecordUpdated('creativeDirectorProject', 'cd-example');emitRecordDeleted('creativeDirectorProject', 'cd-example');emitRecordInvalidated('creativeDirectorProject', 'cd-example');emitRecordInvalidated('creativeCommission', 'cc-example');+ emitRecordUpdated('storyboard', 'sb-example');+ emitRecordDeleted('storyboard', 'sb-example');+ emitRecordInvalidated('storyboard', 'sb-example');emitRecordUpdated('unrelated', 'example');expect(io.emitted.filter(([name]) => name === 'creative-director:project:changed')).toEqual(Array.from({ length: 3 }, () => ['creative-director:project:changed', { id: 'cd-example' }]),@@ -429,6 +432,9 @@ describe('socket.js — initSocket', () => {expect(io.emitted.filter(([name]) => name === 'commission:changed')).toEqual([['commission:changed', { id: 'cc-example' }],]);+ expect(io.emitted.filter(([name]) => name === 'storyboard:changed')).toEqual(+ Array.from({ length: 3 }, () => ['storyboard:changed', { id: 'sb-example' }]),+ );});it('delivers FableLoom snapshots only to subscribed operator views', () => {