Remove system comments from assistant messages

System comment prefixes like `Patch Set 1: ...\n\n(1 comment)` are also
associated with the assistant (eg, when updating votes), so these are
now removed from the assistant messages sent to ChatGPT in the message
history as well.

Change-Id: Iddb6c4863edd7fa59cf11feff1ae00e8f6a5b367
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptComment.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptComment.java
index 59e9a89..5a4a364 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptComment.java
@@ -1,7 +1,6 @@
 package com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt;
 
 import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.data.ChangeSetDataHandler;
 import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.ClientBase;
 import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.api.gerrit.GerritChange;
 import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.messages.ClientMessage;
@@ -28,9 +27,9 @@
             commentMessage.removeDebugMessages();
         }
         else {
-            commentMessage.removeMentions().parseRemoveCommands().removeHeadings();
+            commentMessage.removeMentions().parseRemoveCommands();
         }
-        return commentMessage.getMessage();
+        return commentMessage.removeHeadings().getMessage();
     }
 
     protected boolean isFromAssistant(GerritComment commentProperty) {
diff --git a/src/test/resources/__files/gerritPatchSetDetail.json b/src/test/resources/__files/gerritPatchSetDetail.json
index de8ce0f..e34c2f8 100644
--- a/src/test/resources/__files/gerritPatchSetDetail.json
+++ b/src/test/resources/__files/gerritPatchSetDetail.json
@@ -81,6 +81,20 @@
       "_revision_number": 1
     },
     {
+      "id": "5f915c7d277a0ebc596e9734f0f1704a911d85c6",
+      "author": {
+        "_account_id": 1000000,
+        "name": "ChatGPT",
+        "display_name": "ChatGPT",
+        "email": "gpt@amarulasolutions.com",
+        "username": "gpt"
+      },
+      "date": "2024-04-29 12:52:17.000000000",
+      "message": "Patch Set 1: -Code-Review\n\n(1 comment)",
+      "accounts_in_message": [],
+      "_revision_number": 1
+    },
+    {
       "id": "dbbcc20a0073cfc65c792187e0eef802c3112489",
       "author": {
         "_account_id": 1000000,