Skip to content

Add preview dialog for package actions#402

Draft
RRosio wants to merge 12 commits intomamba-org:mainfrom
RRosio:dry-run-preview
Draft

Add preview dialog for package actions#402
RRosio wants to merge 12 commits intomamba-org:mainfrom
RRosio:dry-run-preview

Conversation

@RRosio
Copy link
Copy Markdown
Collaborator

@RRosio RRosio commented Mar 26, 2026

Adding a dialog allowing users to preview the package changes when running a package action. Uses conda's --dry-run flag.

TODO:

  • Do not request confirmation if only upcoming changes are the requested changes
  • Single separate table for package changes, with the change identified through a badge
  • Add the changes preview to the 'Remove' button
  • Show solver error in UI, already in response
  • Normalize package change preview error dialog/notification for Batch and Direct modes
  • Tests

@RRosio RRosio self-assigned this Mar 26, 2026
@RRosio RRosio added the enhancement New feature or request label Mar 26, 2026
@github-actions
Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on the branch RRosio/gator/dry-run-preview

@RRosio RRosio force-pushed the dry-run-preview branch from 365b839 to 5716a3a Compare April 4, 2026 00:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a package-change preview dialog backed by conda/mamba --dry-run --json, so users can review solver side-effects before applying install/update/remove actions.

Changes:

  • Introduces a new UI dialog (CondaPkgPreview) to display LINK/UNLINK/FETCH transaction diffs with requested-vs-dependency separation.
  • Adds a new backend REST endpoint (PATCH /environments/<env>/packages/preview) and EnvManager dry-run preview implementation with has_side_effects.
  • Wires preview into existing package actions (apply changes, delete package(s), update package) and improves HTTP error-body formatting.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/common/src/tokens.ts Adds shared types + package manager API for dry-run preview results.
packages/common/src/services.ts Implements dry_run_preview client call and improves requestServer error parsing.
packages/common/src/packageActions.ts Integrates preview dialog into package apply/delete/update flows.
packages/common/src/components/CondaPkgPreview.tsx New preview dialog + transaction diff rendering UI.
packages/common/src/components/CondaPkgPanel.tsx Minor comment tweak related to package action cancellation handling.
mamba_gator/handlers.py Adds preview endpoint handler and registers the route.
mamba_gator/envmanager.py Implements dry-run preview execution + normalization + side-effect detection.
mamba_gator/tests/test_manager.py Adds unit tests for preview normalization + consolidation logic.
mamba_gator/tests/test_api.py Adds API tests for the preview task endpoint.
docs/source/user-guide/features.md Documents the new “Preview Package Changes” feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

environment?: string
): Promise<Conda.IPreviewTransactionActions> {
const theEnvironment = environment || this.environment;
console.log('packages are: ', packages);
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Remove the leftover console logging of package names; this will spam the browser console during normal usage and may leak user/environment details. Use the existing logger/debug facilities if you need diagnostics, or gate behind a debug flag.

Suggested change
console.log('packages are: ', packages);

Copilot uses AI. Check for mistakes.
type: 'success',
autoClose: 2000
});
Notification.dismiss(toastId);
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

In the no-side-effects path, the toast is updated to success and then immediately dismissed, so the user likely never sees the message (in contrast to other actions in this repo that rely on autoClose without dismissing). Consider removing the immediate dismiss and letting autoClose handle it, or only dismiss after a timeout.

Suggested change
Notification.dismiss(toastId);

Copilot uses AI. Check for mistakes.
Comment on lines +81 to +85
const confirmed = await openPackagePreviewDialog({
title: 'Preview package changes',
jobs: previewJob,
acceptLabel: 'Apply'
});
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The preview dialog accept button is always labeled "Apply" via dryRunPreview, but this helper is also used for delete/remove flows (e.g., deletePackage/deletePackages). That label is misleading for destructive actions; consider making acceptLabel configurable (default "Apply") and passing "Delete"/"Remove" from callers.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +43
r.build_string !== null
? String(r.build_string)
: r.build !== null
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

sanitizePreviewPackageRow treats undefined build_string/build as non-null, which will coerce to the literal string "undefined" and leak into comparisons/UI. Update the null checks to treat both null and undefined as absent (and only stringify when the value is actually present).

Suggested change
r.build_string !== null
? String(r.build_string)
: r.build !== null
r.build_string !== undefined && r.build_string !== null
? String(r.build_string)
: r.build !== undefined && r.build !== null

Copilot uses AI. Check for mistakes.
}

// TODO: Handle the case where the user cancels the update: show a notification here rather than in the packageActions.ts file
// TODO: Handle the case where the user cancels the update: show a notification here rather than in the packageActions.tsx file
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

This TODO references packageActions.tsx, but the file is packageActions.ts. Please correct the filename in the comment to avoid confusion when someone searches for it later.

Suggested change
// TODO: Handle the case where the user cancels the update: show a notification here rather than in the packageActions.tsx file
// TODO: Handle the case where the user cancels the update: show a notification here rather than in the packageActions.ts file

Copilot uses AI. Check for mistakes.
Comment on lines +1117 to +1123
if "error" not in result:
requested_set = {p.split('=')[0] for p in packages}
plan_names = {
x.get("name", "").strip().lower()
for x in result.get("LINK", []) + result.get("UNLINK", [])
}
result["has_side_effects"] = not plan_names.issubset(requested_set)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

has_side_effects can be miscomputed because requested_set is derived via p.split('=')[0], which fails for common conda specs like "python>=3.10", "python!=3.14.0", or channel-qualified specs. This will cause unnecessary preview dialogs (or incorrect auto-apply decisions). Parse the base package name more robustly (e.g., split on comparison operators and trim, and normalize case to match plan_names).

Copilot uses AI. Check for mistakes.
Comment on lines +391 to +397
When applying changes, users see a pop-up dialog that provides a summary of the side-effects
to packages in an environment based on the requested changes. If there are no additional changes
to packages in the environment, other than the requested changes, the dialog is not displayed.
The preview dialog provides a summary count of packages removed, installed and changed, as well
as a section with the requested package changed followed by a list of the additional packages
changes with more details about those changes. Based on the preview, users can continue to apply
those changes or cancel the operation.
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Documentation text has grammar issues and trailing whitespace (e.g., "as well ", "requested package changed", "additional packages changes"). Please fix wording and remove trailing spaces so the user guide renders cleanly.

Suggested change
When applying changes, users see a pop-up dialog that provides a summary of the side-effects
to packages in an environment based on the requested changes. If there are no additional changes
to packages in the environment, other than the requested changes, the dialog is not displayed.
The preview dialog provides a summary count of packages removed, installed and changed, as well
as a section with the requested package changed followed by a list of the additional packages
changes with more details about those changes. Based on the preview, users can continue to apply
those changes or cancel the operation.
When applying changes, users see a pop-up dialog that provides a summary of the side effects
on packages in an environment based on the requested changes. If there are no additional changes
to packages in the environment other than the requested changes, the dialog is not displayed.
The preview dialog provides a summary count of packages removed, installed, and changed, as well
as a section showing the requested package changes followed by a list of changes to additional
packages, with more details about those changes. Based on the preview, users can continue to apply
the changes or cancel the operation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants