From 612679d2bbfd92e199b83a8d172c8403276d614a Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:37:59 +0300 Subject: [PATCH 1/4] Initial commit with task details for issue #9 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Bot/issues/9 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..11cdb2b1 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Bot/issues/9 +Your prepared branch: issue-9-095eadd0 +Your prepared working directory: /tmp/gh-issue-solver-1757821076647 + +Proceed. \ No newline at end of file From 9a578d2d950265844420bbbf93d2a23427541829 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:44:54 +0300 Subject: [PATCH 2/4] Reduce bot message frequency to prevent spam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Increased default interaction interval from 60 to 300 seconds (5 minutes) - Fixed GitHubStorage.GetIssues() to always update lastIssue timestamp, preventing reprocessing of same timeframes - Added processed item tracking to IssueTracker and PullRequestTracker to prevent duplicate actions - Added break statement in IssueTracker to ensure only one trigger processes each issue 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/Platform.Bot/Program.cs | 2 +- csharp/Platform.Bot/Trackers/IssueTracker.cs | 20 +++++++++++++++++++ .../Trackers/PullRequestTracker.cs | 20 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/csharp/Platform.Bot/Program.cs b/csharp/Platform.Bot/Program.cs index 521a6b95..977273a1 100644 --- a/csharp/Platform.Bot/Program.cs +++ b/csharp/Platform.Bot/Program.cs @@ -71,7 +71,7 @@ private static async Task Main(string[] args) var minimumInteractionIntervalOption = new Option( name: "--minimum-interaction-interval", description: "Minimum interaction interval in seconds.", - getDefaultValue: () => 60); + getDefaultValue: () => 300); var rootCommand = new RootCommand("Sample app for System.CommandLine") { diff --git a/csharp/Platform.Bot/Trackers/IssueTracker.cs b/csharp/Platform.Bot/Trackers/IssueTracker.cs index 1c53a4c9..0ad2b262 100644 --- a/csharp/Platform.Bot/Trackers/IssueTracker.cs +++ b/csharp/Platform.Bot/Trackers/IssueTracker.cs @@ -31,6 +31,14 @@ public class IssueTracker : ITracker /// private IList> _triggers { get; } + /// + /// + /// Tracks processed issues to prevent duplicate actions. + /// + /// + /// + private HashSet _processedIssues { get; } = new HashSet(); + /// /// /// Initializes a new instance. @@ -66,6 +74,15 @@ public async Task Start(CancellationToken cancellationToken) var allIssues = _storage.GetIssues(); foreach (var issue in allIssues) { + // Create a unique key for each issue-trigger combination to prevent duplicate processing + var issueKey = $"{issue.Repository.FullName}#{issue.Number}"; + + // Skip if this issue has already been processed + if (_processedIssues.Contains(issueKey)) + { + continue; + } + foreach (var trigger in _triggers) { if (cancellationToken.IsCancellationRequested) @@ -75,6 +92,9 @@ public async Task Start(CancellationToken cancellationToken) if (await trigger.Condition(issue)) { await trigger.Action(issue); + // Mark issue as processed after successful action + _processedIssues.Add(issueKey); + break; // Only process one trigger per issue to prevent conflicts } } } diff --git a/csharp/Platform.Bot/Trackers/PullRequestTracker.cs b/csharp/Platform.Bot/Trackers/PullRequestTracker.cs index 47287ee1..ec180492 100644 --- a/csharp/Platform.Bot/Trackers/PullRequestTracker.cs +++ b/csharp/Platform.Bot/Trackers/PullRequestTracker.cs @@ -33,6 +33,14 @@ public class PullRequestTracker : ITracker /// private IList> _triggers; + /// + /// + /// Tracks processed pull requests to prevent duplicate actions. + /// + /// + /// + private HashSet _processedPullRequests = new HashSet(); + /// /// /// Initializes a new instance. @@ -75,10 +83,22 @@ public async Task Start(CancellationToken cancellationToken) { return; } + + // Create a unique key for each pull request to prevent duplicate processing + var pullRequestKey = $"{repository.FullName}#{pullRequest.Number}"; + + // Skip if this pull request has already been processed + if (_processedPullRequests.Contains(pullRequestKey)) + { + continue; + } + var detailedPullRequest = _storage.Client.PullRequest.Get(repository.Id, pullRequest.Number).AwaitResult(); if (await trigger.Condition(detailedPullRequest)) { await trigger.Action(detailedPullRequest); + // Mark pull request as processed after successful action + _processedPullRequests.Add(pullRequestKey); } } } From c98f613d16bfababca9ab9664bdf54ce18c559b0 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:45:41 +0300 Subject: [PATCH 3/4] 'Auto-commit changes made by Claude MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude ' --- csharp/Storage/RemoteStorage/GitHubStorage.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/csharp/Storage/RemoteStorage/GitHubStorage.cs b/csharp/Storage/RemoteStorage/GitHubStorage.cs index 888a7426..7c8c7f51 100644 --- a/csharp/Storage/RemoteStorage/GitHubStorage.cs +++ b/csharp/Storage/RemoteStorage/GitHubStorage.cs @@ -103,12 +103,21 @@ public IReadOnlyList GetIssues() Since = lastIssue }; var issues = Client.Issue.GetAllForCurrent(request).Result; + + // Always update lastIssue to current time to prevent reprocessing the same timeframe + // even when there are no new issues + var now = DateTimeOffset.Now; if (issues.Count != 0) { - lastIssue = issues.Max(x => x.CreatedAt); - return issues; + var maxIssueTime = issues.Max(x => x.CreatedAt); + lastIssue = maxIssueTime > now ? maxIssueTime : now; } - return new List(); + else + { + lastIssue = now; + } + + return issues; } public Task> GetCommits(long repositoryId, CommitRequest commitRequest) => Client.Repository.Commit.GetAll(repositoryId, commitRequest); From 638f915e2b221c3a01fa6fd6102377d3670a2154 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:45:42 +0300 Subject: [PATCH 4/4] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 11cdb2b1..00000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Bot/issues/9 -Your prepared branch: issue-9-095eadd0 -Your prepared working directory: /tmp/gh-issue-solver-1757821076647 - -Proceed. \ No newline at end of file