Skip to content

Commit 49f835f

Browse files
committed
npe
1 parent 6beb52a commit 49f835f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/uno/anahata/ai/swing/SwingFunctionPrompter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ public class SwingFunctionPrompter extends JDialog implements FunctionPrompter {
5252
* @param chatPanel The ChatPanel that initiated the prompt.
5353
*/
5454
public SwingFunctionPrompter(ChatPanel chatPanel) {
55-
super((JFrame) SwingUtilities.getWindowAncestor(chatPanel), "Confirm Proposed Actions - " + chatPanel.getChat().getDisplayName(), true);
55+
// We use null as the owner initially because the ChatPanel might not be added to a window yet.
56+
// The title is updated in the prompt() method once the Chat instance is fully initialized.
57+
super((JFrame) null, "Confirm Proposed Actions", true);
5658
this.chatPanel = chatPanel;
5759
}
5860

5961
@Override
6062
public PromptResult prompt(ChatMessage modelMessage, Chat chat) {
6163
try {
6264
SwingUtilities.invokeAndWait(() -> {
65+
setTitle("Confirm Proposed Actions - " + chat.getDisplayName());
6366
interactiveRenderers.clear();
6467
functionConfirmations.clear();
6568
userComment = "";
@@ -68,7 +71,7 @@ public PromptResult prompt(ChatMessage modelMessage, Chat chat) {
6871
initComponents(modelMessage);
6972
pack();
7073
setSize(1024, 768);
71-
setLocationRelativeTo(getOwner());
74+
setLocationRelativeTo(SwingUtilities.getWindowAncestor(chatPanel));
7275
setVisible(true); // This blocks until the dialog is closed
7376
});
7477
} catch (InterruptedException | InvocationTargetException e) {

0 commit comments

Comments
 (0)