Skip to content

fix: refresh scroller layout when tool confirmation dialog is cancelled - #252

Closed
Darshan Poudel (rsd-darshan) wants to merge 8 commits into
microsoft:mainfrom
rsd-darshan:fix/subagent-panel-size-cancel-dialog
Closed

Darshan Poudel (rsd-darshan) wants to merge 8 commits into
microsoft:mainfrom
rsd-darshan:fix/subagent-panel-size-cancel-dialog

Conversation

@rsd-darshan

@rsd-darshan Darshan Poudel (rsd-darshan) commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When the user cancels a subagent tool confirmation dialog, the subagent panel stays expanded at its pre-cancel height
  • Root cause: cancelConfirmation() calls parent.layout() (relays the turn widget's children) but never updates the ScrolledComposite's minimum size via refreshScrollerLayout()
  • On the Continue path this goes unnoticed because subsequent subagent messages trigger a layout refresh; on the Cancel path no further messages arrive, so the panel is stuck

Fix

In InvokeToolConfirmationDialog.cancelConfirmation(), after parent.layout(), walk up the ancestor chain to find ChatContentViewer and call refreshScrollerLayout(). This recomputes setMinHeight() so the scroll area collapses correctly after cancellation.

Test plan

  • Invoke a subagent (e.g. "scan for CVEs")
  • Wait for the tool confirmation dialog to appear
  • Click Cancel
  • Verify the subagent panel resizes/collapses correctly and does not stay stuck at the expanded height
  • Click Continue on a separate invocation and verify that path is unaffected

…l in picker

When a BYOK model is named identically to a Copilot-native model (e.g. GPT-4.1),
both dropdown items received the same ID, causing the picker to highlight both
as selected simultaneously.

Use a provider-prefixed picker ID for BYOK models so each item has a unique
identity, and update the selection and lookup logic to match.

Fixes microsoft#167
Existing internal callers pass plain model names (e.g. fallback model,
custom mode event). Match by picker ID first, then fall back to model
name so both call patterns keep working.
…concatenation

Replaces the custom providerName + "_" + modelName concatenation with the
model's existing getModelKey() method, which already produces a stable
composite key used throughout the codebase. This avoids potential collisions
from naive string concatenation and eliminates the blank-provider-name edge case.
…dules (microsoft#208)

Replace getPickerId() wrapper with direct model.getModelKey() calls at each
use site, removing the unnecessary indirection.
- setActiveModel now accepts only a composite model key (modelKey),
  matching the picker ID used throughout the codebase
- Custom mode event handler resolves the model name to a key via
  findModelKeyByName() before calling setActiveModel
- ModelHoverContentProvider uses model.getModelKey() directly instead
  of model.getModelName()
When the user cancels a subagent tool confirmation dialog, the subagent
panel stays expanded at its pre-cancel height. This happens because
cancelConfirmation() only calls parent.layout() (relaying the turn
widget's children), but never updates the ScrolledComposite's minimum
size via refreshScrollerLayout(). On the Continue path this goes
unnoticed because subsequent subagent messages trigger a layout refresh;
on the Cancel path no further messages arrive, so the panel is stuck.

Fix by walking up the ancestor chain after parent.layout() to find the
ChatContentViewer and calling refreshScrollerLayout(), which recomputes
setMinHeight() and collapses the scroll area correctly.

Fixes microsoft#169

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR standardizes model selection to use the model’s composite key (modelKey) instead of display name, and fixes a UI layout issue after canceling tool confirmation.

Changes:

  • Switch active model selection from modelName to modelKey across the model picker and hover UI.
  • Update ModelService#setActiveModel contract to accept a composite key and adjust call sites accordingly.
  • Refresh the chat scroller layout after canceling a tool confirmation so the UI collapses correctly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
.../swt/ModelHoverContentProvider.java Uses modelKey when activating a model from hover actions.
.../chat/services/ModelService.java Changes setActiveModel to take modelKey, adds name→key resolver, updates bindings and fallback selection.
.../chat/ModelPickerGroupsBuilder.java Uses modelKey as dropdown item id to align with picker binding and activation.
.../chat/InvokeToolConfirmationDialog.java Forces scroll container min-size refresh after cancellation to avoid stale expanded layout.

Comment on lines +334 to +342
private String findModelKeyByName(String modelName) {
Map<String, CopilotModel> currentModels = modelObservable.getValue();
for (Map.Entry<String, CopilotModel> entry : currentModels.entrySet()) {
if (entry.getValue().getModelName().equals(modelName)) {
return entry.getKey();
}
}
return null;
}
Comment on lines +149 to +153
// Resolve name to key, then activate
String modelKey = findModelKeyByName(modelName);
if (modelKey != null) {
setActiveModel(modelKey);
}
Comment on lines +349 to 359
public void setActiveModel(String modelKey) {
Map<String, CopilotModel> currentModels = modelObservable.getValue();

// Find model by model name and get its composite key
String compositeKey = null;
final CopilotModel model;
CopilotModel foundModel = null;

for (Map.Entry<String, CopilotModel> entry : currentModels.entrySet()) {
if (entry.getValue().getModelName().equals(modelName)) {
compositeKey = entry.getKey();
foundModel = entry.getValue();
break;
}
if (currentModels.containsKey(modelKey)) {
compositeKey = modelKey;
foundModel = currentModels.get(modelKey);
}
Comment on lines +248 to +258
// Walk up to refresh the scroll container's minimum size; without this the panel
// stays expanded at its pre-cancel height because ScrolledComposite.setMinHeight()
// is never updated when no further messages arrive after cancellation.
Composite ancestor = parent.getParent();
while (ancestor != null && !ancestor.isDisposed()) {
if (ancestor instanceof ChatContentViewer) {
((ChatContentViewer) ancestor).refreshScrollerLayout();
break;
}
ancestor = ancestor.getParent();
}
@rsd-darshan

Copy link
Copy Markdown
Contributor Author

Closing to reopen from a clean branch based on main — this branch accidentally included unrelated commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants