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

Commit 34ebcf3

Browse files
committed
Update synthetic PR design docs with actual implementation
- Replace placeholder Implementation Plan with real Implementation Status - Add mdbook anchors to UserFeedback struct for live code inclusion - Document actual MCP tool behavior and LLM instruction formatting - Show clear distinction between completed server-side work and remaining IPC/extension work - Reference real code via anchors to keep docs synchronized Addresses #22 - design docs now reflect actual implementation
1 parent 25957ff commit 34ebcf3

File tree

4 files changed

+68
-76
lines changed

4 files changed

+68
-76
lines changed

md/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
- [Copilot Integration Guide](./references/copilot-guide.md) <!-- 💡: Analysis of GitHub Copilot's VSCode integration patterns for AI-assisted development workflows. Covers comment-based AI interaction, inline suggestion systems, and integration with existing VSCode features. Provides insights for building complementary AI tools that work alongside Copilot. Relevant for: AI integration patterns, comment-based workflows, VSCode AI tool ecosystem -->
5757
- [Copilot Integration Guide 2](./references/copilot-guide-2.md) <!-- 💡: Extended analysis of Copilot integration patterns focusing on advanced features like chat interfaces, context awareness, and multi-turn conversations. Covers architectural patterns for AI tools that need to maintain conversation state and integrate with VSCode's editing experience. Relevant for: AI chat interfaces, conversation state management, advanced AI integration -->
5858
- [Copilot Integration Guide 3](./references/copilot-guide-3.md) <!-- 💡: Comprehensive guide for implementing GitHub PR-style commenting UI in VSCode extensions with multi-line comment support, clickable gutter icons, expanded comment threads, and "Make Code Suggestion" functionality. Covers CommentController API, CommentingRangeProvider implementation, and troubleshooting common issues like missing reply buttons. Based on analysis of GitHub PR extension patterns. Relevant for: comment UI implementation, multi-line commenting, suggestion workflows, GitHub PR-style interfaces -->
59-
- [VSCode Comments API Reply Button Implementation](./references/VSCode Comments API Reply Button.md) <!-- 💡: Definitive technical guide for implementing working reply buttons and multi-line comments in VSCode extensions using the Comments API. Covers the complete implementation pattern including CommentingRangeProvider requirements, package.json menu contributions, command registration, and custom action buttons like "Make Suggestion". Includes minimal working examples and troubleshooting for common issues. Based on analysis of microsoft/vscode-pull-request-github extension. Relevant for: reply button functionality, multi-line comment selection, custom comment actions, Comments API implementation -->
59+
- [VSCode Comments API Reply Button Implementation](./references/VSCode-Comments-API-Reply-Button.md) <!-- 💡: Definitive technical guide for implementing working reply buttons and multi-line comments in VSCode extensions using the Comments API. Covers the complete implementation pattern including CommentingRangeProvider requirements, package.json menu contributions, command registration, and custom action buttons like "Make Suggestion". Includes minimal working examples and troubleshooting for common issues. Based on analysis of microsoft/vscode-pull-request-github extension. Relevant for: reply button functionality, multi-line comment selection, custom comment actions, Comments API implementation -->
6060
- [Decision documents]()

md/design/synthetic-pr.md

