chore: remove debugging throughout codebase

This commit is contained in:
Maze Winther
2026-04-15 01:00:05 +02:00
parent dc0a8e7c96
commit 1fa5442f21
12 changed files with 947 additions and 1106 deletions
@@ -17,7 +17,6 @@ function ContextMenu({
...props ...props
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) { }: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "context-menu",
onOpenChange, onOpenChange,
}); });
return ( return (
+5 -2
View File
@@ -12,12 +12,15 @@ function Dialog({
...props ...props
}: React.ComponentProps<typeof DialogPrimitive.Root>) { }: React.ComponentProps<typeof DialogPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "dialog",
open, open,
onOpenChange, onOpenChange,
}); });
return ( return (
<DialogPrimitive.Root open={open} onOpenChange={handleOpenChange} {...props} /> <DialogPrimitive.Root
open={open}
onOpenChange={handleOpenChange}
{...props}
/>
); );
} }
+1 -2
View File
@@ -13,7 +13,6 @@ function DropdownMenu({
...props ...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) { }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "dropdown-menu",
open, open,
onOpenChange, onOpenChange,
}); });
@@ -110,7 +109,7 @@ const DropdownMenuContent = React.forwardRef<
)} )}
{...props} {...props}
/> />
</DropdownMenuPrimitive.Portal> </DropdownMenuPrimitive.Portal>
)); ));
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
-1
View File
@@ -11,7 +11,6 @@ function Popover({
...props ...props
}: React.ComponentProps<typeof PopoverPrimitive.Root>) { }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "popover",
open, open,
onOpenChange, onOpenChange,
}); });
+5 -2
View File
@@ -15,12 +15,15 @@ function Select({
...props ...props
}: React.ComponentProps<typeof SelectPrimitive.Root>) { }: React.ComponentProps<typeof SelectPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "select",
open, open,
onOpenChange, onOpenChange,
}); });
return ( return (
<SelectPrimitive.Root open={open} onOpenChange={handleOpenChange} {...props} /> <SelectPrimitive.Root
open={open}
onOpenChange={handleOpenChange}
{...props}
/>
); );
} }
+5 -2
View File
@@ -13,12 +13,15 @@ function Sheet({
...props ...props
}: React.ComponentProps<typeof SheetPrimitive.Root>) { }: React.ComponentProps<typeof SheetPrimitive.Root>) {
const handleOpenChange = useOverlayOpenChange({ const handleOpenChange = useOverlayOpenChange({
source: "sheet",
open, open,
onOpenChange, onOpenChange,
}); });
return ( return (
<SheetPrimitive.Root open={open} onOpenChange={handleOpenChange} {...props} /> <SheetPrimitive.Root
open={open}
onOpenChange={handleOpenChange}
{...props}
/>
); );
} }
@@ -2,11 +2,9 @@ import { useCallback, useEffect, useId, useRef } from "react";
import { useKeybindingsStore } from "@/stores/keybindings-store"; import { useKeybindingsStore } from "@/stores/keybindings-store";
export function useOverlayOpenChange({ export function useOverlayOpenChange({
source,
open, open,
onOpenChange, onOpenChange,
}: { }: {
source: string;
open?: boolean; open?: boolean;
onOpenChange?: (open: boolean) => void; onOpenChange?: (open: boolean) => void;
}) { }) {
@@ -19,60 +17,39 @@ export function useOverlayOpenChange({
if (!isControlled) return; if (!isControlled) return;
if (open && !isTrackedRef.current) { if (open && !isTrackedRef.current) {
openOverlay(overlayId, source); openOverlay(overlayId);
isTrackedRef.current = true; isTrackedRef.current = true;
return; return;
} }
if (!open && isTrackedRef.current) { if (!open && isTrackedRef.current) {
closeOverlay(overlayId, source); closeOverlay(overlayId);
isTrackedRef.current = false; isTrackedRef.current = false;
} }
}, [closeOverlay, isControlled, open, openOverlay, overlayId, source]); }, [closeOverlay, isControlled, open, openOverlay, overlayId]);
useEffect(() => { useEffect(() => {
return () => { return () => {
if (!isTrackedRef.current) return; if (!isTrackedRef.current) return;
// #region agent log closeOverlay(overlayId);
fetch(
"http://127.0.0.1:7245/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "3997d9",
},
body: JSON.stringify({
sessionId: "3997d9",
runId: "post-fix",
hypothesisId: "H2",
location: "use-overlay-open-change.ts:cleanup",
message: "Overlay closed during unmount cleanup",
data: { source, overlayId },
timestamp: Date.now(),
}),
},
).catch(() => {});
// #endregion
closeOverlay(overlayId, source);
isTrackedRef.current = false; isTrackedRef.current = false;
}; };
}, [closeOverlay, overlayId, source]); }, [closeOverlay, overlayId]);
return useCallback( return useCallback(
(nextOpen: boolean) => { (nextOpen: boolean) => {
if (!isControlled) { if (!isControlled) {
if (nextOpen && !isTrackedRef.current) { if (nextOpen && !isTrackedRef.current) {
openOverlay(overlayId, source); openOverlay(overlayId);
isTrackedRef.current = true; isTrackedRef.current = true;
} else if (!nextOpen && isTrackedRef.current) { } else if (!nextOpen && isTrackedRef.current) {
closeOverlay(overlayId, source); closeOverlay(overlayId);
isTrackedRef.current = false; isTrackedRef.current = false;
} }
} }
onOpenChange?.(nextOpen); onOpenChange?.(nextOpen);
}, },
[closeOverlay, isControlled, onOpenChange, openOverlay, overlayId, source], [closeOverlay, isControlled, onOpenChange, openOverlay, overlayId],
); );
} }
@@ -528,12 +528,10 @@ export class ProjectManager {
} }
async prepareExit(): Promise<void> { async prepareExit(): Promise<void> {
console.log("prepareExit", this.active);
if (!this.active) return; if (!this.active) return;
try { try {
const didUpdateThumbnail = await this.updateThumbnailFromTimeline(); const didUpdateThumbnail = await this.updateThumbnailFromTimeline();
console.log("didUpdateThumbnail", didUpdateThumbnail);
if (didUpdateThumbnail) { if (didUpdateThumbnail) {
await this.editor.save.flush(); await this.editor.save.flush();
} }
-95
View File
@@ -21,68 +21,10 @@ export function useKeybindingsListener() {
useEffect(() => { useEffect(() => {
const eventOptions: AddEventListenerOptions = { capture: true }; const eventOptions: AddEventListenerOptions = { capture: true };
// #region agent log
fetch("http://127.0.0.1:7245/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "3997d9",
},
body: JSON.stringify({
sessionId: "3997d9",
runId: "initial",
hypothesisId: "H1",
location: "use-keybindings.ts:effect",
message: "Keybindings listener mounted",
data: {
overlayDepth,
isLoadingProject,
isRecording,
keybindingCount: Object.keys(keybindings).length,
},
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
const handleKeyDown = (ev: KeyboardEvent) => { const handleKeyDown = (ev: KeyboardEvent) => {
const normalizedKey = (ev.key ?? "").toLowerCase(); const normalizedKey = (ev.key ?? "").toLowerCase();
const shouldLogKey =
ev.code === "Space" ||
ev.code.startsWith("Key") ||
["escape", "delete", "backspace", "enter"].includes(normalizedKey);
if (overlayDepth > 0 || isLoadingProject || isRecording) { if (overlayDepth > 0 || isLoadingProject || isRecording) {
if (shouldLogKey) {
// #region agent log
fetch(
"http://127.0.0.1:7245/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "3997d9",
},
body: JSON.stringify({
sessionId: "3997d9",
runId: "initial",
hypothesisId: "H2",
location: "use-keybindings.ts:blocked",
message: "Shortcut blocked by runtime gate",
data: {
key: ev.key,
code: ev.code,
overlayDepth,
isLoadingProject,
isRecording,
targetTag:
ev.target instanceof HTMLElement ? ev.target.tagName : null,
},
timestamp: Date.now(),
}),
},
).catch(() => {});
// #endregion
}
return; return;
} }
@@ -93,43 +35,6 @@ export function useKeybindingsListener() {
isTypableDOMElement({ element: activeElement }); isTypableDOMElement({ element: activeElement });
const boundAction = binding ? keybindings[binding] : undefined; const boundAction = binding ? keybindings[binding] : undefined;
if (shouldLogKey || binding || boundAction) {
// #region agent log
fetch(
"http://127.0.0.1:7245/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "3997d9",
},
body: JSON.stringify({
sessionId: "3997d9",
runId: "initial",
hypothesisId: !binding ? "H3" : isTextInput ? "H5" : "H4",
location: "use-keybindings.ts:keydown",
message: "Shortcut keydown observed",
data: {
key: ev.key,
code: ev.code,
binding,
boundAction: boundAction ?? null,
isTextInput,
keybindingCount: Object.keys(keybindings).length,
activeTag:
activeElement instanceof HTMLElement
? activeElement.tagName
: null,
targetTag:
ev.target instanceof HTMLElement ? ev.target.tagName : null,
},
timestamp: Date.now(),
}),
},
).catch(() => {});
// #endregion
}
if (normalizedKey === "escape" && isTextInput) { if (normalizedKey === "escape" && isTextInput) {
activeElement.blur(); activeElement.blur();
return; return;
-23
View File
@@ -57,29 +57,6 @@ export const invokeAction: InvokeActionFunc = <A extends TAction>(
args?: TArgOfAction<A>, args?: TArgOfAction<A>,
trigger?: TInvocationTrigger, trigger?: TInvocationTrigger,
) => { ) => {
if (trigger === "keypress") {
// #region agent log
fetch("http://127.0.0.1:7245/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "3997d9",
},
body: JSON.stringify({
sessionId: "3997d9",
runId: "initial",
hypothesisId: "H4",
location: "actions/registry.ts:invokeAction",
message: "Action invoked from keypress",
data: {
action,
handlerCount: boundActions[action]?.length ?? 0,
},
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
}
boundActions[action]?.forEach((handler) => { boundActions[action]?.forEach((handler) => {
handler(args, trigger); handler(args, trigger);
}); });
@@ -52,7 +52,6 @@ class WasmCompositor {
string, string,
{ source: CanvasImageSource; width: number; height: number } { source: CanvasImageSource; width: number; height: number }
>(); >();
private _debugLogged = false;
ensureInitialized({ width, height }: { width: number; height: number }) { ensureInitialized({ width, height }: { width: number; height: number }) {
if (!this.canvas) { if (!this.canvas) {
@@ -121,20 +120,6 @@ class WasmCompositor {
} }
render(frame: FrameDescriptor) { render(frame: FrameDescriptor) {
if (!this._debugLogged) {
this._debugLogged = true;
const firstLayer = frame.items.find((item) => item.type === "layer");
console.log(
"[compositor] first frame — canvas size:",
JSON.stringify({ width: frame.width, height: frame.height }),
"| first layer transform:",
firstLayer && firstLayer.type === "layer"
? JSON.stringify(firstLayer.transform)
: "none",
"| webgpu available:",
typeof navigator !== "undefined" && "gpu" in navigator,
);
}
renderFrame(frame); renderFrame(frame);
} }
} }
@@ -13,18 +13,11 @@ export function initializeGpuRenderer(): Promise<void> {
initPromise = initializeGpu() initPromise = initializeGpu()
.then(() => { .then(() => {
gpuAvailable = true; gpuAvailable = true;
// #region agent log
fetch('http://127.0.0.1:7408/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'b140a6'},body:JSON.stringify({sessionId:'b140a6',location:'gpu-renderer.ts',message:'GPU init SUCCESS',data:{userAgent:navigator.userAgent},timestamp:Date.now()})}).catch(()=>{});
// #endregion
}) })
.catch((error: unknown) => { .catch((error: unknown) => {
gpuAvailable = false; gpuAvailable = false;
const message = const message = error instanceof Error ? error.message : String(error);
error instanceof Error ? error.message : String(error);
console.warn(`GPU renderer unavailable: ${message}`); console.warn(`GPU renderer unavailable: ${message}`);
// #region agent log
fetch('http://127.0.0.1:7408/ingest/669b22f8-172b-4e65-aa3f-1c702ede83f7',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'b140a6'},body:JSON.stringify({sessionId:'b140a6',location:'gpu-renderer.ts',message:'GPU init FAILED',data:{error:message,userAgent:navigator.userAgent,hasGpu:!!navigator.gpu},timestamp:Date.now()})}).catch(()=>{});
// #endregion
}); });
} }
return initPromise; return initPromise;