3D editor: drop render-trace debug, clarify upload modal comments

Remove the TEMP render counters from PageEditor / Controls3D / UploadModal3D
now that the inline-component-anti-pattern bug is understood and fixed.
Investigation showed the apparent "4 renders per click" was a StrictMode
dev artifact (one real render, doubled, hitting two UploadModal3D
instances). The single re-render is benign on its own — the bug was
always that <UploaderModalContent /> registered a fresh component
reference each render and remounted the dropzone mid-click.

Update the call-site comment in all five upload modals to spell out
the consequence (file picker breaks) so the inline call form isn't
mistakenly "cleaned up" back to <Comp />.
This commit is contained in:
Tanish Manku committed 2026-05-08 09:30:35 -07:00
1 parent 82dba6e787
commit 4c66c39109
7 files changed
+7 -62

No files matched your search

@@ -1,4 +1,4 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useState } from "react";
import { Checkbox } from "@storyteller/ui-checkbox";
import { LoadingDots } from "@storyteller/ui-loading";
import { Modal } from "@storyteller/ui-modal";
@@ -39,25 +39,6 @@ export function UploadModal3D(props: Props) {
useState<UploaderState>(initialUploaderState);
const [isCharacter, setIsCharacter] = useState(false);
// TEMP debug: render counter — see why this re-renders mid-click.
const renderRef = useRef({ count: 0, prev: null as Record<string, unknown> | null });
renderRef.current.count += 1;
const traced = { isOpen, uploaderStateStatus: uploaderState.status, isCharacter };
const diff: Record<string, [unknown, unknown]> = {};
if (renderRef.current.prev) {
for (const k of Object.keys(traced) as Array<keyof typeof traced>) {
if (renderRef.current.prev[k] !== traced[k]) {
diff[k] = [renderRef.current.prev[k], traced[k]];
}
}
}
// eslint-disable-next-line no-console
console.debug(
`[render-trace] UploadModal3D #${renderRef.current.count}`,
Object.keys(diff).length ? { diff } : { same: traced },
);
renderRef.current.prev = traced;
const selectedCategory = isCharacter
? FilterEngineCategories.CHARACTER
: FilterEngineCategories.OBJECT;
@@ -184,7 +165,7 @@ export function UploadModal3D(props: Props) {
className="max-w-xl"
showClose={true}
>
{/* Inline call — `<Comp />` would be a fresh component reference each render and remount the subtree. */}
{/* Inline call — `<Comp />` would be a fresh component reference each render, remounting the dropzone mid-click and breaking the file picker. */}
{UploaderModalContent()}
</Modal>
);
@@ -129,7 +129,7 @@ export function UploadModalImage(props: Props) {
className="max-w-xl"
showClose={true}
>
{/* Inline call — `<Comp />` would be a fresh component reference each render and remount the subtree. */}
{/* Inline call — `<Comp />` would be a fresh component reference each render, remounting the dropzone mid-click and breaking the file picker. */}
{UploaderModalContent()}
</Modal>
);
@@ -113,7 +113,7 @@ export function UploadImageMediaModal({
return (
<Modal isOpen={isOpen} onClose={onClose} title={title}>
{/* Inline call — `<Comp />` would be a fresh component reference each render and remount the subtree. */}
{/* Inline call — `<Comp />` would be a fresh component reference each render, remounting the dropzone mid-click and breaking the file picker. */}
{UploaderModalContent()}
</Modal>
);
@@ -100,7 +100,7 @@ export function UploadModalMedia({
return (
<Modal isOpen={isOpen} onClose={onClose} title={title}>
{/* Inline call — `<Comp />` would be a fresh component reference each render and remount the subtree. */}
{/* Inline call — `<Comp />` would be a fresh component reference each render, remounting the dropzone mid-click and breaking the file picker. */}
{UploaderModalContent()}
</Modal>
);
@@ -137,7 +137,7 @@ export function UploadModalSplat(props: Props) {
className="max-w-xl"
showClose={true}
>
{/* Inline call — `<Comp />` would be a fresh component reference each render and remount the subtree. */}
{/* Inline call — `<Comp />` would be a fresh component reference each render, remounting the dropzone mid-click and breaking the file picker. */}
{UploaderModalContent()}
</Modal>
);
@@ -83,12 +83,6 @@ export const PageEditor = () => {
const { triggerRecheck } = useLoginModalStore();
const { status } = authentication;
// TEMP debug: render counter — see whether PageEditor re-renders mid-click.
const _peRenderCount = useRef(0);
_peRenderCount.current += 1;
// eslint-disable-next-line no-console
console.debug(`[render-trace] PageEditor #${_peRenderCount.current}`);
useEffect(() => {
if (status.value === AUTH_STATUS.LOGGED_OUT) {
triggerRecheck();
@@ -13,7 +13,7 @@ import { Button } from "@storyteller/ui-button";
import { Tooltip } from "@storyteller/ui-tooltip";
import { SettingsModal } from "@storyteller/ui-settings-modal";
import { EngineContext } from "../../contexts/EngineContext";
import { useContext, useEffect, useRef, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { useShallow } from "zustand/shallow";
import { usePageSceneStore } from "../../PageSceneStore";
import { useTabStore } from "~/pages/Stores/TabState";
@@ -68,36 +68,6 @@ export const Controls3D = () => {
const outlinerItemCount = usePageSceneStore((s) => s.outlinerItems.length);
// TEMP debug: render counter — see why this re-renders mid-click.
const renderRef = useRef({ count: 0, prev: null as Record<string, unknown> | null });
renderRef.current.count += 1;
const traced = {
assetModalVisible,
selectedMode,
transformSpace,
outlinerItemCount,
upload3DIsShowing,
uploadImageIsShowing,
uploadSplatIsShowing,
showEmptySceneTooltip,
isAddAssetPopoverOpen,
isSettingsModalOpen,
};
const diff: Record<string, [unknown, unknown]> = {};
if (renderRef.current.prev) {
for (const k of Object.keys(traced) as Array<keyof typeof traced>) {
if (renderRef.current.prev[k] !== traced[k]) {
diff[k] = [renderRef.current.prev[k], traced[k]];
}
}
}
// eslint-disable-next-line no-console
console.debug(
`[render-trace] Controls3D #${renderRef.current.count}`,
Object.keys(diff).length ? { diff } : { same: traced },
);
renderRef.current.prev = traced;
useEffect(() => {
const isSceneEmpty =
outlinerItemCount === 0 &&