Skip to content

Commit 4226292

Browse files
committed
Fix AI Infobar Focus and Parent Placement
Move the AI trust prompt infobar into the chat pane's bottom splitter area instead of attaching it to the top-level window, so it participates in the local layout correctly. Also override message display to restore focus after showing the infobar, keeping keyboard interaction available for the prompt buttons. * AI prompt UI * InfoBar behavior **Generated by CodeLite** Signed-off-by: Eran Ifrah <eran@codelite.org>
1 parent f0b3439 commit 4226292

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Plugin/ai/InfoBar.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ InfoBar::InfoBar(wxWindow* parent, std::shared_ptr<std::promise<llm::UserAnswer>
1616
AddButton(wxID_YES, _("Yes"));
1717
AddButton(wxID_NO, _("No"));
1818
AddButton(wxID_YESTOALL, _("Trust"));
19-
2019
Bind(wxEVT_BUTTON, &InfoBar::OnYes, this, wxID_YES);
2120
Bind(wxEVT_BUTTON, &InfoBar::OnNo, this, wxID_NO);
2221
Bind(wxEVT_BUTTON, &InfoBar::OnTrust, this, wxID_YESTOALL);
2322
}
2423

24+
void InfoBar::ShowMessage(const wxString& msg, int flags)
25+
{
26+
wxInfoBar::ShowMessage(msg, flags);
27+
CallAfter(&wxInfoBar::SetFocus);
28+
}
29+
2530
void InfoBar::Dismiss()
2631
{
2732
wxInfoBar::Dismiss();

Plugin/ai/InfoBar.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class WXDLLIMPEXP_SDK InfoBar : public wxInfoBar
2323
* @return void This method does not return a value.
2424
*/
2525
void Dismiss() override;
26+
void ShowMessage(const wxString& msg, int flags = wxICON_INFORMATION) override;
2627

2728
protected:
2829
void OnYes(wxCommandEvent& e);

Plugin/ai/LLMManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "assistant/common/magic_enum.hpp"
1010
#include "clWorkspaceManager.h"
1111
#include "cl_command_event.h"
12+
#include "cl_config.h"
1213
#include "cl_standard_paths.h"
1314
#include "codelite_events.h"
1415
#include "environmentconfig.h"
@@ -1272,7 +1273,7 @@ Manager::PromptUserYesNoTrustQuestion(const wxString& text, const wxString& code
12721273
GetChatWindow()->AppendText(prompt);
12731274
}
12741275

1275-
auto parent = ::wxGetTopLevelParent(GetChatWindow());
1276+
auto parent = GetChatWindow()->GetSplitterPageBottom();
12761277
InfoBar* bar = new InfoBar(parent, promise_ptr);
12771278
parent->GetSizer()->Insert(0, bar, wxSizerFlags(0).Expand());
12781279
bar->ShowMessage(text, wxICON_QUESTION);

0 commit comments

Comments
 (0)