Fix crash when adding an empty profile matcher #21009
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
DHowett
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::DisplayTextbuilds the label as "profile: ..., commandline: ..., source: ..., " and then removes the trailing ", " withresize(size() - 2). When every field is empty the string is empty, sosize() - 2wraps around and the resize throws. It now returns early when the string is empty, the same wayNewTerminalArgs::GenerateNamehandles it.The same function is used for
matchProfilesentries 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:matchProfilesentries 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{"type": "matchProfiles", "name": null, "commandline": null, "source": null}), restarted Terminal Dev and reopened the Dropdown Menu page: no crash, entries unchangedNo automated regression test was added because no existing test project directly covers the Settings Editor view models.
PR Checklist
- If checked, please file a pull request on our docs repo and link it here: #xxx