Skip to main content

App Structure & Frame Loop

vv-app is the only binary. main() picks one of three modes from the command line:

InvocationWhat runs
vv-app [file] [--mcp]The editor window. An optional file is imported at startup; --mcp serves MCP whatever the setting says.
vv-app mcp [project]Headless MCP server on stdio, no window (vv_mcp::serve_headless_stdio).
vv-app mcp --attach [--pid N]Bridges stdio to the socket of a running editor (vv_mcp::bridge_stdio).

Startup

  1. Settings are loaded from settings.json before any thread starts (the Intel experimental-decode flag sets an env var, so it must run first).
  2. Font discovery warms up on a background thread.
  3. eframe is started with the wgpu renderer; the device limits come from vv_render::device_limits.
  4. In the creation callback: theme, language, HW-decode device probing (background thread), the audio output (opened at once because it blocks for hundreds of ms) and a Compositor built on egui's own wgpu device and queue.
  5. The session gets a waker that calls request_repaint, so finished background jobs wake the UI.

What VenturiApp owns

Everything lives in one struct, VenturiApp, driven only from the UI thread. Background threads are reached through the objects it owns.

ch7-ownership.png

The compositor must share egui's wgpu device: a texture from another device cannot be registered in egui, and sharing it lets the viewer show the composited frame without a GPU→CPU readback.

One frame

egui is immediate mode: eframe::App::ui runs the whole sequence below on every repaint. The order matters, because each step sees the state left by the previous one.

ch7-frame-loop.png

Rules the loop enforces

RuleWhy
Edits are applied through History::do_command on the session; panels return commands instead of mutating the project.Every change is undoable and is seen by MCP the same way.
Changes made while the pointer is down go into one undo group (edit_drag_group), closed on release.A drag or a slider sweep is a single undo step.
Changes to several selected clips are wrapped in one CompositeCommand.Undo restores all of them together.
poll_session is skipped while an undo group is open.Job results must not land inside the user's gesture.
Repaints are requested only while something moves: playback, drags, buffering, running jobs.An idle editor does not redraw continuously.

MCP hand-off

With MCP enabled, the Session lives in a slot shared with the MCP host thread. mcp_checkout takes it at the start of the frame and replays what the agent did meanwhile; mcp_checkin publishes whether the user is mid-gesture or a modal dialog is open, then puts the session back. Agent calls therefore run only between frames, and the host holds project-changing calls while the user is mid-gesture. Details in chapter 9.

Source map

ModuleRole
main.rsVenturiApp, startup, frame_ui, playback driving, clipboard, selection helpers
app_menu.rsMenu bar and keyboard shortcuts
project_io.rsImport, open/save, OTIO, export, relink: the UI over session jobs
mcp_host.rsSession hand-off with the MCP host
wayland_dnd.rsFile drops on Wayland, which winit 0.30 handles only on X11