Add bulk live-comment apply for agent reviews#162
Add bulk live-comment apply for agent reviews#162benvinegar merged 7 commits intopi/issue-158-hunk-commentsfrom
Conversation
Greptile SummaryThis PR adds Key changes:
Confidence Score: 5/5Safe to merge — all remaining findings are P2 style suggestions with no impact on runtime correctness. The implementation is well-structured: batch validation happens before any state mutation (all-or-nothing semantics), the 1-based → 0-based hunk offset translation is correctly applied in No files require special attention; the P2 type note is in Important Files Changed
Sequence DiagramsequenceDiagram
participant Agent
participant CLI as hunk session comment apply
participant Daemon as HunkDaemonState
participant Session as Live Hunk Session
participant Bridge as useHunkSessionBridge
Agent->>CLI: stdin JSON { comments: [...] }
CLI->>CLI: parseSessionCommentApplyPayload()<br/>(validate all items before forwarding)
CLI->>Daemon: POST /session-api action=comment-apply
Daemon->>Session: WebSocket comment_batch command
Session->>Bridge: applyIncomingCommentBatch()
Bridge->>Bridge: map() — resolve all targets<br/>(throw on first bad filePath/hunk)
Bridge->>Bridge: setLiveCommentsByFileId()<br/>(single atomic state update)
alt revealMode === "last"
Bridge->>Session: jumpToFile(last entry)
Bridge->>Session: openAgentNotes()
end
Bridge-->>Session: AppliedCommentBatchResult
Session-->>Daemon: { ok: true, result }
Daemon-->>CLI: AppliedCommentBatchResult
CLI-->>Agent: JSON or text output
|
| export interface CommentBatchToolInput extends SessionTargetInput { | ||
| comments: CommentToolInput[]; | ||
| revealMode?: "none" | "last"; | ||
| } |
There was a problem hiding this comment.
Per-item type carries unused session-targeting fields
CommentBatchToolInput.comments is typed as CommentToolInput[], but CommentToolInput extends SessionTargetInput, which adds sessionId?, sessionPath?, and repoRoot? to every item in the array. These fields have no effect per-item — the session is resolved once at the batch level via CommentBatchToolInput extends SessionTargetInput. The per-item session fields are silently discarded in server.ts when mapping over input.comments.
This makes the type slightly misleading: a reader looking at the interface would expect per-comment session routing, but that capability doesn't exist. Consider introducing a narrower type (e.g. CommentItemInput) that carries only the comment-specific fields (filePath, hunkIndex, side, line, summary, rationale, author) and using that for the comments array:
export interface CommentItemInput {
filePath: string;
hunkIndex?: number;
side?: DiffSide;
line?: number;
summary: string;
rationale?: string;
author?: string;
}
export interface CommentBatchToolInput extends SessionTargetInput {
comments: CommentItemInput[];
revealMode?: "none" | "last";
}There was a problem hiding this comment.
Agreed. I split the shared comment payload shape away from session targeting, so batch items now use a comment-only type and no longer imply per-item session routing. The single-comment path still carries session selectors at the top level, while both paths reuse the same comment target fields.
This comment was generated by Pi using OpenAI o3
Summary
hunk session comment applyso agents can send many live comments in one stdin JSON payload--reveal-lastTesting
bun run typecheckbun testDepends on #161 and addresses the remaining bulk-apply part of #158.
This PR description was generated by Pi using OpenAI o3