mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 15:03:16 +00:00
* feat: activate PR babysitting UI toggles for autofix and trigger mode Remove the "coming soon" gating on the Autofix Mode, Autofix Severity Threshold, and Trigger Mode controls in the review settings page so admins can enable CI auto-fix and review-comment resolution on PRs that Open SWE opens. The backend (ci_autofix.py, webapp.py webhook routing) was already fully wired — only the UI was disabled. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * feat: simplify autofix to on/off toggle, remove severity threshold Replace the four-level AutofixMode (off/low/medium/high) and the autofix_severity_threshold setting with a single boolean autofix_enabled toggle. The severity threshold was leftover from the reviewer finding-severity model and does not apply to CI autofix; the agent should fix any failing CI and resolve any comments on PRs it opens. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * feat: move autofix toggle to per-user profile, remove team-level setting The autofix toggle is now per-user (auto_fix_ci in the user profile) instead of team-level (admin-only). This uses the existing auto_fix_ci field that was already in ProfileUpdate but never wired up. Changes: - ci_autofix.py: check per-user auto_fix_ci profile flag after resolving the agent thread's github_login, instead of checking team-level autofix_enabled before knowing the PR - webapp.py: removed early is_autofix_enabled() webhook gates; the per-user check now happens in ci_autofix.py once the thread is found - team_settings.py: removed autofix_enabled field, is_autofix_enabled() - cloud-agents.tsx: enabled the auto_fix_ci toggle (was comingSoon) - review.tsx: removed the admin-level autofix switch - Updated tests and AGENTS.md The agent graph (not the reviewer) is what gets dispatched - this was already correct in ci_autofix.py line 223: client.runs.create( thread_id, "agent", ...). Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * feat: batch PR babysitting events Remove the leftover trigger-mode gate from PR babysitting and batch new CI/review events while an agent run is already active so the running agent can handle the latest PR state before finishing. Also moves review-feedback permission checks behind the per-user opt-out and applies the auto-fix profile gate to merge-conflict babysitting. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * fix: consume batched babysitting events Teach the agent queue middleware to turn pending PR babysitting metadata into an injected instruction for the active run, so batched CI/review events are not dropped while still avoiding duplicate run creation. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * fix: address review findings in PR babysitting batching - Route batched events through the LangGraph store (read in-process by the message-queue middleware) instead of a per-model-call threads.get on every agent thread. - Only record an attempt / mark the head SHA handled on a real dispatch, not on a batch, so an event isn't permanently dropped if the in-flight run ends before consuming it. - Carry the reviewer's comment through batched review feedback instead of replacing it with a generic re-check nudge. --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Per-PR auto-fix opt-out, stored in the LangGraph Store.
|
|
|
|
Auto-fix is gated by the per-user ``auto_fix_ci`` profile flag.
|
|
On top of that, a single PR can be silenced with ``@open-swe autofix off`` (and
|
|
re-enabled with ``@open-swe autofix on``), mirroring Cursor's
|
|
``@cursor autofix off`` per-PR control. The toggle lives here rather than on the
|
|
agent thread so a disable command is honored even before any fix run exists.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from datetime import UTC, datetime
|
|
|
|
from langgraph_sdk import get_client
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
AUTOFIX_PR_STATE_NAMESPACE: list[str] = ["autofix_pr_state"]
|
|
|
|
|
|
def _client():
|
|
return get_client()
|
|
|
|
|
|
def _key(owner: str, repo: str, pr_number: int) -> str:
|
|
return f"{owner.lower()}/{repo.lower()}#{pr_number}"
|
|
|
|
|
|
async def is_pr_autofix_disabled(owner: str, repo: str, pr_number: int) -> bool:
|
|
"""Return whether auto-fix has been turned off for a specific PR."""
|
|
try:
|
|
item = await _client().store.get_item(
|
|
AUTOFIX_PR_STATE_NAMESPACE, _key(owner, repo, pr_number)
|
|
)
|
|
except Exception as e: # noqa: BLE001
|
|
logger.debug("autofix PR state lookup failed: %s", e)
|
|
return False
|
|
if item is None:
|
|
return False
|
|
value = item.get("value") if isinstance(item, dict) else getattr(item, "value", None)
|
|
return bool(value.get("disabled")) if isinstance(value, dict) else False
|
|
|
|
|
|
async def set_pr_autofix_disabled(owner: str, repo: str, pr_number: int, disabled: bool) -> None:
|
|
"""Persist the per-PR auto-fix opt-out flag."""
|
|
await _client().store.put_item(
|
|
AUTOFIX_PR_STATE_NAMESPACE,
|
|
_key(owner, repo, pr_number),
|
|
{"disabled": disabled, "updated_at": datetime.now(UTC).isoformat()},
|
|
)
|