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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(skill): watch pull request status transitions
cyh1aeb53599cc0
diff --git a/skills/background-watch-hook/SKILL.md b/skills/background-watch-hook/SKILL.mdindex d3ffb3c30..cba662a8f 100644--- a/skills/background-watch-hook/SKILL.md+++ b/skills/background-watch-hook/SKILL.md@@ -155,7 +155,7 @@ This separation matters: a forever watch can still use a bounded timeout for eacThis skill ships bundled GitHub waiters:- `scripts/wait_pr.py`- Waits for GitHub PR review activity, including reviews, inline review comments, PR conversation comments, and the special Codex `+1` reaction on the PR body. It can also wait for newly opened PRs in a repository.+ Waits for GitHub PR review activity, including reviews, inline review comments, PR conversation comments, PR status transitions such as `draft -> open`, `open -> merged`, or `open -> closed`, and the special Codex `+1` reaction on the PR body. It can also wait for newly opened PRs in a repository.- `scripts/wait_issue.py`Waits for GitHub issue activity, either newly opened issues in a repository or new comments on a single issue.@@ -216,6 +216,7 @@ GitHub-specific notes:- `--catch-up` reports activity that already exists at startup- without `--catch-up`, the waiter snapshots current PR activity as the baseline- PR activity also includes the special case where `chatgpt-codex-connector[bot]` leaves a `+1` reaction on the PR body instead of posting a comment+- PR activity also includes lifecycle changes on the PR itself, for example draft/ready, closed, reopened, or merged transitions- self-authored comments are ignored by default when the current authenticated GitHub user can be resolved; pass `--include-self-comments` to keep them- authentication is preferred; unauthenticated polling is slower and more fragilediff --git a/skills/background-watch-hook/scripts/wait_pr.py b/skills/background-watch-hook/scripts/wait_pr.pyindex 597f8d137..a0aae8025 100755--- a/skills/background-watch-hook/scripts/wait_pr.py+++ b/skills/background-watch-hook/scripts/wait_pr.py@@ -20,6 +20,7 @@ from _github_wait_common import ( # noqa: E402filter_new,get_authenticated_login,get_token,+ github_get,list_paginated,list_paginated_with_count,max_id,@@ -82,6 +83,43 @@ def _format_reaction(reaction: dict[str, Any]) -> str:)+def _current_pr_status(pr: dict[str, Any] | None) -> str:+ if not isinstance(pr, dict):+ return "unknown"+ if pr.get("merged_at"):+ return "merged"+ if pr.get("draft") is True:+ return "draft"+ state = str(pr.get("state") or "").lower()+ if state in {"open", "closed"}:+ return state+ return state or "unknown"+++def _describe_pr_status_change(previous_status: str, current_status: str) -> str:+ if previous_status == "draft" and current_status == "open":+ return "Pull request is ready for review."+ if previous_status == "open" and current_status == "draft":+ return "Pull request was converted to draft."+ if current_status == "merged":+ return "Pull request was merged."+ if current_status == "closed":+ return "Pull request was closed without merge."+ if current_status == "open":+ return "Pull request was reopened."+ return f"Pull request status changed from {previous_status} to {current_status}."+++def _format_pr_status_event(pr: dict[str, Any], previous_status: str, current_status: str) -> str:+ pr_number = pr.get("number")+ url = pr.get("html_url") or ""+ return (+ f"- pr_status #{pr_number} {previous_status} -> {current_status}\n"+ f" {_describe_pr_status_change(previous_status, current_status)}\n"+ f" {url}"+ )++def _format_pull_request(pr: dict[str, Any]) -> str:pr_number = pr.get("number")author = ((pr.get("user") or {}).get("login")) or "unknown"@@ -93,6 +131,10 @@ def _format_pull_request(pr: dict[str, Any]) -> str:def _fetch_state(repo: str, pr_number: int, token: str | None) -> tuple[dict[str, list[dict[str, Any]]], int]:encoded_repo = urllib.parse.quote(repo, safe="/")+ pull_request = github_get(+ f"https://api.github.com/repos/{encoded_repo}/pulls/{pr_number}",+ token,+ )reviews, review_requests = list_paginated_with_count(f"https://api.github.com/repos/{encoded_repo}/pulls/{pr_number}/reviews",token,@@ -111,12 +153,13 @@ def _fetch_state(repo: str, pr_number: int, token: str | None) -> tuple[dict[str)return ({+ "pull_request": pull_request,"reviews": reviews,"review_comments": review_comments,"issue_comments": issue_comments,"reactions": reactions,},- review_requests + review_comment_requests + issue_comment_requests + reaction_requests,+ 1 + review_requests + review_comment_requests + issue_comment_requests + reaction_requests,)@@ -146,10 +189,12 @@ def _render_activity(review_comment_cursor: int,issue_comment_cursor: int,reaction_cursor: int,+ pr_status: str,event_limit: int,viewer_login: str | None = None,ignore_self_comments: bool = True,-) -> tuple[str | None, int, int, int, int]:+) -> tuple[str | None, int, int, int, int, str]:+ current_pr_status = _current_pr_status(state.get("pull_request"))new_reviews = filter_new(state["reviews"], review_cursor)new_review_comments = filter_new(state["review_comments"], review_comment_cursor)new_issue_comments = filter_new(state["issue_comments"], issue_comment_cursor)@@ -168,16 +213,20 @@ def _render_activity(for reaction in filter_new(state["reactions"], reaction_cursor)if _is_codex_pass_reaction(reaction)]+ has_pr_status_event = current_pr_status != pr_status- if not (new_reviews or new_review_comments or new_issue_comments or new_reactions):- return None, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor+ if not (new_reviews or new_review_comments or new_issue_comments or new_reactions or has_pr_status_event):+ return None, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_statusnext_review_cursor = max(review_cursor, max_id(new_reviews))next_review_comment_cursor = max(review_comment_cursor, max_id(new_review_comments))next_issue_comment_cursor = max(issue_comment_cursor, max_id(new_issue_comments))next_reaction_cursor = max(reaction_cursor, max_id(state["reactions"]))+ next_pr_status = current_pr_statusrendered_events: list[str] = []+ if has_pr_status_event and isinstance(state.get("pull_request"), dict):+ rendered_events.append(_format_pr_status_event(state["pull_request"], pr_status, current_pr_status))rendered_events.extend(_format_review(review) for review in new_reviews)rendered_events.extend(_format_review_comment(comment) for comment in visible_review_comments)rendered_events.extend(_format_issue_comment(comment) for comment in visible_issue_comments)@@ -190,6 +239,7 @@ def _render_activity(next_review_comment_cursor,next_issue_comment_cursor,next_reaction_cursor,+ next_pr_status,)lines = [f"GitHub PR activity detected for {repo}#{pr_number}"]@@ -208,6 +258,7 @@ def _render_activity(next_review_comment_cursor,next_issue_comment_cursor,next_reaction_cursor,+ next_pr_status,)@@ -244,6 +295,7 @@ def _write_cursor_output(review_comment_cursor: int,issue_comment_cursor: int,reaction_cursor: int,+ pr_status: str,) -> None:if not path:return@@ -253,6 +305,7 @@ def _write_cursor_output("review_comment_cursor": review_comment_cursor,"issue_comment_cursor": issue_comment_cursor,"reaction_cursor": reaction_cursor,+ "pr_status": pr_status,}with open(path, "w", encoding="utf-8") as handle:json.dump(payload, handle)@@ -283,6 +336,7 @@ def main() -> int:parser.add_argument("--since-review-comment-id", type=int, default=None, help="Existing review comment cursor")parser.add_argument("--since-issue-comment-id", type=int, default=None, help="Existing PR conversation comment cursor")parser.add_argument("--since-reaction-id", type=int, default=None, help="Existing PR-body reaction cursor")+ parser.add_argument("--since-pr-status", help=argparse.SUPPRESS)parser.add_argument("--since-pr-id", type=int, default=None, help="Existing repository pull request cursor")parser.add_argument("--cursor-output", help=argparse.SUPPRESS)parser.add_argument("--event-limit", type=int, default=8, help="Maximum number of new events to include in stdout")@@ -386,10 +440,11 @@ def main() -> int:if args.since_reaction_id is not Noneelse (0 if args.catch_up else max_id(state["reactions"])))+ pr_status = args.since_pr_status or _current_pr_status(state.get("pull_request"))print((- "Watching GitHub PR %s#%s from cursors: review=%s review_comment=%s issue_comment=%s reaction=%s catch_up=%s"+ "Watching GitHub PR %s#%s from cursors: review=%s review_comment=%s issue_comment=%s reaction=%s pr_status=%s catch_up=%s"% (args.repo,args.pr,@@ -397,13 +452,14 @@ def main() -> int:review_comment_cursor,issue_comment_cursor,reaction_cursor,+ pr_status,args.catch_up,)),file=sys.stderr,)- initial_output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor = _render_activity(+ initial_output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = _render_activity(repo=args.repo,pr_number=args.pr,state=state,@@ -411,6 +467,7 @@ def main() -> int:review_comment_cursor=review_comment_cursor,issue_comment_cursor=issue_comment_cursor,reaction_cursor=reaction_cursor,+ pr_status=pr_status,event_limit=args.event_limit,viewer_login=viewer_login,ignore_self_comments=not args.include_self_comments,@@ -422,6 +479,7 @@ def main() -> int:review_comment_cursor=review_comment_cursor,issue_comment_cursor=issue_comment_cursor,reaction_cursor=reaction_cursor,+ pr_status=pr_status,)print(initial_output)return 0@@ -503,7 +561,7 @@ def main() -> int:effective_interval = target_intervalif args.pr is not None:- output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor = _render_activity(+ output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = _render_activity(repo=args.repo,pr_number=args.pr,state=state,@@ -511,6 +569,7 @@ def main() -> int:review_comment_cursor=review_comment_cursor,issue_comment_cursor=issue_comment_cursor,reaction_cursor=reaction_cursor,+ pr_status=pr_status,event_limit=args.event_limit,viewer_login=viewer_login,ignore_self_comments=not args.include_self_comments,@@ -524,6 +583,7 @@ def main() -> int:review_comment_cursor=review_comment_cursor,issue_comment_cursor=issue_comment_cursor,reaction_cursor=reaction_cursor,+ pr_status=pr_status,)else:output, pr_cursor = _render_new_pull_requests(diff --git a/tests/test_wait_for_github_pr_activity.py b/tests/test_wait_for_github_pr_activity.pyindex 75433cc96..270f89a10 100644--- a/tests/test_wait_for_github_pr_activity.py+++ b/tests/test_wait_for_github_pr_activity.py@@ -25,6 +25,7 @@ def _load_module():def test_render_activity_includes_codex_pr_body_reaction() -> None:module = _load_module()state = {+ "pull_request": {"number": 153, "state": "open", "draft": False},"reviews": [],"review_comments": [],"issue_comments": [],@@ -38,7 +39,7 @@ def test_render_activity_includes_codex_pr_body_reaction() -> None:],}- output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor = module._render_activity(+ output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = module._render_activity(repo="cyhhao/vibe-remote",pr_number=153,state=state,@@ -46,6 +47,7 @@ def test_render_activity_includes_codex_pr_body_reaction() -> None:review_comment_cursor=0,issue_comment_cursor=0,reaction_cursor=0,+ pr_status="open",event_limit=8,)@@ -56,11 +58,13 @@ def test_render_activity_includes_codex_pr_body_reaction() -> None:assert review_cursor == 0assert review_comment_cursor == 0assert issue_comment_cursor == 0+ assert pr_status == "open"def test_render_activity_ignores_non_codex_or_non_plus_one_reactions() -> None:module = _load_module()state = {+ "pull_request": {"number": 153, "state": "open", "draft": False},"reviews": [],"review_comments": [],"issue_comments": [],@@ -88,6 +92,7 @@ def test_render_activity_ignores_non_codex_or_non_plus_one_reactions() -> None:review_comment_cursor=0,issue_comment_cursor=0,reaction_cursor=0,+ pr_status="open",event_limit=8,)@@ -97,6 +102,7 @@ def test_render_activity_ignores_non_codex_or_non_plus_one_reactions() -> None:def test_render_activity_ignores_self_authored_issue_comment_but_advances_cursor() -> None:module = _load_module()state = {+ "pull_request": {"number": 153, "state": "open", "draft": False},"reviews": [],"review_comments": [],"issue_comments": [@@ -110,7 +116,7 @@ def test_render_activity_ignores_self_authored_issue_comment_but_advances_cursor"reactions": [],}- output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor = module._render_activity(+ output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = module._render_activity(repo="cyhhao/vibe-remote",pr_number=153,state=state,@@ -118,6 +124,7 @@ def test_render_activity_ignores_self_authored_issue_comment_but_advances_cursorreview_comment_cursor=0,issue_comment_cursor=0,reaction_cursor=0,+ pr_status="open",event_limit=8,viewer_login="someone",)@@ -127,11 +134,13 @@ def test_render_activity_ignores_self_authored_issue_comment_but_advances_cursorassert review_comment_cursor == 0assert issue_comment_cursor == 126assert reaction_cursor == 0+ assert pr_status == "open"def test_render_activity_includes_self_authored_comment_when_disabled() -> None:module = _load_module()state = {+ "pull_request": {"number": 153, "state": "open", "draft": False},"reviews": [],"review_comments": [],"issue_comments": [@@ -153,6 +162,7 @@ def test_render_activity_includes_self_authored_comment_when_disabled() -> None:review_comment_cursor=0,issue_comment_cursor=0,reaction_cursor=0,+ pr_status="open",event_limit=8,viewer_login="someone",ignore_self_comments=False,@@ -162,6 +172,178 @@ def test_render_activity_includes_self_authored_comment_when_disabled() -> None:assert "issue_comment #127" in output+def test_render_activity_includes_pr_status_change() -> None:+ module = _load_module()+ state = {+ "pull_request": {+ "number": 153,+ "state": "closed",+ "draft": False,+ "merged_at": "2026-04-03T12:45:56Z",+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ }++ output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = module._render_activity(+ repo="cyhhao/vibe-remote",+ pr_number=153,+ state=state,+ review_cursor=0,+ review_comment_cursor=0,+ issue_comment_cursor=0,+ reaction_cursor=0,+ pr_status="open",+ event_limit=8,+ )++ assert output is not None+ assert "pr_status #153 open -> merged" in output+ assert "Pull request was merged." in output+ assert review_cursor == 0+ assert review_comment_cursor == 0+ assert issue_comment_cursor == 0+ assert reaction_cursor == 0+ assert pr_status == "merged"+++def test_render_activity_reports_open_to_draft_transition() -> None:+ module = _load_module()+ state = {+ "pull_request": {+ "number": 153,+ "state": "open",+ "draft": True,+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ }++ output, *_rest, pr_status = module._render_activity(+ repo="cyhhao/vibe-remote",+ pr_number=153,+ state=state,+ review_cursor=0,+ review_comment_cursor=0,+ issue_comment_cursor=0,+ reaction_cursor=0,+ pr_status="open",+ event_limit=8,+ )++ assert output is not None+ assert "pr_status #153 open -> draft" in output+ assert "Pull request was converted to draft." in output+ assert pr_status == "draft"+++def test_render_activity_reports_draft_to_open_transition() -> None:+ module = _load_module()+ state = {+ "pull_request": {+ "number": 153,+ "state": "open",+ "draft": False,+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ }++ output, *_rest, pr_status = module._render_activity(+ repo="cyhhao/vibe-remote",+ pr_number=153,+ state=state,+ review_cursor=0,+ review_comment_cursor=0,+ issue_comment_cursor=0,+ reaction_cursor=0,+ pr_status="draft",+ event_limit=8,+ )++ assert output is not None+ assert "pr_status #153 draft -> open" in output+ assert "Pull request is ready for review." in output+ assert pr_status == "open"+++def test_render_activity_reports_closed_to_open_transition() -> None:+ module = _load_module()+ state = {+ "pull_request": {+ "number": 153,+ "state": "open",+ "draft": False,+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ }++ output, *_rest, pr_status = module._render_activity(+ repo="cyhhao/vibe-remote",+ pr_number=153,+ state=state,+ review_cursor=0,+ review_comment_cursor=0,+ issue_comment_cursor=0,+ reaction_cursor=0,+ pr_status="closed",+ event_limit=8,+ )++ assert output is not None+ assert "pr_status #153 closed -> open" in output+ assert "Pull request was reopened." in output+ assert pr_status == "open"+++def test_render_activity_skips_unchanged_pr_status() -> None:+ module = _load_module()+ state = {+ "pull_request": {+ "number": 153,+ "state": "open",+ "draft": False,+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ }++ output, review_cursor, review_comment_cursor, issue_comment_cursor, reaction_cursor, pr_status = module._render_activity(+ repo="cyhhao/vibe-remote",+ pr_number=153,+ state=state,+ review_cursor=0,+ review_comment_cursor=0,+ issue_comment_cursor=0,+ reaction_cursor=0,+ pr_status="open",+ event_limit=8,+ )++ assert output is None+ assert review_cursor == 0+ assert review_comment_cursor == 0+ assert issue_comment_cursor == 0+ assert reaction_cursor == 0+ assert pr_status == "open"++def test_render_new_pull_requests_includes_new_prs() -> None:module = _load_module()state = {@@ -302,6 +484,62 @@ def test_main_bootstraps_new_pr_watch_from_first_page_only() -> None:assert "pull_request #158" in stdout.getvalue()+def test_main_detects_pr_status_change_during_polling() -> None:+ module = _load_module()+ fetch_calls = 0++ def _fake_fetch_state(repo, pr_number, token):+ nonlocal fetch_calls+ fetch_calls += 1+ if fetch_calls == 1:+ return (+ {+ "pull_request": {+ "number": 153,+ "state": "open",+ "draft": False,+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ },+ 1,+ )+ return (+ {+ "pull_request": {+ "number": 153,+ "state": "closed",+ "draft": False,+ "merged_at": "2026-04-03T12:45:56Z",+ "html_url": "https://github.com/example/repo/pull/153",+ },+ "reviews": [],+ "review_comments": [],+ "issue_comments": [],+ "reactions": [],+ },+ 1,+ )++ stdout = io.StringIO()+ with (+ patch.object(module, "_fetch_state", side_effect=_fake_fetch_state),+ patch.object(module, "get_token", return_value="token"),+ patch.object(module, "get_authenticated_login", return_value=None),+ patch.object(module.time, "sleep", return_value=None),+ patch("sys.argv", ["wait_pr.py", "--repo", "cyhhao/vibe-remote", "--pr", "153", "--interval", "1"]),+ redirect_stdout(stdout),+ ):+ rc = module.main()++ assert rc == 0+ assert fetch_calls == 2+ assert "pr_status #153 open -> merged" in stdout.getvalue()++def test_main_reduces_unauthenticated_new_pr_interval_after_bootstrap() -> None:module = _load_module()fetch_calls: list[int | None] = []