Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions statusline/dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ render() {
ts=$(date '+%Y-%m-%d %H:%M:%S')
now=$(date +%s)

printf '%b' "${C_TITLE}Claude Code Dashboard${R} ${ts} ${DIM}(every ${INTERVAL}s)${R}"
if [ "${_REFRESH_MODE:-polling}" = "inotify" ]; then
printf '%b' "${C_TITLE}Claude Code Dashboard${R} ${ts} ${DIM}(event-driven)${R}"
else
printf '%b' "${C_TITLE}Claude Code Dashboard${R} ${ts} ${DIM}(every ${INTERVAL}s)${R}"
fi
printf '\n\n'

# Column headers
Expand Down Expand Up @@ -107,7 +111,7 @@ render() {

# Determine display status: prefer event-driven .status file
disp_status="" _status_epoch=""
read -r disp_status _status_epoch < "$SESSIONS_DIR/${pid}.status" 2>/dev/null || disp_status=""
[ -f "$SESSIONS_DIR/${pid}.status" ] && read -r disp_status _status_epoch < "$SESSIONS_DIR/${pid}.status"
# Fallback: JSON field, then file age
if [ -z "$disp_status" ]; then
age=$(( now - epoch ))
Expand Down Expand Up @@ -183,6 +187,17 @@ render() {
mkdir -p "$SESSIONS_DIR"
trap 'printf "\n"; exit 0' INT TERM

if command -v inotifywait > /dev/null 2>&1; then
_REFRESH_MODE="inotify"
render
while inotifywait -q -e modify,create,delete --include '\.(status|json)$' "$SESSIONS_DIR" > /dev/null 2>/dev/null; do
render
done
# inotifywait exited unexpectedly — fall back to polling
_REFRESH_MODE="polling"
fi

# Polling loop (primary on macOS, fallback if inotifywait fails)
while true; do
render
sleep "$INTERVAL"
Expand Down