Skip to content
This repository was archived by the owner on Oct 17, 2026. It is now read-only.
This repository was archived by the owner on Oct 17, 2026. It is now read-only.

[Bug]: cursor telemetry lost or mixed between recordings on rapid restart #456

Closed

Description

@shaun0927

Search existing issues

  • I have searched the existing issues

Describe the bug

The main process keeps two module-scope arrays in electron/ipc/handlers.ts for cursor telemetry:

let activeCursorSamples: CursorTelemetryPoint[] = [];
let pendingCursorSamples: CursorTelemetryPoint[] = [];

When set-recording-state fires for a new recording, both arrays are wiped:

if (recording) {
  stopCursorCapture();
  activeCursorSamples = [];
  pendingCursorSamples = [];   // previous recording's telemetry, dropped
  ...

If the user presses Stop and then Record again before store-recorded-session has finished flushing the previous recording's .cursor.json, the previous samples are either lost outright or replaced by the next session's partial samples (depending on whether the store call lands before or after the next set-recording-state(false)).

Expected behavior

Each recording's cursor samples should be preserved exactly as captured until its own store-recorded-session call writes them. Starting a new recording should not alter any previous recording's pending telemetry.

To Reproduce

The state machine reproduces deterministically without the full app:

let active = [], pending = [];
// Recording 1
active.push(...r1Samples);
/* stop */ pending = [...active]; active = [];
// Recording 2 starts before store-recorded-session fires
active = []; pending = [];            // <-- r1 telemetry lost here
active.push(...r2Samples);
/* stop */ pending = [...active]; active = [];
/* late store for r1 */ writeCursorJson(r1Path, pending);   // writes r2 data into r1

In the real app the window is the time between clicking Stop and the IPC handler completing the write, plus any renderer-side bookkeeping. It is narrow but fully reachable with a keyboard shortcut bound to "restart recording" — which the HUD provides.

Screenshots

No response

OS

Other

OS Version

Reproduces against v1.3.0 source on any platform (logic lives in electron/ipc/handlers.ts).

Other OS

No response

Browser

Other

Browser Version

No response

Other Browser

No response

Device Type

None

Other Device

No response

Additional context

A follow-up PR replaces the two module-scope arrays with a small FIFO buffer so each completed recording's batch is retained in arrival order until its own store call consumes it, with a bounded pending queue to avoid memory leaks. Unit tests in src/lib/cursorTelemetryBuffer.test.ts lock in the rapid-restart scenario.

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