← Back to Pull requests

Fix crash when adding an empty profile matcher #21009

Closed
unknown closed this pull request without merging on Dec 02, 2026 20:39 UTC
View on GitHub
unknown unknown commented on Dec 02, 2026 16:18 UTC
Author

Summary of the Pull Request

Clicking "Add profile matcher" on the Dropdown Menu (New Tab Menu) settings page with all three fields empty crashed Terminal. It now adds the entry without crashing.

References and Relevant Issues

Closes #20587

Detailed Description of the Pull Request / Additional comments

MatchProfilesEntryViewModel::DisplayText builds the label as "profile: ..., commandline: ..., source: ..., " and then removes the trailing ", " with resize(size() - 2). When every field is empty the string is empty, so size() - 2 wraps around and the resize throws. It now returns early when the string is empty, the same way NewTerminalArgs::GenerateName handles it.

The same function is used for matchProfiles entries loaded from settings.json, so an empty one there no longer crashes the settings page either.

This only fixes the crash. An empty matcher is still allowed and, as before, matches no profiles.

While testing I also noticed that typing a profile name and clicking "Add profile matcher" straight away, without leaving the text box first, adds an empty entry (so before this fix that crashed too). I've left that behaviour alone here.

Validation Steps Performed

Built and deployed CascadiaPackage (Debug x64) from unmodified main and the patched branch:

  • Before the fix: Settings > Dropdown Menu > Profile matcher, all fields empty, "Add profile matcher": Terminal crashed (0xc000027b in Windows.UI.Xaml.dll)

  • After the fix, the same steps add an empty entry and Terminal keeps running

  • Added a matcher with only a profile name: shows "profile: <name>"

  • Loaded matchProfiles entries from settings.json with: no properties, commandline only, source only, and all three. The settings page opened without crashing and showed a blank label, "commandline: ...", "source: ..." and "profile: ..., commandline: ..., source: ..." respectively

  • In the new tab dropdown, the empty matcher added no profiles; the other three matched the expected profiles

  • Saved from the settings UI with the empty matcher present (written as {"type": "matchProfiles", "name": null, "commandline": null, "source": null}), restarted Terminal Dev and reopened the Dropdown Menu page: no crash, entries unchanged

  • Deleted the empty matcher with its delete button and saved: it was removed from settings.json
  • No automated regression test was added because no existing test project directly covers the Settings Editor view models.

    PR Checklist


  • Closes #20587

  • Tests added/passed

  • Documentation updated

  • - If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)
  • Diff: 339 lines (+254 / -85) across 4 files Reviewer: DHowett Review duration: 261m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 339 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #21009"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%