From 250f1b20e0ac8e6c1ba03f2466ad63ff9b5104de Mon Sep 17 00:00:00 2001
From: Eugene Choi <4eugenechoi@gmail.com>
Date: Thu, 25 Sep 2025 14:56:41 -0400
Subject: [PATCH] [playground] Fix useEffect on tabify (#34594)
There was a bug in the Compiler Playground related to the "Show
Internals" toggle due to a useEffect that was causing the tab names to
flicker from a rerender. Rewritten instead with a `` boundary
+ `use`.
---
.../playground/components/Editor/Output.tsx | 45 ++++++++++++++-----
compiler/apps/playground/package.json | 1 +
compiler/apps/playground/yarn.lock | 5 +++
3 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/compiler/apps/playground/components/Editor/Output.tsx b/compiler/apps/playground/components/Editor/Output.tsx
index 331aa66bcbeb4..dcc8dea5c83bf 100644
--- a/compiler/apps/playground/components/Editor/Output.tsx
+++ b/compiler/apps/playground/components/Editor/Output.tsx
@@ -19,12 +19,13 @@ import {
import parserBabel from 'prettier/plugins/babel';
import * as prettierPluginEstree from 'prettier/plugins/estree';
import * as prettier from 'prettier/standalone';
-import {memo, ReactNode, useEffect, useState} from 'react';
import {type Store} from '../../lib/stores';
+import {memo, ReactNode, use, useState, Suspense} from 'react';
import AccordionWindow from '../AccordionWindow';
import TabbedWindow from '../TabbedWindow';
import {monacoOptions} from './monacoOptions';
import {BabelFileResult} from '@babel/core';
+import {LRUCache} from 'lru-cache';
const MemoizedOutput = memo(Output);
@@ -32,6 +33,10 @@ export default MemoizedOutput;
export const BASIC_OUTPUT_TAB_NAMES = ['Output', 'SourceMap'];
+const tabifyCache = new LRUCache>>({
+ max: 5,
+});
+
export type PrintedCompilerPipelineValue =
| {
kind: 'hir';
@@ -200,6 +205,25 @@ ${code}
return reorderedTabs;
}
+function tabifyCached(
+ store: Store,
+ compilerOutput: CompilerOutput,
+): Promise
+ );
+}
+
+function OutputContent({store, compilerOutput}: Props): JSX.Element {
const [tabsOpen, setTabsOpen] = useState>(
() => new Set(['Output']),
);
- const [tabs, setTabs] = useState