Lines changed: 65 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -256,97 +256,87 @@ extension/src/
256256
└── extension.ts # IPC and main logic
257257
```
258258

259-
## Implementation Plan
259+
## Implementation Status
260260

261-
### 1. Update MCP Tool Interface
261+
### ✅ Completed: Server-Side Blocking Pattern
262+
263+
**MCP Tool Interface** - Real implementation in `server/src/synthetic_pr/mcp_tools.rs`:
262264

263-
**Current `update_review()` signature**:
264265
```rust
265-
pub enum UpdateReviewAction {
266-
WaitForFeedback,
267-
AddComment { comment: serde_json::Value },
268-
Approve,
269-
RequestChanges,
270-
}
266+
{{#include ../../server/src/synthetic_pr/mcp_tools.rs:user_feedback}}
271267
```
272268

273-
**Enhanced for blocking pattern**:
269+
**Blocking MCP Tools** - Real implementation in `server/src/server.rs`:
270+
274271
```rust
275-
// Tool blocks until user provides feedback
276-
// Returns structured user feedback data
277-
pub struct UserFeedbackResponse {
278-
pub review_id: String,
279-
pub comment_id: String,
280-
pub file_path: String,
281-
pub line_number: u32,
282-
pub user_comment: String,
283-
pub context_lines: Vec<String>, // Surrounding code for context
284-
}
272+
{{#include ../../server/src/server.rs:request_review_tool}}
285273
```
286274

287-
### 2. IPC Message Extension
275+
```rust
276+
{{#include ../../server/src/server.rs:update_review_tool}}
277+
```
288278

289-
**New IPC message type**:
290-
```typescript
291-
interface UserCommentPayload {
292-
review_id: string;
293-
comment_id: string;
294-
file_path: string;
295-
line_number: number;
296-
comment_text: string;
297-
context_lines: string[];
298-
}
279+
**LLM Instruction Formatting** - The `format_user_feedback_message` method creates explicit instructions:
280+
281+
For **comment feedback**:
299282
```
283+
The user reviewed your code changes and left a comment on file `src/auth.rs` at line 42:
300284
301-
### 3. Extension Changes
285+
User comment: 'This validation logic looks incomplete - what about edge cases?'
302286
303-
**Enhanced `handleCommentSubmission()`**:
304-
```typescript
305-
private handleCommentSubmission(reply: vscode.CommentReply): void {
306-
// Current: Add comment locally
307-
const newComment = { /* ... */ };
308-
reply.thread.comments = [...reply.thread.comments, newComment];
309-
310-
// NEW: Send to MCP server via IPC
311-
this.sendUserComment({
312-
review_id: this.currentPR.review_id,
313-
comment_id: generateCommentId(),
314-
file_path: reply.thread.uri.fsPath,
315-
line_number: reply.thread.range.start.line + 1,
316-
comment_text: reply.text,
317-
context_lines: this.getContextLines(reply.thread.uri, reply.thread.range)
318-
});
287+
Code context:
288+
```rust
289+
function validateInput(input: string) {
290+
return input.length > 0; // Line 42
319291
}
320292
```
321293

322-
### 4. Server Blocking Logic
294+
Please analyze the user's feedback and prepare a thoughtful response addressing their concern.
295+
Do NOT modify any files on disk.
323296

324-
**MCP tool implementation**:
325-
```rust
326-
pub async fn update_review(params: UpdateReviewParams) -> Result<UpdateReviewResponse> {
327-
match params.action {
328-
UpdateReviewAction::WaitForFeedback => {
329-
// Block until IPC message arrives
330-
let user_feedback = ipc_communicator.wait_for_user_comment().await?;
331-
332-
Ok(UpdateReviewResponse {
333-
status: "user_feedback_received".to_string(),
334-
user_feedback: Some(user_feedback),
335-
message: Some(format!(
336-
"User commented on {}:{} - '{}'. Please respond with update_review()",
337-
user_feedback.file_path,
338-
user_feedback.line_number,
339-
user_feedback.user_comment
340-
))
341-
})
342-
}
343-
// ... other actions
344-
}
297+
When ready, invoke the update_review tool with:
298+
- review_id: 'abc123'
299+
- action: AddComment
300+
- comment: { response: 'Your response text here' }
301+
302+
After responding, invoke update_review again with action: WaitForFeedback to continue the conversation.
303+
```
304+
305+
For **completion feedback**:
306+
```
307+
User completed their review and selected: 'Request agent to make changes'
308+
Additional notes: 'Focus on the validation logic we discussed'
309+
310+
Based on the review discussion, please implement the requested changes.
311+
You may now edit files as needed.
312+
313+
When finished, invoke: update_review(review_id: 'abc123', action: Approve)
314+
```
315+
316+
### 🔄 Next: IPC Message Handling
317+
318+
**Missing IPC Implementation**:
319+
- `wait_for_user_feedback()` method currently returns stub/error
320+
- Need to implement actual blocking mechanism with message queues
321+
- Extension must send `user_comment` IPC messages to unblock server
322+
323+
**Required IPC Message Types**:
324+
```typescript
325+
interface UserCommentPayload {
326+
review_id: string;
327+
feedback_type: "comment" | "complete_review";
328+
file_path?: string;
329+
line_number?: number;
330+
comment_text?: string;
331+
completion_action?: "request_changes" | "checkpoint" | "return";
332+
additional_notes?: string;
333+
context_lines?: string[];
345334
}
346335
```
347336

348-
This creates a **natural conversation loop** where:
349-
1. AI blocks waiting for user input
350-
2. User comments unblock the AI with structured feedback
351-
3. AI processes and responds
352-
4. Cycle repeats for continuous interaction
337+
### 🚧 Remaining: Extension Integration
338+
339+
**Extension Changes Needed**:
340+
1. **Enhanced `handleCommentSubmission()`** - Send user comments via IPC
341+
2. **Complete Review UI** - Tree panel action with three completion choices
342+
3. **IPC Message Routing** - Handle `user_comment` message type
File renamed without changes.

server/src/synthetic_pr/mcp_tools.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct RequestReviewParams {
1818
}
1919

2020
/// User feedback data from blocking MCP tools
21+
// ANCHOR: user_feedback
2122
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
2223
pub struct UserFeedback {
2324
pub review_id: Option<String>,
@@ -29,6 +30,7 @@ pub struct UserFeedback {
2930
pub additional_notes: Option<String>,
3031
pub context_lines: Option<Vec<String>>,
3132
}
33+
// ANCHOR_END: user_feedback
3234

3335
/// Response data from synthetic pull request creation.
3436
#[derive(Debug, Serialize, Deserialize, JsonSchema)]

0 commit comments

Comments
 (0)