Skip to content

Commit 8424b17

Browse files
committed
Refactor AI-powered features and prompt management system
Remove the AI-powered toolbar dropdown and its associated release notes generation functionality from GitConsole. The `GenerateReleaseNotes`, `DoCodeReview`, and `FinaliseReleaseNotes` methods, along with the `OnGitAIDropDown` handler and related UI elements, have been removed to simplify the git console interface. Restructure the prompt configuration system in Config to support dynamic prompt management. The `SetPrompt` method now delegates to a new `AddPrompt` helper, while three new public methods enable flexible prompt handling: `GetAllPrompts` retrieves all configured prompts as label-prompt pairs, `AddPrompt` replaces or adds prompts by label, and `DeletePrompt` removes prompts by label. All operations are thread-safe via mutex locking. Remove the `kReleaseNotesMerge` prompt kind enum value and its corresponding default prompt configuration, simplifying the prompt system. Update the prompt templates in Prompts.cpp for consistency and clarity, and integrate the new `GetAllPrompts` method into ChatAIWindow to provide users with quick access to insert stored prompts via a menu. * Plugin/ai/Config.cpp - Refactor SetPrompt, add AddPrompt, DeletePrompt, GetAllPrompts methods * Plugin/ai/Config.hpp - Remove kReleaseNotesMerge enum, add new public prompt methods * Plugin/ai/Prompts.cpp - Remove PROMPT_GIT_RELEASE_NOTES_MERGE, update prompt formatting * Plugin/ai/ChatAIWindow.cpp - Integrate GetAllPrompts for prompt insertion menu * git/GitConsole.h - Remove AI feature declarations and method signatures * git/GitConsole.cpp - Remove AI toolbar button, dropdown handler, and release notes generation logic **Generated by CodeLite** Signed-off-by: Eran Ifrah <eran@codelite.org>
1 parent ec95042 commit 8424b17

File tree

6 files changed

+106
-354
lines changed

6 files changed

+106
-354
lines changed

Plugin/ai/ChatAIWindow.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,23 @@ void ChatAIWindow::OnOptions(wxAuiToolBarEvent& event)
226226
},
227227
XRCID("wxID_CACHING_POLICY_STATIC_CONTENT"));
228228
menu.Append(wxID_ANY, _("Prompt Caching"), caching_policy_menu);
229+
auto prompts = llm_manager.GetConfig().GetAllPrompts();
230+
if (!prompts.empty()) {
231+
wxMenu* prompt_selection = new wxMenu;
232+
for (const auto& [label, prompt] : prompts) {
233+
auto item_id = wxXmlResource::GetXRCID(label);
234+
prompt_selection->Append(item_id, label);
235+
prompt_selection->Bind(
236+
wxEVT_MENU,
237+
[prompt, this](wxCommandEvent& event) {
238+
wxUnusedVar(event);
239+
m_stcInput->SetText(prompt);
240+
m_stcInput->CallAfter(&wxStyledTextCtrl::SetFocus);
241+
},
242+
item_id);
243+
}
244+
menu.Append(wxID_ANY, _("Insert Prompt"), prompt_selection);
245+
}
229246
menu.AppendSeparator();
230247
menu.Append(XRCID("chat_history"), _("Chat History"))->Enable(CurrentEndpointHasHistory());
231248
menu.Bind(wxEVT_MENU, &ChatAIWindow::OnHistory, this, XRCID("chat_history"));

Plugin/ai/Config.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ T ReadValue(const nlohmann::json& j, const std::string& name, const T& d = {})
2525
const std::map<std::string, std::string> kDefaultPromptTable = {
2626
{PromptKindToString(PromptKind::kCommentGeneration), PROMPT_DOCSTRING_GEN},
2727
{PromptKindToString(PromptKind::kReleaseNotesGenerate), PROMPT_GIT_RELEASE_NOTES},
28-
{PromptKindToString(PromptKind::kReleaseNotesMerge), PROMPT_GIT_RELEASE_NOTES_MERGE},
2928
{PromptKindToString(PromptKind::kGitChangesCodeReview), PROMPT_GIT_CODE_REVIEW},
3029
{PromptKindToString(PromptKind::kGitCommitMessage), PROMPT_GIT_COMMIT_MSG}};
3130

@@ -127,17 +126,40 @@ wxString Config::GetPrompt(PromptKind kind) const
127126
return wxEmptyString;
128127
}
129128

