From ebe98fdee99354697dbcaafe1c176c762d9f9c84 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Fri, 27 Mar 2026 14:05:22 -0700 Subject: [PATCH] Debug command. (#23851) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/cli/src/utils/activityLogger.ts | 21 ++++- packages/devtools/GEMINI.md | 9 +- packages/devtools/client/src/App.tsx | 108 +++++++++++++++++++---- packages/devtools/src/index.ts | 36 +++++++- 4 files changed, 153 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/utils/activityLogger.ts b/packages/cli/src/utils/activityLogger.ts index 14cef88a54..8118ccdde9 100644 --- a/packages/cli/src/utils/activityLogger.ts +++ b/packages/cli/src/utils/activityLogger.ts @@ -803,7 +803,26 @@ function setupNetworkLogging( // Flush buffered logs flushBuffer(); break; - + case 'trigger-debugger': { + import('node:inspector') + .then((inspector) => { + inspector.open(); + debugLogger.log( + 'Node debugger attached. Open chrome://inspect in Chrome to start debugging.', + ); + return import('./events.js'); + }) + .then(({ appEvents, AppEvent, TransientMessageType }) => { + appEvents.emit(AppEvent.TransientMessage, { + message: 'Debugger attached from DevTools.', + type: TransientMessageType.Hint, + }); + }) + .catch((err) => + debugLogger.debug('Failed to trigger debugger:', err), + ); + break; + } case 'ping': sendMessage({ type: 'pong', timestamp: Date.now() }); break; diff --git a/packages/devtools/GEMINI.md b/packages/devtools/GEMINI.md index 9da1828a25..7397cedf84 100644 --- a/packages/devtools/GEMINI.md +++ b/packages/devtools/GEMINI.md @@ -51,10 +51,11 @@ gemini.tsx / nonInteractiveCli.ts ## API Endpoints -| Endpoint | Method | Description | -| --------- | --------- | --------------------------------------------------------------------------- | -| `/ws` | WebSocket | Log ingestion from CLI sessions (register, network, console) | -| `/events` | SSE | Pushes snapshot on connect, then incremental network/console/session events | +| Endpoint | Method | Description | +| ----------------------- | --------- | --------------------------------------------------------------------------- | +| `/ws` | WebSocket | Log ingestion from CLI sessions (register, network, console) | +| `/events` | SSE | Pushes snapshot on connect, then incremental network/console/session events | +| `/api/trigger-debugger` | POST | Triggers the Node.js debugger for a specific CLI session via WebSocket | ## Development diff --git a/packages/devtools/client/src/App.tsx b/packages/devtools/client/src/App.tsx index 9c531435b4..7869b93c3c 100644 --- a/packages/devtools/client/src/App.tsx +++ b/packages/devtools/client/src/App.tsx @@ -39,6 +39,21 @@ export default function App() { null, ); + // --- Toast Logic --- + const [toastMessage, setToastMessage] = useState(null); + const toastTimeoutRef = useRef | null>(null); + + const showToast = (msg: string) => { + setToastMessage(msg); + if (toastTimeoutRef.current) { + clearTimeout(toastTimeoutRef.current); + } + toastTimeoutRef.current = setTimeout(() => { + setToastMessage(null); + toastTimeoutRef.current = null; + }, 5000); + }; + // --- Theme Logic --- const [themeMode, setThemeMode] = useState(() => { const saved = localStorage.getItem('devtools-theme'); @@ -306,21 +321,52 @@ export default function App() { > {selectedSessionId && connectedSessions.includes(selectedSessionId) && ( - + <> + + + )}