← Back to Pull requests

Don't clobber NewTerminalArgs settings when initializing a tab #20810

Open
zadjii-msft opened this pull request with 48 lines diff across 4 files
View on GitHub
zadjii-msft zadjii-msft commented on Oct 16, 2026 18:26 UTC
Author

#20328 added a call to Tab::UpdateSettings in _InitializeTab so that the tab header would pick up the window's tabWidthMode (previously done in Tab::Initialize via the global settings).

HOWEVER, UpdateSettings also pushes profile-only settings into every pane, overwriting settings that came from NewTerminalArgs (e.g. CLI args like --suppressApplicationTitle, --colorScheme, etc).

Instead, pass the window settings into Tab::Initialize and only update the header width there, like it was before #20328.

Closes #20749

Related to #20751

Diff: 48 lines (+38 / -10) across 4 files Reviewer: lhecker Review duration: 41930m
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.31) × (1 − Review Confidence (0.92)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.31 · 48 lines diff across 4 files
0.31
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.93 · 4 substantive comment(s)
0.93
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
92%
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.233
Real PR Conversation Timeline
6 items
lhecker lhecker commented on code on Oct 19, 2026 15:22 UTC
Code Review
src/cascadia/LocalTests_TerminalApp/TabTests.cpp:1
@@ -1518,4 +1520,30 @@ namespace TerminalAppLocalTests
         });
     }
 
+    void TabTests::TestNewTabArgsOverrideProfileSettings()
+    {
+        Log::Comment(L"GH#20749: Settings from NewTerminalArgs should not be "
+                     L"replaced with the profile's settings when the tab is initialized.");
+
+        auto page = _commonSetup();
+        VERIFY_IS_NOT_NULL(page);
+
+        TestOnUIThread([&page]() {
+            NewTerminalArgs newTerminalArgs{ 0 };
+            newTerminalArgs.ColorScheme(L"Vintage");
+            page->_OpenNewTab(newTerminalArgs);
+        });
+        VERIFY_ARE_EQUAL(2u, page->_tabs.Size());
+
+        TestOnUIThread([&page]() {
+            const auto& activeControl{ page->_GetActiveControl() };
+            VERIFY_IS_NOT_NULL(activeControl);
+
+            Log::Comment(L"The new tab should use the scheme from the args, not the profile");
+            const til::color backgroundColor{ activeControl.BackgroundColor() };
+            VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, backgroundColor);
+        });
+        Log::Comment(L"Sleep to let events propagate");
+        Sleep(250);

This test is sus. Could probably be part of an existing test?

lhecker lhecker commented on code on Oct 19, 2026 15:23 UTC
Code Review
src/cascadia/TerminalApp/Tab.cpp:1
@@ -315,13 +315,19 @@ namespace winrt::TerminalApp::implementation
     // - Called after construction of a Tab object to bind event handlers to its
     //   associated Pane and TermControl objects
     // Arguments:
-    // - <none>
+    // - windowSettings: the settings for the window this tab is being added to
     // Return Value:
     // - <none>
-    void Tab::Initialize()
+    void Tab::Initialize(const WindowSettings& windowSettings)
     {
         ASSERT_UI_THREAD();
 
+        // GH#20749: Only apply the tab-level window settings here. Don't call
+        // UpdateSettings, because that would also push profile-only settings

Eh? Why does UpdateSettings override those launch args in the first place?

lhecker lhecker commented on Oct 19, 2026 15:24 UTC
Reviewer

Two? nits? LGTM.

zadjii-msft zadjii-msft commented on code on Oct 21, 2026 10:51 UTC
Code Review
src/cascadia/TerminalApp/Tab.cpp:1
@@ -315,13 +315,19 @@ namespace winrt::TerminalApp::implementation
     // - Called after construction of a Tab object to bind event handlers to its
     //   associated Pane and TermControl objects
     // Arguments:
-    // - <none>
+    // - windowSettings: the settings for the window this tab is being added to
     // Return Value:
     // - <none>
-    void Tab::Initialize()
+    void Tab::Initialize(const WindowSettings& windowSettings)
     {
         ASSERT_UI_THREAD();
 
+        // GH#20749: Only apply the tab-level window settings here. Don't call
+        // UpdateSettings, because that would also push profile-only settings

Mostly historical reasons I guess. There's been a bug on the backlog for ages for "hot reloading the settings can clobber CLI args". I wanted to scope this fix down to just fixing this bug rather than ((however big that fix ends up being))

zadjii-msft zadjii-msft commented on code on Oct 21, 2026 14:40 UTC
Code Review
src/cascadia/LocalTests_TerminalApp/TabTests.cpp:1
@@ -1518,4 +1520,30 @@ namespace TerminalAppLocalTests
         });
     }
 
+    void TabTests::TestNewTabArgsOverrideProfileSettings()
+    {
+        Log::Comment(L"GH#20749: Settings from NewTerminalArgs should not be "
+                     L"replaced with the profile's settings when the tab is initialized.");
+
+        auto page = _commonSetup();
+        VERIFY_IS_NOT_NULL(page);
+
+        TestOnUIThread([&page]() {
+            NewTerminalArgs newTerminalArgs{ 0 };
+            newTerminalArgs.ColorScheme(L"Vintage");
+            page->_OpenNewTab(newTerminalArgs);
+        });
+        VERIFY_ARE_EQUAL(2u, page->_tabs.Size());
+
+        TestOnUIThread([&page]() {
+            const auto& activeControl{ page->_GetActiveControl() };
+            VERIFY_IS_NOT_NULL(activeControl);
+
+            Log::Comment(L"The new tab should use the scheme from the args, not the profile");
+            const til::color backgroundColor{ activeControl.BackgroundColor() };
+            VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, backgroundColor);
+        });
+        Log::Comment(L"Sleep to let events propagate");
+        Sleep(250);

I mean, maybe? I don't hate that it's an actually pretty specific test for the original regression.

It's more of a bigger issue that every "UI" test we write needs to add a 250ms wait at the end to make sure things worked.

we have like, insanely low test coverage for how our UI works so I'm kinda inclined to add more

Reviewers
Assignees
zadjii-msft zadjii-msft
Labels
risk: low confidence: 92.2% 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: 30.7% (LOW) · Higher = larger blast radius
30.7%
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: 92.2% · Lower = rushed or shallow review
92.2%
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: 2.4% · Safe to merge
2.4%