-
Notifications
You must be signed in to change notification settings - Fork 148
feat: add diagnostic logs panel with debug capture mode #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b644d28
feat: add diagnostic logs panel with debug capture mode
AmintaCCCP d49c1a7
fix: address CodeRabbit review comments
AmintaCCCP 91f872d
fix: close event-type dropdown on outside click and Escape
AmintaCCCP e66bf05
fix: improve diagnostic logs panel UX
AmintaCCCP 7ec2180
fix: address CodeRabbit review — sort all scope branches, remove unus…
AmintaCCCP 4d947ad
feat: add fork/workflow event types, capture HTTP details in debug, i…
AmintaCCCP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import React, { useState, useEffect, useCallback } from 'react'; | ||
| import { logger } from '../services/logger'; | ||
| import { backend } from '../services/backendAdapter'; | ||
|
|
||
| /** | ||
| * Global debug mode indicator — fixed bottom-right corner. | ||
| * Reads debug state from sessionStorage; visible across all pages. | ||
| * Click to quickly disable all debug modes. | ||
| */ | ||
| export const DebugModeIndicator: React.FC = () => { | ||
| const [frontendDebug, setFrontendDebug] = useState(() => sessionStorage.getItem('gsm:frontend-debug') === 'true'); | ||
| const [backendDebug, setBackendDebug] = useState(() => sessionStorage.getItem('gsm:backend-debug') === 'true'); | ||
|
|
||
| // Sync with sessionStorage changes (e.g. from DiagnosticLogsPanel) | ||
| useEffect(() => { | ||
| const check = () => { | ||
| setFrontendDebug(sessionStorage.getItem('gsm:frontend-debug') === 'true'); | ||
| setBackendDebug(sessionStorage.getItem('gsm:backend-debug') === 'true'); | ||
| }; | ||
| // Also listen for storage events from other tabs | ||
| window.addEventListener('storage', check); | ||
| // Poll for changes (sessionStorage doesn't fire storage events in same tab) | ||
| const interval = setInterval(check, 2000); | ||
| return () => { | ||
| window.removeEventListener('storage', check); | ||
| clearInterval(interval); | ||
| }; | ||
| }, []); | ||
|
|
||
| const disableAll = useCallback(async () => { | ||
| // Disable frontend debug | ||
| logger.setLevel('info'); | ||
| sessionStorage.setItem('gsm:frontend-debug', 'false'); | ||
| setFrontendDebug(false); | ||
|
|
||
| // Disable backend debug | ||
| if (backend.isAvailable) { | ||
| try { | ||
| const secret = sessionStorage.getItem('github-stars-manager-backend-secret'); | ||
| await fetch('/api/logs/debug', { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${secret}` }, | ||
| body: JSON.stringify({ enabled: false }), | ||
| }); | ||
| } catch { /* Backend unreachable */ } | ||
| } | ||
| sessionStorage.setItem('gsm:backend-debug', 'false'); | ||
| setBackendDebug(false); | ||
| }, []); | ||
|
|
||
| if (!frontendDebug && !backendDebug) return null; | ||
|
|
||
| return ( | ||
| <button | ||
| onClick={disableAll} | ||
| className="fixed bottom-6 right-6 z-50 flex items-center space-x-2 px-3 py-2 bg-green-500 text-white rounded-full shadow-lg hover:bg-green-600 transition-colors text-sm font-medium cursor-pointer" | ||
| title="Click to disable debug mode / 点击关闭调试模式" | ||
| > | ||
| <span className="w-2 h-2 rounded-full bg-white animate-pulse" /> | ||
| <span>DEBUG</span> | ||
| {frontendDebug && <span className="text-xs opacity-80">FE</span>} | ||
| {backendDebug && <span className="text-xs opacity-80">BE</span>} | ||
| </button> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.