Skip to content

fix(auto-updater): add conditional timestamp update and reduce check interval - #179

Merged
baleen37 merged 1 commit into
mainfrom
fix/auto-updater-timestamp-conditional
Jan 26, 2026
Merged

fix(auto-updater): add conditional timestamp update and reduce check interval#179
baleen37 merged 1 commit into
mainfrom
fix/auto-updater-timestamp-conditional

Conversation

@baleen37

@baleen37 baleen37 commented Jan 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • ✅ Reduce CHECK_INTERVAL from 6 hours to 1 hour for faster update detection
  • ✅ Add conditional timestamp update: only update when success_count > 0
  • ✅ Fix critical bug where timestamp was updated even when all plugins failed
  • ✅ Add comprehensive BATS tests for timestamp update logic and interval verification
  • ✅ Add logging for timestamp update events (updated/skipped)

Problem

Critical Bug: The timestamp was unconditionally updated at the end of update-all-plugins.sh, even when all plugins failed to install/update. This prevented retry attempts for 6 hours (now 1 hour), blocking recovery from transient network or plugin installation failures.

Before:

# Always updates timestamp, regardless of success/failure
date +%s > "$TIMESTAMP_FILE"

Impact:

  • Network failures → timestamp updated → no retry for 6 hours
  • All plugins fail → timestamp updated → no retry for 6 hours
  • User must manually intervene to retry

Solution

Conditional Timestamp Update:

# Only update timestamp if at least one plugin succeeded
if [[ $success_count -gt 0 ]]; then
    date +%s > "$TIMESTAMP_FILE"
    log_info "Updated last-check timestamp"
else
    log_warning "Skipping timestamp update (no successful updates)"
fi

Check Interval Reduction:

  • Changed from 6 hours (21600s) to 1 hour (3600s)
  • Faster update detection while preventing excessive API calls

Testing

New Test File: plugins/auto-updater/tests/timestamp-update.bats

  • ✅ 8 new BATS tests covering:
    • 1-hour interval boundary conditions (3599s, 3600s, 3601s)
    • Conditional timestamp update logic verification
    • First-run scenario (missing timestamp file)
    • Logging verification

Test Results:

  • ✅ All 8 new tests pass
  • ✅ All 101 existing tests pass
  • ✅ No regressions detected

Orchestration Workflow

This fix was validated through a complete bugfix workflow:

  1. Explorer Agent: Identified root cause and edge cases
  2. TDD-Guide Agent: Designed comprehensive test strategy
  3. Code-Reviewer Agent: Verified CLAUDE.md compliance and production readiness

Final Verdict: SHIP ✅ (after implementing recommended fixes)

Files Modified

  • plugins/auto-updater/hooks/auto-update-hook.sh (1 line)
  • plugins/auto-updater/scripts/update-all-plugins.sh (12 lines added)
  • plugins/auto-updater/tests/timestamp-update.bats (118 lines, new file)

Benefits

  • Faster Recovery: Failed updates can retry in 1 hour instead of 6
  • Reliable Updates: Successful partial updates still update timestamp
  • Better Observability: Logs show when timestamp is updated/skipped
  • Regression Prevention: Tests prevent future timestamp logic bugs

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced auto-update check frequency to enable more timely plugin updates
    • Improved update record tracking to only persist timestamps when plugin installations complete successfully, preventing false or stale records
  • Tests

    • Added comprehensive test suite validating auto-updater intervals and conditional timestamp behavior

✏️ Tip: You can customize this high-level summary in your review settings.

…interval

- Reduce CHECK_INTERVAL from 6 hours to 1 hour for faster update detection
- Add conditional timestamp update: only update when success_count > 0
- Fix critical bug where timestamp was updated even when all plugins failed
- Add comprehensive BATS tests for timestamp update logic and interval verification
- Add logging for timestamp update events (updated/skipped)

This prevents failed updates from blocking retry attempts for 1 hour, allowing
faster recovery from transient network or plugin installation failures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@baleen37
baleen37 enabled auto-merge (squash) January 26, 2026 05:37
@coderabbitai

coderabbitai Bot commented Jan 26, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes modify the auto-updater behavior by reducing the execution interval from 6 hours to 1 hour and making timestamp updates conditional—only updating when plugins are successfully installed, rather than updating unconditionally on every run.

Changes

Cohort / File(s) Summary
Auto-updater configuration & logic
plugins/auto-updater/hooks/auto-update-hook.sh, plugins/auto-updater/scripts/update-all-plugins.sh
Reduced CHECK_INTERVAL from 21600 to 3600 seconds (6 hours to 1 hour). Made last-check timestamp update conditional: updates only when at least one plugin was successfully installed (success_count > 0), otherwise logs warning and skips timestamp touch.
Auto-updater test suite
plugins/auto-updater/tests/timestamp-update.bats
Added 118 lines of new test coverage validating: interval constant (3600 seconds), conditional execution based on last-check timestamp (no run at 3599s, run at 3600s and 3601s, run on missing file), timestamp update logic in update-all-plugins.sh, and appropriate logging for update vs. skip scenarios. Includes temporary test environment setup with mock update-checker.sh.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Poem

🐰 Faster hops, just one hour waits,
Timestamps tick on winning gates,
Only when plugins thrive and shine,
Updates dance right on time! ⏱️✨

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@baleen37
baleen37 merged commit af0d17d into main Jan 26, 2026
1 of 2 checks passed
@baleen37
baleen37 deleted the fix/auto-updater-timestamp-conditional branch January 26, 2026 05:38
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.

1 participant