mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
chore: remove debugging throughout codebase
This commit is contained in:
@@ -17,7 +17,6 @@ function ContextMenu({
|
||||
...props
|
||||
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "context-menu",
|
||||
onOpenChange,
|
||||
});
|
||||
return (
|
||||
|
||||
@@ -12,12 +12,15 @@ function Dialog({
|
||||
...props
|
||||
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "dialog",
|
||||
open,
|
||||
onOpenChange,
|
||||
});
|
||||
return (
|
||||
<DialogPrimitive.Root open={open} onOpenChange={handleOpenChange} {...props} />
|
||||
<DialogPrimitive.Root
|
||||
open={open}
|
||||
onOpenChange={handleOpenChange}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ function DropdownMenu({
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "dropdown-menu",
|
||||
open,
|
||||
onOpenChange,
|
||||
});
|
||||
@@ -105,12 +104,12 @@ const DropdownMenuContent = React.forwardRef<
|
||||
e.preventDefault();
|
||||
}}
|
||||
className={cn(
|
||||
"group/menu bg-popover text-popover-foreground z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
"group/menu bg-popover text-popover-foreground z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
));
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ function Popover({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "popover",
|
||||
open,
|
||||
onOpenChange,
|
||||
});
|
||||
|
||||
@@ -15,12 +15,15 @@ function Select({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "select",
|
||||
open,
|
||||
onOpenChange,
|
||||
});
|
||||
return (
|
||||
<SelectPrimitive.Root open={open} onOpenChange={handleOpenChange} {...props} />
|
||||
<SelectPrimitive.Root
|
||||
open={open}
|
||||
onOpenChange={handleOpenChange}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,15 @@ function Sheet({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
||||
const handleOpenChange = useOverlayOpenChange({
|
||||
source: "sheet",
|
||||
open,
|
||||
onOpenChange,
|
||||
});
|
||||
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";
|
||||
|
||||
export function useOverlayOpenChange({
|
||||
source,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: {
|
||||
source: string;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}) {
|
||||
@@ -19,60 +17,39 @@ export function useOverlayOpenChange({
|
||||
if (!isControlled) return;
|
||||
|
||||
if (open && !isTrackedRef.current) {
|
||||
openOverlay(overlayId, source);
|
||||
openOverlay(overlayId);
|
||||
isTrackedRef.current = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!open && isTrackedRef.current) {
|
||||
closeOverlay(overlayId, source);
|
||||
closeOverlay(overlayId);
|
||||
isTrackedRef.current = false;
|
||||
}
|
||||
}, [closeOverlay, isControlled, open, openOverlay, overlayId, source]);
|
||||
}, [closeOverlay, isControlled, open, openOverlay, overlayId]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (!isTrackedRef.current) return;
|
||||
// #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: "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);
|
||||
closeOverlay(overlayId);
|
||||
isTrackedRef.current = false;
|
||||
};
|
||||
}, [closeOverlay, overlayId, source]);
|
||||
}, [closeOverlay, overlayId]);
|
||||
|
||||
return useCallback(
|
||||
(nextOpen: boolean) => {
|
||||
if (!isControlled) {
|
||||
if (nextOpen && !isTrackedRef.current) {
|
||||
openOverlay(overlayId, source);
|
||||
openOverlay(overlayId);
|
||||
isTrackedRef.current = true;
|
||||
} else if (!nextOpen && isTrackedRef.current) {
|
||||
closeOverlay(overlayId, source);
|
||||
closeOverlay(overlayId);
|
||||
isTrackedRef.current = false;
|
||||
}
|
||||
}
|
||||
|
||||
onOpenChange?.(nextOpen);
|
||||
},
|
||||
[closeOverlay, isControlled, onOpenChange, openOverlay, overlayId, source],
|
||||
[closeOverlay, isControlled, onOpenChange, openOverlay, overlayId],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -528,12 +528,10 @@ export class ProjectManager {
|
||||
}
|
||||
|
||||
async prepareExit(): Promise<void> {
|
||||
console.log("prepareExit", this.active);
|
||||
if (!this.active) return;
|
||||
|
||||
try {
|
||||
const didUpdateThumbnail = await this.updateThumbnailFromTimeline();
|
||||
console.log("didUpdateThumbnail", didUpdateThumbnail);
|
||||
if (didUpdateThumbnail) {
|
||||
await this.editor.save.flush();
|
||||
}
|
||||
|
||||
@@ -21,68 +21,10 @@ export function useKeybindingsListener() {
|
||||
|
||||
useEffect(() => {
|
||||
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 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 (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;
|
||||
}
|
||||
|
||||
@@ -93,43 +35,6 @@ export function useKeybindingsListener() {
|
||||
isTypableDOMElement({ element: activeElement });
|
||||
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) {
|
||||
activeElement.blur();
|
||||
return;
|
||||
|
||||
@@ -57,29 +57,6 @@ export const invokeAction: InvokeActionFunc = <A extends TAction>(
|
||||
args?: TArgOfAction<A>,
|
||||
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) => {
|
||||
handler(args, trigger);
|
||||
});
|
||||
|
||||
@@ -52,7 +52,6 @@ class WasmCompositor {
|
||||
string,
|
||||
{ source: CanvasImageSource; width: number; height: number }
|
||||
>();
|
||||
private _debugLogged = false;
|
||||
|
||||
ensureInitialized({ width, height }: { width: number; height: number }) {
|
||||
if (!this.canvas) {
|
||||
@@ -121,20 +120,6 @@ class WasmCompositor {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,11 @@ export function initializeGpuRenderer(): Promise<void> {
|
||||
initPromise = initializeGpu()
|
||||
.then(() => {
|
||||
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) => {
|
||||
gpuAvailable = false;
|
||||
const message =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user