mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 13:13:14 +00:00
* feat: chat with your PR on the review page
Add a sandbox-less `chat` graph that answers questions about a single PR
from its diff, the published review findings, and read-only GitHub access.
- agent/chat.py: deepagents graph, no sandbox (default StateBackend, file
mutation + execute tools excluded). PR context is seeded as virtual files
under /pr/; a repo-scoped App token is resolved in-graph.
- tools: read_repo_file, search_repo_code, list_review_findings.
- dashboard/review_chat_api.py + routes: per-user chat thread, LangGraph
stream/commands/state/history proxy pinned to the chat assistant, seeds
diff/findings/overview on first run. Gated by repo access.
- UI: Chat tab wired to a chat-scoped StreamProvider (replaces Coming Soon).
* feat: admin setting for review-chat default model
Add a 'Open SWE Review Chat' default to team settings (default_chat_model /
default_chat_reasoning_effort). get_team_default_model("chat") inherits the
Agent default when unset; the chat graph resolves through it. Admin RolePicker
gains an 'Agent default' inherit option that clears the override.
* feat: multi-conversation review chat (tabs, new chat, history)
Replace the single per-PR chat thread with multiple per-user conversations:
- threads minted client-side; first message persists with a title derived
from the prompt.
- list + delete endpoints; chat panel gets a tab strip (history), new-chat
(+), close (x), refresh, an intro greeting, and suggested prompts.
- get_review_chat now returns availability only (ids are client-minted).
* ui fixes
* ui: review-chat history dropdown, full-width AI replies, resizable side panel
* fix(review-chat): enforce per-user thread ownership on proxy endpoints; reseed PR context on head change
---------
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
"""Tool: ``list_review_findings``. Read the published review's findings.
|
|
|
|
The PR chat agent runs on its own thread; the findings live on the canonical
|
|
reviewer thread for the PR. The reviewer thread id is seeded into the run config
|
|
by the dashboard chat proxy.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
from typing import Any
|
|
|
|
from langgraph.config import get_config
|
|
|
|
from ..reviewer_findings import list_findings as list_findings_async
|
|
|
|
_COMPACT_FIELDS = (
|
|
"id",
|
|
"severity",
|
|
"confidence",
|
|
"category",
|
|
"title",
|
|
"description",
|
|
"suggestion",
|
|
"file",
|
|
"start_line",
|
|
"end_line",
|
|
"side",
|
|
"status",
|
|
"resolution_note",
|
|
)
|
|
|
|
|
|
def _compact(finding: dict[str, Any]) -> dict[str, Any]:
|
|
return {key: finding.get(key) for key in _COMPACT_FIELDS if finding.get(key) is not None}
|
|
|
|
|
|
def list_review_findings(status_filter: str | None = None) -> dict[str, Any]:
|
|
"""List the findings the reviewer published for this PR.
|
|
|
|
Use this to ground answers about the review — what was flagged, the
|
|
severity/confidence, and any resolution notes. Prefer quoting these over
|
|
re-deriving issues from the diff.
|
|
|
|
Args:
|
|
status_filter: One of ``open``, ``resolved``, ``dismissed``. ``None``
|
|
(default) returns findings of every status.
|
|
|
|
Returns:
|
|
``{findings, count}``; ``{findings: [], count: 0, error}`` on failure.
|
|
"""
|
|
if status_filter is not None and status_filter not in {"open", "resolved", "dismissed"}:
|
|
return {"findings": [], "count": 0, "error": f"Invalid status_filter: {status_filter}"}
|
|
|
|
config = get_config()
|
|
configurable = config.get("configurable", {}) if isinstance(config, dict) else {}
|
|
reviewer_thread_id = (
|
|
configurable.get("reviewer_thread_id") if isinstance(configurable, dict) else None
|
|
)
|
|
if not isinstance(reviewer_thread_id, str) or not reviewer_thread_id:
|
|
return {"findings": [], "count": 0, "error": "reviewer thread unavailable"}
|
|
|
|
try:
|
|
findings = asyncio.run(list_findings_async(reviewer_thread_id))
|
|
except Exception as exc: # noqa: BLE001
|
|
return {"findings": [], "count": 0, "error": f"could not load findings: {exc!s}"}
|
|
|
|
if status_filter is not None:
|
|
findings = [f for f in findings if f.get("status") == status_filter]
|
|
compact = [_compact(f) for f in findings]
|
|
return {"findings": compact, "count": len(compact)}
|