-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Currently, when running in github_action mode, Flow Lens deletes all previous Flow Lens comments before publishing new ones, regardless of whether the content has changed. This creates unnecessary GitHub API calls and comment notifications, especially in PRs with multiple flow files where only some have changed.
Current Behavior
In uml_writer.ts:
- Fetches all PR comments
- Deletes all comments containing "flow-lens-hidden-comment"
- Creates new comments for all flows
Proposed Behavior
Only delete and republish comments when the content has actually changed:
- Fetch existing comments
- For each flow file:
- Check if an existing comment exists for this file
- Compare new comment content with existing content
- Only delete and republish if content differs
Proposed Implementation
private async writeGithubComment(config: RuntimeConfig) {
try {
const existingComments = await this.githubClient.getAllCommentsForPullRequest();
const flowLensComments = new Map<string, {id: number, body: string}>();
// Index existing comments by file path
for (const comment of existingComments) {
if (comment.body.includes(HIDDEN_COMMENT_PREFIX)) {
const filePath = extractFilePathFromComment(comment.body);
flowLensComments.set(filePath, {
id: comment.id,
body: comment.body
});
}
}
// Process each flow difference
for (const [filePath, flowDifference] of this.filePathToFlowDifference) {
const newCommentBody = this.githubClient.translateToComment(
getBody(flowDifference),
filePath
);
const existingComment = flowLensComments.get(filePath);
if (!existingComment || existingComment.body !== newCommentBody) {
// Delete old comment if it exists
if (existingComment) {
await this.githubClient.deleteReviewComment(existingComment.id);
}
// Post new comment
await this.githubClient.writeComment(newCommentBody);
}
}
} catch (error) {
console.error("Failed to update GitHub comments:", error);
throw error;
}
}Related Files
src/main/uml_writer.tssrc/main/github_client.ts
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request