Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat: add opt-in react-grab dev element inspector (web + desktop) (#4381)
Naiyuan Qing6d0e875dbbec
diff --git a/apps/desktop/src/renderer/src/main.tsx b/apps/desktop/src/renderer/src/main.tsxindex 1dd7ee22ba..a525a3a9a9 100644--- a/apps/desktop/src/renderer/src/main.tsx+++ b/apps/desktop/src/renderer/src/main.tsx@@ -13,4 +13,18 @@ import "@fontsource/geist-mono/400.css";import "@fontsource/geist-mono/700.css";import "./globals.css";+// react-grab: dev-only element inspector. Hold ⌘C (Mac) / Ctrl+C and click any+// element to copy its source path + line + component stack for pasting to an AI.+// Opt-in per developer: only loads when VITE_REACT_GRAB is set in a local,+// gitignored apps/desktop/.env.development.local — it never activates for anyone+// else, and the whole branch is tree-shaken out of production builds. The web app+// wires the same tool via next/script in apps/web/app/layout.tsx.+// See https://www.react-grab.com/+if (import.meta.env.DEV && import.meta.env.VITE_REACT_GRAB) {+ const grab = document.createElement("script");+ grab.src = "//unpkg.com/react-grab/dist/index.global.js";+ grab.crossOrigin = "anonymous";+ document.head.appendChild(grab);+}+ReactDOM.createRoot(document.getElementById("root")!).render(<App />);diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex fdd052f4d9..7b7084d2fc 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -1,4 +1,5 @@import type { Metadata, Viewport } from "next";+import Script from "next/script";import { Inter, Geist_Mono, Source_Serif_4 } from "next/font/google";import { ThemeProvider } from "@/components/theme-provider";import { Toaster } from "@multica/ui/components/ui/sonner";@@ -116,6 +117,24 @@ export default async function RootLayout({className={cn("antialiased font-sans h-full", inter.variable, geistMono.variable, sourceSerif.variable)}><body className="h-full overflow-hidden">+ {/*+ react-grab: dev-only element inspector. Hold ⌘C (Mac) / Ctrl+C and click+ any element to copy its source path + line + component stack for pasting+ to an AI. Opt-in per developer: only loads when VITE_REACT_GRAB is set in+ a local, gitignored apps/web/.env.local — it never activates for anyone+ else. Both guards are read server-side, so the <Script> is omitted from+ the HTML entirely unless you opted in. The VITE_ prefix is shared with the+ desktop renderer (apps/desktop/src/renderer/src/main.tsx), where Vite only+ exposes VITE_-prefixed vars to client code, so one var name covers both+ apps. See https://www.react-grab.com/+ */}+ {process.env.NODE_ENV === "development" && process.env.VITE_REACT_GRAB && (+ <Script+ src="//unpkg.com/react-grab/dist/index.global.js"+ crossOrigin="anonymous"+ strategy="beforeInteractive"+ />+ )}<ThemeProvider><WebProviders locale={locale} resources={resources}>{children}