Skip to content

Conversation

@jcalado
Copy link

@jcalado jcalado commented Jun 19, 2025

No description provided.

@vercel
Copy link

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
create-caspar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 6:24am

@jcalado jcalado marked this pull request as ready for review October 28, 2025 22:56
Copilot AI review requested due to automatic review settings October 28, 2025 22:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a "next" command functionality for CasparCG graphics templates. The feature allows triggering a next action on templates both individually and in bulk, enabling better control over template transitions.

  • Adds nextCount state tracking in the graphics-kit TemplateProvider
  • Implements caspar-next and caspar-next-all actions in the client reducer
  • Adds UI button and keyboard shortcut ('n') to trigger next actions
  • Integrates server-side support for the CasparCG NEXT command

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/graphics-kit/src/use-caspar.js Exposes nextCount from context to template hooks
packages/graphics-kit/src/TemplateProvider.jsx Adds nextCount state and window.next() handler
packages/caspar-graphics/src/node/server.js Implements server-side CasparCG NEXT command
packages/caspar-graphics/src/client/app.jsx Adds reducer actions and keyboard shortcut for next functionality
packages/caspar-graphics/src/client/TemplatePreview.jsx Triggers next on templates via nextExecutionId changes
packages/caspar-graphics/src/client/Sidebar.jsx Adds "Next" button in template controls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +217 to 221
const updateTemplate = (data, idx = index) => {
const templates = [...state.templates]
templates[index] = { ...template, ...data }
templates[idx] = { ...state.templates[idx], ...data }
return { ...state, templates }
}
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updateTemplate function can be called with an invalid index when no template is found. The removed check for index === -1 means that updateTemplate will attempt to access state.templates[-1] which returns undefined, causing the spread operation to fail. Add a guard check before the switch statement to return early if index === -1 for single-template actions.

Copilot uses AI. Check for mistakes.
Comment on lines +270 to +271
const templates = state.templates.map(t =>
t.enabled && t.show ? { ...t, nextExecutionId: Date.now() } : t
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple templates triggered simultaneously with caspar-next-all will receive the same Date.now() timestamp. If the execution is fast enough, these identical timestamps may not trigger the useEffect dependencies properly for all templates. Consider using a more robust approach like incrementing unique IDs (e.g., Date.now() + index) to ensure each template gets a unique value.

Suggested change
const templates = state.templates.map(t =>
t.enabled && t.show ? { ...t, nextExecutionId: Date.now() } : t
const templates = state.templates.map((t, idx) =>
t.enabled && t.show ? { ...t, nextExecutionId: Date.now() + idx } : t

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant