Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,17 @@ public CompletableFuture<LanguageModelToolConfirmationResult> requestToolExecuti
// process all the messages before showing the confirmation dialog
reset();

this.confirmDialog = new InvokeToolConfirmationDialog(this, title, message, input);
Runnable refreshLayout = null;
Composite ancestor = this.getParent();
while (ancestor != null && !ancestor.isDisposed()) {
if (ancestor instanceof ChatContentViewer) {
final ChatContentViewer viewer = (ChatContentViewer) ancestor;
refreshLayout = viewer::refreshScrollerLayout;
break;
}
ancestor = ancestor.getParent();
}
this.confirmDialog = new InvokeToolConfirmationDialog(this, title, message, input, refreshLayout);
CompletableFuture<LanguageModelToolConfirmationResult> toolConfirmationFuture = this.confirmDialog
.getConfirmationFuture();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class InvokeToolConfirmationDialog extends Composite {
private Label titleLbl;
private Font boldFont;
private Runnable titleFontChangeCallback;
private final Runnable onCancelCallback;

/**
* Create a new confirmation dialog for tool execution.
Expand All @@ -60,11 +61,14 @@ public class InvokeToolConfirmationDialog extends Composite {
* @param title The title of the confirmation dialog
* @param message The message to display
* @param input The input object to pass to the tool
* @param onCancelCallback invoked after the dialog is disposed on cancellation, for layout refresh
*/
public InvokeToolConfirmationDialog(Composite parent, String title, String message, Object input) {
public InvokeToolConfirmationDialog(Composite parent, String title, String message, Object input,
Runnable onCancelCallback) {
super(parent, SWT.BORDER | SWT.WRAP);
this.setLayout(new GridLayout(1, false));
this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
this.onCancelCallback = onCancelCallback;

createDialogContent(title, message, input);

Expand Down Expand Up @@ -242,9 +246,8 @@ public void cancelConfirmation() {
new AgentToolCancelLabel(this.getParent(), SWT.NONE, this.cancelMessage);
}
this.dispose();
// Check if parent is still valid before using it
if (parent != null && !parent.isDisposed()) {
parent.layout();
if (onCancelCallback != null) {
onCancelCallback.run();
}
}, this);
}
Expand Down