Skip to content

Commit 7a336a0

Browse files
committed
wip: revert session ids
1 parent 4aafbb9 commit 7a336a0

File tree

5 files changed

+22
-41
lines changed

5 files changed

+22
-41
lines changed

src/github/process-review.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@ export async function processReview(
6363
const prDetailsContent = `Repository: ${payload.repository.full_name}, PR Number: ${prDetails.pr_number}, Commit SHA: ${prDetails.commit_sha}, PR URL: ${prDetails.pr_url}`;
6464

6565
console.log(`Starting review session for job ${jobId}`);
66-
const sessionId = `session-${jobId}`;
67-
startReviewSession(sessionId);
66+
startReviewSession();
6867

6968
console.log(`Calling reviewDiff() for job ${jobId}`);
70-
await reviewDiff(diffContent, prDetailsContent, installationId, sessionId);
69+
await reviewDiff(diffContent, prDetailsContent, installationId);
7170
console.log(`Review completed for job ${jobId}`);
7271

7372
// Collect all comments from the review session
74-
const collector = endReviewSession(sessionId);
73+
const collector = endReviewSession();
7574
console.log(`Collected ${collector.getInlineComments().length} inline comments and ${collector.getGeneralComments().length} general comments`);
7675

7776
// Post aggregated review if there are any comments
@@ -111,8 +110,7 @@ export async function processReview(
111110

112111
// End review session if it was started
113112
try {
114-
const sessionId = `session-${jobId}`;
115-
endReviewSession(sessionId);
113+
endReviewSession();
116114
} catch {
117115
console.log('No active review session to end');
118116
}

src/mcp/tools/leave_comment.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ export async function leaveGeneralComment(
1515

1616
console.log('📝 Collecting general comment for later review');
1717

18-
// Get session ID from environment (passed by the review process)
19-
const sessionId = process.env.REVIEW_SESSION_ID;
20-
if (!sessionId) {
21-
throw new Error('No REVIEW_SESSION_ID found in environment. Review session not properly initialized.');
22-
}
23-
24-
const collector = getCurrentCollector(sessionId);
18+
const collector = getCurrentCollector();
2519
collector.addGeneralComment(message);
2620

2721
return {

src/mcp/tools/leave_inline_comment.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export async function leaveInlineComment(
1818

1919
console.log('📝 Collecting inline comment for later review:', { path, line });
2020

21-
// Get session ID from environment (passed by the review process)
22-
const sessionId = process.env.REVIEW_SESSION_ID;
23-
if (!sessionId) {
24-
throw new Error('No REVIEW_SESSION_ID found in environment. Review session not properly initialized.');
25-
}
26-
27-
const collector = getCurrentCollector(sessionId);
21+
const collector = getCurrentCollector();
2822
collector.addInlineComment(path, line, message);
2923

3024
return {

src/review/comment-collector.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,26 @@ export class ReviewCommentCollector {
5050
}
5151
}
5252

53-
// Global collectors keyed by session ID for concurrent reviews
54-
const activeCollectors = new Map<string, ReviewCommentCollector>();
53+
// Global collector instance for the current review session
54+
let currentCollector: ReviewCommentCollector | null = null;
5555

56-
export function startReviewSession(sessionId: string): ReviewCommentCollector {
57-
const collector = new ReviewCommentCollector();
58-
activeCollectors.set(sessionId, collector);
59-
console.log(`Started review session: ${sessionId}`);
60-
return collector;
56+
export function startReviewSession(): ReviewCommentCollector {
57+
currentCollector = new ReviewCommentCollector();
58+
return currentCollector;
6159
}
6260

63-
export function getCurrentCollector(sessionId: string): ReviewCommentCollector {
64-
const collector = activeCollectors.get(sessionId);
65-
if (!collector) {
66-
throw new Error(`No active review session found for ID: ${sessionId}. Call startReviewSession() first.`);
61+
export function getCurrentCollector(): ReviewCommentCollector {
62+
if (!currentCollector) {
63+
throw new Error('No active review session. Call startReviewSession() first.');
6764
}
68-
return collector;
65+
return currentCollector;
6966
}
7067

71-
export function endReviewSession(sessionId: string): ReviewCommentCollector {
72-
const collector = activeCollectors.get(sessionId);
73-
if (!collector) {
74-
throw new Error(`No active review session found for ID: ${sessionId}.`);
68+
export function endReviewSession(): ReviewCommentCollector {
69+
if (!currentCollector) {
70+
throw new Error('No active review session to end.');
7571
}
76-
activeCollectors.delete(sessionId);
77-
console.log(`Ended review session: ${sessionId}`);
72+
const collector = currentCollector;
73+
currentCollector = null;
7874
return collector;
7975
}

src/review/reviewer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Config, getConfig } from "../config.js";
66
import { newThread, execute } from "../amp.js";
77

88

9-
export const reviewDiff = async (diffContent: string, mrDetailsContent: string, installationId: number, sessionId?: string) => {
9+
export const reviewDiff = async (diffContent: string, mrDetailsContent: string, installationId: number) => {
1010

1111
// Get config
1212
const config: Config = getConfig();
@@ -45,15 +45,14 @@ export const reviewDiff = async (diffContent: string, mrDetailsContent: string,
4545
// Write settings to file with installation ID
4646
const settings = { ...ampConfig.settings };
4747

48-
// Ensure GitHub MCP server environment exists and set installation ID and session ID
48+
// Ensure GitHub MCP server environment exists and set installation ID
4949
settings['amp.mcpServers'] = {
5050
...settings['amp.mcpServers'],
5151
github: {
5252
...settings['amp.mcpServers']?.github,
5353
env: {
5454
...settings['amp.mcpServers']?.github?.env,
5555
GITHUB_INSTALLATION_ID: installationId.toString(),
56-
...(sessionId && { REVIEW_SESSION_ID: sessionId }),
5756
}
5857
}
5958
};

0 commit comments

Comments
 (0)