Fixes #issue. Dialog renders with Base scheme instead of Dialog scheme when running#4841
Conversation
…unning Co-authored-by: tig <585482+tig@users.noreply.github.com> Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/0ca8d90a-caee-43ac-bfbc-6e62aae4ed58
|
@copilot you need to document what you learned at each step specified in the issue. |
Updated the PR description with documentation of all three steps: Step 1 — Tests: Added Step 2 — Commit history: The repository is a shallow clone so Step 3 — Fix: In |
|
@copilot you should be able to access the branches of the most recent PRs that were merged to v2_develop. I need to know which pr broke this. |
The regression was introduced by PR #4568 ( Before PR #4568, if (IsRunning)
{
SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Dialog); // ← correct
Padding!.SetScheme (SchemeManager.GetScheme (Schemes.Base));
Arrangement |= ...;
}PR #4568 was fixing issue #4567 ( PR #4568's fix moved
The fix in the current PR uses a sentinel check: restore to |
|
@copilot now fix it. |
Already done in commit |
|
@copilot run all tests. Including IntegrationTests. Ci/cd tests are failing. |
Ran both full test suites locally — all pass:
The two CI failures are pre-existing flaky tests unrelated to my changes (which only touch
|
Dialog<TResult>always rendered with theBasecolor scheme when running modally — theDialogscheme was never applied.Proposed Changes/Todos
git logSetStyle()to restore"Dialog"scheme when runningStep 1 — Write failing tests that illustrate the issue
Added two tests to
Tests/UnitTestsParallelizable/Views/DialogTests.cs:SchemeName_IsBase_WhenNotRunning— confirms that a non-runningDialogexposesSchemeName = "Base"(intentional design-time behaviour; passes before and after the fix).SchemeName_IsDialog_WhenRunning— capturesSchemeNameduring the first iteration callback while the dialog is actually running. This test failed before the fix becauseSchemeNamewas"Base"instead of"Dialog".Two pre-existing tests in
MessageBoxTestsindependently expose the same class of bug:Query_Sets_Dialog_SchemeName— expects"Dialog"while aMessageBox.Querydialog runs. (was also failing)ErrorQuery_Sets_Error_SchemeName— expects"Error"while aMessageBox.ErrorQuerydialog runs. (was also failing)Step 2 — Identify the PR that introduced the regression
Using
git log --oneline -- Terminal.Gui/Views/Dialog.cson the full (unshallowed) history, the regression was traced to:PR #4568 —
Fix MessageBox not setting SchemeName correctly(commitfe383fbf, merged Jan 13 2026)Before PR #4568,
SetStyle()'s running branch correctly setSchemeName = "Dialog":PR #4568 was fixing issue #4567 (
MessageBox.ErrorQuery does not use correct scheme). The original code always restoredSchemeName = "Dialog"when running — which inadvertently overwrote the"Error"scheme thatMessageBox.QueryFull()had set after construction.PR #4568's attempted fix moved
SchemeName = "Dialog"fromSetStyle()into the constructor and removed it from the running branch:Why this created the regression:
SchemeName = "Dialog", then immediately callsSetStyle()withIsRunning == false→SchemeName = "Base"(overwrites step 1).app.Run()callsSetStyle()withIsRunning == true→ only updatesArrangement;SchemeNamestays"Base"❌Why
MessageBox.ErrorQueryappeared to be fixed by PR #4568:QueryFull()setsSchemeName = "Error"after construction (afterSetStyle()has already run). Since the new running branch no longer overwritesSchemeName, the"Error"value survivesapp.Run(). But regularDialog— which never setsSchemeNameafter construction — was left stuck at"Base".Step 3 — Fix the bug
In
SetStyle(), whenIsRunning == true, restoreSchemeNameto"Dialog"only if it is still"Base"(the pre-run sentinel written bySetStyle()'s own not-running branch). This guard preserves any explicitly-set scheme (e.g."Error"set byMessageBox.ErrorQuery) while fixing the default case:This correctly handles all cases:
Dialog:"Base"→ restored to"Dialog"✅MessageBox.Query:"Base"→ restored to"Dialog"✅MessageBox.ErrorQuery:"Error"→ left unchanged ✅All four scheme-related tests now pass; no other tests were broken.
Test Results
Full test suites pass locally with 0 failures:
The two CI failures observed are pre-existing flaky tests unrelated to these changes (which only touch
DialogTResult.csandDialogTests.cs):Load_WithInvalidJson_AddsJsonError— environment-sensitive on Ubuntu CI; passes locallyAfter_Deactivation_Keys_Are_Not_Eaten_By_PopoverMenu_With_SubMenu— timing-sensitive on macOS CI; passes locallyPull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)Original prompt
SchemeName = "Dialog"#4840🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.