Status bar v2: expandable sections with live Git status
- Git section: branch, last commit, uncommitted files with API - ANAF section: collapsible with last check time - Cron section: shows today's jobs with done/pending status - Refresh button + auto-refresh on page focus - New /api/git endpoint for live git status - All sections collapsible with localStorage persistence
This commit is contained in:
@@ -63,6 +63,8 @@ class TaskBoardHandler(SimpleHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == '/api/status':
|
||||
self.send_json({'status': 'ok', 'time': datetime.now().isoformat()})
|
||||
elif self.path == '/api/git':
|
||||
self.handle_git_status()
|
||||
elif self.path.startswith('/api/files'):
|
||||
self.handle_files_get()
|
||||
elif self.path.startswith('/api/'):
|
||||
@@ -71,6 +73,62 @@ class TaskBoardHandler(SimpleHTTPRequestHandler):
|
||||
# Serve static files
|
||||
super().do_GET()
|
||||
|
||||
def handle_git_status(self):
|
||||
"""Get git status for dashboard."""
|
||||
try:
|
||||
workspace = Path('/home/moltbot/clawd')
|
||||
|
||||
# Get current branch
|
||||
branch = subprocess.run(
|
||||
['git', 'branch', '--show-current'],
|
||||
cwd=workspace, capture_output=True, text=True, timeout=5
|
||||
).stdout.strip()
|
||||
|
||||
# Get last commit
|
||||
last_commit = subprocess.run(
|
||||
['git', 'log', '-1', '--format=%h|%s|%cr'],
|
||||
cwd=workspace, capture_output=True, text=True, timeout=5
|
||||
).stdout.strip()
|
||||
|
||||
commit_parts = last_commit.split('|') if last_commit else ['', '', '']
|
||||
|
||||
# Get uncommitted files
|
||||
status_output = subprocess.run(
|
||||
['git', 'status', '--short'],
|
||||
cwd=workspace, capture_output=True, text=True, timeout=5
|
||||
).stdout.strip()
|
||||
|
||||
uncommitted = status_output.split('\n') if status_output else []
|
||||
uncommitted = [f for f in uncommitted if f.strip()]
|
||||
|
||||
# Get diff stats if there are uncommitted files
|
||||
diff_stat = ''
|
||||
if uncommitted:
|
||||
diff_stat = subprocess.run(
|
||||
['git', 'diff', '--stat', '--cached'],
|
||||
cwd=workspace, capture_output=True, text=True, timeout=5
|
||||
).stdout.strip()
|
||||
if not diff_stat:
|
||||
diff_stat = subprocess.run(
|
||||
['git', 'diff', '--stat'],
|
||||
cwd=workspace, capture_output=True, text=True, timeout=5
|
||||
).stdout.strip()
|
||||
|
||||
self.send_json({
|
||||
'branch': branch,
|
||||
'lastCommit': {
|
||||
'hash': commit_parts[0] if len(commit_parts) > 0 else '',
|
||||
'message': commit_parts[1] if len(commit_parts) > 1 else '',
|
||||
'time': commit_parts[2] if len(commit_parts) > 2 else ''
|
||||
},
|
||||
'uncommitted': uncommitted,
|
||||
'uncommittedCount': len(uncommitted),
|
||||
'diffStat': diff_stat,
|
||||
'clean': len(uncommitted) == 0
|
||||
})
|
||||
except Exception as e:
|
||||
self.send_json({'error': str(e)}, 500)
|
||||
|
||||
def handle_files_get(self):
|
||||
"""List files or get file content."""
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
Reference in New Issue
Block a user