Skip to content

Agent bridge cannot read or set the timeline duration #171

Open

Description

@ruizemanuel

The MCP server has 19 tools covering layers, params, custom shaders and screenshots. None of them touch the composition duration, and get_project_state does not report it either. So an agent can see almost everything about a composition except how long it is.

Reading is the bigger half. A looping scene hardcodes its period in the shader, and if Dur does not match, the loop silently fails to close. The agent has no way to detect that. Building scenes through this server I have had to read the field off the timeline by hand every time, and once I got it wrong by inferring it from the thumbnail slider in the publish dialog.

The fix looks small, because the pieces are already there. useTimelineStore is imported in src/lib/agent-bridge/commands.ts and used for seedDurationFromMedia. setDuration already clamps through clampDuration and re-clamps currentTime, so there is no new validation to write.

Read side, one line in getProjectState():

durationSeconds: useTimelineStore.getState().duration,

Write side, a handler alongside the others, using the requireNumber helper already in that file:

set_composition_duration: (payload) => {
  const seconds = requireNumber(payload, "seconds")
  useTimelineStore.getState().setDuration(seconds)
  const { duration } = useTimelineStore.getState()
  return { durationSeconds: duration, clamped: duration !== seconds }
},

Plus a tool file in packages/shader-lab-mcp/src/tools/ following the existing proxy() pattern.

I went through the 21 open PRs first. #167 rewrites the compositionSize line inside getProjectState and #164 changes the default duration, but neither exposes duration to the bridge, so the gap survives V3. Happy to rebase on #167 if it lands first.

Would you take a PR? I can send the read side on its own if you would rather not give an agent the write side.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions