Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit 1ff009e

Browse files
committed
Implement inline commenting in diff view
**Complete Comment System: Diff View → LLM Feedback** **Implementation:** - Added comment callback mechanism to SyntheticPRProvider - Modified handleCommentSubmission to extract file path and line number - Added handleCommentFeedback method to DaemonClient - Wired up comment submission to feedback system **Flow:** 1. User adds comment in diff view using VSCode comment UI 2. Comment appears in thread (existing behavior) 3. Comment details sent as feedback to LLM with file path and line number 4. Tree view clears to show completion 5. LLM receives structured comment feedback **Benefits:** - **Line-specific comments** - Comments tied to exact file and line - **Native VSCode UI** - Uses built-in comment system - **Complete feedback loop** - Comments flow back to LLM for response - **Clean integration** - Works with existing review system **Result:** Users can now add meaningful comments on specific lines of code!
1 parent 2a13102 commit 1ff009e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

extension/src/extension.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,36 @@ class DaemonClient implements vscode.Disposable {
475475
};
476476
}
477477

478+
/**
479+
* Handle comment feedback from diff view
480+
*/
481+
public handleCommentFeedback(comment: string, filePath: string, lineNumber: number): void {
482+
const reviewId = this.currentReviewId;
483+
if (!reviewId) {
484+
vscode.window.showErrorMessage('No active review found');
485+
return;
486+
}
487+
488+
const resolver = this.pendingFeedbackResolvers.get(reviewId);
489+
if (!resolver) {
490+
vscode.window.showErrorMessage('No pending feedback request found');
491+
return;
492+
}
493+
494+
// Resolve with comment feedback
495+
resolver({
496+
feedback_type: 'comment',
497+
review_id: reviewId,
498+
comment_text: comment,
499+
file_path: filePath,
500+
line_number: lineNumber
501+
});
502+
503+
// Clear tree view and cleanup
504+
this.syntheticPRProvider.clearPR();
505+
this.pendingFeedbackResolvers.delete(reviewId);
506+
}
507+
478508
/**
479509
* Handle review action from tree view button click
480510
*/
@@ -775,6 +805,11 @@ export function activate(context: vscode.ExtensionContext) {
775805
const daemonClient = new DaemonClient(context, reviewProvider, outputChannel, syntheticPRProvider);
776806
daemonClient.start();
777807

808+
// Set up comment callback to send comments as feedback
809+
syntheticPRProvider.setCommentCallback((comment: string, filePath: string, lineNumber: number) => {
810+
daemonClient.handleCommentFeedback(comment, filePath, lineNumber);
811+
});
812+
778813
// 💡: Set up universal selection detection for interactive code review
779814
setupSelectionDetection(context, outputChannel, daemonClient);
780815

extension/src/syntheticPRProvider.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class SyntheticPRProvider implements vscode.Disposable {
6868
private treeProvider: SyntheticPRTreeProvider;
6969
private diffContentProvider: DialecticDiffContentProvider;
7070
private currentPR: SyntheticPRData | null = null;
71+
private onCommentCallback?: (comment: string, filePath: string, lineNumber: number) => void;
7172

7273
constructor(private context: vscode.ExtensionContext) {
7374
// Create diff content provider for virtual diff content
@@ -455,6 +456,24 @@ export class SyntheticPRProvider implements vscode.Disposable {
455456

456457
// Ensure the thread can accept more replies
457458
reply.thread.canReply = true;
459+
460+
// Send comment as feedback to LLM
461+
if (this.onCommentCallback && reply.thread.range) {
462+
const uri = reply.thread.uri;
463+
const lineNumber = reply.thread.range.start.line + 1; // Convert to 1-based
464+
const filePath = uri.scheme === 'dialectic-diff' ?
465+
uri.path.replace('/diff/', '') : // Extract file path from diff URI
466+
vscode.workspace.asRelativePath(uri);
467+
468+
this.onCommentCallback(reply.text, filePath, lineNumber);
469+
}
470+
}
471+
472+
/**
473+
* Set callback for when user submits a comment
474+
*/
475+
setCommentCallback(callback: (comment: string, filePath: string, lineNumber: number) => void): void {
476+
this.onCommentCallback = callback;
458477
}
459478

460479
/**

0 commit comments

Comments
 (0)