Skip to content

feat(dashboard): use inotify for event-driven redraws on Linux#14

Open
MuLinForest wants to merge 4 commits into
kayhaowu:mainfrom
MuLinForest:feat/inotify-dashboard
Open

feat(dashboard): use inotify for event-driven redraws on Linux#14
MuLinForest wants to merge 4 commits into
kayhaowu:mainfrom
MuLinForest:feat/inotify-dashboard

Conversation

@MuLinForest
Copy link
Copy Markdown

Closes #9

Summary

  • Replace fixed-interval polling with inotifywait when available — redraws only on session file changes, near-zero CPU when idle
  • Graceful fallback to polling if inotify-tools not installed (macOS) or if inotifywait exits unexpectedly
  • Header shows (event-driven) vs (every 2s) to reflect active mode
  • Uses _REFRESH_MODE global variable; render() needs no arguments

Test plan

  • Linux with inotify-tools: dashboard shows (event-driven), redraws on session change
  • Linux without inotify-tools: falls back to polling, shows (every 2s)
  • macOS: polling as before
  • Kill inotifywait manually: dashboard continues via polling fallback

MuLinForest and others added 2 commits March 25, 2026 19:28
Replace fixed-interval polling with inotifywait when available.
Dashboard now redraws only when session files change, reducing CPU
usage to near-zero during idle periods.

Falls back to the original 2s polling loop on macOS or when
inotify-tools is not installed. If inotifywait exits unexpectedly,
also falls back to polling rather than silently terminating.

Header shows "(event-driven)" vs "(every 2s)" to reflect active mode.

Closes kayhaowu#9

Co-Authored-By: Claude Code <claude-core@mulin.date>
read < file with 2>/dev/null does not suppress redirect errors in
dash. Check file existence first to avoid spurious error output.

Co-Authored-By: Claude Code <claude-core@mulin.date>
@MuLinForest MuLinForest force-pushed the feat/inotify-dashboard branch from ac87d80 to f824f97 Compare March 25, 2026 13:58
MuLinForest and others added 2 commits March 26, 2026 11:00
…s redraws

heartbeat.sh writes $PID.hb.dat every 2s, causing inotifywait to fire
continuously and negating the event-driven benefit. Filter to only watch
.status and .json files so redraws only happen on actual state changes.

Co-authored-by: Claude Sonnet 4.6 <claude-code@mulin.date>
inotifywait prints the event (e.g. "MODIFY 990079.json") to stdout on
each trigger, which leaked into the terminal between renders. Redirect
stdout to /dev/null since only the exit code is needed.

Co-Authored-By: Claude Sonnet 4.6 <claude-code@mulin.date>
MuLinForest added a commit to MuLinForest/claude-code-toolkit that referenced this pull request Mar 26, 2026
…session_title in single jq call

Resolve dashboard.sh conflict: add session_title to PR kayhaowu#17's consolidated
jq read, removing the redundant individual jq calls from PR kayhaowu#15.

Co-Authored-By: Claude Sonnet 4.6 <claude-code@mulin.date>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(dashboard): 以 inotify 取代固定間隔輪詢,降低 CPU 使用率

1 participant