feat: update plugin from latest release#4
Conversation
📝 WalkthroughWalkthroughAgent Watch plugin now supports release-asset-based self-updates instead of requiring local git checkouts. A new ChangesRelease Asset Self-Update
Sequence DiagramsequenceDiagram
participant User
participant xbar
participant update_plugin_from_release
participant GitHub
participant Filesystem
User->>xbar: Click "Update to latest release"
xbar->>update_plugin_from_release: Call update-release action
update_plugin_from_release->>GitHub: Download RELEASE_ASSET_URL
GitHub-->>update_plugin_from_release: agent-watch.30s.sh asset
update_plugin_from_release->>update_plugin_from_release: Validate shebang and PLUGIN_VERSION
update_plugin_from_release->>Filesystem: chmod +x temp file
update_plugin_from_release->>Filesystem: Atomically replace PLUGIN_PATH
Filesystem-->>update_plugin_from_release: Success
update_plugin_from_release-->>xbar: Update complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bin/agent-watch.30s.sh`:
- Around line 248-255: The updater currently allows overwriting files even when
the plugin is a git checkout; in update_plugin_from_release() add a guard that
detects repository-managed installs (e.g., presence of a .git directory or using
git rev-parse --is-inside-work-tree) and aborts with a clear message instead of
proceeding, and combine that check with the existing writability checks for
PLUGIN_PATH and PLUGIN_DIR so the updater only runs for copied installs; also
apply the same guard to the code path that displays the action (the lines
referenced around where the update action is shown) so the update option is not
presented for checkout-managed plugins.
- Around line 263-266: The download currently uses "$CURL -fsSL
$RELEASE_ASSET_URL -o $tmp" with no timeout or retry; change the invocation that
uses the CURL variable to include a per-request timeout and a bounded retry
policy (e.g., add curl flags like --max-time, --connect-timeout, --retry and
--retry-delay/--retry-connrefused) or wrap the call in a timeout utility, and
ensure failures still rm -f "$tmp" and return 1; update the invocation that
references RELEASE_ASSET_URL and tmp so the script fails quickly on hanging
networks and retries a few times before giving up.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f8cf849a-27b5-479c-9e43-a2ca96a97391
📒 Files selected for processing (2)
README.mdbin/agent-watch.30s.sh
1188bf5 to
8693101
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
bin/agent-watch.30s.sh (1)
958-961:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse the same checkout predicate when rendering the update action.
print_plugin_rows()hides “Update to latest release” whenever any repo root is found, butupdate_plugin_from_release()only blocks whenPLUGIN_PATHis actually inside that repo. IfAGENTWATCH_REPO_DIRis set just for metadata, copied-plugin installs lose the update action.Suggested fix
print_plugin_rows() { local root git_summary version_label root="$(plugin_repo_root)" version_label="$(plugin_version_label "$root")" emit "--Version: ${version_label} | font=Menlo" emit "--Config: $(shorten_path "$CONFIG_FILE") | font=Menlo" emit "--Script: $(shorten_path "$PLUGIN_PATH") | font=Menlo" if [[ -n "$root" ]]; then git_summary="$(plugin_git_summary "$root")" emit "--Repo: $(shorten_path "$root") | font=Menlo" emit "--Git: ${git_summary:-unknown} | font=Menlo" + fi + if [[ -n "$root" && "$PLUGIN_PATH" == "$root"/* ]]; then emit "----Use git commands for development updates | color=gray" else emit "--Update to latest release | bash=$PLUGIN_PATH param1=update-release terminal=true refresh=true" fi emit "--Open config file | bash=$PLUGIN_PATH param1=open param2=agent-watch-config terminal=false refresh=true"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bin/agent-watch.30s.sh` around lines 958 - 961, print_plugin_rows() currently hides the "Update to latest release" action whenever any repo root is present, but update_plugin_from_release() only blocks when PLUGIN_PATH is inside that repo; make the rendering predicate identical to the runtime check so copied-plugin installs still show the update action. Update the conditional in print_plugin_rows() to call or replicate the same check used by update_plugin_from_release() (use PLUGIN_PATH and AGENTWATCH_REPO_DIR to determine "inside repo" rather than "any repo root found") so the button is rendered only when the update handler would actually block.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@bin/agent-watch.30s.sh`:
- Around line 958-961: print_plugin_rows() currently hides the "Update to latest
release" action whenever any repo root is present, but
update_plugin_from_release() only blocks when PLUGIN_PATH is inside that repo;
make the rendering predicate identical to the runtime check so copied-plugin
installs still show the update action. Update the conditional in
print_plugin_rows() to call or replicate the same check used by
update_plugin_from_release() (use PLUGIN_PATH and AGENTWATCH_REPO_DIR to
determine "inside repo" rather than "any repo root found") so the button is
rendered only when the update handler would actually block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fccf7d36-eb72-417e-8d40-6c6fc917f66d
📒 Files selected for processing (2)
README.mdbin/agent-watch.30s.sh
✅ Files skipped from review due to trivial changes (1)
- README.md
Summary
Validation
Summary by CodeRabbit
New Features
Documentation