* fix(ui): make chat message action icons always visible - Removes opacity-0 and pointer-events-none classes from UserMessageBody action buttons container. - Ensures icons are visible by default instead of only on hover/focus. - Addresses user feedback about empty space at the bottom of chat bubbles. * fix(ui): make chat message action icons always visible - Removes opacity-0 and pointer-events-none classes from UserMessageBody action buttons container. - Ensures icons are visible by default instead of only on hover/focus. - Addresses user feedback about empty space at the bottom of chat bubbles. * fix(ui): prevent diff comment input from closing on click (#3) Replaced global `document.querySelector('[data-comment-ui]')` with a local `useRef` to detect clicks inside the comment input area. This fixes an issue where clicking the input in one diff viewer would close it if another diff viewer (found first by querySelector) existed in the DOM. - Added `commentContainerRef` in `PierreDiffViewer.tsx`. - Updated `handleClickOutside` to check against the ref. - Attached ref to comment UI containers in both 'fill' and 'inline' layouts. - Preserved `data-comment-ui` attribute for backward compatibility. * feat(ui): add visual connector lines to file explorer (#2) - Replaced manual padding-based indentation with nested list structure - Added vertical connector lines using border-l on nested ul - Added horizontal connector lines using pseudo-elements on list items - Added tail masking for the last item in a branch to create the 'L' shape - Removed manual padding calculation from file/folder buttons * Create openchamber.yml * Create OPENCODE_FOR_ACTIONS.md * feat: update OpenChamber for Actions workflow and docs (#6) - Rename `docs/OPENCODE_FOR_ACTIONS.md` to `docs/OPENCHAMBER_FOR_ACTIONS.md`. - Update `README.md` to include a section on OpenChamber for Actions. - Update `.github/workflows/openchamber.yml` to allow users to select which service to expose (OpenChamber, OpenCode, or Both). - Update documentation to reflect the new workflow options. * feat: Add shimmer effect for generating messages (#7) * Create test_unreleased.yml * Update test_unreleased.yml * Delete test_unreleased.yml * 🧪 Labs: Enhanced File Explorer with Context Menus & UI Improvements (#13) * feat: add file management capabilities (create, rename, delete) (#11) Added backend endpoints for delete and rename operations. Extended FilesAPI interface and implementation. Updated FilesView with toolbar buttons for Create File/Folder. Added context menu to file tree items for Rename, Delete, and Copy Path. Implemented dialogs for all file operations. * Refactor UI/UX: Modernize styles, components, and layout architecture (#10) Refactored `packages/ui` CSS into modular files (design-system, typography, mobile). Modernized `Header` with pill-style tabs and semantic Flexbox layout. Enhanced `Chat` UI with threading visuals, improved typography, and better spacing. Updated `Sidebar` to match the new design system aesthetic. Verified with full workspace build. * Add workflow * Change to manual dispatch only * Delete test.yml * Update openchamber.yml * Fix styling and workflow improvements (#17) * Refactor OpenChamber workflow and update docs (#18) - Refactor `.github/workflows/openchamber.yml` to use modular helper scripts. - Add helper scripts in `scripts/`: `monitor.sh`, `persistence-restore.sh`, `persistence-save.sh`, `opencode-config.sh`. - Update `docs/OPENCHAMBER_FOR_ACTIONS.md` to reflect new inputs and features. - Implement robust monitoring with self-healing and proper URL logging. - Improve persistence robustness for file copying. * Expose Opencode Core, Web, and Chamber via Cloudflare tunnels (#19) This commit updates the GitHub Actions workflow and monitoring script to: 1. Install `wetty` to expose the core Opencode TTY over the web (interpreted from user request for "WiTTY"). 2. Start `opencode web` (8080), `openchamber` (9090), and `wetty` (3000) concurrently. 3. Configure Cloudflare to create three separate tunnels for these ports. 4. Update `monitor.sh` to accept and display URLs for all three services. * Update opencode-config.sh * Tighten actions persistence and UI polish * Delete openchamber.yml * Delete persistence-save.sh * Delete persistence-restore.sh * Delete opencode-config.sh * Delete monitor.sh * Delete install.sh * Fix OpenChamber workflow and scripts for multi-service tunnels (#21) * Create auto-opencode.yml * Update opencode.yml * feat: add password protection for OpenChamber in Actions (#22) - Introduce `OPENCODE_SERVER_PASSWORD` secret support in `.github/workflows/opencode.yml`. - Automatically set `OPENCHAMBER_UI_PASSWORD` and `OPENCODE_UI_PASSWORD` if the secret is provided. - Configure `ttyd` to use basic auth (`-c user:password`) when password is set. - Update `scripts/monitor.sh` to respect password settings during service restarts. - Significantly update `docs/OPENCHAMBER_FOR_ACTIONS.md` with an overview, password configuration instructions, and improved layout (collapsible sections). * use one password env variable * Update OPENCHAMBER_FOR_ACTIONS.md * feat: improve GITHUB_STEP_SUMMARY, fix TTY home logic and add encryption support in scripts * feat: lazy load large diffs to prevent page freeze (#186) When diff content exceeds 1500 lines or 150KB, show a placeholder with "Load Diff" button instead of parsing immediately. This prevents the page from freezing when viewing large diffs. Co-authored-by: Jovines <jovines@qq.com> * feat: add Web Push API support and PWA integration (#189) * feat: add Web Push API support and PWA integration Add web Push API with subscribe/unsubscribe and visibility endpoints Introduce usePushVisibilityBeacon and useSessionDeepLink hooks Integrate PWA with service worker, registerSW, and VAPID key persistence * feat: add heartbeat visibility beacon for web runtime Add a 10s heartbeat to ping visibility while visible Subscribe to visibilitychange, focus, blur, pageshow, and pagehide events to report state Clear heartbeat interval on unmount to avoid leaks * feat(UI): Introduce new UI components for file attachments and related views (#191) Add file management API and UI components Implement directory listing, search and CRUD operations in desktop backend Expose new Files API on frontend to list, search, and modify files * feat: add workbox-window and improve event stream cleanup Add workbox-window dependency to bun.lock and web package.json Cancel and release the stream reader on disconnect to avoid leaks * feat: provider config management (#193) * feat: support scoped removal of provider config (auth, user, project, custom) * feat: implement UI session token management with cookies for window visibility control * feature: header layout changes (#195) * fix(ui): remove fixed sessions button and mac titlebar coupling Remove fixed sessions button from header on desktop Mac Eliminate Mac titlebar spacer and drag-to-dock logic in sidebar Update layout to rely on standard header/sidebar without mac-specific tweaks * feat: improve mobile header with session toggle and back button Add back button in mobile header to exit session switcher Show Sessions label when session switcher is open in mobile header Toggle between opening sessions and back navigation based on session state * restore: add back scripts/install.sh from main branch * docs: improve Tech Stack section with organized label badges * Fix actions auth and remove shimmer
293 lines
9.4 KiB
Bash
Executable File
293 lines
9.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# ==============================================================================
|
|
# OpenCode Monitor & Self-Heal Script
|
|
# ==============================================================================
|
|
# This script monitors OpenCode (TTY), OpenChamber, and OpenCode Web services,
|
|
# automatically restarting them if they crash. It also manages the tunnel connections.
|
|
#
|
|
# Usage: ./monitor.sh <tunnel_provider> <timeout_minutes> <url_tty> <url_chamber> <url_web>
|
|
#
|
|
# Arguments:
|
|
# tunnel_provider: "ngrok" or "cloudflare"
|
|
# timeout_minutes: Auto-shutdown timeout in minutes
|
|
# url_tty: Initial tunnel URL for OpenCode TTY
|
|
# url_chamber: Initial tunnel URL for OpenChamber
|
|
# url_web: Initial tunnel URL for OpenCode Web
|
|
# ==============================================================================
|
|
|
|
set -uo pipefail
|
|
|
|
TUNNEL_PROVIDER="${1:-cloudflare}"
|
|
TIMEOUT_MINUTES="${2:-300}"
|
|
URL_TTY="${3:-}"
|
|
URL_CHAMBER="${4:-}"
|
|
URL_WEB="${5:-}"
|
|
|
|
echo "=============================================="
|
|
echo "OpenCode Monitor & Self-Heal"
|
|
echo "=============================================="
|
|
echo "Tunnel Provider: $TUNNEL_PROVIDER"
|
|
echo "Timeout: $TIMEOUT_MINUTES minute(s)"
|
|
echo "----------------------------------------------"
|
|
echo "OpenCode TTY URL: $URL_TTY"
|
|
echo "OpenChamber URL: $URL_CHAMBER"
|
|
echo "OpenCode Web URL: $URL_WEB"
|
|
echo "=============================================="
|
|
echo ""
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Configuration
|
|
# ------------------------------------------------------------------------------
|
|
TTY_PORT=7681
|
|
OPENCHAMBER_PORT=9090
|
|
OPENCODE_WEB_PORT=8080
|
|
|
|
START_TIME=$(date +%s)
|
|
TIMEOUT_SECONDS=$((TIMEOUT_MINUTES * 60))
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Helper Functions
|
|
# ------------------------------------------------------------------------------
|
|
|
|
log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
|
}
|
|
|
|
check_port() {
|
|
local port=$1
|
|
lsof -i :"$port" > /dev/null 2>&1
|
|
}
|
|
|
|
get_remaining_time() {
|
|
local elapsed=$(($(date +%s) - START_TIME))
|
|
local remaining=$((TIMEOUT_SECONDS - elapsed))
|
|
echo $remaining
|
|
}
|
|
|
|
format_time() {
|
|
local seconds=$1
|
|
local minutes=$((seconds / 60))
|
|
local hours=$((minutes / 60))
|
|
minutes=$((minutes % 60))
|
|
|
|
if [ $hours -gt 0 ]; then
|
|
echo "${hours}h ${minutes}m"
|
|
else
|
|
echo "${minutes}m"
|
|
fi
|
|
}
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Service Management
|
|
# ------------------------------------------------------------------------------
|
|
|
|
restart_opencode_tty() {
|
|
log "Restarting OpenCode TTY on port $TTY_PORT..."
|
|
pkill -f "ttyd" 2>/dev/null || true
|
|
sleep 2
|
|
|
|
if [ -n "${OPENCHAMBER_UI_PASSWORD:-}" ]; then
|
|
log "Restarting TTY with password protection."
|
|
nohup stdbuf -oL ttyd -c "user:${OPENCHAMBER_UI_PASSWORD}" -p $TTY_PORT bash -c "cd \$HOME && exec opencode" >> opencode_tty.log 2>&1 &
|
|
else
|
|
nohup stdbuf -oL ttyd -p $TTY_PORT bash -c "cd \$HOME && exec opencode" >> opencode_tty.log 2>&1 &
|
|
fi
|
|
sleep 5
|
|
|
|
if check_port $TTY_PORT; then
|
|
log "OpenCode TTY restarted successfully"
|
|
return 0
|
|
else
|
|
log "ERROR: Failed to restart OpenCode TTY"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
restart_openchamber() {
|
|
log "Restarting OpenChamber on port $OPENCHAMBER_PORT..."
|
|
pkill -f "openchamber" 2>/dev/null || true
|
|
sleep 2
|
|
if [ -n "${OPENCHAMBER_UI_PASSWORD:-}" ]; then
|
|
nohup stdbuf -oL openchamber --port $OPENCHAMBER_PORT --ui-password "$OPENCHAMBER_UI_PASSWORD" >> openchamber.log 2>&1 &
|
|
else
|
|
nohup stdbuf -oL openchamber --port $OPENCHAMBER_PORT >> openchamber.log 2>&1 &
|
|
fi
|
|
sleep 5
|
|
|
|
if check_port $OPENCHAMBER_PORT; then
|
|
log "OpenChamber restarted successfully"
|
|
return 0
|
|
else
|
|
log "ERROR: Failed to restart OpenChamber"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
restart_opencode_web() {
|
|
log "Restarting OpenCode Web on port $OPENCODE_WEB_PORT..."
|
|
# Note: "opencode web" might be matched by "opencode" so we use full command in pkill if possible or handle order
|
|
pkill -f "opencode web" 2>/dev/null || true
|
|
sleep 2
|
|
if [ -n "${OPENCHAMBER_UI_PASSWORD:-}" ]; then
|
|
OPENCODE_SERVER_PASSWORD="$OPENCHAMBER_UI_PASSWORD" nohup stdbuf -oL opencode web --port $OPENCODE_WEB_PORT >> opencode_web.log 2>&1 &
|
|
else
|
|
nohup stdbuf -oL opencode web --port $OPENCODE_WEB_PORT >> opencode_web.log 2>&1 &
|
|
fi
|
|
sleep 5
|
|
|
|
if check_port $OPENCODE_WEB_PORT; then
|
|
log "OpenCode Web restarted successfully"
|
|
return 0
|
|
else
|
|
log "ERROR: Failed to restart OpenCode Web"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
restart_tunnels() {
|
|
log "Restarting tunnels ($TUNNEL_PROVIDER)..."
|
|
|
|
if [ "$TUNNEL_PROVIDER" = "ngrok" ]; then
|
|
pkill -f "ngrok" 2>/dev/null || true
|
|
sleep 2
|
|
# Complex to manage multiple ngrok tunnels without config file.
|
|
# For now, attempting to restore single tunnel logic or just warn.
|
|
log "WARNING: Multi-tunnel restart for ngrok not fully supported in this script version."
|
|
# Attempt to start tunnels again (blindly)
|
|
nohup ngrok http 127.0.0.1:$OPENCHAMBER_PORT --log=stdout > tunnel_chamber.log 2>&1 &
|
|
nohup ngrok http 127.0.0.1:$OPENCODE_WEB_PORT --log=stdout > tunnel_web.log 2>&1 &
|
|
nohup ngrok http 127.0.0.1:$TTY_PORT --log=stdout > tunnel_tty.log 2>&1 &
|
|
sleep 10
|
|
else
|
|
pkill -f "cloudflared" 2>/dev/null || true
|
|
sleep 2
|
|
nohup cloudflared tunnel --url http://127.0.0.1:$TTY_PORT > tunnel_tty.log 2>&1 &
|
|
nohup cloudflared tunnel --url http://127.0.0.1:$OPENCHAMBER_PORT > tunnel_chamber.log 2>&1 &
|
|
nohup cloudflared tunnel --url http://127.0.0.1:$OPENCODE_WEB_PORT > tunnel_web.log 2>&1 &
|
|
sleep 15
|
|
|
|
# Get new URLs
|
|
URL_TTY=$(grep -o 'https://[-a-z0-9.]*trycloudflare.com' tunnel_tty.log 2>/dev/null | tail -n 1)
|
|
URL_CHAMBER=$(grep -o 'https://[-a-z0-9.]*trycloudflare.com' tunnel_chamber.log 2>/dev/null | tail -n 1)
|
|
URL_WEB=$(grep -o 'https://[-a-z0-9.]*trycloudflare.com' tunnel_web.log 2>/dev/null | tail -n 1)
|
|
fi
|
|
|
|
log "Tunnels restarted."
|
|
echo ""
|
|
echo "=============================================="
|
|
echo "NEW ACCESS URLS:"
|
|
echo "OpenCode TTY: $URL_TTY"
|
|
echo "OpenChamber: $URL_CHAMBER"
|
|
echo "OpenCode Web: $URL_WEB"
|
|
echo "=============================================="
|
|
echo ""
|
|
}
|
|
|
|
check_tunnels() {
|
|
if [ "$TUNNEL_PROVIDER" = "ngrok" ]; then
|
|
pgrep -f "ngrok" > /dev/null 2>&1
|
|
else
|
|
pgrep -f "cloudflared" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Graceful Shutdown
|
|
# ------------------------------------------------------------------------------
|
|
|
|
shutdown() {
|
|
log "Initiating graceful shutdown..."
|
|
|
|
# Kill all services
|
|
pkill -f "ttyd" 2>/dev/null || true
|
|
pkill -f "opencode" 2>/dev/null || true
|
|
pkill -f "openchamber" 2>/dev/null || true
|
|
pkill -f "opencode web" 2>/dev/null || true
|
|
pkill -f "ngrok" 2>/dev/null || true
|
|
pkill -f "cloudflared" 2>/dev/null || true
|
|
|
|
log "All services stopped"
|
|
exit 0
|
|
}
|
|
|
|
# Trap signals for graceful shutdown
|
|
trap shutdown SIGTERM SIGINT
|
|
|
|
# ==============================================================================
|
|
# Main Monitoring Loop
|
|
# ==============================================================================
|
|
|
|
log "Starting monitoring loop..."
|
|
echo ""
|
|
|
|
# Write initial URLs to GitHub Step Summary (if running in GitHub Actions)
|
|
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
|
{
|
|
echo "## OpenChamber for Actions"
|
|
echo ""
|
|
echo "| Service | URL |"
|
|
echo "|---------|-----|"
|
|
echo "| **OpenCode TTY** | $URL_TTY |"
|
|
echo "| **OpenChamber** | $URL_CHAMBER |"
|
|
echo "| **OpenCode Web** | $URL_WEB |"
|
|
echo ""
|
|
echo "_Timeout: ${TIMEOUT_MINUTES} minutes_"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
# Status display interval (every 5 minutes = 300 seconds)
|
|
LAST_STATUS_TIME=0
|
|
STATUS_INTERVAL=300
|
|
|
|
while true; do
|
|
REMAINING=$(get_remaining_time)
|
|
|
|
# Check for timeout
|
|
if [ "$REMAINING" -le 0 ]; then
|
|
log "Timeout reached. Initiating graceful shutdown..."
|
|
shutdown
|
|
fi
|
|
|
|
# Periodic status update (every 5 minutes)
|
|
CURRENT_TIME=$(date +%s)
|
|
if [ $((CURRENT_TIME - LAST_STATUS_TIME)) -ge $STATUS_INTERVAL ]; then
|
|
echo ""
|
|
echo "=============================================="
|
|
log "Status Update"
|
|
echo "Time remaining: $(format_time "$REMAINING")"
|
|
echo "OpenCode TTY: $URL_TTY"
|
|
echo "OpenChamber: $URL_CHAMBER"
|
|
echo "OpenCode Web: $URL_WEB"
|
|
echo "=============================================="
|
|
echo ""
|
|
LAST_STATUS_TIME=$CURRENT_TIME
|
|
fi
|
|
|
|
# Check OpenCode TTY
|
|
if ! check_port $TTY_PORT; then
|
|
log "OpenCode TTY not responding on port $TTY_PORT"
|
|
restart_opencode_tty
|
|
fi
|
|
|
|
# Check OpenChamber
|
|
if ! check_port $OPENCHAMBER_PORT; then
|
|
log "OpenChamber not responding on port $OPENCHAMBER_PORT"
|
|
restart_openchamber
|
|
fi
|
|
|
|
# Check OpenCode Web
|
|
if ! check_port $OPENCODE_WEB_PORT; then
|
|
log "OpenCode Web not responding on port $OPENCODE_WEB_PORT"
|
|
restart_opencode_web
|
|
fi
|
|
|
|
# Check Tunnel Process (Basic check)
|
|
if ! check_tunnels; then
|
|
log "Tunnel processes not running"
|
|
restart_tunnels
|
|
fi
|
|
|
|
# Sleep before next check
|
|
sleep 5
|
|
done
|