Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(skill): honor saved cursors on watcher restart

cyh8657a9cae257
diff --git a/skills/background-watch-hook/scripts/wait_issue.py b/skills/background-watch-hook/scripts/wait_issue.py
index 6be187a01..7441ce0c4 100644
--- a/skills/background-watch-hook/scripts/wait_issue.py
+++ b/skills/background-watch-hook/scripts/wait_issue.py
@@ -217,7 +217,14 @@ def main() -> int:
if args.issue is not None:
state, requests_per_poll_count = _fetch_issue_comment_state(args.repo, args.issue, token)
else:
- state, requests_per_poll_count = _fetch_new_issue_state(args.repo, token)
+ initial_raw_issue_stop_after_id = None
+ if args.since_raw_issue_id is not None and not args.catch_up:
+ initial_raw_issue_stop_after_id = args.since_raw_issue_id
+ state, requests_per_poll_count = _fetch_new_issue_state(
+ args.repo,
+ token,
+ stop_after_id=initial_raw_issue_stop_after_id,
+ )
except urllib.error.HTTPError as err:
print(f"GitHub API error: {err.code} {err.reason}", file=sys.stderr)
return 1
diff --git a/skills/background-watch-hook/scripts/wait_pr.py b/skills/background-watch-hook/scripts/wait_pr.py
index 8954c9a10..8d72eb8ee 100755
--- a/skills/background-watch-hook/scripts/wait_pr.py
+++ b/skills/background-watch-hook/scripts/wait_pr.py
@@ -322,7 +322,14 @@ def main() -> int:
if args.pr is not None:
state, requests_per_poll_count = _fetch_state(args.repo, args.pr, token)
else:
- state, requests_per_poll_count = _fetch_new_pr_state(args.repo, token)
+ initial_pr_stop_after_id = None
+ if args.since_pr_id is not None and not args.catch_up:
+ initial_pr_stop_after_id = args.since_pr_id
+ state, requests_per_poll_count = _fetch_new_pr_state(
+ args.repo,
+ token,
+ stop_after_id=initial_pr_stop_after_id,
+ )
except urllib.error.HTTPError as err:
print(f"GitHub API error: {err.code} {err.reason}", file=sys.stderr)
return 1
diff --git a/tests/test_wait_for_github_issue_activity.py b/tests/test_wait_for_github_issue_activity.py
index 4dbe00f14..4a172a9de 100644
--- a/tests/test_wait_for_github_issue_activity.py
+++ b/tests/test_wait_for_github_issue_activity.py
@@ -193,3 +193,53 @@ def test_main_uses_raw_issue_cursor_for_new_issue_paging() -> None:
assert rc == 0
assert calls == [None, 401]
assert "issue #41" in stdout.getvalue()
+
+
+def test_main_uses_since_raw_issue_cursor_for_initial_new_issue_fetch() -> None:
+ module = _load_module()
+ calls: list[int | None] = []
+
+ def _fake_fetch_new_issue_state(repo, token, *, stop_after_id=None):
+ calls.append(stop_after_id)
+ return (
+ {
+ "issues": [
+ {
+ "id": 405,
+ "number": 41,
+ "title": "New issue",
+ "state": "open",
+ "html_url": "https://github.com/example/repo/issues/41",
+ "user": {"login": "someone"},
+ }
+ ],
+ "raw_issue_cursor": 406,
+ },
+ 1,
+ )
+
+ stdout = io.StringIO()
+ with (
+ patch.object(module, "_fetch_new_issue_state", side_effect=_fake_fetch_new_issue_state),
+ patch.object(module, "get_token", return_value="token"),
+ patch.object(module, "get_authenticated_login", return_value=None),
+ patch(
+ "sys.argv",
+ [
+ "wait_issue.py",
+ "--repo",
+ "cyhhao/vibe-remote",
+ "--new-issues",
+ "--since-issue-id",
+ "400",
+ "--since-raw-issue-id",
+ "401",
+ ],
+ ),
+ redirect_stdout(stdout),
+ ):
+ rc = module.main()
+
+ assert rc == 0
+ assert calls == [401]
+ assert "issue #41" in stdout.getvalue()
diff --git a/tests/test_wait_for_github_pr_activity.py b/tests/test_wait_for_github_pr_activity.py
index e20b5f2bd..3c1d15b14 100644
--- a/tests/test_wait_for_github_pr_activity.py
+++ b/tests/test_wait_for_github_pr_activity.py
@@ -1,6 +1,8 @@
from __future__ import annotations
+import io
import importlib.util
+from contextlib import redirect_stdout
from pathlib import Path
from unittest.mock import patch
@@ -210,3 +212,50 @@ def test_fetch_new_pr_state_stops_after_cursor() -> None:
assert state["pull_requests"][0]["id"] == 410
assert request_count == 1
+
+
+def test_main_uses_since_pr_cursor_for_initial_new_pr_fetch() -> None:
+ module = _load_module()
+ calls: list[int | None] = []
+
+ def _fake_fetch_new_pr_state(repo, token, *, stop_after_id=None):
+ calls.append(stop_after_id)
+ return (
+ {
+ "pull_requests": [
+ {
+ "id": 410,
+ "number": 158,
+ "title": "New PR",
+ "state": "open",
+ "html_url": "https://github.com/example/repo/pull/158",
+ "user": {"login": "cyhhao"},
+ }
+ ]
+ },
+ 1,
+ )
+
+ stdout = io.StringIO()
+ with (
+ patch.object(module, "_fetch_new_pr_state", side_effect=_fake_fetch_new_pr_state),
+ patch.object(module, "get_token", return_value="token"),
+ patch.object(module, "get_authenticated_login", return_value=None),
+ patch(
+ "sys.argv",
+ [
+ "wait_pr.py",
+ "--repo",
+ "cyhhao/vibe-remote",
+ "--new-prs",
+ "--since-pr-id",
+ "405",
+ ],
+ ),
+ redirect_stdout(stdout),
+ ):
+ rc = module.main()
+
+ assert rc == 0
+ assert calls == [405]
+ assert "pull_request #158" in stdout.getvalue()