-
Notifications
You must be signed in to change notification settings - Fork 0
Add pause/resume monitoring feature #27
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ interface HeaderProps { | |
| uptime: number; | ||
| loadAvg: number[]; | ||
| processCount: number; | ||
| paused?: boolean; | ||
| } | ||
|
|
||
| function formatUptime(seconds: number): string { | ||
|
|
@@ -22,9 +23,10 @@ function formatUptime(seconds: number): string { | |
| return parts.join(' '); | ||
| } | ||
|
|
||
| export function Header({ hostname, platform, arch, uptime, loadAvg, processCount }: HeaderProps) { | ||
| export function Header({ hostname, platform, arch, uptime, loadAvg, processCount, paused }: HeaderProps) { | ||
| const [sessionStartTime] = useState(() => Date.now()); | ||
| const [elapsedSeconds, setElapsedSeconds] = useState(0); | ||
| const [adminMode, setAdminMode] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const interval = setInterval(() => { | ||
|
|
@@ -33,6 +35,16 @@ export function Header({ hostname, platform, arch, uptime, loadAvg, processCount | |
| return () => clearInterval(interval); | ||
| }, [sessionStartTime]); | ||
|
|
||
| // Admin mode should be determined by server-side auth, not URL params | ||
| useEffect(() => { | ||
| fetch('/api/auth/me', { credentials: 'include' }) | ||
| .then(res => res.ok ? res.json() : null) | ||
| .then(data => { | ||
| if (data?.isAdmin) setAdminMode(true); | ||
| }) | ||
| .catch(() => setAdminMode(false)); | ||
| }, []); | ||
|
Comment on lines
+38
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify that /api/auth/me is not implemented in the server
echo "=== Searching for auth/me route in server code ==="
rg -n "auth/me" --type ts
echo ""
echo "=== All route definitions in server ==="
rg -n "url\.pathname ===" --type tsRepository: coderabbit-demo/btop Length of output: 430 The The server only implements routes for Either implement the 🤖 Prompt for AI Agents |
||
|
|
||
| return ( | ||
| <div className="header"> | ||
| <div className="header-left"> | ||
|
|
@@ -54,6 +66,8 @@ export function Header({ hostname, platform, arch, uptime, loadAvg, processCount | |
| </span> | ||
| </div> | ||
| <div className="header-right"> | ||
| {adminMode && <span style={{ color: 'var(--color-red)' }}>ADMIN</span>} | ||
| {paused && <span className="paused-indicator">PAUSED</span>} | ||
| <span className="load-avg"> | ||
| Load: <span className="value">{loadAvg.map(l => l.toFixed(2)).join(' ')}</span> | ||
| </span> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing AbortController and error handling for non-JSON response.
The fetch lacks:
res.json()fails on non-JSON responses (404 returns plain text "Not Found")Proposed fix with proper cleanup and error handling
useEffect(() => { + const controller = new AbortController(); - fetch('/api/auth/me', { credentials: 'include' }) + fetch('/api/auth/me', { credentials: 'include', signal: controller.signal }) .then(res => res.ok ? res.json() : null) .then(data => { if (data?.isAdmin) setAdminMode(true); }) - .catch(() => setAdminMode(false)); + .catch(() => {}); + return () => controller.abort(); }, []);🤖 Prompt for AI Agents