Skip to content

About

An advanced React component for rendering CodeVideo projects.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

@fullstackcraftllc/codevideo-ide-react

NPM Version

React component for the CodeVideo IDE. Our first "nearly-complete" functionality component for replaying IDE sessions, complete with a file explorer, multiple editor tab support, and a terminal.

IT'S CRITICAL THIS SHIPS TO PRODUCTION ONLY AFTER CONFIRMING THERE ARE NO SSR ISSUES - MONACO IS INFAMOUS FOR SSR ISSUES!

Typically, this is caused by calling monaco.editor by accident, when the react ref globalMonacoRef.current.editor. can be used instead.

Examples

There is a Next.js site (in this repo under the ./example folder) featuring the CodeVideoIDE component in various configurations.

In step mode using the arrow keys to navigate through steps:

https://codevideo.github.io/codevideo-ide-react/step

In replay mode, starting a full replay with sound as soon as the page is interacted with:

https://codevideo.github.io/codevideo-ide-react/replay

In replay mode compatible with puppeteer recording callbacks, starting a full replay with sound as soon as the page is interacted with:

https://codevideo.github.io/codevideo-ide-react/puppeteer

In replay mode with a simulated LLM stream appending actions to a growing array while playback runs (the isStreaming prop):

https://codevideo.github.io/codevideo-ide-react/streaming

Quickstart (working on this repo)

git clone https://github.com/codevideo/codevideo-ide-react.git
cd codevideo-ide-react
nvm use          # pins Node 22 (.nvmrc)
npm install
npm test         # full jest suite
npm run example:local   # build the lib + run the example app against it

Streaming actions (live-generated content)

The component is fully controlled: the parent owns currentActionIndex and advances it from actionFinishedCallback. With the isStreaming prop you can feed it a growing actions array (e.g. generated live by an LLM) and playback continues seamlessly across appends:

  • appends never restart the current animation (detection is content-based, so Redux-style immutable array rebuilds work)
  • when playback runs out of actions it idles ("buffering") instead of calling playBackCompleteCallback, and resumes automatically on the next append
  • set isStreaming back to false once the stream ends to restore normal completion semantics

See example/src/pages/streaming.tsx for a complete working simulation - the exact wiring a real streaming consumer uses.

Regression testing (golden render)

Experimental offline rendering is available through renderMode="deterministic" and an optional renderSeed. It uses action-scoped mouse randomness and emits onRenderEvent / onRenderError callbacks. Prepared speech items need assetId, actionIndex and measured durationMs; deterministic playback emits cues without playing browser audio. Virtual time is installed by the CLI runner, outside this component. The default remains realtime. The golden benchmark below supports 1/2/4/8/12 browser workers with repeated measurements. The exported RenderSession and RenderCheckpointV1 contracts support planning and suspended checkpoint restore; the CLI enables them with --render-strategy ab-initio.

Beyond the jest suite, visual/timing behavior is guarded by a golden-render workflow: a deterministic fixture rendered to video via codevideo-cli and compared against a known-good reference (duration + keyframe contact sheets). See scripts/golden/README.md - no API keys required.

Installation

Install the package itself via npm:

npm install @fullstackcraftllc/codevideo-ide-react

Ensure that you include radix CSS in your project. For frameworks like Next.js, you can include this in the root of your project:

import "@radix-ui/themes/styles.css";

For Gatsby, add this to your gatsby-browser.js and gatsby-ssr.js files:

require('@radix-ui/themes/styles.css');

Portrait layouts and selections

isFileExplorerVisible, isEditorTabsVisible, isMinimapVisible, and isMouseVisible are independent optional booleans (all default to true). Hiding the editor tabs also hides their filenames. Hiding the mouse only stops drawing the cursor: mouse actions keep their timing and effects, and the position is still tracked, so there's no need for a first action that moves the cursor off screen. wordWrap accepts 'on' (default) or 'off'; wrapping only changes the visual layout and never inserts newlines into source content. These options also work in record and step modes and can change after mounting.

<CodeVideoIDE {...props}
  isFileExplorerVisible={false}
  isEditorTabsVisible={false}
  isMinimapVisible={false}
  isMouseVisible={false}
  wordWrap="on"
/>

editor-shift+arrow-right, left, up, and down extend an anchored selection one logical character/line at a time; value is the number of key presses, with keyboardTypingPauseMs between presses. Reversing direction shrinks the selection and can extend it past the original anchor.

editor-command+shift+arrow-right selects to the logical line end, excluding its newline; editor-command+shift+arrow-left selects to absolute column one, including indentation. editor-shift+end / editor-shift+home are the equivalent Windows/Linux actions. Soft wrapping does not change these boundaries. Each is repeatable; pressing again at the boundary does not select the next line.

About

An advanced React component for rendering CodeVideo projects.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages