@samitouri / QOS-React-2 / commits / 57fbe3ba37

[Compiler playground] bold changed passes (#29159)

<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> In the playground, it's hard to see at a glance what compiler passes are involved in introducing changes. This PR bolds every pass that introduces a change. ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> Before: <img width="1728" alt="image" src="https://github.com/facebook/react/assets/5144292/803ca786-0726-4456-b0db-520dc90a6771"> After: <img width="1728" alt="image" src="https://github.com/facebook/react/assets/5144292/38885644-00e9-4065-9c44-db533000d13a">

Jack Youstra committed May 20, 2024 at 08:05 UTC 57fbe3ba3729935b7ce5b670e57d30d487134bcb
2 files changed +22 -2
compiler/apps/playground/components/Editor/Output.tsx
+16
@@ -187,6 +187,21 @@ function Output({ store, compilerOutput }: Props) {
187 });
188 }, [store.source, compilerOutput]);
189
190 + const changedPasses: Set<string> = new Set();
191 + let lastResult: string = "";
192 + for (const [passName, results] of compilerOutput.results) {
193 + for (const result of results) {
194 + let currResult = "";
195 + if (result.kind === "hir" || result.kind === "reactive") {
196 + currResult += `function ${result.fnName}\n\n${result.value}`;
197 + }
198 + if (currResult !== lastResult) {
199 + changedPasses.add(passName);
200 + }
201 + lastResult = currResult;
202 + }
203 + }
204 +
205 return (
206 <>
207 <TabbedWindow
@@ -194,6 +209,7 @@ function Output({ store, compilerOutput }: Props) {
209 setTabsOpen={setTabsOpen}
210 tabsOpen={tabsOpen}
211 tabs={tabs}
212 + changedPasses={changedPasses}
213 />
214 {compilerOutput.kind === "err" ? (
215 <div
compiler/apps/playground/components/TabbedWindow.tsx
+6 -2
@@ -15,6 +15,7 @@ export default function TabbedWindow(props: {
15 tabs: TabsRecord;
16 tabsOpen: Set<string>;
17 setTabsOpen: (newTab: Set<string>) => void;
18 + changedPasses: Set<string>;
19 }): React.ReactElement {
20 if (props.tabs.size === 0) {
21 return (
@@ -36,6 +37,7 @@ export default function TabbedWindow(props: {
37 tabs={props.tabs}
38 tabsOpen={props.tabsOpen}
39 setTabsOpen={props.setTabsOpen}
40 + hasChanged={props.changedPasses.has(name)}
41 />
42 );
43 })}
@@ -48,11 +50,13 @@ function TabbedWindowItem({
50 tabs,
51 tabsOpen,
52 setTabsOpen,
53 + hasChanged,
54 }: {
55 name: string;
56 tabs: TabsRecord;
57 tabsOpen: Set<string>;
58 setTabsOpen: (newTab: Set<string>) => void;
59 + hasChanged: boolean;
60 }): React.ReactElement {
61 const isShow = tabsOpen.has(name);
62
@@ -74,7 +78,7 @@ function TabbedWindowItem({
78 title="Minimize tab"
79 aria-label="Minimize tab"
80 onClick={toggleTabs}
77 - className="p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 font-medium text-secondary hover:text-link"
81 + className={`p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 ${hasChanged ? 'font-bold' : 'font-light'} text-secondary hover:text-link`}
82 >
83 - {name}
84 </h2>
@@ -87,7 +91,7 @@ function TabbedWindowItem({
91 aria-label={`Expand compiler tab: ${name}`}
92 style={{ transform: "rotate(90deg) translate(-50%)" }}
93 onClick={toggleTabs}
90 - className="flex-grow-0 w-5 transition-colors duration-150 ease-in font-medium text-secondary hover:text-link"
94 + className={`flex-grow-0 w-5 transition-colors duration-150 ease-in ${hasChanged ? 'font-bold' : 'font-light'} text-secondary hover:text-link`}
95 >
96 {name}
97 </button>