130-
void Config::SetPrompt(PromptKind kind, const wxString& prompt)
129+
void Config::DeletePrompt(const wxString& label)
130+
{
131+
std::scoped_lock lk{m_mutex};
132+
m_prompts.erase(label.ToStdString(wxConvUTF8));
133+
}
134+
135+
void Config::AddPrompt(const wxString& label, const wxString& prompt)
131136
{
132-
auto label = PromptKindToString(kind);
133137
std::scoped_lock lk{m_mutex};
138+
std::string utf8 = label.ToStdString(wxConvUTF8);
139+
m_prompts.erase(utf8);
140+
m_prompts.insert({utf8, prompt.ToStdString(wxConvUTF8)});
141+
}
142+
143+
std::vector<std::pair<wxString, wxString>> Config::GetAllPrompts() const
144+
{
145+
std::scoped_lock lk{m_mutex};
146+
std::vector<std::pair<wxString, wxString>> result;
147+
result.reserve(m_prompts.size());
148+
for (const auto& [label, prompt] : m_prompts) {
149+
result.push_back({wxString::FromUTF8(label), wxString::FromUTF8(prompt)});
150+
}
151+
return result;
152+
}
153+
154+
void Config::SetPrompt(PromptKind kind, const wxString& prompt)
155+
{
134156
switch (kind) {
135157
case PromptKind::kMax:
136158
break;
137-
default:
138-
m_prompts.erase(label);
139-
m_prompts.insert({label, prompt.ToStdString(wxConvUTF8)});
140-
break;
159+
default: {
160+
auto label = PromptKindToString(kind);
161+
AddPrompt(wxString::FromUTF8(label), prompt);
162+
} break;
141163
}
142164
}
143165

