fix: address CodeRabbit review feedback

- Fix telemetry drift reset: use nextExpectedMs - now for delay instead
  of stale drift value after baseline reset (avoids 1ms rapid sample)
- Use RECORDER_TIMESLICE_MS for mic fallback recorder (was hardcoded 1000)
- Return requested timeMs in extensionHost getCursorAt boundary clamps
- Remove premature null of webcam URL to prevent flicker on path change
- Use fs.realpath in IPC get-local-media-url to match media server check
This commit is contained in:
webadderall
2026-04-18 19:03:36 +10:00
parent 9100899adb
commit ffc5959994
5 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ export function startCursorSampling() {
nextExpectedMs = now + CURSOR_SAMPLE_INTERVAL_MS;
}
const delay = Math.max(1, CURSOR_SAMPLE_INTERVAL_MS - drift);
const delay = Math.max(1, nextExpectedMs - now);
setCursorCaptureInterval(setTimeout(tick, delay));
};
+7 -2
View File
@@ -379,12 +379,17 @@ export function registerProjectHandlers() {
}
});
ipcMain.handle('get-local-media-url', (_, filePath: string) => {
ipcMain.handle('get-local-media-url', async (_, filePath: string) => {
const baseUrl = getMediaServerBaseUrl();
if (!baseUrl || !filePath) {
return { success: false as const };
}
const resolved = path.resolve(filePath);
let resolved: string;
try {
resolved = await fs.realpath(path.resolve(filePath));
} catch {
return { success: false as const };
}
if (!approvedLocalReadPaths.has(resolved)) {
console.warn(`[get-local-media-url] Blocked unapproved path: ${resolved}`);
return { success: false as const };
@@ -1807,7 +1807,6 @@ export default function VideoEditor() {
setResolvedWebcamVideoUrl(null);
return;
}
setResolvedWebcamVideoUrl(null);
void resolveVideoUrl(webcam.sourcePath).then((url) => {
if (!cancelled) setResolvedWebcamVideoUrl(url);
});
+1 -1
View File
@@ -968,7 +968,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
micFallbackChunks.current.push(event.data);
}
};
recorder.start(1000);
recorder.start(RECORDER_TIMESLICE_MS);
micFallbackRecorder.current = recorder;
} catch (micError) {
console.warn("Browser microphone fallback failed:", micError);
+2 -2
View File
@@ -854,8 +854,8 @@ export class ExtensionHost {
const t = host._cursorTelemetry;
if (!t || t.length === 0) return null;
if (timeMs <= t[0].timeMs) return { ...t[0] };
if (timeMs >= t[t.length - 1].timeMs) return { ...t[t.length - 1] };
if (timeMs <= t[0].timeMs) return { ...t[0], timeMs };
if (timeMs >= t[t.length - 1].timeMs) return { ...t[t.length - 1], timeMs };
let lo = 0;
let hi = t.length - 1;