From 38b229edea2244608f024422b4d03312af62790c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:17:19 +0000 Subject: [PATCH 1/5] Initial plan From 24c8e48fa9b396a83ae5669a50d4675130c44c0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:22:14 +0000 Subject: [PATCH 2/5] Change PR thread names to show title instead of URL Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com> --- gradlew | 0 .../review/GitHubReviewService.java | 29 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java index 002dd57b..5e6ed357 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java @@ -100,10 +100,10 @@ public long createReviewForumPost(Guild guild, GitHubPullRequest pullRequest) th throw new IOException("Forum channel not found with ID: " + this.appConfig.reviewSystem.reviewForumId); } - MessageCreateData createData = MessageCreateData.fromContent(pullRequestTitleFromUrl); + MessageCreateData createData = MessageCreateData.fromContent(pullRequest.toUrl()); return forumChannel.createForumPost(pullRequestTitleFromUrl, createData) - .setName(pullRequest.toUrl()) + .setName(pullRequestTitleFromUrl) .setTags(ForumTagSnowflake.fromId(this.appConfig.reviewSystem.inReviewForumTagId)) .complete() .getThreadChannel() @@ -225,6 +225,21 @@ private void sendDirectMessage(User user, String message) { ); } + private Result getPullRequestFromThread(ThreadChannel threadChannel) { + try { + // Try to get the first message in the thread which should contain the PR URL + String firstMessageContent = threadChannel.retrieveMessageById(threadChannel.getIdLong()) + .complete() + .getContentRaw(); + + return GitHubPullRequest.fromUrl(firstMessageContent); + } + catch (Exception exception) { + LOGGER.log(Level.WARNING, "Failed to retrieve first message from thread: " + threadChannel.getId(), exception); + return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + } + } + public CompletableFuture mentionReviewersOnAllReviewChannels(JDA jda) { return CompletableFuture.runAsync(() -> { Guild guild = jda.getGuildById(this.appConfig.guildId); @@ -239,7 +254,7 @@ public CompletableFuture mentionReviewersOnAllReviewChannels(JDA jda) { for (ForumChannel forumChannel : guild.getForumChannels()) { for (ThreadChannel threadChannel : forumChannel.getThreadChannels()) { Result result = - GitHubPullRequest.fromUrl(threadChannel.getName()); + this.getPullRequestFromThread(threadChannel); if (result.isErr()) { continue; @@ -268,7 +283,10 @@ public boolean isReviewPostCreatedInGuild(Guild guild, String url) { try { for (ForumChannel forumChannel : guild.getForumChannels()) { for (ThreadChannel threadChannel : forumChannel.getThreadChannels()) { - if (url.equals(threadChannel.getName())) { + Result result = + this.getPullRequestFromThread(threadChannel); + + if (result.isOk() && url.equals(result.get().toUrl())) { return true; } } @@ -295,8 +313,7 @@ public CompletableFuture archiveMergedPullRequest(JDA jda) { for (ForumChannel forumChannel : guild.getForumChannels()) { for (ThreadChannel threadChannel : forumChannel.getThreadChannels()) { - String name = threadChannel.getName(); - Result result = GitHubPullRequest.fromUrl(name); + Result result = this.getPullRequestFromThread(threadChannel); if (result.isErr()) { continue; From 0951a498833d829dc4d960e65d893e31e5413996 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:24:10 +0000 Subject: [PATCH 3/5] Fix getPullRequestFromThread to correctly retrieve first message Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com> --- .../review/GitHubReviewService.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java index 5e6ed357..695e6329 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java @@ -228,14 +228,28 @@ private void sendDirectMessage(User user, String message) { private Result getPullRequestFromThread(ThreadChannel threadChannel) { try { // Try to get the first message in the thread which should contain the PR URL - String firstMessageContent = threadChannel.retrieveMessageById(threadChannel.getIdLong()) - .complete() - .getContentRaw(); + List messages = threadChannel.getHistory() + .retrievePast(1) + .complete(); + if (messages.isEmpty()) { + LOGGER.log(Level.WARNING, "No messages found in thread: " + threadChannel.getId()); + return Result.error(new IllegalArgumentException("No messages in thread")); + } + + String firstMessageContent = messages.get(0).getContentRaw(); return GitHubPullRequest.fromUrl(firstMessageContent); } + catch (net.dv8tion.jda.api.exceptions.ErrorResponseException exception) { + LOGGER.log(Level.WARNING, "Discord API error retrieving message from thread: " + threadChannel.getId(), exception); + return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + } + catch (RateLimitedException exception) { + LOGGER.log(Level.WARNING, "Rate limited when retrieving message from thread: " + threadChannel.getId(), exception); + return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + } catch (Exception exception) { - LOGGER.log(Level.WARNING, "Failed to retrieve first message from thread: " + threadChannel.getId(), exception); + LOGGER.log(Level.WARNING, "Unexpected error retrieving message from thread: " + threadChannel.getId(), exception); return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); } } From d421a113a5507b688452c04bbd6119861a1cc85e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:25:31 +0000 Subject: [PATCH 4/5] Remove redundant setName() call in createReviewForumPost Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com> --- .../com/eternalcode/discordapp/review/GitHubReviewService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java index 695e6329..a3843828 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java @@ -103,7 +103,6 @@ public long createReviewForumPost(Guild guild, GitHubPullRequest pullRequest) th MessageCreateData createData = MessageCreateData.fromContent(pullRequest.toUrl()); return forumChannel.createForumPost(pullRequestTitleFromUrl, createData) - .setName(pullRequestTitleFromUrl) .setTags(ForumTagSnowflake.fromId(this.appConfig.reviewSystem.inReviewForumTagId)) .complete() .getThreadChannel() From fd61418d233c3445a718b62e26241bdf3c704d4d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:26:49 +0000 Subject: [PATCH 5/5] Improve code clarity and error messages Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com> --- .../discordapp/review/GitHubReviewService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java index a3843828..c58ea44b 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java @@ -92,7 +92,7 @@ public boolean checkPullRequestTitle(GitHubPullRequest url) throws IOException { public long createReviewForumPost(Guild guild, GitHubPullRequest pullRequest) throws IOException { this.waitForRateLimit(); - String pullRequestTitleFromUrl = + String pullRequestTitle = GitHubReviewUtil.getPullRequestTitleFromUrl(pullRequest, this.appConfig.githubToken); ForumChannel forumChannel = guild.getForumChannelById(this.appConfig.reviewSystem.reviewForumId); @@ -102,7 +102,7 @@ public long createReviewForumPost(Guild guild, GitHubPullRequest pullRequest) th MessageCreateData createData = MessageCreateData.fromContent(pullRequest.toUrl()); - return forumChannel.createForumPost(pullRequestTitleFromUrl, createData) + return forumChannel.createForumPost(pullRequestTitle, createData) .setTags(ForumTagSnowflake.fromId(this.appConfig.reviewSystem.inReviewForumTagId)) .complete() .getThreadChannel() @@ -241,15 +241,15 @@ private Result getPullRequestFromTh } catch (net.dv8tion.jda.api.exceptions.ErrorResponseException exception) { LOGGER.log(Level.WARNING, "Discord API error retrieving message from thread: " + threadChannel.getId(), exception); - return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + return Result.error(new IllegalArgumentException("Discord API error: " + exception.getMeaning())); } catch (RateLimitedException exception) { LOGGER.log(Level.WARNING, "Rate limited when retrieving message from thread: " + threadChannel.getId(), exception); - return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + return Result.error(new IllegalArgumentException("Rate limited by Discord API")); } catch (Exception exception) { LOGGER.log(Level.WARNING, "Unexpected error retrieving message from thread: " + threadChannel.getId(), exception); - return Result.error(new IllegalArgumentException("Failed to retrieve PR URL from thread")); + return Result.error(new IllegalArgumentException("Unexpected error: " + exception.getMessage())); } }