Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/inline-pr-replies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"kilo-code": minor
---

Write and preview multiline PR comments and code suggestions, reply from the PR panel or diff view, and edit or delete your own comments directly in Agent Manager.

Comment on selected PR diff lines, submit reviews, and preview and apply suggested changes to the local worktree without staging, committing, or pushing.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import { normalizeBaseBranch } from "./base-branch"
import { handleBaseUpdate } from "./base-update"
import { GitStatsPoller, type LocalStats, type WorktreePresenceResult, type WorktreeStats } from "./GitStatsPoller"
import { PRStatusBridge } from "./pr-status-bridge"
import { createPollers, type ProjectPollers } from "./project/pollers"
import { GitOps } from "./GitOps"
import type { GitExecutable } from "../util/git-executable"
Expand Down Expand Up @@ -100,7 +99,7 @@ export class AgentManagerProvider implements Disposable {
private stateReady: Promise<void> | undefined
private statsPoller: GitStatsPoller
private readonly projectPollers: ProjectPollers
private prBridge!: PRStatusBridge
private prBridge!: ReturnType<typeof createPollers>["pr"]
private orchestration: AgentManagerOrchestrationBridge
private gitOps: GitOps
private diffs: WorktreeDiffController
Expand Down Expand Up @@ -241,6 +240,7 @@ export class AgentManagerProvider implements Disposable {
projectId: () => this.context?.id,
})
const pollers = createPollers({
dirtyFiles: () => this.host.dirtyFiles(),
git: this.gitOps,
semaphore,
state: () => this.state,
Expand Down
40 changes: 29 additions & 11 deletions packages/kilo-vscode/src/agent-manager/PRStatusPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ export class PRStatusPoller {

/** Force-refresh a specific worktree immediately, bypassing the PR cache. */
refresh(worktreeId: string): void {
if (!this.active) return
const wt = this.options.getWorktrees().find((w) => w.id === worktreeId)
if (wt) this.prCache.delete(this.key(wt.branch, wt.path))
void this.fetchOne(worktreeId)
this.lastHash.delete(worktreeId)
if (!this.active) return
void this.fetchOne(worktreeId, this.generation, true)
}

setActiveWorktreeId(id: string | undefined): void {
Expand Down Expand Up @@ -260,7 +261,11 @@ export class PRStatusPoller {
this.failures++
}

private async fetchOne(worktreeId: string, generation = this.generation): Promise<void> {
private async fetchOne(
worktreeId: string,
generation = this.generation,
full = this.activeWorktreeId === worktreeId,
): Promise<void> {
const wt = this.target(worktreeId)
if (!wt) return

Expand All @@ -269,8 +274,8 @@ export class PRStatusPoller {
branch = this.options.getBranch ? await this.options.getBranch(wt) : wt.branch
if (this.stale(generation)) return
const pr = await this.cachedFetchPR(branch ?? wt.branch, wt.path)
if (!pr || this.stale(generation)) {
if (this.stale(generation)) return
if (this.stale(generation)) return
if (!pr) {
const hash = `${worktreeId}:${branch ?? wt.branch}:none`
if (this.lastHash.get(worktreeId) === hash) return
this.lastHash.set(worktreeId, hash)
Expand All @@ -280,13 +285,14 @@ export class PRStatusPoller {

const [checks, reviewers, threads] = await Promise.all([
...this.extras(pr, wt.path),
this.fetchThreads(pr.number, wt.path, this.activeWorktreeId === worktreeId),
this.fetchThreads(pr.number, wt.path, full),
])
if (this.stale(generation)) return
if (threads && (threads.baseRefOid !== pr.baseRefOid || threads.headRefOid !== pr.headRefOid))
this.prCache.delete(this.key(branch ?? wt.branch, wt.path))

const status: PRStatus = {
id: pr.id,
number: pr.number,
baseRefOid: pr.baseRefOid,
headRefOid: pr.headRefOid,
Expand Down Expand Up @@ -339,7 +345,7 @@ export class PRStatusPoller {
}

private static readonly BASE_JSON_FIELDS =
"number,title,body,url,state,isDraft,reviewDecision,additions,deletions,changedFiles,headRefName,baseRefOid,headRefOid"
"id,number,title,body,url,state,isDraft,reviewDecision,additions,deletions,changedFiles,headRefName,baseRefOid,headRefOid"
private static readonly PR_JSON_FIELDS = `${PRStatusPoller.BASE_JSON_FIELDS},statusCheckRollup,reviewRequests,reviews`

/** Return a cached PR lookup if still fresh, otherwise fetch and cache.
Expand Down Expand Up @@ -504,7 +510,11 @@ export class PRStatusPoller {
cwd: string,
full: boolean,
): Promise<
Pick<PRStatus, "comments" | "unresolvedThreads" | "conversation" | "baseRefOid" | "headRefOid"> | undefined
| Pick<
PRStatus,
"comments" | "unresolvedThreads" | "conversation" | "baseRefOid" | "headRefOid" | "viewerDidAuthor"
>
| undefined
> {
let refs: { baseRefOid: string; headRefOid: string } | undefined
try {
Expand All @@ -519,6 +529,9 @@ export class PRStatusPoller {
startLine
originalStartLine
startDiffSide
latest: comments(last: 10) {
nodes { id author { login avatarUrl } body viewerDidAuthor viewerCanUpdate viewerCanDelete }
}
comments(first: 10) {
nodes {
id
Expand All @@ -530,7 +543,8 @@ export class PRStatusPoller {
url
createdAt
diffHunk
reactionGroups { content reactors { totalCount } viewerHasReacted }
reactionGroups { content reactors { totalCount } viewerHasReacted }
viewerDidAuthor viewerCanUpdate viewerCanDelete
}
}`
: ""
Expand All @@ -542,7 +556,8 @@ export class PRStatusPoller {
body
createdAt
url
reactionGroups { content reactors { totalCount } viewerHasReacted }
reactionGroups { content reactors { totalCount } viewerHasReacted }
viewerDidAuthor viewerCanUpdate viewerCanDelete
}
}
reviews(last: 50) {
Expand All @@ -569,6 +584,7 @@ export class PRStatusPoller {
pullRequest(number: $number) {
baseRefOid
headRefOid
viewerDidAuthor
reviewThreads(first: 100, after: $cursor) {
totalCount
pageInfo { hasNextPage endCursor }
Expand Down Expand Up @@ -627,6 +643,7 @@ export class PRStatusPoller {
})
return {
...refs,
viewerDidAuthor: page.viewerDidAuthor,
unresolvedThreads: unresolved,
comments: { total, unresolved, comments },
conversation,
Expand Down Expand Up @@ -655,6 +672,7 @@ function threads(json: string) {
pullRequest?: {
baseRefOid?: string
headRefOid?: string
viewerDidAuthor?: boolean
reviewThreads?: {
totalCount: number
pageInfo: { hasNextPage: boolean; endCursor?: string | null }
Expand All @@ -676,7 +694,7 @@ function threads(json: string) {
) {
throw new Error("Incomplete PR review threads response")
}
return { ...page, baseRefOid: pr.baseRefOid, headRefOid: pr.headRefOid }
return { ...page, baseRefOid: pr.baseRefOid, headRefOid: pr.headRefOid, viewerDidAuthor: pr.viewerDidAuthor }
}

/** Run async thunks with bounded concurrency, returning settled results. */
Expand Down
3 changes: 3 additions & 0 deletions packages/kilo-vscode/src/agent-manager/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export interface Host {
/** Get the workspace/project root path. */
workspacePath(): string | undefined

/** Local files with unsaved editor changes. */
dirtyFiles(): string[]

/** Show a folder picker and return the selected path, or undefined when cancelled. */
pickFolder(): Promise<string | undefined>

Expand Down
Loading
Loading