Skip to content

CmdPal: Fix image overflow in Details panel#47385

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-image-overflow-details-panel
Draft

CmdPal: Fix image overflow in Details panel#47385
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-image-overflow-details-panel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

Images in Details.Body markdown regressed in v0.93.0: plain ![Alt](url) renders at natural dimensions (e.g. 1280px) instead of being constrained to the panel width, causing horizontal overflow with no scroll.

Summary of the Pull Request

ImageProvider.GetImage() explicitly set FitColumnWidth = imageSource.Hints.FitMode == "fit", which evaluates to false when no ?--x-cmdpal-fit=fit query parameter is present — overriding the InlineImageOptions.FitColumnWidth = true default in RtbInlineImageFactory.

Changes:

  • ImageProvider.cs: Changed condition to FitMode is null || FitMode.Equals("fit", StringComparison.OrdinalIgnoreCase) so the default (no hint) correctly fits to column width, mixed-case values like ?--x-cmdpal-fit=Fit are handled correctly, and users can opt out with ?--x-cmdpal-fit=none.
  • SampleMarkdownImagesPage.cs: Updated docs to reflect fit as the default; changed the "No scaling" example to use ?--x-cmdpal-fit=none; added a note that the no-fit path uses source pixel dimensions which may differ from the natural visual size under non-100% DPI scaling.

Fit semantics after fix:

URL FitColumnWidth
![img](https://example.com/img.jpg) true (default)
![img](https://example.com/img.jpg?--x-cmdpal-fit=fit) true (explicit, case-insensitive)
![img](https://example.com/img.jpg?--x-cmdpal-fit=none) false (opt-out)

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

RtbInlineImageFactory.InlineImageOptions.FitColumnWidth defaults to true, and Update() uses rtb.ActualWidth to cap image size to the column. The bug was that ImageProvider always passed an explicit false unless ?--x-cmdpal-fit=fit was in the URL, bypassing that default entirely. The fix also switches to a case-insensitive string comparison so query values like Fit or FIT are treated identically to fit.

Validation Steps Performed

  • Verified plain ![Alt](url) markdown in a Details.Body is now constrained to the Details panel width (restores v0.92.1 behavior).
  • Verified ?--x-cmdpal-fit=none disables fitting for images that should render at natural (pixel) size.
  • Verified ?--x-cmdpal-fit=fit and mixed-case variants (e.g. ?--x-cmdpal-fit=Fit) still take the fit path.

Copilot AI linked an issue Apr 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix image overflow in command palette details panel CmdPal: Fix image overflow in Details panel Apr 29, 2026
Copilot AI requested a review from MuyuanMS April 29, 2026 09:33
@niels9001 niels9001 added the Product-Command Palette Refers to the Command Palette utility label Apr 29, 2026
@MuyuanMS MuyuanMS requested a review from Copilot May 14, 2026 03:09
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

Fixes a regression in CmdPal’s markdown image rendering where images in Details.Body could render at their natural (large) dimensions and overflow the Details panel by restoring “fit to column width” as the default behavior when no fit hint is provided.

Changes:

  • Adjust ImageProvider.GetImage() to treat missing --x-cmdpal-fit as “fit” (FitColumnWidth = true) while still allowing opt-out via --x-cmdpal-fit=none.
  • Update the Sample Pages markdown image documentation/examples to reflect fit as the default and none as the opt-out.

Reviewed changes

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

File Description
src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/MarkdownImageProviders/ImageProvider.cs Restores default “fit to column width” behavior when no fit hint is present.
src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleMarkdownImagesPage.cs Updates sample docs/examples to match the new default fit semantics and demonstrate opt-out.

Comment on lines 23 to 27
{
DownscaleOnly = imageSource.Hints.DownscaleOnly ?? true,
FitColumnWidth = imageSource.Hints.FitMode == "fit",
FitColumnWidth = imageSource.Hints.FitMode is null or "fit",
MaxWidthDip = imageSource.Hints.MaxPixelWidth,
MaxHeightDip = imageSource.Hints.MaxPixelHeight,
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.

Fixed — the FitMode check in ImageProvider now uses StringComparison.OrdinalIgnoreCase, so mixed-case query values still take the fit path.

Comment on lines +158 to 161
- `none`: no automatic scaling, provides image as is
- `--x-cmdpal-upscale`
- `true`: allow upscaling
- `false`: downscale only (default)
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.

Added a note to the sample Markdown images page calling out that the no-fit sample uses source pixel size, so it can differ from the natural visual size under non-100% DPI scaling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MuyuanMS
Copy link
Copy Markdown
Contributor

@copilot please re-review the latest changes.

@zadjii-msft
Copy link
Copy Markdown
Member

Can you please add before and after screenshots of this change?

@zadjii-msft zadjii-msft added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmdPal: Image overflow in Details panel

5 participants