From c77a22d4c6b3a8bb4d4bbdb636774b2aa2c2da3b Mon Sep 17 00:00:00 2001
From: Seth Troisi <sethtroisi@google.com>
Date: Wed, 30 Jul 2025 17:43:11 -0700
Subject: Add render counter in debug mode (#5242)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
---
 packages/cli/src/ui/components/DebugProfiler.tsx | 32 ++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 packages/cli/src/ui/components/DebugProfiler.tsx

(limited to 'packages/cli/src/ui/components/DebugProfiler.tsx')

diff --git a/packages/cli/src/ui/components/DebugProfiler.tsx b/packages/cli/src/ui/components/DebugProfiler.tsx
new file mode 100644
index 00000000..89c40a91
--- /dev/null
+++ b/packages/cli/src/ui/components/DebugProfiler.tsx
@@ -0,0 +1,32 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { Text, useInput } from 'ink';
+import { useEffect, useRef, useState } from 'react';
+import { Colors } from '../colors.js';
+
+export const DebugProfiler = () => {
+  const numRenders = useRef(0);
+  const [showNumRenders, setShowNumRenders] = useState(false);
+
+  useEffect(() => {
+    numRenders.current++;
+  });
+
+  useInput((input, key) => {
+    if (key.ctrl && input === 'b') {
+      setShowNumRenders((prev) => !prev);
+    }
+  });
+
+  if (!showNumRenders) {
+    return null;
+  }
+
+  return (
+    <Text color={Colors.AccentYellow}>Renders: {numRenders.current} </Text>
+  );
+};
-- 
cgit v1.2.3

