Skip to content

fix: priority-aware status writes, dedup, and missing status mappings#35

Merged
brianruggieri merged 5 commits into
mainfrom
fix/status-write-improvements
Mar 16, 2026
Merged

fix: priority-aware status writes, dedup, and missing status mappings#35
brianruggieri merged 5 commits into
mainfrom
fix/status-write-improvements

Conversation

@brianruggieri

Copy link
Copy Markdown
Owner

Summary

  • Priority-aware writes: hook_runner.sh now checks the current status file priority before writing. High-priority statuses like ⏸️ Awaiting approval (p88) are no longer overwritten by concurrent lower-priority pre-tool hooks like 🖥️ Running (p55). Completion events (✅, 💾, 🏁, ❌, 🐛) bypass the priority check and always win immediately.
  • Write deduplication: Skips redundant file writes when the status hasn't changed (~50% I/O reduction during tool bursts). Logs status_dedup debug events for observability.
  • Missing status mappings: Added 🔧 Working and 📤 Sending to the monitor's known-status validation. No more unknown_status debug log noise.

What changed

File Change
lib/hook_runner.sh Added _status_priority(), _is_completion_event(), _priority_write() functions; replaced 4 unconditional atomic_write calls; added dedup checks
lib/monitor.sh Added Working, Sending to known-status case; added sync comment
tests/test-suite.sh 22 new tests (2 status mapping + 14 priority + 6 dedup)
README.md Updated status priority table

Test plan

  • All 187 tests pass (165 existing + 22 new)
  • ShellCheck clean on all modified files
  • Priority tests verify: blocked writes, completion bypass, reset paths, equal-priority transitions
  • Dedup tests verify: same-status skip, different-status write, empty-file dedup, stale clearing
  • Existing test compatibility verified (no regressions)

Adds *Working* and *Sending* to the known-status case block so the
monitor no longer logs unknown_status debug events when the Skill tool
(🔧 Working) or SendMessage (📤 Sending) fire. Updates priority comment
block, README status table, and adds test assertions for both statuses.
Copilot AI review requested due to automatic review settings March 16, 2026 17:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves how ccp writes and displays pane status by preventing low-priority concurrent hook updates from overwriting higher-priority statuses, reducing redundant status-file I/O via deduplication, and expanding the monitor’s known-status set to include new statuses.

Changes:

  • Add priority-aware status writes (with completion-event bypass) and status write deduplication in lib/hook_runner.sh.
  • Extend monitor known-status validation / priority mapping to include 🔧 Working and 📤 Sending in lib/monitor.sh.
  • Add new regression tests for priority behavior, dedup behavior, and new status mappings; update README status reference.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
lib/hook_runner.sh Introduces _status_priority, _is_completion_event, and _priority_write to arbitrate concurrent status writes and deduplicate unchanged writes.
lib/monitor.sh Adds Working/Sending to known-status validation and documents the need to keep priority tables in sync.
tests/test-suite.sh Adds/updates tests for status priority mapping, priority-aware blocking/bypass behavior, and deduplication.
README.md Updates the status reference table to include Sending, Working, and Monitoring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/hook_runner.sh Outdated
Comment on lines +122 to +124
*Editing*|*Working*) echo 65 ;;
*"Tests passed"*|*Committed*|*Completed*|*"Subagent finished"*) echo 60 ;;
*Reading*|*Browsing*|*Running*|*Sending*) echo 55 ;;
Comment thread lib/hook_runner.sh Outdated
*Docker*|*Thinking*|*Delegating*) echo 70 ;;
*Editing*|*Working*) echo 65 ;;
*"Tests passed"*|*Committed*|*Completed*|*"Subagent finished"*) echo 60 ;;
*Reading*|*Browsing*|*Running*|*Sending*) echo 55 ;;
Comment thread README.md Outdated
| 🔧 | Working | Skill tool or unclassified tool | 55 |
| 📡 | Monitoring | Background agents running while Claude is idle | 20 |

Higher priority always wins. The one exception: completion events (✅, 💾, 🏁) override any active status immediately, regardless of priority.
Comment thread tests/test-suite.sh
Comment on lines +1137 to +1141
printf '🤖 Delegating' > "${TMP_STATUS}"
result=$(echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' \
| CCP_STATUS_FILE="${TMP_STATUS}" CCP_CONTEXT_FILE="${TMP_CONTEXT}" \
bash "${LIB_DIR}/hook_runner.sh" pre-tool && cat "${TMP_STATUS}" 2>/dev/null || true)
assert_equals "priority: 🖥️ Running blocked by 🤖 Delegating" "🤖 Delegating" "${result}"
- Align Working priority to 55 (matching monitor.sh sync contract)
- Add lifecycle statuses at priority 52 to _status_priority()
- Update README completion events list to include ❌ and 🐛
- Add test: Working (p55) blocked by Editing (p65)
@brianruggieri
brianruggieri merged commit 6f0a4ee into main Mar 16, 2026
@brianruggieri
brianruggieri deleted the fix/status-write-improvements branch March 16, 2026 18:34
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.

2 participants