Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): improve browser recording quality #8839

Mergedmaria-rcksmerged 11 commits intomain fromrefs/pull/8839/headmerged by maria-rcks View on GitHub

maria-rckscommented

browser recordings previously serialized jpeg screenshots through ipc at a fixed 12 fps and re-encoded them through a canvas, which caused low and uneven frame rates. this switches recording to electron's native tab media stream, preserves the preview's current dimensions, and negotiates the best available mediarecorder codec while saving the recorder's actual output format.\n\nrecordings default to 30 fps and can be set to 30 or 60 fps in Settings > Integrations > Browser. hidden tabs remain offscreen; recording gives each guest two bounded paint opportunities before native source acquisition, then primes it with a best-effort non-encoded capture with one retry. this allows multiple tabs to record without opening their threads. native stream acquisition has a five-second bound and disposes streams that resolve after timeout.\n\nfocused tests, lint, formatting, and affected package typechecks pass. an animated-page capture produced av1 at 1000x620, 60.01 fps, and bt.709 color; a two-tab pass confirmed both recordings continued while both previews were hidden. built with gpt-5.6-sol in the codex harness.


Note

Medium Risk Recording is a full pipeline swap with an IPC return-type change and new failure modes (dimensions, capture timeout, missing MIME); desktop tab/webview lifecycle races are explicitly serialized but remain sensitive.

Overview Replaces the old 12 fps JPEG screencast → canvas → MediaRecorder path with native Chromium tab capture: desktop startRecording now returns a DesktopPreviewRecordingSource (sourceId, dimensions), and the renderer acquires that stream via getUserMedia and encodes with MediaRecorder.

Desktop PreviewManager measures viewport size, optionally warms the guest with capturePage, resolves getMediaSourceId, and keeps only a background-throttling lease for recording—the periodic capturePage loop is picture-in-picture only. Saved artifacts pick file extensions from the recorder MIME via recordingFileExtension. New errors include PreviewRecordingSourceSizeUnavailableError; start/stop recording use tab lifecycle locking and race-handling tests were updated accordingly.

Web browserRecording drops frame subscription and canvas sizing; it holds browser surface activity, waits two animation frames (bounded timeout), applies browserRecordingFrameRate (30 or 60 fps, default 30 in contracts), negotiates preferred codecs, and saves the recorder’s actual output type. Startup capture is bounded (5s) with cleanup for late streams.

Settings & contracts: browserRecordingFrameRate client setting, Integrations UI, search/restore labels; IPC/previewBridge startScreencast return type changes to DesktopPreviewRecordingSource.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 385b43162ea5ab6ff17ecec115842b2540491297. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Improve browser recording quality with native MediaStream capture

  • Replaces canvas-based JPEG frame rendering with native MediaStream capture using MediaRecorder.
  • PreviewManager.startRecording measures source dimensions and returns DesktopPreviewRecordingSource (sourceId, width, height) instead of void.
  • Adds browserRecordingFrameRate client setting (30 or 60 fps) configurable via the Integrations settings panel.
  • Risk: desktop.ipc.preview.startRecording and DesktopPreviewBridge.recording.startScreencast now return DesktopPreviewRecordingSource; out-of-tree callers must handle the new return type and PreviewRecordingSourceSizeUnavailableError.
Macroscope summarized 385b431.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: cefe4431-da73-464e-849d-85405318640f

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Warning

      Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. One convention finding in apps/desktop/src/preview/Manager.ts: the new recording-source size validation is a pure domain/validation failure but is modeled by throwing a synthetic Error inside attempt so it surfaces as a generic PreviewOperationError whose only real information lives in a manufactured cause. Details inline.

      The rest of the change looks consistent with the repo's Effect conventions: namespace imports (* as Effect, * as PreviewManager), the new IPC method uses DesktopIpc.makeIpcMethod with Effect.fn and resolves PreviewManager.PreviewManager from the environment, no new ManagedRuntime.make / runPromise / service-instance injection was introduced, and the widened startRecording return type is reflected in the inline Context.Service interface and the contracts schema.

      Posted via Macroscope — Effect Service Conventions
    4. One convention issue found in the changed error-handling code. Everything else (the new PreviewRecordingSourceSizeUnavailableError tagged error, its union registration, the DesktopIpc.makeIpcMethod conversion for startRecording, and the contracts schema) follows the service conventions.

      Posted via Macroscope — Effect Service Conventions
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR replaces the existing recording pipeline with native tab capture and changes desktop IPC, stream lifecycle, codec negotiation, artifact formats, and persisted recording settings. It also introduces a 30 FPS product default and a new user-facing frame-rate control, so the breadth and runtime impact warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. apps/web/src/browser/hostedBrowserWebviewStyle.ts line 46OutdatedResolvedby maria-rcks
    7. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 14cb6ffa38975f6a1282c256ccc5911e8d02f0f0. Configure [here](https://www.cursor.com/dashboard/bugbot).
      apps/desktop/src/preview/Manager.ts line 3147OutdatedResolvedby maria-rcks
    8. apps/web/src/browser/browserRecording.ts line 393OutdatedResolvedby maria-rcks
    9. One error-modeling convention issue in the new browser recording capture path. The two findings from earlier runs (the fabricated Error for the missing output format, and the bare Error for invalid measured source dimensions in PreviewManager.startRecording) are both resolved — BrowserRecordingFormatUnavailableError and PreviewRecordingSourceSizeUnavailableError now model those failures structurally.

      Posted via Macroscope — Effect Service Conventions
      apps/web/src/browser/browserRecording.ts lines 219 to 221OutdatedResolvedby maria-rcks
    10. maria-rcks merged this3958111

    11. maria-rcks closed this

Sign in to join this conversation.