feat: add prompt attachment support across sessions

This commit is contained in:
Mohamed Boudra
2026-04-11 16:58:39 +07:00
parent aa1d33f0a0
commit 28f45a41a5
21 changed files with 915 additions and 70 deletions
@@ -0,0 +1,55 @@
import { describe, expect, it } from "vitest";
import { buildGitHubAttachmentFromSearchItem } from "./review-attachments";
describe("buildGitHubAttachmentFromSearchItem", () => {
it("builds a github_pr attachment for pull requests", () => {
const attachment = buildGitHubAttachmentFromSearchItem({
kind: "pr",
number: 123,
title: "Fix race in worktree setup",
url: "https://github.com/getpaseo/paseo/pull/123",
state: "OPEN",
body: "PR body",
labels: ["bug"],
baseRefName: "main",
headRefName: "fix/worktree-race",
});
expect(attachment).toEqual({
type: "github_pr",
mimeType: "application/github-pr",
number: 123,
title: "Fix race in worktree setup",
url: "https://github.com/getpaseo/paseo/pull/123",
body: "PR body",
baseRefName: "main",
headRefName: "fix/worktree-race",
});
});
it("builds a github_issue attachment for issues", () => {
const attachment = buildGitHubAttachmentFromSearchItem({
kind: "issue",
number: 55,
title: "Improve startup error details",
url: "https://github.com/getpaseo/paseo/issues/55",
state: "OPEN",
body: "Issue body",
labels: ["bug"],
});
expect(attachment).toEqual({
type: "github_issue",
mimeType: "application/github-issue",
number: 55,
title: "Improve startup error details",
url: "https://github.com/getpaseo/paseo/issues/55",
body: "Issue body",
});
});
it("returns null when no item is selected", () => {
expect(buildGitHubAttachmentFromSearchItem(null)).toBeNull();
});
});
@@ -0,0 +1,31 @@
import type { AgentAttachment, GitHubSearchItem } from "@server/shared/messages";
export function buildGitHubAttachmentFromSearchItem(
item: GitHubSearchItem | null,
): AgentAttachment | null {
if (!item) {
return null;
}
if (item.kind === "pr") {
return {
type: "github_pr",
mimeType: "application/github-pr",
number: item.number,
title: item.title,
url: item.url,
...(item.body ? { body: item.body } : {}),
...(item.baseRefName ? { baseRefName: item.baseRefName } : {}),
...(item.headRefName ? { headRefName: item.headRefName } : {}),
};
}
return {
type: "github_issue",
mimeType: "application/github-issue",
number: item.number,
title: item.title,
url: item.url,
...(item.body ? { body: item.body } : {}),
};
}