diff --git a/packages/kilo-vscode/tests/unit/comments-github.test.ts b/packages/kilo-vscode/tests/unit/comments-github.test.ts index 8395294bf61..9e0c35cbc82 100644 --- a/packages/kilo-vscode/tests/unit/comments-github.test.ts +++ b/packages/kilo-vscode/tests/unit/comments-github.test.ts @@ -1,5 +1,10 @@ import { describe, expect, it } from "bun:test" -import { postAllGithub, resolveGithubContext, type CommentsGithub } from "../../webview-ui/diff-viewer/comments-github" +import { + createCommentsGithub, + postAllGithub, + resolveGithubContext, + type CommentsGithub, +} from "../../webview-ui/diff-viewer/comments-github" import type { PRDiffSnapshot, PRTarget } from "../../src/shared/pr-comment-actions" import type { ReviewComment } from "../../webview-ui/diff-viewer/review-comments" @@ -23,7 +28,6 @@ function comment(id: string, line: number): ReviewComment { function fake(handler: (comment: ReviewComment) => { success: boolean; error?: string }): CommentsGithub { return { - available: () => true, resolve: () => undefined, send: async (item) => handler(item), } @@ -44,7 +48,6 @@ describe("resolveGithubContext", () => { prNumber: 7, prUrl: target.prUrl, snapshotId: "snap-1", - label: "GitHub #7", closed: false, }) }) @@ -84,6 +87,33 @@ describe("resolveGithubContext", () => { }) }) +describe("createCommentsGithub", () => { + function github(canPublish: boolean) { + return createCommentsGithub({ + target: () => target, + snapshot: () => snapshot, + diffs: () => [], + post: () => {}, + canPublish: () => canPublish, + }) + } + + it("resolves a context while publication is enabled", () => { + expect(github(true).resolve(comment("a", 2))).toEqual({ + prNumber: 7, + prUrl: target.prUrl, + snapshotId: "snap-1", + closed: true, + }) + }) + + it("refuses to resolve or send while publication is disabled", async () => { + const disabled = github(false) + expect(disabled.resolve(comment("a", 2))).toBeUndefined() + await expect(disabled.send(comment("a", 2))).resolves.toEqual({ success: false }) + }) +}) + describe("postAllGithub", () => { it("posts every comment in order when each request succeeds", async () => { const sent: string[] = [] diff --git a/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx b/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx index ae14746c5a2..158e412130c 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx @@ -64,7 +64,6 @@ type Props = { prNumber: number prUrl: string snapshotId: string - label: string closed: boolean } initialBody?: string diff --git a/packages/kilo-vscode/webview-ui/diff-viewer/comments-github.ts b/packages/kilo-vscode/webview-ui/diff-viewer/comments-github.ts index 4408ec5f1ef..d81422dc800 100644 --- a/packages/kilo-vscode/webview-ui/diff-viewer/comments-github.ts +++ b/packages/kilo-vscode/webview-ui/diff-viewer/comments-github.ts @@ -11,13 +11,10 @@ export interface GithubContext { prNumber: number prUrl: string snapshotId: string - label: string closed: boolean } export interface CommentsGithub { - /** True when a PR with a loaded snapshot is available for publication. */ - available: () => boolean /** Resolve the GitHub target for a comment. `closed` means the line is not publishable. */ resolve: (comment: ReviewComment) => GithubContext | undefined send: (comment: ReviewComment) => Promise<{ success: boolean; error?: string }> @@ -53,7 +50,6 @@ export function resolveGithubContext(opts: { prNumber: opts.target.prNumber, prUrl: opts.target.prUrl, snapshotId: opts.snapshot.id, - label: `GitHub #${opts.target.prNumber}`, closed: !allowed, } } @@ -82,8 +78,6 @@ export function createCommentsGithub(opts: Options): CommentsGithub { }) } - const available = () => opts.canPublish?.() !== false && !!opts.target() && !!opts.snapshot() - const send = (comment: ReviewComment) => { const { promise, resolve: settle } = Promise.withResolvers<{ success: boolean; error?: string }>() const target = opts.target() @@ -113,7 +107,7 @@ export function createCommentsGithub(opts: Options): CommentsGithub { return promise } - return { available, resolve, send } + return { resolve, send } } /**