mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
feat(pr-actions): Prettier
This commit is contained in:
@@ -4,10 +4,10 @@ import { GH_MUTATION_TIMEOUT } from "./pr-constants"
|
||||
export async function resolveComment(threadId: string, cwd: string): Promise<void> {
|
||||
const mutation = `mutation($id: ID!) { resolveReviewThread(input: { threadId: $id }) { thread { isResolved } } }`
|
||||
try {
|
||||
await execGhRead(
|
||||
["api", "graphql", "-f", `query=${mutation}`, "-F", `id=${threadId}`],
|
||||
{ cwd, timeout: GH_MUTATION_TIMEOUT },
|
||||
)
|
||||
await execGhRead(["api", "graphql", "-f", `query=${mutation}`, "-F", `id=${threadId}`], {
|
||||
cwd,
|
||||
timeout: GH_MUTATION_TIMEOUT,
|
||||
})
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const stderr = (err as Record<string, unknown>).stderr
|
||||
@@ -18,10 +18,10 @@ export async function resolveComment(threadId: string, cwd: string): Promise<voi
|
||||
export async function unresolveComment(threadId: string, cwd: string): Promise<void> {
|
||||
const mutation = `mutation($id: ID!) { unresolveReviewThread(input: { threadId: $id }) { thread { isResolved } } }`
|
||||
try {
|
||||
await execGhRead(
|
||||
["api", "graphql", "-f", `query=${mutation}`, "-F", `id=${threadId}`],
|
||||
{ cwd, timeout: GH_MUTATION_TIMEOUT },
|
||||
)
|
||||
await execGhRead(["api", "graphql", "-f", `query=${mutation}`, "-F", `id=${threadId}`], {
|
||||
cwd,
|
||||
timeout: GH_MUTATION_TIMEOUT,
|
||||
})
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const stderr = (err as Record<string, unknown>).stderr
|
||||
|
||||
@@ -205,13 +205,17 @@ describe("PRStatusBridge.handleMessage resolveComment", () => {
|
||||
it("returns true for agentManager.resolveComment", () => {
|
||||
const { bridge } = harness()
|
||||
resolveComment.mockResolvedValueOnce(undefined)
|
||||
expect(bridge.handleMessage({ type: "agentManager.resolveComment", worktreeId: "wt1", threadId: "PRT_1" })).toBe(true)
|
||||
expect(bridge.handleMessage({ type: "agentManager.resolveComment", worktreeId: "wt1", threadId: "PRT_1" })).toBe(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
it("returns true for agentManager.unresolveComment", () => {
|
||||
const { bridge } = harness()
|
||||
unresolveComment.mockResolvedValueOnce(undefined)
|
||||
expect(bridge.handleMessage({ type: "agentManager.unresolveComment", worktreeId: "wt1", threadId: "PRT_1" })).toBe(true)
|
||||
expect(bridge.handleMessage({ type: "agentManager.unresolveComment", worktreeId: "wt1", threadId: "PRT_1" })).toBe(
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
it("posts resolveCommentResult with success:true on resolve success", async () => {
|
||||
@@ -220,7 +224,14 @@ describe("PRStatusBridge.handleMessage resolveComment", () => {
|
||||
bridge.handleMessage({ type: "agentManager.resolveComment", worktreeId: "wt1", threadId: "PRT_1" })
|
||||
await Promise.resolve()
|
||||
const result = sent.find((m) => m.type === "agentManager.resolveCommentResult")
|
||||
expect(result).toEqual(expect.objectContaining({ type: "agentManager.resolveCommentResult", worktreeId: "wt1", threadId: "PRT_1", success: true }))
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
type: "agentManager.resolveCommentResult",
|
||||
worktreeId: "wt1",
|
||||
threadId: "PRT_1",
|
||||
success: true,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it("posts unresolveCommentResult with success:true on unresolve success", async () => {
|
||||
|
||||
@@ -255,9 +255,7 @@ describe("parseComments", () => {
|
||||
})
|
||||
|
||||
it("uses comment id as threadId fallback when thread has no id", () => {
|
||||
const threads: GhThread[] = [
|
||||
{ isResolved: false, comments: { nodes: [{ id: "c2", body: "note" }] } },
|
||||
]
|
||||
const threads: GhThread[] = [{ isResolved: false, comments: { nodes: [{ id: "c2", body: "note" }] } }]
|
||||
const result = parseComments(threads)
|
||||
expect(result[0]?.threadId).toBe("c2")
|
||||
})
|
||||
|
||||
@@ -13,14 +13,13 @@ function DiffHunk(props: { hunk: string }) {
|
||||
<div class="am-pr-diff-hunk">
|
||||
<For each={lines()}>
|
||||
{(line) => {
|
||||
const cls =
|
||||
line.startsWith("+")
|
||||
? "am-pr-diff-line-add"
|
||||
: line.startsWith("-")
|
||||
? "am-pr-diff-line-del"
|
||||
: line.startsWith("@@")
|
||||
? "am-pr-diff-line-meta"
|
||||
: "am-pr-diff-line-ctx"
|
||||
const cls = line.startsWith("+")
|
||||
? "am-pr-diff-line-add"
|
||||
: line.startsWith("-")
|
||||
? "am-pr-diff-line-del"
|
||||
: line.startsWith("@@")
|
||||
? "am-pr-diff-line-meta"
|
||||
: "am-pr-diff-line-ctx"
|
||||
return <div class={`am-pr-diff-line ${cls}`}>{line || " "}</div>
|
||||
}}
|
||||
</For>
|
||||
@@ -34,10 +33,16 @@ function CommentCard(props: { comment: PRComment; worktreeId: string }) {
|
||||
const [actionError, setActionError] = createSignal<string | undefined>(undefined)
|
||||
|
||||
// Clear optimistic state if the comment at this position changes (Index tracks by position)
|
||||
createEffect(on(() => props.comment.threadId, () => {
|
||||
setOptimisticResolved(undefined)
|
||||
setActionError(undefined)
|
||||
}, { defer: true }))
|
||||
createEffect(
|
||||
on(
|
||||
() => props.comment.threadId,
|
||||
() => {
|
||||
setOptimisticResolved(undefined)
|
||||
setActionError(undefined)
|
||||
},
|
||||
{ defer: true },
|
||||
),
|
||||
)
|
||||
|
||||
const resolved = createMemo(() => optimisticResolved() ?? props.comment.resolved)
|
||||
|
||||
@@ -54,7 +59,11 @@ function CommentCard(props: { comment: PRComment; worktreeId: string }) {
|
||||
setActionError(undefined)
|
||||
} else {
|
||||
setOptimisticResolved(undefined)
|
||||
setActionError(msg.type === "agentManager.resolveCommentResult" ? "Failed to resolve thread." : "Failed to unresolve thread.")
|
||||
setActionError(
|
||||
msg.type === "agentManager.resolveCommentResult"
|
||||
? "Failed to resolve thread."
|
||||
: "Failed to unresolve thread.",
|
||||
)
|
||||
}
|
||||
}
|
||||
window.addEventListener("message", handler)
|
||||
@@ -74,9 +83,7 @@ function CommentCard(props: { comment: PRComment; worktreeId: string }) {
|
||||
|
||||
return (
|
||||
<div class="am-pr-panel-comment" classList={{ "am-pr-panel-comment-resolved": resolved() }}>
|
||||
<Show when={props.comment.diffHunk}>
|
||||
{(hunk) => <DiffHunk hunk={hunk()} />}
|
||||
</Show>
|
||||
<Show when={props.comment.diffHunk}>{(hunk) => <DiffHunk hunk={hunk()} />}</Show>
|
||||
<div class="am-pr-panel-comment-header am-pr-row">
|
||||
<span class="am-pr-panel-comment-author">{props.comment.author}</span>
|
||||
<Show when={props.comment.file}>
|
||||
@@ -90,9 +97,7 @@ function CommentCard(props: { comment: PRComment; worktreeId: string }) {
|
||||
</Show>
|
||||
<CopyButton text={props.comment.body} class="am-pr-copy-btn" />
|
||||
</div>
|
||||
<Show when={actionError()}>
|
||||
{(err) => <div class="am-pr-resolve-error">{err()}</div>}
|
||||
</Show>
|
||||
<Show when={actionError()}>{(err) => <div class="am-pr-resolve-error">{err()}</div>}</Show>
|
||||
<div class="am-pr-panel-comment-body">
|
||||
<Markdown text={props.comment.body} />
|
||||
</div>
|
||||
|
||||
@@ -83,7 +83,9 @@ export const PRPanel: Component<PRPanelProps> = (props) => {
|
||||
</div>
|
||||
<Show when={showScrollTop()}>
|
||||
<Tooltip value="Scroll to top" placement="left">
|
||||
<button class="am-pr-scroll-top" onClick={scrollToTop}>↑</button>
|
||||
<button class="am-pr-scroll-top" onClick={scrollToTop}>
|
||||
↑
|
||||
</button>
|
||||
</Tooltip>
|
||||
</Show>
|
||||
</div>
|
||||
|
||||
@@ -70,9 +70,7 @@ export function PRSummary(props: PRSummaryProps) {
|
||||
>
|
||||
<Icon name={row.icon} size="small" class="am-pr-summary-icon" />
|
||||
<span class="am-pr-summary-label">{row.label}</span>
|
||||
{row.isComments && props.onJumpToComments && (
|
||||
<span class="am-pr-summary-jump">Jump to comments ↓</span>
|
||||
)}
|
||||
{row.isComments && props.onJumpToComments && <span class="am-pr-summary-jump">Jump to comments ↓</span>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user