mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(agents): add PR title, draft, and status icons to sidebar (#22952)
Adds `pull_request_title` and `pull_request_draft` to the chat diff status pipeline (DB → provider → SDK → frontend). The GitHub provider now fetches the PR title alongside existing status fields. The agents sidebar now displays PR-state-aware icons for chats that have a linked pull request (when the chat is in waiting/completed state): - **Open PR**: `GitPullRequestArrow` (green) - **Draft PR**: `GitPullRequestDraft` (gray) - **Merged PR**: `GitMerge` (purple) - **Closed PR**: `GitPullRequestClosed` (red) Running/pending/paused/error chats keep their existing activity icons (spinner, pause, error triangle). ### Changes **Database migration** (`000432`): Adds `pull_request_title TEXT` and `pull_request_draft BOOLEAN` columns to `chat_diff_statuses`. **Backend pipeline**: - `gitprovider.PRStatus` gains a `Title` field - GitHub provider decodes the `title` from the API response - `gitsync` and `coderd/chats.go` pass title + draft through to the DB upsert - `codersdk.ChatDiffStatus` exposes both new fields in the API response **Frontend** (`AgentsSidebar.tsx`): New `getPRIconConfig()` function resolves the appropriate Lucide git icon based on `pull_request_state` and `pull_request_draft`. Only applies when the chat is in a terminal state (waiting/completed). **Real-time sync**: No changes needed — the existing `diff_status_change` pubsub event already propagates the full `ChatDiffStatus` including the new fields.
This commit is contained in:
@@ -258,6 +258,7 @@ func (g *githubProvider) FetchPullRequestStatus(
|
||||
)
|
||||
|
||||
var pull struct {
|
||||
Title string `json:"title"`
|
||||
State string `json:"state"`
|
||||
Merged bool `json:"merged"`
|
||||
Draft bool `json:"draft"`
|
||||
@@ -298,6 +299,7 @@ func (g *githubProvider) FetchPullRequestStatus(
|
||||
}
|
||||
|
||||
return &PRStatus{
|
||||
Title: pull.Title,
|
||||
State: state,
|
||||
Draft: pull.Draft,
|
||||
HeadSHA: pull.Head.SHA,
|
||||
|
||||
Reference in New Issue
Block a user