Plugin/ai/Config.hpp

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ enum class PromptKind {
2222
kCommentGeneration,
2323
kGitCommitMessage,
2424
kReleaseNotesGenerate,
25-
kReleaseNotesMerge,
2625
kGitChangesCodeReview,
2726
kMax, // Must be last
2827
};
@@ -61,8 +60,6 @@ inline CachePolicy CachePolicyFromString(const wxString& policy)
6160
inline std::string PromptKindToString(PromptKind kind)
6261
{
6362
switch (kind) {
64-
case llm::PromptKind::kReleaseNotesMerge:
65-
return "Git Release Notes: Merge";
6663
case llm::PromptKind::kReleaseNotesGenerate:
6764
return "Git Release Notes: Generate";
6865
case llm::PromptKind::kCommentGeneration:
@@ -411,6 +408,56 @@ class WXDLLIMPEXP_SDK Config
411408
*/
412409
void SetPrompt(PromptKind kind, const wxString& prompt);
413410

411+
/**
412+
* Retrieves all configured prompts as a vector of label-prompt pairs.
413+
*
414+
* This method provides thread-safe access to all prompts stored in the configuration.
415+
* Each prompt is converted from UTF-8 encoding to wxString format. The method acquires
416+
* a mutex lock to ensure consistent read access and prevents concurrent modifications.
417+
*
418+
* Parameters:
419+
* (none)
420+
*
421+
* Returns:
422+
* A vector of pairs where each pair contains a prompt label (first) and its
423+
* corresponding prompt text (second), both as wxString objects. Returns an empty
424+
* vector if no prompts are configured.
425+
*/
426+
std::vector<std::pair<wxString, wxString>> GetAllPrompts() const;
427+
428+
/**
429+
* Adds or replaces a prompt entry in the configuration.
430+
*
431+
* This method thread-safely adds a new prompt to the internal prompts map,
432+
* using the provided label as the key. If an entry with the same label already
433+
* exists, it is first removed and then replaced with the new prompt value.
434+
* Both the label and prompt are converted from wxString to UTF-8 encoded
435+
* standard strings before storage.
436+
*
437+
* Parameters:
438+
* label - A wxString containing the unique identifier for the prompt entry.
439+
* prompt - A wxString containing the prompt text or content to be stored.
440+
*
441+
* Returns:
442+
* Nothing (void).
443+
*/
444+
void AddPrompt(const wxString& label, const wxString& prompt);
445+
/**
446+
* Deletes a prompt configuration entry by its label.
447+
*
448+
* This function removes the prompt associated with the given label from the
449+
* internal prompts collection. Thread-safe operation is ensured via an internal
450+
* mutex lock that is held for the duration of the erase operation.
451+
*
452+
* Parameters:
453+
* label - A wxString containing the label of the prompt to delete. The label
454+
* is converted to a UTF-8 encoded std::string for lookup and removal.
455+
*
456+
* Returns:
457+
* void - No value is returned.
458+
*/
459+
void DeletePrompt(const wxString& label);
460+
414461
/**
415462
* @brief Resets the prompt collection to its default state.
416463
*

Plugin/ai/Prompts.cpp

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The documentation comment must contain **all** of the following sections (in thi
1515
4. **Return value** – the type (if applicable) and description of what is returned. If the function returns nothing, explicitly state that.
1616
5. **Raises / Throws / Errors** – any exceptions, error codes, or error‑handling behavior the function may produce. If none, you may omit this section.
1717
18-
Follow the exact syntax for the target languages doc‑comment style (e.g., `/** … */` for Java, `""" … """` for Python, `/// …` for Rust, `/** … */` for TypeScript/JSDoc, `/*** … */` for Doxygen, etc.).
18+
Follow the exact syntax for the target language's doc‑comment style (e.g., `/** … */` for Java, `""" … """` for Python, `/// …` for Rust, `/** … */` for TypeScript/JSDoc, `/*** … */` for Doxygen, etc.).
1919
2020
Do **not** include any extra explanatory text outside the comment block.
2121
If the function is a method belonging to a class, also include a brief note about the class/context if it helps the reader.
@@ -42,17 +42,17 @@ const std::string PROMPT_GIT_COMMIT_MSG =
4242
4343
## Requirements
4444
* The first line (the **title**) must be ≤ 80 characters.
45-
* The title must be written in **title case**, start with a **imperative verb** (e.g. Fix”, “Add”, “Refactor”, “Update), and must not end with a period.
45+
* The title must be written in **title case**, start with a **imperative verb** (e.g. "Fix", "Add", "Refactor", "Update"), and must not end with a period.
4646
* After the title leave a **blank line**.
4747
* The body may contain one or more paragraphs that:
4848
* Summarize **what** was changed (high‑level overview, not a line‑by‑line description).
49-
* If the change touches multiple logical areas, add a short *** <area>** bullet list at the end of the body.
49+
* If the change touches multiple logical areas, add a short **"* <area>"** bullet list at the end of the body.
5050
* Do **not** repeat the diff verbatim in the commit message; use it only as source material for understanding the change.
51-
* Append a footer with the following text at the end of the generated commit message: "** Generated by CodeLite. **"
51+
* Append a footer with the following text at the end of the generated commit message: "**Generated by CodeLite**"
5252
5353
## Input
54-
Below is the `git diff` of the change you need to describe. Use it to infer the intent of the change, the files involved, and any important code‑level details (e.g. added/removed public APIs, refactorings, bug‑fixes, test additions, etc.).
55-
54+
Below is the `git diff` of the change you need to describe. Use it to infer the intent of the change, the files involved,
55+
and any important code‑level details (e.g. added/removed public APIs, refactorings, bug‑fixes, test additions, etc.).
5656
5757
```diff
5858
{{context}}
@@ -66,14 +66,15 @@ const std::string PROMPT_GIT_RELEASE_NOTES =
6666
R"(You are an expert technical writer who creates concise, well‑structured release notes for public websites.
6767
6868
Your job:
69+
6970
1. Obtain all git commits from HEAD to the latest tag. Use `git describe --tags --abbrev=0` to find the latest tag, then `git log <tag>..HEAD --oneline` to list the commits.
7071
2. Group the commits into the following sections **only if there is at least one item**:
7172
- **✨ New Features** – new public‑facing functionality.
7273
- **🐛 Bug Fixes** – corrections of defects.
7374
- **🔧 Improvements / Refactorings** – internal enhancements, performance, code cleanup, etc.
7475
- **📝 Documentation** – docs, READMEs, comments, examples, API docs.
7576
- **⚠️ Breaking Changes** – anything that might require users to change their code or configuration.
76-
- **🚀 Other** – anything that doesnt fit above (e.g., CI/CD updates, test additions, build scripts).
77+
- **🚀 Other** – anything that doesn't fit above (e.g., CI/CD updates, test additions, build scripts).
7778
7879
3. For each commit, keep only the essential part of its subject line (ignore the hash, date, author).
7980
- If the commit message already contains a conventional prefix (e.g., `feat:`, `fix:`, `docs:`), **use that to decide the section**.
@@ -91,19 +92,7 @@ Your job:
9192
# Release {{VERSION}} – {{RELEASE_DATE}}
9293
```
9394
94-
6. End the notes with a short “_Thank you for using our software!_” line.)";
95-
96-
const std::string PROMPT_GIT_RELEASE_NOTES_MERGE =
97-
R"(Rephrase the following release notes text. Remove duplicate entries and merge the sections.
98-
99-
Add a summary section that contains list of contributors and the number of commit they did.
100-
101-
Here are the release notes:
102-
103-
```markdown
104-
{{context}}
105-
```
106-
)";
95+
6. End the notes with a short "_Thank you for using our software!_" line.)";
10796

10897
const std::string PROMPT_GIT_CODE_REVIEW =
10998
R"(You are an expert developer performing a code review. Your task is to analyze the provided git diff and offer constructive feedback.
@@ -118,11 +107,7 @@ Your review should cover the following points:
118107
Provide a concise summary at the beginning of your review. For each suggestion, use a GCC style format.
119108
If you provide a code example for an improvement, include the filename where the change should be applied.
120109
121-
Here is the git diff to review:
122-
123-
```diff
124-
{{context}}
125-
```
110+
To obtain the git diff, use the command: `git --no-pager diff HEAD`
126111
127112
Here are some examples:
128113

0 commit comments

Comments
 (0)