diff --git a/api/openapi.yaml b/api/openapi.yaml
index 52a192d..695d88a 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -127,7 +127,7 @@ paths:
patch:
operationId: updateMe
tags: [auth]
- summary: Update profile fields (chat name color)
+ summary: Update profile fields (chat name color, GitHub login)
requestBody:
required: true
content:
@@ -138,6 +138,9 @@ paths:
name_color:
type: string
description: "#rrggbb, or empty string to clear"
+ github_login:
+ type: string
+ description: GitHub username bound for "mine" filters, or empty to clear
responses:
"200":
description: Updated user
@@ -2690,7 +2693,7 @@ paths:
properties:
pull:
type: object
- description: "number, title, state, draft, merged, mergeable, body, url, author, head, base, additions, deletions, changed_files, commit_count, labels, created_at, updated_at, repo"
+ description: "number, title, state, draft, merged, mergeable, body, url, author, head, base, additions, deletions, changed_files, commit_count, labels, assignees, reviewers, teams, merged_by, created_at, updated_at, repo"
files:
type: array
items: { type: object }
@@ -2700,6 +2703,42 @@ paths:
checks:
type: array
items: { type: object }
+ reviews:
+ type: array
+ description: latest submitted review state per reviewer
+ items: { type: object }
+ review_decision:
+ type: string
+ description: approved | changes_requested | pending | ""
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "404": { $ref: "#/components/responses/NotFound" }
+ "502": { description: "GitHub upstream error" }
+
+ /api/projects/{projectId}/github/issue:
+ get:
+ operationId: issueDetail
+ summary: In-app GitHub issue detail — issue plus comment thread
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string }, description: "owner/name or repo id; optional when only one repo is linked" }
+ - { name: number, in: query, required: true, schema: { type: integer } }
+ responses:
+ "200":
+ description: Issue detail bundle
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ issue:
+ type: object
+ description: "number, title, state, body, url, author, avatar_url, author_type, labels, assignees, comment_count, milestone, created_at, updated_at"
+ comments:
+ type: array
+ items: { type: object }
+ repo:
+ type: object
"400": { $ref: "#/components/responses/BadRequest" }
"404": { $ref: "#/components/responses/NotFound" }
"502": { description: "GitHub upstream error" }
@@ -2858,6 +2897,159 @@ paths:
"400": { $ref: "#/components/responses/BadRequest" }
"502": { description: "GitHub upstream error" }
+ /api/projects/{projectId}/github/labels:
+ get:
+ operationId: repoLabels
+ summary: Label catalog of a linked repository
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string } }
+ responses:
+ "200":
+ description: Labels
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ labels:
+ type: array
+ items:
+ type: object
+ properties:
+ name: { type: string }
+ color: { type: string }
+ description: { type: string }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "502": { description: "GitHub upstream error" }
+ post:
+ operationId: createRepoLabel
+ summary: Create a label on a linked repository
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string } }
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [name]
+ properties:
+ name: { type: string }
+ color:
+ type: string
+ description: 6-char hex, with or without '#'
+ description: { type: string }
+ responses:
+ "201":
+ description: Created label
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name: { type: string }
+ color: { type: string }
+ description: { type: string }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "502": { description: "GitHub upstream error" }
+
+ /api/projects/{projectId}/github/assignees:
+ get:
+ operationId: repoAssignees
+ summary: Assignable users of a linked repository
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string } }
+ responses:
+ "200":
+ description: Assignable users
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ users:
+ type: array
+ items:
+ type: object
+ properties:
+ login: { type: string }
+ avatar_url: { type: string }
+ type: { type: string }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "502": { description: "GitHub upstream error" }
+
+ /api/projects/{projectId}/github/issues/update:
+ post:
+ operationId: updateGitHubIssue
+ summary: Update a GitHub issue's title, body, labels, or assignees
+ description: Each provided set replaces the whole list on GitHub. Works on PR numbers too — they share the issues endpoint upstream.
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string } }
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [number]
+ properties:
+ number: { type: integer }
+ title: { type: string }
+ body: { type: string }
+ labels: { type: array, items: { type: string } }
+ assignees: { type: array, items: { type: string } }
+ responses:
+ "200":
+ description: Updated issue fields
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ title: { type: string }
+ body: { type: string }
+ labels: { type: array, items: { type: object } }
+ assignees: { type: array, items: { type: object } }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "502": { description: "GitHub upstream error" }
+
+ /api/projects/{projectId}/github/issues/state:
+ post:
+ operationId: setIssueState
+ summary: Close or reopen a GitHub issue
+ tags: [github]
+ parameters:
+ - $ref: "#/components/parameters/ProjectId"
+ - { name: repo, in: query, schema: { type: string } }
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [number, state]
+ properties:
+ number: { type: integer }
+ state: { type: string, enum: [open, closed] }
+ responses:
+ "200":
+ description: New issue state
+ content:
+ application/json:
+ schema:
+ type: object
+ properties: { state: { type: string } }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "502": { description: "GitHub upstream error" }
+
/api/projects/{projectId}/github/pull/state:
post:
operationId: setPullState
@@ -2975,10 +3167,11 @@ paths:
/api/workspaces/{workspaceId}/github/pulls:
get:
operationId: workspacePulls
- summary: Open pull requests across every linked repo in the workspace
+ summary: Pull requests across every linked repo in the workspace
tags: [github]
parameters:
- { name: workspaceId, in: path, required: true, schema: { type: string, format: uuid } }
+ - { name: state, in: query, schema: { type: string, enum: [open, closed, all], default: open } }
responses:
"200":
description: PR groups keyed by project+repo
@@ -2993,6 +3186,28 @@ paths:
"400": { $ref: "#/components/responses/BadRequest" }
"403": { $ref: "#/components/responses/Forbidden" }
+ /api/workspaces/{workspaceId}/github/issues:
+ get:
+ operationId: workspaceIssues
+ summary: Issues across every linked repo in the workspace
+ tags: [github]
+ parameters:
+ - { name: workspaceId, in: path, required: true, schema: { type: string, format: uuid } }
+ - { name: state, in: query, schema: { type: string, enum: [open, closed, all], default: open } }
+ responses:
+ "200":
+ description: Issue groups keyed by project+repo; issue_id links mirrored Relay issues
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ groups:
+ type: array
+ items: { type: object }
+ "400": { $ref: "#/components/responses/BadRequest" }
+ "403": { $ref: "#/components/responses/Forbidden" }
+
/api/projects/{projectId}/github/commits:
get:
operationId: gitCommits
@@ -4393,6 +4608,9 @@ components:
name_color:
type: ["string", "null"]
description: Chat name color as #rrggbb; null = palette default.
+ github_login:
+ type: string
+ description: Bound GitHub username; empty = not linked.
avatar_url: { type: ["string", "null"] }
created_at: { type: string, format: date-time }
@@ -4915,6 +5133,8 @@ components:
kind: { type: string, enum: [issue, pr] }
state: { type: string, enum: [open, closed, merged], description: "GitHub's raw state" }
url: { type: string }
+ author: { type: string, description: "GitHub login of the issue/PR author" }
+ avatar_url: { type: string, description: "GitHub avatar URL of the author" }
IssueActivity:
type: object
diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx
index 88d25b9..64466b8 100644
--- a/apps/web/src/App.tsx
+++ b/apps/web/src/App.tsx
@@ -5,6 +5,7 @@ import { ConfirmHost } from "./components/Confirm";
import { ProfileModalHost } from "./components/ProfileModal";
import { CommitModalHost } from "./features/github/CommitModal";
import { GitHubCreateModalHost } from "./features/github/CreateModals";
+import { GitHubIssueModalHost } from "./features/github/GitHubIssueModal";
import { Rail } from "./components/Rail";
import { ServerBanner } from "./components/ServerBanner";
import { LimitedBanner } from "./components/LimitedBanner";
@@ -55,6 +56,7 @@ export default function App(props: ParentProps) {
+
diff --git a/apps/web/src/components/Rail.tsx b/apps/web/src/components/Rail.tsx
index 03413c1..90f4966 100644
--- a/apps/web/src/components/Rail.tsx
+++ b/apps/web/src/components/Rail.tsx
@@ -52,6 +52,7 @@ import {
ChevronDownIcon,
ChevronLeftIcon,
ChevronRightIcon,
+ CircleDotIcon,
GitPullRequestIcon,
GripIcon,
BookmarkIcon,
@@ -757,6 +758,7 @@ export function Rail() {
if (e.type === "review.created" || e.type === "review.responded") {
void refreshUnread();
}
+ if (e.type.startsWith("issue.")) refetchGh();
});
onCleanup(unsub);
createEffect(() => {
@@ -768,6 +770,22 @@ export function Rail() {
onCleanup(() => window.removeEventListener("keydown", onKey));
});
const active = activeWorkspace(session.workspaces);
+ // Open-issue/PR counts for the nav badges. Both endpoints cache 60s
+ // server-side; a missing GitHub app yields null and the badges hide.
+ const [ghCounts, { refetch: refetchGh }] = createResource(
+ () => active()?.id,
+ async (ws) => {
+ const [pulls, issues] = await Promise.all([
+ api.workspacePulls(ws).catch(() => null),
+ api.workspaceIssues(ws).catch(() => null),
+ ]);
+ return {
+ pulls: pulls?.groups.reduce((n, g) => n + g.pulls.length, 0) ?? null,
+ issues:
+ issues?.groups.reduce((n, g) => n + g.issues.length, 0) ?? null,
+ };
+ },
+ );
// The rail shows one workspace at a time — workspaces are separate
// namespaces, so switching swaps the whole project list.
const list = () =>
@@ -925,6 +943,20 @@ export function Rail() {
Pull requests
+ 0}>
+
+ {ghCounts()?.pulls}
+
+
+
+
+
+ Issues
+ 0}>
+
+ {ghCounts()?.issues}
+
+
diff --git a/apps/web/src/components/icons.tsx b/apps/web/src/components/icons.tsx
index 2806dc5..25cb507 100644
--- a/apps/web/src/components/icons.tsx
+++ b/apps/web/src/components/icons.tsx
@@ -227,6 +227,24 @@ export function IssueIcon(props: IconProps): JSX.Element {
);
}
+export function CircleDotIcon(props: IconProps): JSX.Element {
+ return (
+
+ );
+}
+
export function GitPullRequestIcon(props: IconProps): JSX.Element {
return (
@@ -242,13 +255,92 @@ function PRBody(props: {
conflicts
-
- {(l) => (
-
- {l}
+
+
+ approved
+
+
+
+
+ changes requested
+
+
+
+
+ review pending
+
+
+ 0}>
+
+
+ {(rv) => (
+
+
+
+ )}
+
+
+
+ 0 || (pr().teams?.length ?? 0) > 0}>
+ a.login), ...(pr().teams ?? []).map((t) => `${t.slug} (team)`)].join(", ")}`}
+ >
+
+
+ {(a) => (
+
+ )}
+
+
+ {(t) => (
+
+ T
+
+ )}
+
- )}
-
+ review requested
+
+
+ 0}>
+ a.login).join(", ")}`}
+ >
+
+
+ {(a) => (
+
+ )}
+
+
+ assigned
+
+
+ props.onMerged()}
+ />
diff --git a/apps/web/src/features/github/PullRequestList.tsx b/apps/web/src/features/github/PullRequestList.tsx
index 316d5ba..a2915e0 100644
--- a/apps/web/src/features/github/PullRequestList.tsx
+++ b/apps/web/src/features/github/PullRequestList.tsx
@@ -12,7 +12,7 @@ import { api } from "../../lib/api";
import { subscribe } from "../../lib/events";
import { Spinner, Tip } from "../../components/ui";
import { GitPullRequestIcon } from "../../components/icons";
-import { markGitHub } from "./GitHub";
+import { GhAvatar, markGitHub } from "./GitHub";
import { PullRequestDetail } from "./PullRequestDetail";
import { openCreatePull } from "./CreateModals";
import type { Issue } from "@relay/api-client";
@@ -125,6 +125,18 @@ export function PullRequestList(props: { projectId: string }) {
{markGitHub("", "h-3 w-3")}
{i.github?.repo}
+
+ {(a) => (
+
+
+ {a()}
+
+ )}
+
(
#{g().number} {g().state}
+
+
+
)}
diff --git a/apps/web/src/features/projects/ProjectPage.tsx b/apps/web/src/features/projects/ProjectPage.tsx
index 56798f2..99953a6 100644
--- a/apps/web/src/features/projects/ProjectPage.tsx
+++ b/apps/web/src/features/projects/ProjectPage.tsx
@@ -69,6 +69,7 @@ import { isClosed, statusDefs, StatusDot } from "../issues/meta";
import { Reviews } from "../reviews/Reviews";
import { WebhooksSection } from "../webhooks/Webhooks";
import { openCommit } from "../github/CommitModal";
+import { openGhIssue } from "../github/GitHubIssueModal";
type View =
| "issues"
@@ -1697,6 +1698,20 @@ export default function ProjectPage() {
}
});
+ // ?gh=owner/name:number deep link — opens the GitHub issue modal once,
+ // then drops the param (mirrors ?pr= on the pulls view).
+ createEffect(() => {
+ const raw = searchParams.gh;
+ const gh = Array.isArray(raw) ? raw[0] : raw;
+ if (!gh) return;
+ const sep = gh.lastIndexOf(":");
+ const num = Number(gh.slice(sep + 1));
+ if (sep > 0 && Number.isInteger(num) && num > 0) {
+ openGhIssue(params.projectId, gh.slice(0, sep), num);
+ setSearchParams({ gh: undefined });
+ }
+ });
+
const [overview, { refetch: refetchOverview }] = createResource(
() => params.projectId,
(id) => api.projectOverview(id),
diff --git a/apps/web/src/features/workspaces/Settings.tsx b/apps/web/src/features/workspaces/Settings.tsx
index 5b0028c..f70ef9d 100644
--- a/apps/web/src/features/workspaces/Settings.tsx
+++ b/apps/web/src/features/workspaces/Settings.tsx
@@ -829,6 +829,56 @@ function NameColorRow() {
);
}
+// GitHub login: binds the Relay user to their GitHub account so the
+// workspace Issues/Pulls pages can offer "mine" / "assigned to me" filters.
+// Free-text bind, not OAuth — the GitHub App is server-scoped, not per-user.
+function GitHubLoginRow() {
+ const session = useSession();
+ const [value, setValue] = createSignal(session.user()?.github_login ?? "");
+ const [busy, setBusy] = createSignal(false);
+ const [error, setError] = createSignal(null);
+
+ async function save() {
+ setBusy(true);
+ setError(null);
+ try {
+ await api.updateMe({ github_login: value().trim() });
+ await session.refresh();
+ } catch (err) {
+ setError(errorMessage(err, "Could not save GitHub username"));
+ } finally {
+ setBusy(false);
+ }
+ }
+
+ return (
+
+ GitHub
+ setValue(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") void save();
+ }}
+ disabled={busy()}
+ placeholder="github username"
+ class={`${inputClass} w-44`}
+ />
+
+
+
+ );
+}
+
// Connection card: which backend this app talks to. Local mode stores
// everything on this device; one connect form handles both auth styles —
// email+password in-app or approval in the system browser — and the
@@ -1403,6 +1453,7 @@ export default function Settings() {
+
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index 6e87ba2..9962f09 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -22,6 +22,7 @@ import Home from "./pages/Home";
import Inbox from "./pages/Inbox";
import Overview from "./pages/Overview";
import Pulls from "./pages/Pulls";
+import Issues from "./pages/Issues";
import Saved from "./pages/Saved";
import AgentProfile from "./pages/AgentProfile";
import Connect from "./pages/Connect";
@@ -110,6 +111,7 @@ render(
+
diff --git a/apps/web/src/pages/Issues.tsx b/apps/web/src/pages/Issues.tsx
new file mode 100644
index 0000000..b72a2b1
--- /dev/null
+++ b/apps/web/src/pages/Issues.tsx
@@ -0,0 +1,343 @@
+import { A, useNavigate, useSearchParams } from "@solidjs/router";
+import {
+ createMemo,
+ createResource,
+ createSignal,
+ For,
+ onCleanup,
+ Show,
+} from "solid-js";
+import type { WorkspaceIssues } from "@relay/api-client";
+import { api } from "../lib/api";
+import { subscribe } from "../lib/events";
+import { timeAgo } from "../lib/time";
+import { FullPageSpinner, inputClass } from "../components/ui";
+import { IssueIcon, SearchIcon, ThreadIcon } from "../components/icons";
+import {
+ GhAuthor,
+ GhAvatar,
+ GhLabelChip,
+ markGitHub,
+} from "../features/github/GitHub";
+import { openGhIssue } from "../features/github/GitHubIssueModal";
+import { openCreateIssue } from "../features/github/CreateModals";
+import { Select } from "../components/Select";
+import { useSession } from "../stores/session";
+import { activeWorkspace } from "../stores/workspace";
+
+// Workspace-wide GitHub issues: every linked repo's open issues in one list,
+// sibling of the Pulls page. Rows deep-link to the mirrored Relay issue when
+// one exists, else to the project's issues view.
+export default function Issues() {
+ const session = useSession();
+ const navigate = useNavigate();
+ const active = activeWorkspace(session.workspaces);
+ const [query, setQuery] = createSignal("");
+ const [withIssuesOnly, setWithIssuesOnly] = createSignal(true);
+ // Involvement filter — only offered once the user binds their GitHub
+ // login in Settings (free-text bind, GitHub App is server-scoped).
+ const me = () => (session.user()?.github_login ?? "").toLowerCase();
+ type Who = "any" | "mine" | "assigned";
+ const [who, setWho] = createSignal("any");
+ const involvesMe = (i: Group["issues"][number]) => {
+ switch (who()) {
+ case "mine":
+ return i.author.toLowerCase() === me();
+ case "assigned":
+ return i.assignees.some((a) => a.login.toLowerCase() === me());
+ default:
+ return true;
+ }
+ };
+ // state lives in the URL — shareable and survives reload/navigation.
+ const [params, setParams] = useSearchParams<{ state?: string }>();
+ const stateFilter = () =>
+ params.state === "closed" || params.state === "all" ? params.state : "open";
+ const setStateFilter = (s: "open" | "closed" | "all") =>
+ setParams({ state: s === "open" ? undefined : s });
+
+ const [data, { refetch }] = createResource(
+ () => ({ ws: active()?.id, state: stateFilter() }),
+ (k) => (k.ws ? api.workspaceIssues(k.ws, k.state) : null),
+ );
+
+ const unsub = subscribe((e) => {
+ if (e.type.startsWith("issue.") || e.type === "stream.resync")
+ void refetch();
+ });
+ onCleanup(unsub);
+
+ // The server-side payload is 60s-cached anyway — a quiet refresh keeps the
+ // workspace view fresh without hammering GitHub.
+ const ticker = setInterval(() => void refetch(), 60_000);
+ onCleanup(() => clearInterval(ticker));
+
+ type Group = WorkspaceIssues["groups"][number];
+ const groups = createMemo(() => {
+ const q = query().trim().toLowerCase();
+ return (data.latest?.groups ?? [])
+ .map((g) => ({
+ ...g,
+ issues: g.issues
+ .slice()
+ .sort(
+ (a, b) =>
+ +new Date(b.updated_at) - +new Date(a.updated_at),
+ )
+ .filter(
+ (i) =>
+ involvesMe(i) &&
+ (!q ||
+ i.title.toLowerCase().includes(q) ||
+ i.author.toLowerCase().includes(q) ||
+ String(i.number).includes(q) ||
+ g.repo.full_name.toLowerCase().includes(q) ||
+ g.project_name.toLowerCase().includes(q)),
+ ),
+ }))
+ .filter((g) => !withIssuesOnly() || g.issues.length > 0);
+ });
+ const total = createMemo(() =>
+ groups().reduce((n, g) => n + g.issues.length, 0),
+ );
+
+ const open = (g: Group, i: Group["issues"][number]) => {
+ if (i.issue_id) {
+ navigate(`/app/p/${g.project_id}/i/${i.issue_id}`);
+ } else {
+ // Not mirrored — show the live GitHub issue in-app instead of
+ // dead-ending on the project's issues view.
+ openGhIssue(g.project_id, g.repo.full_name, i.number);
+ }
+ };
+
+ return (
+
+
+
Issues
+
+
+ {(s) => (
+
+ )}
+
+
+
0}>
+
+ {total()}
+
+
+
+
+ setQuery(e.currentTarget.value)}
+ placeholder="Filter by title, repo, author…"
+ class={`${inputClass} pl-8`}
+ />
+
+
+
+ {(t) => (
+
+ fetched {timeAgo(t())}
+
+ )}
+
+
+
+
+
+
+
+ 0}>
+
+ {data.latest!.failed!.join(", ")} failed to load
+
+
+
+
+
+
+
+ }
+ >
+ 0}
+ fallback={
+
+ {data.error
+ ? "Could not load issues — is GitHub connected?"
+ : (data.latest?.groups.length ?? 0) === 0
+ ? "No repositories linked yet. Link one under a project's Development view."
+ : query().trim()
+ ? "Nothing matches the filter."
+ : `No ${stateFilter()} issues.`}
+
+ }
+ >
+
+ {(g) => (
+
+
+
+ {g.project_name}
+
+ /
+ {markGitHub("", "h-3.5 w-3.5")}
+
+ {g.repo.full_name}
+
+
+
+
+
+ No open issues
+
+ }
+ >
+ {(i) => (
+ -
+
+
+ )}
+
+
+
+ )}
+
+
+
+
+ );
+}
diff --git a/apps/web/src/pages/Pulls.tsx b/apps/web/src/pages/Pulls.tsx
index bd527ee..58e92d6 100644
--- a/apps/web/src/pages/Pulls.tsx
+++ b/apps/web/src/pages/Pulls.tsx
@@ -1,4 +1,4 @@
-import { A, useNavigate } from "@solidjs/router";
+import { A, useNavigate, useSearchParams } from "@solidjs/router";
import {
createMemo,
createResource,
@@ -12,8 +12,19 @@ import { api } from "../lib/api";
import { subscribe } from "../lib/events";
import { timeAgo } from "../lib/time";
import { FullPageSpinner, inputClass } from "../components/ui";
-import { GitPullRequestIcon, SearchIcon } from "../components/icons";
-import { markGitHub } from "../features/github/GitHub";
+import {
+ GitPullRequestIcon,
+ SearchIcon,
+ ThreadIcon,
+} from "../components/icons";
+import {
+ GhAuthor,
+ GhAvatar,
+ GhLabelChip,
+ markGitHub,
+} from "../features/github/GitHub";
+import { openCreatePull } from "../features/github/CreateModals";
+import { Select } from "../components/Select";
import { useSession } from "../stores/session";
import { activeWorkspace } from "../stores/workspace";
@@ -26,10 +37,35 @@ export default function Pulls() {
const active = activeWorkspace(session.workspaces);
const [query, setQuery] = createSignal("");
const [withPullsOnly, setWithPullsOnly] = createSignal(true);
+ // "Needs review" — PRs still waiting on a requested reviewer. When the
+ // user has bound their GitHub login in Settings, the Involvement select
+ // narrows further to their own authored/reviewing/assigned sets.
+ const [needsReview, setNeedsReview] = createSignal(false);
+ const me = () => (session.user()?.github_login ?? "").toLowerCase();
+ type Who = "any" | "mine" | "review" | "assigned";
+ const [who, setWho] = createSignal("any");
+ const involvesMe = (p: Group["pulls"][number]) => {
+ switch (who()) {
+ case "mine":
+ return p.author.toLowerCase() === me();
+ case "review":
+ return p.reviewers.some((a) => a.login.toLowerCase() === me());
+ case "assigned":
+ return p.assignees.some((a) => a.login.toLowerCase() === me());
+ default:
+ return true;
+ }
+ };
+ // state lives in the URL — shareable and survives reload/navigation.
+ const [params, setParams] = useSearchParams<{ state?: string }>();
+ const stateFilter = () =>
+ params.state === "closed" || params.state === "all" ? params.state : "open";
+ const setStateFilter = (s: "open" | "closed" | "all") =>
+ setParams({ state: s === "open" ? undefined : s });
const [data, { refetch }] = createResource(
- () => active()?.id,
- (ws) => api.workspacePulls(ws),
+ () => ({ ws: active()?.id, state: stateFilter() }),
+ (k) => (k.ws ? api.workspacePulls(k.ws, k.state) : null),
);
// Mirrored PR issues emit issue.*; CI/deploy webhooks republish as
@@ -44,21 +80,36 @@ export default function Pulls() {
});
onCleanup(unsub);
+ // Server-side payload is 60s-cached anyway — a quiet refresh keeps the
+ // view fresh without hammering GitHub.
+ const ticker = setInterval(() => void refetch(), 60_000);
+ onCleanup(() => clearInterval(ticker));
+
type Group = WorkspacePulls["groups"][number];
const groups = createMemo(() => {
const q = query().trim().toLowerCase();
return (data.latest?.groups ?? [])
.map((g) => ({
...g,
- pulls: g.pulls.filter(
- (p) =>
- !q ||
- p.title.toLowerCase().includes(q) ||
- p.author.toLowerCase().includes(q) ||
- String(p.number).includes(q) ||
- g.repo.full_name.toLowerCase().includes(q) ||
- g.project_name.toLowerCase().includes(q),
- ),
+ pulls: g.pulls
+ .slice()
+ .sort(
+ (a, b) =>
+ +new Date(b.updated_at) - +new Date(a.updated_at),
+ )
+ .filter(
+ (p) =>
+ (!needsReview() ||
+ p.reviewers.length > 0 ||
+ (p.teams?.length ?? 0) > 0) &&
+ involvesMe(p) &&
+ (!q ||
+ p.title.toLowerCase().includes(q) ||
+ p.author.toLowerCase().includes(q) ||
+ String(p.number).includes(q) ||
+ g.repo.full_name.toLowerCase().includes(q) ||
+ g.project_name.toLowerCase().includes(q)),
+ ),
}))
.filter((g) => !withPullsOnly() || g.pulls.length > 0);
});
@@ -75,9 +126,26 @@ export default function Pulls() {
Pull requests
+
+
+ {(s) => (
+
+ )}
+
+
0}>
- {total()} open
+ {total()}
@@ -96,17 +164,54 @@ export default function Pulls() {
>
Refresh
+
+ {(t) => (
+
+ fetched {timeAgo(t())}
+
+ )}
+
-
+
+
+
+
+
+ 0}>
+
+ {data.latest!.failed!.join(", ")} failed to load
+
+
+
}
>
@@ -148,6 +255,15 @@ export default function Pulls() {
>
{g.repo.full_name}
+
@@ -179,23 +301,85 @@ export default function Pulls() {
draft
+
+
+ merged
+
+
+
+
+ closed
+
+
{p.head} → {p.base}
- {p.author}
+
+
+
- {(l) => (
-
- {l}
-
- )}
+ {(l) => }
-
- {timeAgo(p.updated_at)}
+
+ 0 || (p.teams?.length ?? 0) > 0}>
+ a.login), ...(p.teams ?? []).map((t) => `${t.slug} (team)`)].join(", ")}`}
+ >
+
+ {(a) => (
+
+ )}
+
+
+ {(t) => (
+
+ T
+
+ )}
+
+
+
+ 0}>
+ a.login).join(", ")}`}
+ >
+
+ {(a) => (
+
+ )}
+
+
+
+ 0}>
+
+
+ {p.comments}
+
+
+
+ {timeAgo(p.updated_at)}
+
diff --git a/db/migrations/0054_github_author.sql b/db/migrations/0054_github_author.sql
new file mode 100644
index 0000000..3416e3a
--- /dev/null
+++ b/db/migrations/0054_github_author.sql
@@ -0,0 +1,9 @@
+-- +goose Up
+-- Mirrored GitHub issues/PRs remember who filed them — the mirror upsert
+-- refreshes these on every write, so the reconcile sweep backfills them.
+alter table issues add column github_author text;
+alter table issues add column github_avatar_url text;
+
+-- +goose Down
+alter table issues drop column github_avatar_url;
+alter table issues drop column github_author;
diff --git a/db/migrations/0055_github_login.sql b/db/migrations/0055_github_login.sql
new file mode 100644
index 0000000..897508a
--- /dev/null
+++ b/db/migrations/0055_github_login.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+alter table users add column github_login text not null default '';
+
+-- +goose Down
+alter table users drop column github_login;
diff --git a/db/queries/github.sql b/db/queries/github.sql
index ac77284..6e0661e 100644
--- a/db/queries/github.sql
+++ b/db/queries/github.sql
@@ -69,10 +69,12 @@ where github_repo_id = sqlc.arg(repo_id) and github_number = sqlc.arg(number);
-- name: CreateGitHubIssue :one
insert into issues (project_id, number, title, description, status, priority,
github_node_id, github_repo_id, github_number, origin,
- github_kind, github_state, github_url)
+ github_kind, github_state, github_url,
+ github_author, github_avatar_url)
values (sqlc.arg(project_id), sqlc.arg(number), sqlc.arg(title), sqlc.arg(description),
sqlc.arg(status), 'none', sqlc.arg(node_id), sqlc.arg(repo_id), sqlc.arg(gh_number), 'github',
- sqlc.arg(kind), sqlc.arg(gh_state), sqlc.arg(gh_url))
+ sqlc.arg(kind), sqlc.arg(gh_state), sqlc.arg(gh_url),
+ sqlc.narg(gh_author), sqlc.narg(gh_avatar_url))
returning *;
-- name: UpdateGitHubIssue :one
@@ -82,6 +84,8 @@ update issues set
status = coalesce(sqlc.narg(status)::text, status),
github_state = coalesce(sqlc.narg(gh_state)::text, github_state),
github_url = coalesce(sqlc.narg(gh_url)::text, github_url),
+ github_author = coalesce(sqlc.narg(gh_author)::text, github_author),
+ github_avatar_url = coalesce(sqlc.narg(gh_avatar_url)::text, github_avatar_url),
updated_at = now()
where id = sqlc.arg(id)
returning *;
diff --git a/db/queries/users.sql b/db/queries/users.sql
index 30d1cfb..e74bb6c 100644
--- a/db/queries/users.sql
+++ b/db/queries/users.sql
@@ -1,22 +1,26 @@
-- name: CreateUser :one
insert into users (email, password_hash, name)
values ($1, $2, $3)
-returning id, email, name, created_at;
+returning id, email, name, github_login, created_at;
-- name: GetUserByEmail :one
-select id, email, password_hash, name, name_color, avatar_key, created_at
+select id, email, password_hash, name, name_color, avatar_key, github_login, created_at
from users
where lower(email) = lower($1);
-- name: GetUserByID :one
-select id, email, name, name_color, avatar_key, created_at
+select id, email, name, name_color, avatar_key, github_login, created_at
from users
where id = $1;
-- name: UpdateUserAvatar :one
update users set avatar_key = $2 where id = $1
-returning id, email, name, name_color, avatar_key, created_at;
+returning id, email, name, name_color, avatar_key, github_login, created_at;
-- name: UpdateUserNameColor :one
update users set name_color = $2 where id = $1
-returning id, email, name, name_color, avatar_key, created_at;
+returning id, email, name, name_color, avatar_key, github_login, created_at;
+
+-- name: UpdateUserGitHubLogin :one
+update users set github_login = $2 where id = $1
+returning id, email, name, name_color, avatar_key, github_login, created_at;
diff --git a/internal/auth/handlers.go b/internal/auth/handlers.go
index a28e2d7..c7c9e6e 100644
--- a/internal/auth/handlers.go
+++ b/internal/auth/handlers.go
@@ -1,10 +1,13 @@
package auth
import (
+ "context"
"errors"
+ "fmt"
"net/http"
"regexp"
"strings"
+ "time"
"github.com/Dvorinka/relay/internal/db"
"github.com/Dvorinka/relay/internal/httpx"
@@ -56,12 +59,13 @@ type sessionOut struct {
}
type userOut struct {
- ID string `json:"id"`
- Email string `json:"email"`
- Name string `json:"name"`
- NameColor *string `json:"name_color"`
- AvatarURL *string `json:"avatar_url"`
- CreatedAt string `json:"created_at"`
+ ID string `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ NameColor *string `json:"name_color"`
+ GitHubLogin string `json:"github_login"`
+ AvatarURL *string `json:"avatar_url"`
+ CreatedAt string `json:"created_at"`
}
func toSessionOut(c Credentials) sessionOut {
@@ -90,41 +94,90 @@ func UserOut(u db.GetUserByIDRow) userOut {
}
return userOut{
ID: u.ID.String(), Email: u.Email, Name: u.Name, NameColor: color,
- AvatarURL: avatar,
- CreatedAt: u.CreatedAt.Time.Format("2006-01-02T15:04:05Z07:00"),
+ GitHubLogin: u.GithubLogin,
+ AvatarURL: avatar,
+ CreatedAt: u.CreatedAt.Time.Format("2006-01-02T15:04:05Z07:00"),
}
}
var nameColorPattern = regexp.MustCompile(`^#[0-9a-fA-F]{6}$`)
+// GitHub login rules: 1–39 chars, alnum or single hyphens, no edge hyphen.
+var githubLoginPattern = regexp.MustCompile(`^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38})$`)
+
+var githubLookupClient = &http.Client{Timeout: 5 * time.Second}
+
+// githubUserExists asks GitHub's public user endpoint. A 404 is a firm no;
+// anything else — rate limit, outage, network — returns true so a transient
+// failure never blocks a profile save.
+func githubUserExists(ctx context.Context, login string) bool {
+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
+ defer cancel()
+ req, err := http.NewRequestWithContext(ctx, "GET",
+ fmt.Sprintf("https://api.github.com/users/%s", login), nil)
+ if err != nil {
+ return true
+ }
+ req.Header.Set("Accept", "application/vnd.github+json")
+ res, err := githubLookupClient.Do(req)
+ if err != nil {
+ return true
+ }
+ _ = res.Body.Close()
+ return res.StatusCode != http.StatusNotFound
+}
+
// handleUpdateMe patches profile fields. name_color accepts "#rrggbb" or
-// empty (clears back to the palette default).
+// empty (clears back to the palette default); github_login binds the user's
+// GitHub account so issue/PR surfaces can offer "mine" filters — empty
+// clears the binding.
func (s *Service) handleUpdateMe(c *gin.Context) {
user := CurrentUser(c)
var req struct {
- NameColor *string `json:"name_color"`
+ NameColor *string `json:"name_color"`
+ GitHubLogin *string `json:"github_login"`
}
if !httpx.BindJSON(c, &req) {
return
}
- if req.NameColor == nil {
+ switch {
+ case req.NameColor != nil:
+ v := strings.TrimSpace(*req.NameColor)
+ if v != "" && !nameColorPattern.MatchString(v) {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "name_color must be #rrggbb or empty")
+ return
+ }
+ row, err := s.q.UpdateUserNameColor(c.Request.Context(), db.UpdateUserNameColorParams{
+ ID: user.ID,
+ NameColor: pgtype.Text{String: strings.ToLower(v), Valid: v != ""},
+ })
+ if err != nil {
+ httpx.Error(c, http.StatusInternalServerError, "internal", "internal error")
+ return
+ }
+ c.JSON(http.StatusOK, gin.H{"user": UserOut(db.GetUserByIDRow(row))})
+ case req.GitHubLogin != nil:
+ v := strings.TrimSpace(*req.GitHubLogin)
+ if v != "" && !githubLoginPattern.MatchString(v) {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "github_login must be a valid GitHub username or empty")
+ return
+ }
+ if v != "" && !githubUserExists(c.Request.Context(), v) {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "no GitHub account with that username")
+ return
+ }
+ row, err := s.q.UpdateUserGitHubLogin(c.Request.Context(), db.UpdateUserGitHubLoginParams{
+ ID: user.ID,
+ GithubLogin: v,
+ })
+ if err != nil {
+ httpx.Error(c, http.StatusInternalServerError, "internal", "internal error")
+ return
+ }
+ c.JSON(http.StatusOK, gin.H{"user": UserOut(db.GetUserByIDRow(row))})
+ default:
httpx.Error(c, http.StatusBadRequest, "bad_request", "nothing to update")
- return
- }
- v := strings.TrimSpace(*req.NameColor)
- if v != "" && !nameColorPattern.MatchString(v) {
- httpx.Error(c, http.StatusBadRequest, "bad_request", "name_color must be #rrggbb or empty")
- return
- }
- row, err := s.q.UpdateUserNameColor(c.Request.Context(), db.UpdateUserNameColorParams{
- ID: user.ID,
- NameColor: pgtype.Text{String: strings.ToLower(v), Valid: v != ""},
- })
- if err != nil {
- httpx.Error(c, http.StatusInternalServerError, "internal", "internal error")
- return
}
- c.JSON(http.StatusOK, gin.H{"user": UserOut(db.GetUserByIDRow(row))})
}
// --- handlers ---
diff --git a/internal/auth/service.go b/internal/auth/service.go
index 43d9289..85bed6e 100644
--- a/internal/auth/service.go
+++ b/internal/auth/service.go
@@ -112,7 +112,7 @@ func (s *Service) Login(ctx context.Context, email, password, ip, ua string) (Cr
if err != nil {
return creds, "", err
}
- creds.User = db.GetUserByIDRow{ID: row.ID, Email: row.Email, Name: row.Name, AvatarKey: row.AvatarKey}
+ creds.User = db.GetUserByIDRow{ID: row.ID, Email: row.Email, Name: row.Name, AvatarKey: row.AvatarKey, NameColor: row.NameColor, GithubLogin: row.GithubLogin}
creds.Workspaces, _ = s.q.ListWorkspacesForUser(ctx, row.ID)
return creds, token, nil
}
diff --git a/internal/db/github.sql.go b/internal/db/github.sql.go
index 304af20..a12dc06 100644
--- a/internal/db/github.sql.go
+++ b/internal/db/github.sql.go
@@ -14,11 +14,13 @@ import (
const createGitHubIssue = `-- name: CreateGitHubIssue :one
insert into issues (project_id, number, title, description, status, priority,
github_node_id, github_repo_id, github_number, origin,
- github_kind, github_state, github_url)
+ github_kind, github_state, github_url,
+ github_author, github_avatar_url)
values ($1, $2, $3, $4,
$5, 'none', $6, $7, $8, 'github',
- $9, $10, $11)
-returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url
+ $9, $10, $11,
+ $12, $13)
+returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url
`
type CreateGitHubIssueParams struct {
@@ -33,6 +35,8 @@ type CreateGitHubIssueParams struct {
Kind string `json:"kind"`
GhState pgtype.Text `json:"gh_state"`
GhUrl pgtype.Text `json:"gh_url"`
+ GhAuthor pgtype.Text `json:"gh_author"`
+ GhAvatarUrl pgtype.Text `json:"gh_avatar_url"`
}
func (q *Queries) CreateGitHubIssue(ctx context.Context, arg CreateGitHubIssueParams) (Issue, error) {
@@ -48,6 +52,8 @@ func (q *Queries) CreateGitHubIssue(ctx context.Context, arg CreateGitHubIssuePa
arg.Kind,
arg.GhState,
arg.GhUrl,
+ arg.GhAuthor,
+ arg.GhAvatarUrl,
)
var i Issue
err := row.Scan(
@@ -70,6 +76,8 @@ func (q *Queries) CreateGitHubIssue(ctx context.Context, arg CreateGitHubIssuePa
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
@@ -102,7 +110,7 @@ func (q *Queries) DeleteRepoLink(ctx context.Context, id pgtype.UUID) error {
}
const findIssueByGitHub = `-- name: FindIssueByGitHub :one
-select id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url from issues
+select id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url from issues
where github_repo_id = $1 and github_number = $2
`
@@ -134,6 +142,8 @@ func (q *Queries) FindIssueByGitHub(ctx context.Context, arg FindIssueByGitHubPa
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
@@ -474,9 +484,11 @@ update issues set
status = coalesce($3::text, status),
github_state = coalesce($4::text, github_state),
github_url = coalesce($5::text, github_url),
+ github_author = coalesce($6::text, github_author),
+ github_avatar_url = coalesce($7::text, github_avatar_url),
updated_at = now()
-where id = $6
-returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url
+where id = $8
+returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url
`
type UpdateGitHubIssueParams struct {
@@ -485,6 +497,8 @@ type UpdateGitHubIssueParams struct {
Status pgtype.Text `json:"status"`
GhState pgtype.Text `json:"gh_state"`
GhUrl pgtype.Text `json:"gh_url"`
+ GhAuthor pgtype.Text `json:"gh_author"`
+ GhAvatarUrl pgtype.Text `json:"gh_avatar_url"`
ID pgtype.UUID `json:"id"`
}
@@ -495,6 +509,8 @@ func (q *Queries) UpdateGitHubIssue(ctx context.Context, arg UpdateGitHubIssuePa
arg.Status,
arg.GhState,
arg.GhUrl,
+ arg.GhAuthor,
+ arg.GhAvatarUrl,
arg.ID,
)
var i Issue
@@ -518,6 +534,8 @@ func (q *Queries) UpdateGitHubIssue(ctx context.Context, arg UpdateGitHubIssuePa
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
diff --git a/internal/db/issues.sql.go b/internal/db/issues.sql.go
index 9b233f7..b6b6abb 100644
--- a/internal/db/issues.sql.go
+++ b/internal/db/issues.sql.go
@@ -32,7 +32,7 @@ const createIssue = `-- name: CreateIssue :one
insert into issues (project_id, number, title, description, status, priority, assignee_id, created_by)
values ($1, $2, $3, $4,
$5, $6, $7, $8)
-returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url
+returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url
`
type CreateIssueParams struct {
@@ -78,6 +78,8 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
@@ -142,7 +144,7 @@ func (q *Queries) CreateLabel(ctx context.Context, arg CreateLabelParams) (Issue
}
const getIssueByID = `-- name: GetIssueByID :one
-select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
+select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, i.github_author, i.github_avatar_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
gr.owner as github_repo_owner, gr.name as github_repo_name
from issues i
left join users u on u.id = i.assignee_id
@@ -170,6 +172,8 @@ type GetIssueByIDRow struct {
GithubKind string `json:"github_kind"`
GithubState pgtype.Text `json:"github_state"`
GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
AssigneeName pgtype.Text `json:"assignee_name"`
AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
GithubRepoOwner pgtype.Text `json:"github_repo_owner"`
@@ -199,6 +203,8 @@ func (q *Queries) GetIssueByID(ctx context.Context, id pgtype.UUID) (GetIssueByI
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
&i.AssigneeName,
&i.AssigneeAvatar,
&i.GithubRepoOwner,
@@ -235,7 +241,7 @@ func (q *Queries) GetIssueConversation(ctx context.Context, issueID pgtype.UUID)
}
const getIssueForUser = `-- name: GetIssueForUser :one
-select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
+select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, i.github_author, i.github_avatar_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
gr.owner as github_repo_owner, gr.name as github_repo_name,
gr.installation_id as github_installation_id
from issues i
@@ -271,6 +277,8 @@ type GetIssueForUserRow struct {
GithubKind string `json:"github_kind"`
GithubState pgtype.Text `json:"github_state"`
GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
AssigneeName pgtype.Text `json:"assignee_name"`
AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
GithubRepoOwner pgtype.Text `json:"github_repo_owner"`
@@ -301,6 +309,8 @@ func (q *Queries) GetIssueForUser(ctx context.Context, arg GetIssueForUserParams
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
&i.AssigneeName,
&i.AssigneeAvatar,
&i.GithubRepoOwner,
@@ -480,7 +490,7 @@ func (q *Queries) ListIssueLabels(ctx context.Context, issueID pgtype.UUID) ([]I
}
const listIssuesForUser = `-- name: ListIssuesForUser :many
-select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
+select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, i.github_author, i.github_avatar_url, u.name as assignee_name, u.avatar_key as assignee_avatar,
gr.owner as github_repo_owner, gr.name as github_repo_name
from issues i
join projects p on p.id = i.project_id
@@ -526,6 +536,8 @@ type ListIssuesForUserRow struct {
GithubKind string `json:"github_kind"`
GithubState pgtype.Text `json:"github_state"`
GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
AssigneeName pgtype.Text `json:"assignee_name"`
AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
GithubRepoOwner pgtype.Text `json:"github_repo_owner"`
@@ -568,6 +580,8 @@ func (q *Queries) ListIssuesForUser(ctx context.Context, arg ListIssuesForUserPa
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
&i.AssigneeName,
&i.AssigneeAvatar,
&i.GithubRepoOwner,
@@ -825,7 +839,7 @@ update issues set
priority = coalesce($4, priority),
updated_at = now()
where id = $5
-returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url
+returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url
`
type UpdateIssueFieldsParams struct {
@@ -865,6 +879,8 @@ func (q *Queries) UpdateIssueFields(ctx context.Context, arg UpdateIssueFieldsPa
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
diff --git a/internal/db/mcp.sql.go b/internal/db/mcp.sql.go
index ebfba75..c70667d 100644
--- a/internal/db/mcp.sql.go
+++ b/internal/db/mcp.sql.go
@@ -439,7 +439,7 @@ const createIssueForAgent = `-- name: CreateIssueForAgent :one
insert into issues (project_id, number, title, description, status, priority, assignee_id, created_by, agent_id)
values ($1, $2, $3, $4,
'todo', $5, null, null, $6)
-returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url
+returning id, project_id, number, title, description, status, priority, assignee_id, agent_id, created_by, created_at, updated_at, github_node_id, github_repo_id, github_number, origin, github_kind, github_state, github_url, github_author, github_avatar_url
`
type CreateIssueForAgentParams struct {
@@ -481,6 +481,8 @@ func (q *Queries) CreateIssueForAgent(ctx context.Context, arg CreateIssueForAge
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
)
return i, err
}
@@ -508,34 +510,36 @@ func (q *Queries) GetAttachmentByID(ctx context.Context, id pgtype.UUID) (Attach
}
const getIssueForAgent = `-- name: GetIssueForAgent :one
-select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, u.name as assignee_name, u.avatar_key as assignee_avatar
+select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, i.github_author, i.github_avatar_url, u.name as assignee_name, u.avatar_key as assignee_avatar
from issues i
left join users u on u.id = i.assignee_id
where i.id = $1
`
type GetIssueForAgentRow struct {
- ID pgtype.UUID `json:"id"`
- ProjectID pgtype.UUID `json:"project_id"`
- Number int32 `json:"number"`
- Title string `json:"title"`
- Description string `json:"description"`
- Status string `json:"status"`
- Priority string `json:"priority"`
- AssigneeID pgtype.UUID `json:"assignee_id"`
- AgentID pgtype.UUID `json:"agent_id"`
- CreatedBy pgtype.UUID `json:"created_by"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
- UpdatedAt pgtype.Timestamptz `json:"updated_at"`
- GithubNodeID pgtype.Text `json:"github_node_id"`
- GithubRepoID pgtype.UUID `json:"github_repo_id"`
- GithubNumber pgtype.Int4 `json:"github_number"`
- Origin string `json:"origin"`
- GithubKind string `json:"github_kind"`
- GithubState pgtype.Text `json:"github_state"`
- GithubUrl pgtype.Text `json:"github_url"`
- AssigneeName pgtype.Text `json:"assignee_name"`
- AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
+ ID pgtype.UUID `json:"id"`
+ ProjectID pgtype.UUID `json:"project_id"`
+ Number int32 `json:"number"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Status string `json:"status"`
+ Priority string `json:"priority"`
+ AssigneeID pgtype.UUID `json:"assignee_id"`
+ AgentID pgtype.UUID `json:"agent_id"`
+ CreatedBy pgtype.UUID `json:"created_by"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
+ UpdatedAt pgtype.Timestamptz `json:"updated_at"`
+ GithubNodeID pgtype.Text `json:"github_node_id"`
+ GithubRepoID pgtype.UUID `json:"github_repo_id"`
+ GithubNumber pgtype.Int4 `json:"github_number"`
+ Origin string `json:"origin"`
+ GithubKind string `json:"github_kind"`
+ GithubState pgtype.Text `json:"github_state"`
+ GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
+ AssigneeName pgtype.Text `json:"assignee_name"`
+ AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
}
func (q *Queries) GetIssueForAgent(ctx context.Context, id pgtype.UUID) (GetIssueForAgentRow, error) {
@@ -561,6 +565,8 @@ func (q *Queries) GetIssueForAgent(ctx context.Context, id pgtype.UUID) (GetIssu
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
&i.AssigneeName,
&i.AssigneeAvatar,
)
@@ -754,7 +760,7 @@ func (q *Queries) ListProjectConversations(ctx context.Context, projectID pgtype
}
const listProjectIssuesForAgent = `-- name: ListProjectIssuesForAgent :many
-select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, u.name as assignee_name, u.avatar_key as assignee_avatar
+select i.id, i.project_id, i.number, i.title, i.description, i.status, i.priority, i.assignee_id, i.agent_id, i.created_by, i.created_at, i.updated_at, i.github_node_id, i.github_repo_id, i.github_number, i.origin, i.github_kind, i.github_state, i.github_url, i.github_author, i.github_avatar_url, u.name as assignee_name, u.avatar_key as assignee_avatar
from issues i
left join users u on u.id = i.assignee_id
where i.project_id = $1
@@ -770,27 +776,29 @@ type ListProjectIssuesForAgentParams struct {
}
type ListProjectIssuesForAgentRow struct {
- ID pgtype.UUID `json:"id"`
- ProjectID pgtype.UUID `json:"project_id"`
- Number int32 `json:"number"`
- Title string `json:"title"`
- Description string `json:"description"`
- Status string `json:"status"`
- Priority string `json:"priority"`
- AssigneeID pgtype.UUID `json:"assignee_id"`
- AgentID pgtype.UUID `json:"agent_id"`
- CreatedBy pgtype.UUID `json:"created_by"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
- UpdatedAt pgtype.Timestamptz `json:"updated_at"`
- GithubNodeID pgtype.Text `json:"github_node_id"`
- GithubRepoID pgtype.UUID `json:"github_repo_id"`
- GithubNumber pgtype.Int4 `json:"github_number"`
- Origin string `json:"origin"`
- GithubKind string `json:"github_kind"`
- GithubState pgtype.Text `json:"github_state"`
- GithubUrl pgtype.Text `json:"github_url"`
- AssigneeName pgtype.Text `json:"assignee_name"`
- AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
+ ID pgtype.UUID `json:"id"`
+ ProjectID pgtype.UUID `json:"project_id"`
+ Number int32 `json:"number"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Status string `json:"status"`
+ Priority string `json:"priority"`
+ AssigneeID pgtype.UUID `json:"assignee_id"`
+ AgentID pgtype.UUID `json:"agent_id"`
+ CreatedBy pgtype.UUID `json:"created_by"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
+ UpdatedAt pgtype.Timestamptz `json:"updated_at"`
+ GithubNodeID pgtype.Text `json:"github_node_id"`
+ GithubRepoID pgtype.UUID `json:"github_repo_id"`
+ GithubNumber pgtype.Int4 `json:"github_number"`
+ Origin string `json:"origin"`
+ GithubKind string `json:"github_kind"`
+ GithubState pgtype.Text `json:"github_state"`
+ GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
+ AssigneeName pgtype.Text `json:"assignee_name"`
+ AssigneeAvatar pgtype.Text `json:"assignee_avatar"`
}
func (q *Queries) ListProjectIssuesForAgent(ctx context.Context, arg ListProjectIssuesForAgentParams) ([]ListProjectIssuesForAgentRow, error) {
@@ -822,6 +830,8 @@ func (q *Queries) ListProjectIssuesForAgent(ctx context.Context, arg ListProject
&i.GithubKind,
&i.GithubState,
&i.GithubUrl,
+ &i.GithubAuthor,
+ &i.GithubAvatarUrl,
&i.AssigneeName,
&i.AssigneeAvatar,
); err != nil {
diff --git a/internal/db/models.go b/internal/db/models.go
index 5e56825..01b8d09 100644
--- a/internal/db/models.go
+++ b/internal/db/models.go
@@ -198,25 +198,27 @@ type InboundHookThread struct {
}
type Issue struct {
- ID pgtype.UUID `json:"id"`
- ProjectID pgtype.UUID `json:"project_id"`
- Number int32 `json:"number"`
- Title string `json:"title"`
- Description string `json:"description"`
- Status string `json:"status"`
- Priority string `json:"priority"`
- AssigneeID pgtype.UUID `json:"assignee_id"`
- AgentID pgtype.UUID `json:"agent_id"`
- CreatedBy pgtype.UUID `json:"created_by"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
- UpdatedAt pgtype.Timestamptz `json:"updated_at"`
- GithubNodeID pgtype.Text `json:"github_node_id"`
- GithubRepoID pgtype.UUID `json:"github_repo_id"`
- GithubNumber pgtype.Int4 `json:"github_number"`
- Origin string `json:"origin"`
- GithubKind string `json:"github_kind"`
- GithubState pgtype.Text `json:"github_state"`
- GithubUrl pgtype.Text `json:"github_url"`
+ ID pgtype.UUID `json:"id"`
+ ProjectID pgtype.UUID `json:"project_id"`
+ Number int32 `json:"number"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Status string `json:"status"`
+ Priority string `json:"priority"`
+ AssigneeID pgtype.UUID `json:"assignee_id"`
+ AgentID pgtype.UUID `json:"agent_id"`
+ CreatedBy pgtype.UUID `json:"created_by"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
+ UpdatedAt pgtype.Timestamptz `json:"updated_at"`
+ GithubNodeID pgtype.Text `json:"github_node_id"`
+ GithubRepoID pgtype.UUID `json:"github_repo_id"`
+ GithubNumber pgtype.Int4 `json:"github_number"`
+ Origin string `json:"origin"`
+ GithubKind string `json:"github_kind"`
+ GithubState pgtype.Text `json:"github_state"`
+ GithubUrl pgtype.Text `json:"github_url"`
+ GithubAuthor pgtype.Text `json:"github_author"`
+ GithubAvatarUrl pgtype.Text `json:"github_avatar_url"`
}
type IssueActivity struct {
@@ -460,6 +462,7 @@ type User struct {
NameColor pgtype.Text `json:"name_color"`
LastSeenAt pgtype.Timestamptz `json:"last_seen_at"`
DigestEnabled bool `json:"digest_enabled"`
+ GithubLogin string `json:"github_login"`
}
type WebhookDelivery struct {
diff --git a/internal/db/users.sql.go b/internal/db/users.sql.go
index 127a1ef..f560a48 100644
--- a/internal/db/users.sql.go
+++ b/internal/db/users.sql.go
@@ -14,7 +14,7 @@ import (
const createUser = `-- name: CreateUser :one
insert into users (email, password_hash, name)
values ($1, $2, $3)
-returning id, email, name, created_at
+returning id, email, name, github_login, created_at
`
type CreateUserParams struct {
@@ -24,10 +24,11 @@ type CreateUserParams struct {
}
type CreateUserRow struct {
- ID pgtype.UUID `json:"id"`
- Email string `json:"email"`
- Name string `json:"name"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
+ ID pgtype.UUID `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ GithubLogin string `json:"github_login"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error) {
@@ -37,13 +38,14 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateU
&i.ID,
&i.Email,
&i.Name,
+ &i.GithubLogin,
&i.CreatedAt,
)
return i, err
}
const getUserByEmail = `-- name: GetUserByEmail :one
-select id, email, password_hash, name, name_color, avatar_key, created_at
+select id, email, password_hash, name, name_color, avatar_key, github_login, created_at
from users
where lower(email) = lower($1)
`
@@ -55,6 +57,7 @@ type GetUserByEmailRow struct {
Name string `json:"name"`
NameColor pgtype.Text `json:"name_color"`
AvatarKey pgtype.Text `json:"avatar_key"`
+ GithubLogin string `json:"github_login"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
@@ -68,24 +71,26 @@ func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (GetUserByEm
&i.Name,
&i.NameColor,
&i.AvatarKey,
+ &i.GithubLogin,
&i.CreatedAt,
)
return i, err
}
const getUserByID = `-- name: GetUserByID :one
-select id, email, name, name_color, avatar_key, created_at
+select id, email, name, name_color, avatar_key, github_login, created_at
from users
where id = $1
`
type GetUserByIDRow struct {
- ID pgtype.UUID `json:"id"`
- Email string `json:"email"`
- Name string `json:"name"`
- NameColor pgtype.Text `json:"name_color"`
- AvatarKey pgtype.Text `json:"avatar_key"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
+ ID pgtype.UUID `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ NameColor pgtype.Text `json:"name_color"`
+ AvatarKey pgtype.Text `json:"avatar_key"`
+ GithubLogin string `json:"github_login"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error) {
@@ -97,6 +102,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDR
&i.Name,
&i.NameColor,
&i.AvatarKey,
+ &i.GithubLogin,
&i.CreatedAt,
)
return i, err
@@ -104,7 +110,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDR
const updateUserAvatar = `-- name: UpdateUserAvatar :one
update users set avatar_key = $2 where id = $1
-returning id, email, name, name_color, avatar_key, created_at
+returning id, email, name, name_color, avatar_key, github_login, created_at
`
type UpdateUserAvatarParams struct {
@@ -113,12 +119,13 @@ type UpdateUserAvatarParams struct {
}
type UpdateUserAvatarRow struct {
- ID pgtype.UUID `json:"id"`
- Email string `json:"email"`
- Name string `json:"name"`
- NameColor pgtype.Text `json:"name_color"`
- AvatarKey pgtype.Text `json:"avatar_key"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
+ ID pgtype.UUID `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ NameColor pgtype.Text `json:"name_color"`
+ AvatarKey pgtype.Text `json:"avatar_key"`
+ GithubLogin string `json:"github_login"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) UpdateUserAvatar(ctx context.Context, arg UpdateUserAvatarParams) (UpdateUserAvatarRow, error) {
@@ -130,6 +137,42 @@ func (q *Queries) UpdateUserAvatar(ctx context.Context, arg UpdateUserAvatarPara
&i.Name,
&i.NameColor,
&i.AvatarKey,
+ &i.GithubLogin,
+ &i.CreatedAt,
+ )
+ return i, err
+}
+
+const updateUserGitHubLogin = `-- name: UpdateUserGitHubLogin :one
+update users set github_login = $2 where id = $1
+returning id, email, name, name_color, avatar_key, github_login, created_at
+`
+
+type UpdateUserGitHubLoginParams struct {
+ ID pgtype.UUID `json:"id"`
+ GithubLogin string `json:"github_login"`
+}
+
+type UpdateUserGitHubLoginRow struct {
+ ID pgtype.UUID `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ NameColor pgtype.Text `json:"name_color"`
+ AvatarKey pgtype.Text `json:"avatar_key"`
+ GithubLogin string `json:"github_login"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
+}
+
+func (q *Queries) UpdateUserGitHubLogin(ctx context.Context, arg UpdateUserGitHubLoginParams) (UpdateUserGitHubLoginRow, error) {
+ row := q.db.QueryRow(ctx, updateUserGitHubLogin, arg.ID, arg.GithubLogin)
+ var i UpdateUserGitHubLoginRow
+ err := row.Scan(
+ &i.ID,
+ &i.Email,
+ &i.Name,
+ &i.NameColor,
+ &i.AvatarKey,
+ &i.GithubLogin,
&i.CreatedAt,
)
return i, err
@@ -137,7 +180,7 @@ func (q *Queries) UpdateUserAvatar(ctx context.Context, arg UpdateUserAvatarPara
const updateUserNameColor = `-- name: UpdateUserNameColor :one
update users set name_color = $2 where id = $1
-returning id, email, name, name_color, avatar_key, created_at
+returning id, email, name, name_color, avatar_key, github_login, created_at
`
type UpdateUserNameColorParams struct {
@@ -146,12 +189,13 @@ type UpdateUserNameColorParams struct {
}
type UpdateUserNameColorRow struct {
- ID pgtype.UUID `json:"id"`
- Email string `json:"email"`
- Name string `json:"name"`
- NameColor pgtype.Text `json:"name_color"`
- AvatarKey pgtype.Text `json:"avatar_key"`
- CreatedAt pgtype.Timestamptz `json:"created_at"`
+ ID pgtype.UUID `json:"id"`
+ Email string `json:"email"`
+ Name string `json:"name"`
+ NameColor pgtype.Text `json:"name_color"`
+ AvatarKey pgtype.Text `json:"avatar_key"`
+ GithubLogin string `json:"github_login"`
+ CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) UpdateUserNameColor(ctx context.Context, arg UpdateUserNameColorParams) (UpdateUserNameColorRow, error) {
@@ -163,6 +207,7 @@ func (q *Queries) UpdateUserNameColor(ctx context.Context, arg UpdateUserNameCol
&i.Name,
&i.NameColor,
&i.AvatarKey,
+ &i.GithubLogin,
&i.CreatedAt,
)
return i, err
diff --git a/internal/github/client.go b/internal/github/client.go
index 884c905..93019a3 100644
--- a/internal/github/client.go
+++ b/internal/github/client.go
@@ -155,34 +155,64 @@ type GHIssue struct {
Body string `json:"body"`
NodeID string `json:"node_id"`
User struct {
- Login string `json:"login"`
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ Type string `json:"type"` // User | Bot
} `json:"user"`
PullRequest *struct{} `json:"pull_request"` // non-nil means it's a PR
Labels []struct {
Name string `json:"name"`
Color string `json:"color"`
} `json:"labels"`
+ Assignees []struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ } `json:"assignees"`
+ Milestone *struct {
+ Title string `json:"title"`
+ } `json:"milestone"`
+ Comments int `json:"comments"`
+ CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
+// GHIssueComment is one comment on an issue or pull request — GitHub serves
+// both through the issues comments API.
+type GHIssueComment struct {
+ HTMLURL string `json:"html_url"`
+ Body string `json:"body"`
+ User struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ Type string `json:"type"`
+ } `json:"user"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
type PR struct {
- Number int `json:"number"`
- Title string `json:"title"`
- State string `json:"state"`
- Draft bool `json:"draft"`
- Body string `json:"body"`
- NodeID string `json:"node_id"`
- Merged bool `json:"merged"`
- MergedAt *time.Time `json:"merged_at"`
- Mergeable *bool `json:"mergeable"`
- MergeableState string `json:"mergeable_state"`
- Additions int `json:"additions"`
- Deletions int `json:"deletions"`
- ChangedFiles int `json:"changed_files"`
- Commits int `json:"commits"`
- HTMLURL string `json:"html_url"`
+ Number int `json:"number"`
+ Title string `json:"title"`
+ State string `json:"state"`
+ Draft bool `json:"draft"`
+ Body string `json:"body"`
+ NodeID string `json:"node_id"`
+ Merged bool `json:"merged"`
+ MergedAt *time.Time `json:"merged_at"`
+ MergedBy *struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ } `json:"merged_by"`
+ Mergeable *bool `json:"mergeable"`
+ MergeableState string `json:"mergeable_state"`
+ Additions int `json:"additions"`
+ Deletions int `json:"deletions"`
+ ChangedFiles int `json:"changed_files"`
+ Commits int `json:"commits"`
+ HTMLURL string `json:"html_url"`
User struct {
- Login string `json:"login"`
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ Type string `json:"type"` // User | Bot
} `json:"user"`
Head struct {
Ref string `json:"ref"`
@@ -192,8 +222,21 @@ type PR struct {
Ref string `json:"ref"`
} `json:"base"`
Labels []struct {
- Name string `json:"name"`
+ Name string `json:"name"`
+ Color string `json:"color"`
} `json:"labels"`
+ Assignees []struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ } `json:"assignees"`
+ RequestedReviewers []struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ } `json:"requested_reviewers"`
+ RequestedTeams []struct {
+ Slug string `json:"slug"`
+ Name string `json:"name"`
+ } `json:"requested_teams"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
@@ -783,6 +826,153 @@ func (c *Client) CreateIssueComment(ctx context.Context, installID int64, owner,
tok, bytes.NewReader(payload), nil)
}
+// IssuePatch carries the fields PATCH issues/{n} accepts — labels and
+// assignees both REPLACE the whole set when non-nil, so callers send the
+// full desired list, not a delta.
+type IssuePatch struct {
+ Labels *[]string `json:"labels,omitempty"`
+ Assignees *[]string `json:"assignees,omitempty"`
+ Title string `json:"title,omitempty"`
+ Body *string `json:"body,omitempty"`
+}
+
+// UpdateIssue edits a GitHub issue — works on PRs too, they share the
+// issues endpoint upstream (labels/assignees on a PR go through here).
+func (c *Client) UpdateIssue(ctx context.Context, installID int64, owner, repo string, number int, patch IssuePatch) (*GHIssue, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ payload, _ := json.Marshal(patch)
+ var out GHIssue
+ err = c.do(ctx, "PATCH",
+ fmt.Sprintf("%s/repos/%s/%s/issues/%d", apiBase, owner, repo, number),
+ tok, bytes.NewReader(payload), &out)
+ return &out, err
+}
+
+// RepoLabel is one label defined on the repository.
+type RepoLabel struct {
+ Name string `json:"name"`
+ Color string `json:"color"`
+ Description string `json:"description"`
+}
+
+// ListRepoLabels returns the repo's label catalog — the picker options for
+// label editing. First page (100) covers almost every repo.
+func (c *Client) ListRepoLabels(ctx context.Context, installID int64, owner, repo string) ([]RepoLabel, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ var out []RepoLabel
+ err = c.do(ctx, "GET",
+ fmt.Sprintf("%s/repos/%s/%s/labels?per_page=100", apiBase, owner, repo),
+ tok, nil, &out)
+ return out, err
+}
+
+// CreateRepoLabel defines a new label on the repository. color is a 6-char
+// hex string without '#'; empty lets GitHub pick.
+func (c *Client) CreateRepoLabel(ctx context.Context, installID int64, owner, repo, name, color, description string) (*RepoLabel, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ payload, _ := json.Marshal(map[string]string{
+ "name": name, "color": color, "description": description,
+ })
+ var out RepoLabel
+ err = c.do(ctx, "POST",
+ fmt.Sprintf("%s/repos/%s/%s/labels", apiBase, owner, repo),
+ tok, bytes.NewReader(payload), &out)
+ return &out, err
+}
+
+// GHUser is GitHub's compact user object — login/avatar/type.
+type GHUser struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ Type string `json:"type"` // User | Bot
+}
+
+// ListRepoAssignees returns users issues may be assigned to — collaborators
+// and org members. First page (100).
+func (c *Client) ListRepoAssignees(ctx context.Context, installID int64, owner, repo string) ([]GHUser, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ var out []GHUser
+ err = c.do(ctx, "GET",
+ fmt.Sprintf("%s/repos/%s/%s/assignees?per_page=100", apiBase, owner, repo),
+ tok, nil, &out)
+ return out, err
+}
+
+// PRReview is one submitted review on a pull request.
+type PRReview struct {
+ User struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ Type string `json:"type"`
+ } `json:"user"`
+ State string `json:"state"` // APPROVED | CHANGES_REQUESTED | COMMENTED | DISMISSED | PENDING
+ SubmittedAt time.Time `json:"submitted_at"`
+}
+
+// ListPRReviews returns submitted reviews on a PR — the REST stand-in for
+// GraphQL's reviewDecision. Caller reduces to latest-per-reviewer.
+func (c *Client) ListPRReviews(ctx context.Context, installID int64, owner, repo string, number int) ([]PRReview, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ var out []PRReview
+ err = c.do(ctx, "GET",
+ fmt.Sprintf("%s/repos/%s/%s/pulls/%d/reviews?per_page=100", apiBase, owner, repo, number),
+ tok, nil, &out)
+ return out, err
+}
+
+// ListPRCommentCounts returns issue-thread comment counts keyed by PR
+// number. The pulls endpoint omits the count; the issues endpoint carries
+// it on PR entries, which the issue listers fold out — so this walks the
+// issues endpoint raw and keeps only PR rows.
+func (c *Client) ListPRCommentCounts(ctx context.Context, installID int64, owner, repo, state string) (map[int]int, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ out := map[int]int{}
+ u := fmt.Sprintf("%s/repos/%s/%s/issues?state=%s", apiBase, owner, repo, url.QueryEscape(state))
+ err = c.listPaged(ctx, tok, u, func(dec *json.Decoder) error {
+ var i GHIssue
+ if err := dec.Decode(&i); err != nil {
+ return err
+ }
+ if i.PullRequest != nil {
+ out[i.Number] = i.Comments
+ }
+ return nil
+ })
+ return out, err
+}
+
+// ListIssueComments returns the comment thread on an issue or PR — both
+// ride the issues comments API. First page, oldest first.
+func (c *Client) ListIssueComments(ctx context.Context, installID int64, owner, repo string, number int) ([]GHIssueComment, error) {
+ tok, err := c.installationToken(ctx, installID)
+ if err != nil {
+ return nil, err
+ }
+ var out []GHIssueComment
+ err = c.do(ctx, "GET",
+ fmt.Sprintf("%s/repos/%s/%s/issues/%d/comments?per_page=100", apiBase, owner, repo, number),
+ tok, nil, &out)
+ return out, err
+}
+
// CreatePR opens a pull request on GitHub.
func (c *Client) CreatePR(ctx context.Context, installID int64, owner, repo, head, base, title, body string, draft bool) (*PR, error) {
tok, err := c.installationToken(ctx, installID)
diff --git a/internal/github/github.go b/internal/github/github.go
index fa406ba..5a1ea0f 100644
--- a/internal/github/github.go
+++ b/internal/github/github.go
@@ -17,6 +17,7 @@ import (
"net/http"
"net/url"
"os/exec"
+ "regexp"
"sort"
"strconv"
"strings"
@@ -97,6 +98,12 @@ func (s *Service) RegisterRoutes(g *gin.RouterGroup, pub *gin.RouterGroup) {
g.GET("/projects/:id/github/files", s.projectMemberOnly, s.handleRepoTree)
g.GET("/projects/:id/github/files/read", s.projectMemberOnly, s.handleRepoFile)
g.GET("/projects/:id/github/pull", s.projectMemberOnly, s.handlePullDetail)
+ g.GET("/projects/:id/github/issue", s.projectMemberOnly, s.handleIssueDetail)
+ g.POST("/projects/:id/github/issues/state", s.projectMemberOnly, s.handleIssueState)
+ g.POST("/projects/:id/github/issues/update", s.projectMemberOnly, s.handleIssueUpdate)
+ g.GET("/projects/:id/github/labels", s.projectMemberOnly, s.handleRepoLabels)
+ g.POST("/projects/:id/github/labels", s.projectMemberOnly, s.handleCreateLabel)
+ g.GET("/projects/:id/github/assignees", s.projectMemberOnly, s.handleRepoAssignees)
g.POST("/projects/:id/github/pulls", s.projectMemberOnly, s.handleCreatePull)
g.POST("/projects/:id/github/issues", s.projectMemberOnly, s.handleCreateGitHubIssue)
g.POST("/messages/:id/github", s.handleFileMessage)
@@ -107,6 +114,7 @@ func (s *Service) RegisterRoutes(g *gin.RouterGroup, pub *gin.RouterGroup) {
g.GET("/projects/:id/github/actions", s.projectMemberOnly, s.handleActions)
g.POST("/projects/:id/github/actions/rerun", s.projectMemberOnly, s.handleActionRerun)
g.GET("/workspaces/:id/github/pulls", s.memberOnly, s.handleWorkspacePulls)
+ g.GET("/workspaces/:id/github/issues", s.memberOnly, s.handleWorkspaceIssues)
g.GET("/projects/:id/github/commits", s.projectMemberOnly, s.handleCommits)
g.GET("/projects/:id/github/commit", s.projectMemberOnly, s.handleCommitDetail)
g.GET("/projects/:id/github/branches", s.projectMemberOnly, s.handleBranches)
@@ -648,6 +656,8 @@ func (s *Service) handleDevelopment(c *gin.Context) {
panel.Issues = append(panel.Issues, gin.H{
"number": i.Number, "title": i.Title, "state": i.State,
"url": i.HTMLURL, "author": i.User.Login,
+ "avatar_url": i.User.AvatarURL, "author_type": i.User.Type,
+ "comments": i.Comments,
"updated_at": i.UpdatedAt,
})
}
@@ -657,6 +667,7 @@ func (s *Service) handleDevelopment(c *gin.Context) {
panel.PRs = append(panel.PRs, gin.H{
"number": pr.Number, "title": pr.Title, "state": pr.State,
"draft": pr.Draft, "url": pr.HTMLURL, "author": pr.User.Login,
+ "avatar_url": pr.User.AvatarURL, "author_type": pr.User.Type,
"head": pr.Head.Ref, "base": pr.Base.Ref,
"updated_at": pr.UpdatedAt,
})
@@ -734,6 +745,7 @@ func (s *Service) handlePullDetail(c *gin.Context) {
if pr.Head.SHA != "" {
checks, _ = cli.ListCheckRuns(ctx, repo.InstallationID, repo.Owner, repo.Name, pr.Head.SHA)
}
+ reviews, _ := cli.ListPRReviews(ctx, repo.InstallationID, repo.Owner, repo.Name, number)
mergeable := ""
if pr.Mergeable != nil {
if *pr.Mergeable {
@@ -742,9 +754,31 @@ func (s *Service) handlePullDetail(c *gin.Context) {
mergeable = "conflicting"
}
}
- labels := make([]string, 0, len(pr.Labels))
+ labels := make([]gin.H, 0, len(pr.Labels))
for _, l := range pr.Labels {
- labels = append(labels, l.Name)
+ labels = append(labels, gin.H{"name": l.Name, "color": l.Color})
+ }
+ assignees := make([]gin.H, 0, len(pr.Assignees))
+ for _, a := range pr.Assignees {
+ assignees = append(assignees, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ reviewers := make([]gin.H, 0, len(pr.RequestedReviewers))
+ for _, a := range pr.RequestedReviewers {
+ reviewers = append(reviewers, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ teams := make([]gin.H, 0, len(pr.RequestedTeams))
+ for _, t := range pr.RequestedTeams {
+ teams = append(teams, gin.H{"slug": t.Slug, "name": t.Name})
+ }
+ var mergedBy gin.H
+ if pr.MergedBy != nil {
+ mergedBy = gin.H{
+ "login": pr.MergedBy.Login, "avatar_url": pr.MergedBy.AvatarURL,
+ }
}
outFiles := make([]gin.H, 0, len(files))
for _, f := range files {
@@ -768,22 +802,53 @@ func (s *Service) handlePullDetail(c *gin.Context) {
"conclusion": ch.Conclusion, "url": ch.HTMLURL,
})
}
+ // Latest submitted state per reviewer — DISMISSED cancels that reviewer's
+ // earlier vote. COMMENTED reviews count as activity, not a decision.
+ latest := map[string]gin.H{}
+ for _, rv := range reviews {
+ latest[rv.User.Login] = gin.H{
+ "login": rv.User.Login, "avatar_url": rv.User.AvatarURL,
+ "state": rv.State, "submitted_at": rv.SubmittedAt,
+ }
+ }
+ outReviews := make([]gin.H, 0, len(latest))
+ decision := ""
+ for _, rv := range latest {
+ outReviews = append(outReviews, rv)
+ switch rv["state"] {
+ case "CHANGES_REQUESTED":
+ decision = "changes_requested"
+ case "APPROVED":
+ if decision == "" {
+ decision = "approved"
+ }
+ }
+ }
+ if decision == "" && len(pr.RequestedReviewers) > 0 {
+ decision = "pending"
+ }
c.JSON(http.StatusOK, gin.H{
"pull": gin.H{
"number": pr.Number, "title": pr.Title, "state": pr.State,
"draft": pr.Draft, "merged": pr.Merged, "merged_at": pr.MergedAt,
"mergeable": mergeable, "mergeable_state": pr.MergeableState,
"body": pr.Body, "url": pr.HTMLURL, "author": pr.User.Login,
+ "avatar_url": pr.User.AvatarURL, "author_type": pr.User.Type,
"head": pr.Head.Ref, "base": pr.Base.Ref,
"additions": pr.Additions, "deletions": pr.Deletions,
"changed_files": pr.ChangedFiles, "commit_count": pr.Commits,
- "labels": labels,
+ "labels": labels,
+ "assignees": assignees, "reviewers": reviewers,
+ "teams": teams,
+ "merged_by": mergedBy,
"created_at": pr.CreatedAt, "updated_at": pr.UpdatedAt,
"repo": repoJSON(repo),
},
- "files": outFiles,
- "commits": outCommits,
- "checks": outChecks,
+ "files": outFiles,
+ "commits": outCommits,
+ "checks": outChecks,
+ "reviews": outReviews,
+ "review_decision": decision,
})
}
@@ -1090,6 +1155,259 @@ func (s *Service) handleCreatePull(c *gin.Context) {
})
}
+// handleIssueDetail bundles a GitHub issue with its comment thread for the
+// in-app issue view — sibling of handlePullDetail.
+func (s *Service) handleIssueDetail(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ number, err := strconv.Atoi(c.Query("number"))
+ if err != nil || number <= 0 {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "number is required")
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+
+ iss, err := cli.GetIssue(ctx, repo.InstallationID, repo.Owner, repo.Name, number)
+ if err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", "could not load the issue")
+ return
+ }
+ // Comments are supplementary — a failure degrades to an empty thread.
+ comments, _ := cli.ListIssueComments(ctx, repo.InstallationID, repo.Owner, repo.Name, number)
+
+ labels := make([]gin.H, 0, len(iss.Labels))
+ for _, l := range iss.Labels {
+ labels = append(labels, gin.H{"name": l.Name, "color": l.Color})
+ }
+ assignees := make([]gin.H, 0, len(iss.Assignees))
+ for _, a := range iss.Assignees {
+ assignees = append(assignees, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ outComments := make([]gin.H, 0, len(comments))
+ for _, cm := range comments {
+ outComments = append(outComments, gin.H{
+ "body": cm.Body, "url": cm.HTMLURL,
+ "author": cm.User.Login, "avatar_url": cm.User.AvatarURL,
+ "author_type": cm.User.Type, "created_at": cm.CreatedAt,
+ })
+ }
+ issue := gin.H{
+ "number": iss.Number, "title": iss.Title, "state": iss.State,
+ "body": iss.Body, "url": iss.HTMLURL, "author": iss.User.Login,
+ "avatar_url": iss.User.AvatarURL, "author_type": iss.User.Type,
+ "labels": labels,
+ "assignees": assignees, "comment_count": iss.Comments,
+ "created_at": iss.CreatedAt, "updated_at": iss.UpdatedAt,
+ }
+ if iss.Milestone != nil {
+ issue["milestone"] = iss.Milestone.Title
+ }
+ c.JSON(http.StatusOK, gin.H{
+ "issue": issue,
+ "comments": outComments,
+ "repo": repoJSON(repo),
+ })
+}
+
+// handleIssueState closes or reopens a GitHub issue — mirror of the pull
+// state endpoint.
+func (s *Service) handleIssueState(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ var req struct {
+ Number int `json:"number"`
+ State string `json:"state"`
+ }
+ if err := c.ShouldBindJSON(&req); err != nil || req.Number <= 0 ||
+ (req.State != "open" && req.State != "closed") {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "number and state open|closed are required")
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+ if err := cli.SetIssueState(ctx, repo.InstallationID, repo.Owner, repo.Name,
+ req.Number, req.State); err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", truncate(err.Error(), 300))
+ return
+ }
+ s.invalidateDevPanel(p.ID)
+ c.JSON(http.StatusOK, gin.H{"state": req.State})
+}
+
+// handleRepoLabels returns the repo's label catalog — picker options for
+// the issue/PR label editor.
+func (s *Service) handleRepoLabels(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+ labels, err := cli.ListRepoLabels(ctx, repo.InstallationID, repo.Owner, repo.Name)
+ if err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", truncate(err.Error(), 300))
+ return
+ }
+ out := make([]gin.H, 0, len(labels))
+ for _, l := range labels {
+ out = append(out, gin.H{
+ "name": l.Name, "color": l.Color, "description": l.Description,
+ })
+ }
+ c.JSON(http.StatusOK, gin.H{"labels": out})
+}
+
+var labelColorPattern = regexp.MustCompile(`^[0-9a-fA-F]{6}$`)
+
+// handleCreateLabel defines a new label on the linked repo — feeds the
+// "new label" affordance in the issue/PR meta editor.
+func (s *Service) handleCreateLabel(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ var req struct {
+ Name string `json:"name"`
+ Color string `json:"color"`
+ Description string `json:"description"`
+ }
+ if err := c.ShouldBindJSON(&req); err != nil ||
+ strings.TrimSpace(req.Name) == "" {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "name is required")
+ return
+ }
+ color := strings.TrimPrefix(strings.TrimSpace(req.Color), "#")
+ if color != "" && !labelColorPattern.MatchString(color) {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "color must be a 6-char hex")
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+ l, err := cli.CreateRepoLabel(ctx, repo.InstallationID, repo.Owner, repo.Name,
+ strings.TrimSpace(req.Name), color, req.Description)
+ if err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", truncate(err.Error(), 300))
+ return
+ }
+ c.JSON(http.StatusCreated, gin.H{
+ "name": l.Name, "color": l.Color, "description": l.Description,
+ })
+}
+
+// handleRepoAssignees returns the repo's assignable users — picker options
+// for the issue/PR assignee editor.
+func (s *Service) handleRepoAssignees(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+ users, err := cli.ListRepoAssignees(ctx, repo.InstallationID, repo.Owner, repo.Name)
+ if err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", truncate(err.Error(), 300))
+ return
+ }
+ out := make([]gin.H, 0, len(users))
+ for _, u := range users {
+ out = append(out, gin.H{
+ "login": u.Login, "avatar_url": u.AvatarURL, "type": u.Type,
+ })
+ }
+ c.JSON(http.StatusOK, gin.H{"users": out})
+}
+
+// handleIssueUpdate edits labels/assignees on a GitHub issue — PATCH
+// replaces each set wholesale when provided. Works on PR numbers too.
+func (s *Service) handleIssueUpdate(c *gin.Context) {
+ p := project(c)
+ repo, ok := s.linkedRepo(c, p)
+ if !ok {
+ return
+ }
+ var req struct {
+ Number int `json:"number"`
+ Labels *[]string `json:"labels"`
+ Assignees *[]string `json:"assignees"`
+ Title *string `json:"title"`
+ Body *string `json:"body"`
+ }
+ if err := c.ShouldBindJSON(&req); err != nil || req.Number <= 0 ||
+ (req.Labels == nil && req.Assignees == nil && req.Title == nil && req.Body == nil) {
+ httpx.Error(c, http.StatusBadRequest, "bad_request", "number plus at least one field to update are required")
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 15*time.Second)
+ defer cancel()
+ patch := IssuePatch{Labels: req.Labels, Assignees: req.Assignees, Body: req.Body}
+ if req.Title != nil {
+ patch.Title = *req.Title
+ }
+ iss, err := cli.UpdateIssue(ctx, repo.InstallationID, repo.Owner, repo.Name,
+ req.Number, patch)
+ if err != nil {
+ httpx.Error(c, http.StatusBadGateway, "github_error", truncate(err.Error(), 300))
+ return
+ }
+ s.invalidateDevPanel(p.ID)
+ labels := make([]gin.H, 0, len(iss.Labels))
+ for _, l := range iss.Labels {
+ labels = append(labels, gin.H{"name": l.Name, "color": l.Color})
+ }
+ assignees := make([]gin.H, 0, len(iss.Assignees))
+ for _, a := range iss.Assignees {
+ assignees = append(assignees, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ c.JSON(http.StatusOK, gin.H{
+ "title": iss.Title, "body": iss.Body,
+ "labels": labels, "assignees": assignees,
+ })
+}
+
// handleIssueComment posts a comment on a GitHub issue or pull request —
// both ride the issues comments API upstream.
func (s *Service) handleIssueComment(c *gin.Context) {
@@ -1134,7 +1452,8 @@ func (s *Service) invalidateDevPanel(projectID pgtype.UUID) {
// that group rather than blanking the whole view.
func (s *Service) handleWorkspacePulls(c *gin.Context) {
wsID, _ := httpx.PathUUID(c, "id")
- key := "wspulls:" + wsID.String()
+ state := c.DefaultQuery("state", "open")
+ key := "wspulls:" + wsID.String() + ":" + state
if v, ok := s.cache.Load(key); ok {
if e := v.(cacheEntry); time.Now().Before(e.expiry) {
c.JSON(http.StatusOK, e.data)
@@ -1169,7 +1488,10 @@ func (s *Service) handleWorkspacePulls(c *gin.Context) {
for i := range jobs {
r := repos[i]
ctx, cancel := context.WithTimeout(c.Request.Context(), 12*time.Second)
- prs, err := cli.ListPRs(ctx, r.InstallationID, r.Owner, r.Name)
+ prs, err := cli.ListPRsWithState(ctx, r.InstallationID, r.Owner, r.Name, state)
+ // Comment counts ride the issues endpoint — best-effort, a
+ // failure here degrades the field, not the whole group.
+ counts, _ := cli.ListPRCommentCounts(ctx, r.InstallationID, r.Owner, r.Name, state)
cancel()
if err != nil {
s.log.Warn("workspace pulls", zap.String("repo", r.Owner+"/"+r.Name), zap.Error(err))
@@ -1178,14 +1500,34 @@ func (s *Service) handleWorkspacePulls(c *gin.Context) {
}
out := make([]gin.H, 0, len(prs))
for _, pr := range prs {
- labels := make([]string, 0, len(pr.Labels))
+ labels := make([]gin.H, 0, len(pr.Labels))
for _, l := range pr.Labels {
- labels = append(labels, l.Name)
+ labels = append(labels, gin.H{"name": l.Name, "color": l.Color})
+ }
+ assignees := make([]gin.H, 0, len(pr.Assignees))
+ for _, a := range pr.Assignees {
+ assignees = append(assignees, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ reviewers := make([]gin.H, 0, len(pr.RequestedReviewers))
+ for _, a := range pr.RequestedReviewers {
+ reviewers = append(reviewers, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ teams := make([]gin.H, 0, len(pr.RequestedTeams))
+ for _, t := range pr.RequestedTeams {
+ teams = append(teams, gin.H{"slug": t.Slug, "name": t.Name})
}
out = append(out, gin.H{
"number": pr.Number, "title": pr.Title, "state": pr.State,
"draft": pr.Draft, "url": pr.HTMLURL, "author": pr.User.Login,
- "head": pr.Head.Ref, "base": pr.Base.Ref, "labels": labels,
+ "avatar_url": pr.User.AvatarURL, "author_type": pr.User.Type,
+ "merged_at": pr.MergedAt,
+ "head": pr.Head.Ref, "base": pr.Base.Ref, "labels": labels,
+ "assignees": assignees, "reviewers": reviewers, "teams": teams,
+ "comments": counts[pr.Number],
"created_at": pr.CreatedAt, "updated_at": pr.UpdatedAt,
})
}
@@ -1204,9 +1546,11 @@ func (s *Service) handleWorkspacePulls(c *gin.Context) {
pulls[res.idx] = res.pulls
}
groups := make([]gin.H, 0, len(repos))
+ var failed []string
for i, r := range repos {
if pulls[i] == nil {
- continue // repo call failed
+ failed = append(failed, r.Owner+"/"+r.Name) // repo call failed
+ continue
}
groups = append(groups, gin.H{
"project_id": r.ProjectID.String(),
@@ -1219,7 +1563,123 @@ func (s *Service) handleWorkspacePulls(c *gin.Context) {
"pulls": pulls[i],
})
}
- payload := gin.H{"groups": groups, "fetched_at": time.Now()}
+ payload := gin.H{"groups": groups, "failed": failed, "fetched_at": time.Now()}
+ s.cache.Store(key, cacheEntry{data: payload, expiry: time.Now().Add(60 * time.Second)})
+ c.JSON(http.StatusOK, payload)
+}
+
+// handleWorkspaceIssues aggregates open issues across every linked repo in
+// the workspace — sibling of handleWorkspacePulls. issue_id links the row to
+// its mirrored Relay issue when one exists, so rows can deep-link in-app.
+func (s *Service) handleWorkspaceIssues(c *gin.Context) {
+ wsID, _ := httpx.PathUUID(c, "id")
+ state := c.DefaultQuery("state", "open")
+ key := "wsissues:" + wsID.String() + ":" + state
+ if v, ok := s.cache.Load(key); ok {
+ if e := v.(cacheEntry); time.Now().Before(e.expiry) {
+ c.JSON(http.StatusOK, e.data)
+ return
+ }
+ }
+ repos, err := s.q.ListWorkspaceRepoProjects(c.Request.Context(), wsID)
+ if err != nil {
+ httpx.Error(c, http.StatusInternalServerError, "internal", "internal error")
+ return
+ }
+ cli, err := s.githubClient(c.Request.Context())
+ if err != nil {
+ httpx.Error(c, http.StatusBadRequest, "not_registered", "GitHub is not connected")
+ return
+ }
+ type result struct {
+ idx int
+ issues []gin.H
+ }
+ jobs := make(chan int, len(repos))
+ results := make(chan result, len(repos))
+ workers := 4
+ if len(repos) < workers {
+ workers = len(repos)
+ }
+ var wg sync.WaitGroup
+ for range workers {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for i := range jobs {
+ r := repos[i]
+ ctx, cancel := context.WithTimeout(c.Request.Context(), 12*time.Second)
+ list, err := cli.ListIssuesWithState(ctx, r.InstallationID, r.Owner, r.Name, state)
+ if err != nil {
+ cancel()
+ s.log.Warn("workspace issues", zap.String("repo", r.Owner+"/"+r.Name), zap.Error(err))
+ results <- result{i, nil}
+ continue
+ }
+ out := make([]gin.H, 0, len(list))
+ for _, iss := range list {
+ labels := make([]gin.H, 0, len(iss.Labels))
+ for _, l := range iss.Labels {
+ labels = append(labels, gin.H{"name": l.Name, "color": l.Color})
+ }
+ assignees := make([]gin.H, 0, len(iss.Assignees))
+ for _, a := range iss.Assignees {
+ assignees = append(assignees, gin.H{
+ "login": a.Login, "avatar_url": a.AvatarURL,
+ })
+ }
+ entry := gin.H{
+ "number": iss.Number, "title": iss.Title, "state": iss.State,
+ "url": iss.HTMLURL, "author": iss.User.Login,
+ "avatar_url": iss.User.AvatarURL, "author_type": iss.User.Type,
+ "labels": labels,
+ "assignees": assignees, "comments": iss.Comments,
+ "created_at": iss.CreatedAt, "updated_at": iss.UpdatedAt,
+ }
+ if iss.Milestone != nil {
+ entry["milestone"] = iss.Milestone.Title
+ }
+ if mirrored, err := s.q.FindIssueByGitHub(ctx, db.FindIssueByGitHubParams{
+ RepoID: r.ID, Number: pgtype.Int4{Int32: int32(iss.Number), Valid: true},
+ }); err == nil {
+ entry["issue_id"] = mirrored.ID.String()
+ }
+ out = append(out, entry)
+ }
+ cancel()
+ results <- result{i, out}
+ }
+ }()
+ }
+ for i := range repos {
+ jobs <- i
+ }
+ close(jobs)
+ wg.Wait()
+ close(results)
+ issues := make([][]gin.H, len(repos))
+ for res := range results {
+ issues[res.idx] = res.issues
+ }
+ groups := make([]gin.H, 0, len(repos))
+ var failed []string
+ for i, r := range repos {
+ if issues[i] == nil {
+ failed = append(failed, r.Owner+"/"+r.Name) // repo call failed
+ continue
+ }
+ groups = append(groups, gin.H{
+ "project_id": r.ProjectID.String(),
+ "project_name": r.ProjectName,
+ "project_key": r.ProjectKey,
+ "repo": repoJSON(db.Repository{
+ ID: r.ID, Owner: r.Owner, Name: r.Name,
+ DefaultBranch: r.DefaultBranch, InstallationID: r.InstallationID,
+ }),
+ "issues": issues[i],
+ })
+ }
+ payload := gin.H{"groups": groups, "failed": failed, "fetched_at": time.Now()}
s.cache.Store(key, cacheEntry{data: payload, expiry: time.Now().Add(60 * time.Second)})
c.JSON(http.StatusOK, payload)
}
@@ -1409,6 +1869,10 @@ type webhookPayload struct {
State string `json:"state"`
NodeID string `json:"node_id"`
HTMLURL string `json:"html_url"`
+ User struct {
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
+ } `json:"user"`
} `json:"issue"`
PullRequest *struct {
Number int `json:"number"`
@@ -1420,7 +1884,8 @@ type webhookPayload struct {
NodeID string `json:"node_id"`
HTMLURL string `json:"html_url"`
User struct {
- Login string `json:"login"`
+ Login string `json:"login"`
+ AvatarURL string `json:"avatar_url"`
} `json:"user"`
} `json:"pull_request"`
}
@@ -1569,6 +2034,7 @@ func (s *Service) onIssue(ctx context.Context, p webhookPayload) {
url: p.Issue.HTMLURL,
nodeID: p.Issue.NodeID,
status: issueStatus(p.Issue.State),
+ author: p.Issue.User.Login, avatarURL: p.Issue.User.AvatarURL,
}
_, created, _, err := s.upsertGitHub(ctx, repo, item)
if err != nil {
@@ -1600,15 +2066,17 @@ func (s *Service) publishIssue(projectID pgtype.UUID, issueID pgtype.UUID, creat
// importItem is one GitHub object normalized for upsertGitHub.
type importItem struct {
- kind string // 'issue' | 'pr'
- number int
- title string
- body string
- state string // raw GitHub state: open|closed|merged
- url string
- nodeID string
- status string // mapped Relay status
- issueID pgtype.UUID // filled by upsertGitHub
+ kind string // 'issue' | 'pr'
+ number int
+ title string
+ body string
+ state string // raw GitHub state: open|closed|merged
+ url string
+ nodeID string
+ status string // mapped Relay status
+ author string // GitHub login of whoever filed it
+ avatarURL string // their avatar — hotlinked, never stored
+ issueID pgtype.UUID // filled by upsertGitHub
}
// issueStatus maps a GitHub issue state onto a Relay status.
@@ -1653,9 +2121,11 @@ func (s *Service) upsertGitHub(ctx context.Context, repo db.Repository, in impor
Status: in.status,
NodeID: pgtype.Text{String: in.nodeID, Valid: in.nodeID != ""},
RepoID: repo.ID, GhNumber: pgtype.Int4{Int32: int32(in.number), Valid: true},
- Kind: in.kind,
- GhState: pgtype.Text{String: in.state, Valid: in.state != ""},
- GhUrl: pgtype.Text{String: in.url, Valid: in.url != ""},
+ Kind: in.kind,
+ GhState: pgtype.Text{String: in.state, Valid: in.state != ""},
+ GhUrl: pgtype.Text{String: in.url, Valid: in.url != ""},
+ GhAuthor: pgtype.Text{String: in.author, Valid: in.author != ""},
+ GhAvatarUrl: pgtype.Text{String: in.avatarURL, Valid: in.avatarURL != ""},
})
if err != nil {
return pgtype.UUID{}, false, false, err
@@ -1667,9 +2137,14 @@ func (s *Service) upsertGitHub(ctx context.Context, repo db.Repository, in impor
return pgtype.UUID{}, false, false, err
}
desc := truncate(in.body, 40000)
+ // Webhook payloads lack avatar_url — treat empty incoming fields as
+ // "no data" rather than a change to blank.
+ authorMoved := in.author != "" && existing.GithubAuthor.String != in.author
+ avatarMoved := in.avatarURL != "" && existing.GithubAvatarUrl.String != in.avatarURL
if existing.Status == in.status && existing.Title == in.title &&
existing.Description == desc &&
- existing.GithubState.String == in.state && existing.GithubUrl.String == in.url {
+ existing.GithubState.String == in.state && existing.GithubUrl.String == in.url &&
+ !authorMoved && !avatarMoved {
return existing.ID, false, false, nil
}
if existing.Status != in.status {
@@ -1683,6 +2158,8 @@ func (s *Service) upsertGitHub(ctx context.Context, repo db.Repository, in impor
Status: pgtype.Text{String: in.status, Valid: true},
GhState: pgtype.Text{String: in.state, Valid: in.state != ""},
GhUrl: pgtype.Text{String: in.url, Valid: in.url != ""},
+ GhAuthor: pgtype.Text{String: in.author, Valid: in.author != ""},
+ GhAvatarUrl: pgtype.Text{String: in.avatarURL, Valid: in.avatarURL != ""},
})
return row.ID, false, true, err
}
@@ -1695,6 +2172,7 @@ func (s *Service) MirrorIssue(ctx context.Context, repo db.Repository, i GHIssue
kind: "issue", number: i.Number, title: i.Title, body: i.Body,
state: i.State, url: i.HTMLURL, nodeID: i.NodeID,
status: issueStatus(i.State),
+ author: i.User.Login, avatarURL: i.User.AvatarURL,
})
return id, err
}
@@ -1705,6 +2183,7 @@ func (s *Service) MirrorPR(ctx context.Context, repo db.Repository, p PR) (pgtyp
kind: "pr", number: p.Number, title: p.Title, body: p.Body,
state: p.State, url: p.HTMLURL, nodeID: p.NodeID,
status: prStatus(p.State, p.Merged, p.Draft),
+ author: p.User.Login, avatarURL: p.User.AvatarURL,
})
return id, err
}
@@ -1744,6 +2223,7 @@ func (s *Service) onPullRequest(ctx context.Context, p webhookPayload) {
url: pr.HTMLURL,
nodeID: pr.NodeID,
status: prStatus(pr.State, pr.Merged, pr.Draft),
+ author: pr.User.Login, avatarURL: pr.User.AvatarURL,
}
_, created, _, err := s.upsertGitHub(ctx, repo, item)
if err != nil {
@@ -1843,6 +2323,7 @@ func (s *Service) importRepo(ctx context.Context, cli *Client, repo db.Repositor
kind: "issue", number: gi.Number, title: gi.Title, body: gi.Body,
state: gi.State, url: gi.HTMLURL, nodeID: gi.NodeID,
status: issueStatus(gi.State),
+ author: gi.User.Login, avatarURL: gi.User.AvatarURL,
}
id, created, _, err := s.upsertGitHub(ctx, repo, item)
if err != nil {
@@ -1861,6 +2342,7 @@ func (s *Service) importRepo(ctx context.Context, cli *Client, repo db.Repositor
kind: "pr", number: pr.Number, title: pr.Title, body: pr.Body,
state: state, url: pr.HTMLURL, nodeID: pr.NodeID,
status: prStatus(pr.State, pr.MergedAt != nil, pr.Draft),
+ author: pr.User.Login, avatarURL: pr.User.AvatarURL,
}
_, created, _, err := s.upsertGitHub(ctx, repo, item)
if err != nil {
@@ -1952,6 +2434,7 @@ func (s *Service) reconcileRepo(ctx context.Context, cli *Client, repo db.Reposi
kind: "issue", number: gi.Number, title: gi.Title, body: gi.Body,
state: gi.State, url: gi.HTMLURL, nodeID: gi.NodeID,
status: issueStatus(gi.State),
+ author: gi.User.Login, avatarURL: gi.User.AvatarURL,
})
}
prs, err := cli.ListPRsRecently(ctx, repo.InstallationID, repo.Owner, repo.Name)
@@ -1967,6 +2450,7 @@ func (s *Service) reconcileRepo(ctx context.Context, cli *Client, repo db.Reposi
kind: "pr", number: pr.Number, title: pr.Title, body: pr.Body,
state: state, url: pr.HTMLURL, nodeID: pr.NodeID,
status: prStatus(pr.State, pr.MergedAt != nil, pr.Draft),
+ author: pr.User.Login, avatarURL: pr.User.AvatarURL,
})
}
}
diff --git a/internal/issues/issues.go b/internal/issues/issues.go
index 3d42016..50e04d7 100644
--- a/internal/issues/issues.go
+++ b/internal/issues/issues.go
@@ -783,6 +783,12 @@ func issueJSON(i db.Issue, assigneeName, assigneeAvatar pgtype.Text, labels []gi
"state": state,
"url": url,
}
+ if i.GithubAuthor.Valid && i.GithubAuthor.String != "" {
+ out["github"].(gin.H)["author"] = i.GithubAuthor.String
+ }
+ if i.GithubAvatarUrl.Valid && i.GithubAvatarUrl.String != "" {
+ out["github"].(gin.H)["avatar_url"] = i.GithubAvatarUrl.String
+ }
}
return out
}
@@ -803,6 +809,7 @@ func listRowToIssue(r db.ListIssuesForUserRow) db.Issue {
GithubNodeID: r.GithubNodeID, GithubRepoID: r.GithubRepoID,
GithubNumber: r.GithubNumber, Origin: r.Origin,
GithubKind: r.GithubKind, GithubState: r.GithubState, GithubUrl: r.GithubUrl,
+ GithubAuthor: r.GithubAuthor, GithubAvatarUrl: r.GithubAvatarUrl,
CreatedAt: r.CreatedAt, UpdatedAt: r.UpdatedAt,
}
}
@@ -815,6 +822,7 @@ func forUserRowToIssue(r db.GetIssueForUserRow) db.Issue {
GithubNodeID: r.GithubNodeID, GithubRepoID: r.GithubRepoID,
GithubNumber: r.GithubNumber, Origin: r.Origin,
GithubKind: r.GithubKind, GithubState: r.GithubState, GithubUrl: r.GithubUrl,
+ GithubAuthor: r.GithubAuthor, GithubAvatarUrl: r.GithubAvatarUrl,
CreatedAt: r.CreatedAt, UpdatedAt: r.UpdatedAt,
}
}
@@ -827,6 +835,7 @@ func byIDRowToIssue(r db.GetIssueByIDRow) db.Issue {
GithubNodeID: r.GithubNodeID, GithubRepoID: r.GithubRepoID,
GithubNumber: r.GithubNumber, Origin: r.Origin,
GithubKind: r.GithubKind, GithubState: r.GithubState, GithubUrl: r.GithubUrl,
+ GithubAuthor: r.GithubAuthor, GithubAvatarUrl: r.GithubAvatarUrl,
CreatedAt: r.CreatedAt, UpdatedAt: r.UpdatedAt,
}
}
diff --git a/packages/api-client/src/generated/schema.ts b/packages/api-client/src/generated/schema.ts
index 4c7506b..3f39050 100644
--- a/packages/api-client/src/generated/schema.ts
+++ b/packages/api-client/src/generated/schema.ts
@@ -102,7 +102,7 @@ export interface paths {
delete?: never;
options?: never;
head?: never;
- /** Update profile fields (chat name color) */
+ /** Update profile fields (chat name color, GitHub login) */
patch: operations["updateMe"];
trace?: never;
};
@@ -1651,6 +1651,23 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/api/projects/{projectId}/github/issue": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ /** In-app GitHub issue detail — issue plus comment thread */
+ get: operations["issueDetail"];
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/api/projects/{projectId}/github/pull/merge": {
parameters: {
query?: never;
@@ -1731,6 +1748,78 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/api/projects/{projectId}/github/labels": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ /** Label catalog of a linked repository */
+ get: operations["repoLabels"];
+ put?: never;
+ /** Create a label on a linked repository */
+ post: operations["createRepoLabel"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/projects/{projectId}/github/assignees": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ /** Assignable users of a linked repository */
+ get: operations["repoAssignees"];
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/projects/{projectId}/github/issues/update": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Update a GitHub issue's title, body, labels, or assignees
+ * @description Each provided set replaces the whole list on GitHub. Works on PR numbers too — they share the issues endpoint upstream.
+ */
+ post: operations["updateGitHubIssue"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/projects/{projectId}/github/issues/state": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /** Close or reopen a GitHub issue */
+ post: operations["setIssueState"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/api/projects/{projectId}/github/pull/state": {
parameters: {
query?: never;
@@ -1809,7 +1898,7 @@ export interface paths {
path?: never;
cookie?: never;
};
- /** Open pull requests across every linked repo in the workspace */
+ /** Pull requests across every linked repo in the workspace */
get: operations["workspacePulls"];
put?: never;
post?: never;
@@ -1819,6 +1908,23 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/api/workspaces/{workspaceId}/github/issues": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ /** Issues across every linked repo in the workspace */
+ get: operations["workspaceIssues"];
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/api/projects/{projectId}/github/commits": {
parameters: {
query?: never;
@@ -2650,6 +2756,8 @@ export interface components {
name: string;
/** @description Chat name color as */
name_color?: string | null;
+ /** @description Bound GitHub username; empty = not linked. */
+ github_login?: string;
avatar_url?: string | null;
/** Format: date-time */
created_at?: string;
@@ -3144,6 +3252,10 @@ export interface components {
*/
state?: "open" | "closed" | "merged";
url?: string;
+ /** @description GitHub login of the issue/PR author */
+ author?: string;
+ /** @description GitHub avatar URL of the author */
+ avatar_url?: string;
};
};
IssueActivity: {
@@ -3601,6 +3713,8 @@ export interface operations {
"application/json": {
/** @description #rrggbb, or empty string to clear */
name_color?: string;
+ /** @description GitHub username bound for "mine" filters, or empty to clear */
+ github_login?: string;
};
};
};
@@ -7041,11 +7155,55 @@ export interface operations {
};
content: {
"application/json": {
- /** @description number, title, state, draft, merged, mergeable, body, url, author, head, base, additions, deletions, changed_files, commit_count, labels, created_at, updated_at, repo */
+ /** @description number, title, state, draft, merged, mergeable, body, url, author, head, base, additions, deletions, changed_files, commit_count, labels, assignees, reviewers, teams, merged_by, created_at, updated_at, repo */
pull?: Record;
files?: Record[];
commits?: Record[];
checks?: Record[];
+ /** @description latest submitted review state per reviewer */
+ reviews?: Record[];
+ /** @description approved | changes_requested | pending | "" */
+ review_decision?: string;
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ 404: components["responses"]["NotFound"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ issueDetail: {
+ parameters: {
+ query: {
+ /** @description owner/name or repo id; optional when only one repo is linked */
+ repo?: string;
+ number: number;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Issue detail bundle */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ /** @description number, title, state, body, url, author, avatar_url, author_type, labels, assignees, comment_count, milestone, created_at, updated_at */
+ issue?: Record;
+ comments?: Record[];
+ repo?: Record;
};
};
};
@@ -7258,6 +7416,216 @@ export interface operations {
};
};
};
+ repoLabels: {
+ parameters: {
+ query?: {
+ repo?: string;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Labels */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ labels?: {
+ name?: string;
+ color?: string;
+ description?: string;
+ }[];
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ createRepoLabel: {
+ parameters: {
+ query?: {
+ repo?: string;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": {
+ name: string;
+ /** @description 6-char hex, with or without '#' */
+ color?: string;
+ description?: string;
+ };
+ };
+ };
+ responses: {
+ /** @description Created label */
+ 201: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ name?: string;
+ color?: string;
+ description?: string;
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ repoAssignees: {
+ parameters: {
+ query?: {
+ repo?: string;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Assignable users */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ users?: {
+ login?: string;
+ avatar_url?: string;
+ type?: string;
+ }[];
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ updateGitHubIssue: {
+ parameters: {
+ query?: {
+ repo?: string;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": {
+ number: number;
+ title?: string;
+ body?: string;
+ labels?: string[];
+ assignees?: string[];
+ };
+ };
+ };
+ responses: {
+ /** @description Updated issue fields */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ title?: string;
+ body?: string;
+ labels?: Record[];
+ assignees?: Record[];
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ setIssueState: {
+ parameters: {
+ query?: {
+ repo?: string;
+ };
+ header?: never;
+ path: {
+ projectId: components["parameters"]["ProjectId"];
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": {
+ number: number;
+ /** @enum {string} */
+ state: "open" | "closed";
+ };
+ };
+ };
+ responses: {
+ /** @description New issue state */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ state?: string;
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ /** @description GitHub upstream error */
+ 502: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
setPullState: {
parameters: {
query?: {
@@ -7423,7 +7791,9 @@ export interface operations {
};
workspacePulls: {
parameters: {
- query?: never;
+ query?: {
+ state?: "open" | "closed" | "all";
+ };
header?: never;
path: {
workspaceId: string;
@@ -7447,6 +7817,34 @@ export interface operations {
403: components["responses"]["Forbidden"];
};
};
+ workspaceIssues: {
+ parameters: {
+ query?: {
+ state?: "open" | "closed" | "all";
+ };
+ header?: never;
+ path: {
+ workspaceId: string;
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Issue groups keyed by project+repo; issue_id links mirrored Relay issues */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": {
+ groups?: Record[];
+ };
+ };
+ };
+ 400: components["responses"]["BadRequest"];
+ 403: components["responses"]["Forbidden"];
+ };
+ };
gitCommits: {
parameters: {
query?: {
diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts
index d60fb3d..20f70e6 100644
--- a/packages/api-client/src/index.ts
+++ b/packages/api-client/src/index.ts
@@ -155,13 +155,19 @@ export interface PullDetail {
body: string;
url: string;
author: string;
+ avatar_url?: string;
+ author_type?: string;
head: string;
base: string;
additions: number;
deletions: number;
changed_files: number;
commit_count: number;
- labels: string[];
+ labels: { name: string; color?: string }[];
+ assignees: { login: string; avatar_url?: string }[];
+ reviewers: { login: string; avatar_url?: string }[];
+ teams?: { slug: string; name: string }[];
+ merged_by?: { login: string; avatar_url?: string } | null;
created_at: string;
updated_at: string;
repo: LinkedRepo;
@@ -179,6 +185,14 @@ export interface PullDetail {
conclusion: string;
url: string;
}[];
+ // Latest submitted review state per reviewer + the reduced decision.
+ reviews: {
+ login: string;
+ avatar_url?: string;
+ state: string; // APPROVED | CHANGES_REQUESTED | COMMENTED | …
+ submitted_at: string;
+ }[];
+ review_decision: string; // "approved" | "changes_requested" | "pending" | ""
}
// WorkflowRun is one row of a repo's GitHub Actions list.
@@ -213,13 +227,84 @@ export interface WorkspacePulls {
draft: boolean;
url: string;
author: string;
+ avatar_url?: string;
+ merged_at?: string | null;
head: string;
base: string;
- labels: string[];
+ labels: { name: string; color?: string }[];
+ assignees: { login: string; avatar_url?: string }[];
+ reviewers: { login: string; avatar_url?: string }[];
+ teams?: { slug: string; name: string }[];
+ comments?: number;
+ author_type?: string; // "User" | "Bot"
created_at: string;
updated_at: string;
}[];
}[];
+ // Repos whose GitHub call failed — their groups are omitted, this is how
+ // the page can still say so.
+ failed?: string[];
+ fetched_at?: string;
+}
+
+// WorkspaceIssues groups every linked repo's open GitHub issues by project —
+// sibling of WorkspacePulls. issue_id links the mirrored Relay issue when
+// one exists, so rows can deep-link in-app.
+export interface WorkspaceIssues {
+ groups: {
+ project_id: string;
+ project_name: string;
+ project_key: string;
+ repo: LinkedRepo;
+ issues: {
+ number: number;
+ title: string;
+ state: string;
+ url: string;
+ author: string;
+ avatar_url?: string;
+ labels: { name: string; color?: string }[];
+ assignees: { login: string; avatar_url?: string }[];
+ comments: number;
+ author_type?: string; // "User" | "Bot"
+ milestone?: string;
+ issue_id?: string;
+ created_at: string;
+ updated_at: string;
+ }[];
+ }[];
+ failed?: string[]; // repos whose GitHub call failed
+ fetched_at: string;
+}
+
+// IssueDetail is the in-app GitHub issue view: the issue plus its comment
+// thread — sibling of PullDetail.
+export interface IssueDetail {
+ issue: {
+ number: number;
+ title: string;
+ state: string;
+ body: string;
+ url: string;
+ author: string;
+ avatar_url?: string;
+ author_type?: string;
+ labels: { name: string; color?: string }[];
+ assignees: { login: string; avatar_url?: string }[];
+ comment_count: number;
+ milestone?: string;
+ created_at: string;
+ updated_at: string;
+ };
+ comments: {
+ body: string;
+ url: string;
+ author: string;
+ avatar_url?: string;
+ author_type?: string;
+ created_at: string;
+ }[];
+ repo: LinkedRepo;
}
export interface RepoCommit {
@@ -279,6 +364,9 @@ export interface DevRepoPanel {
state: string;
url: string;
author: string;
+ avatar_url?: string;
+ author_type?: string;
+ comments?: number;
updated_at: string;
}[];
prs: {
@@ -288,6 +376,8 @@ export interface DevRepoPanel {
draft: boolean;
url: string;
author: string;
+ avatar_url?: string;
+ author_type?: string;
head: string;
base: string;
updated_at?: string;
@@ -502,7 +592,7 @@ export function createClient(
current_password: currentPassword,
new_password: newPassword,
}),
- updateMe: (input: { name_color: string }) =>
+ updateMe: (input: { name_color?: string; github_login?: string }) =>
patch<{ user: User }>("/api/auth/me", input),
// Browser sign-in for the desktop shell: start, approve (signed-in),
// poll until approved. The approve call rides the existing session.
@@ -875,6 +965,20 @@ export function createClient(
request(
`/api/projects/${projectId}/github/pull?repo=${encodeURIComponent(repo)}&number=${number}`,
),
+ issueDetail: (projectId: string, repo: string, number: number) =>
+ request(
+ `/api/projects/${projectId}/github/issue?repo=${encodeURIComponent(repo)}&number=${number}`,
+ ),
+ setIssueState: (
+ projectId: string,
+ repo: string,
+ number: number,
+ state: "open" | "closed",
+ ) =>
+ post<{ state: string }>(
+ `/api/projects/${projectId}/github/issues/state?repo=${encodeURIComponent(repo)}`,
+ { number, state },
+ ),
createPullRequest: (
projectId: string,
repo: string,
@@ -897,6 +1001,43 @@ export function createClient(
`/api/projects/${projectId}/github/issues?repo=${encodeURIComponent(repo)}`,
input,
),
+ createRepoLabel: (
+ projectId: string,
+ repo: string,
+ input: { name: string; color?: string; description?: string },
+ ) =>
+ post<{ name: string; color?: string; description?: string }>(
+ `/api/projects/${projectId}/github/labels?repo=${encodeURIComponent(repo)}`,
+ input,
+ ),
+ repoLabels: (projectId: string, repo: string) =>
+ request<{ labels: { name: string; color: string; description: string }[] }>(
+ `/api/projects/${projectId}/github/labels?repo=${encodeURIComponent(repo)}`,
+ ),
+ repoAssignees: (projectId: string, repo: string) =>
+ request<{ users: { login: string; avatar_url?: string; type?: string }[] }>(
+ `/api/projects/${projectId}/github/assignees?repo=${encodeURIComponent(repo)}`,
+ ),
+ updateGitHubIssue: (
+ projectId: string,
+ repo: string,
+ input: {
+ number: number;
+ labels?: string[];
+ assignees?: string[];
+ title?: string;
+ body?: string;
+ },
+ ) =>
+ post<{
+ title: string;
+ body: string;
+ labels: { name: string; color?: string }[];
+ assignees: { login: string; avatar_url?: string }[];
+ }>(
+ `/api/projects/${projectId}/github/issues/update?repo=${encodeURIComponent(repo)}`,
+ input,
+ ),
commentOnIssue: (projectId: string, repo: string, number: number, body: string) =>
post<{ commented: boolean }>(
`/api/projects/${projectId}/github/issues/comments?repo=${encodeURIComponent(repo)}`,
@@ -942,8 +1083,10 @@ export function createClient(
`/api/projects/${projectId}/github/actions/rerun?repo=${encodeURIComponent(repo)}`,
{ run_id: runId },
),
- workspacePulls: (workspaceId: string) =>
- request(`/api/workspaces/${workspaceId}/github/pulls`),
+ workspacePulls: (workspaceId: string, state = "open") =>
+ request(`/api/workspaces/${workspaceId}/github/pulls?state=${state}`),
+ workspaceIssues: (workspaceId: string, state = "open") =>
+ request(`/api/workspaces/${workspaceId}/github/issues?state=${state}`),
repoCommits: (projectId: string, repo: string, branch?: string) =>
request<{ commits: RepoCommit[]; branch: string }>(
`/api/projects/${projectId}/github/commits?repo=${encodeURIComponent(repo)}${branch ? `&branch=${encodeURIComponent(branch)}` : ""}`,