Skip to content

Update to TG 2.5.x (PR 5416 preview) - #202

Draft
tig wants to merge 3 commits into
developfrom
tg25-port
Draft

Update to TG 2.5.x (PR 5416 preview)#202
tig wants to merge 3 commits into
developfrom
tg25-port

Conversation

@tig

@tig tig commented Aug 23, 2026

Copy link
Copy Markdown
Member

⚠️ DO NOT MERGE with the pre-release pin in place

This PR pins a vendored pre-releaseTerminal.Gui 2.5.0-tig-remove-cm-followup.2, built from tui-cs/Terminal.Gui#5416 (head e8aba423) and committed as .nupkg/.snupkg files under local_packages/. Before merging:

  1. Update the Terminal.Gui pin to the public 2.5.x version in Directory.Build.props (TerminalGuiVersion; the only place the version is pinned — src/Clet/Clet.csproj references $(TerminalGuiVersion)).
  2. Delete local_packages/ and remove the tgui-pr-5416 package source from nuget.config (delete the file if nothing else needs it).
  3. Revert the .gitignore exception for local_packages/*.nupkg / *.snupkg (the TEMP: block at the end of .gitignore).
  4. Re-run build and tests (dotnet restore && dotnet build, then the four test projects) and confirm the restore pulls Terminal.Gui from nuget.org, not a local feed.

What this PR does

Ports clet to the Terminal.Gui 2.5.0 preview (ConfigurationManager removal). Part of the v2.5.0 ecosystem-validation gate tui-cs/Terminal.Gui#5630; TG changes come from tui-cs/Terminal.Gui#5416. Vendored-package pattern precedent: tig/winprint#272.

API breaks fixed (2.4.5 → 2.5.0 preview)

  • ConfigurationManager, ConfigLocations, [ConfigurationProperty], SettingsScope are deleted. Replaced with a new CletConfiguration static wrapper around TuiConfigurationBuilder ("clet"): Apply () at startup (Program.Main) pushes TG settings to the static facades and binds clet's own sections; Reload () re-reads all sources after a config file changes (also reloads TuiConfigurationBuilder.Shared so ThemeManager sees new themes).
  • [ConfigurationProperty] reflection discovery is gone. EditorSettings and FileAccessSettings now bind explicitly from the nested "EditorSettings" / "FileAccessSettings" sections (IConfiguration indexer reads — AOT/trim-safe, no binder reflection). The Clet.ConfigTests CM reflection proxies are deleted.
  • Config JSON is nested-shape only. Dotted top-level keys ("EditorSettings.LineNumbers", "Key.Separator", …) are detected as legacy and silently skipped by TG 2.5. clet's default config template, the JSONC-preserving EditorSettings.Save, and FileAccessSettings.AddToConfig all now read/write the nested shape ("EditorSettings": { "LineNumbers": … }). Existing user configs with dotted keys are ignored by TG (with a log warning), not migrated.
  • ConfigurationManager.ThrowOnJsonErrors / throwing Load+Apply are gone. The MEC loader never throws; per-source errors land in TuiJsonErrors. ConfigClet now: (1) checks JSON syntax with JsonDocument so errors keep line/column info for the editor jump-to-error UX, (2) drains TuiJsonErrors after reload, and (3) explicitly validates the "Theme" value against ThemeManager.GetThemeNames () — the 2.5 loader silently ignores unknown themes, which would have regressed clet's bad-theme error dialog.
  • Not hit by clet: View.Text non-virtual (no overrides), IAcceptTarget namespace move (no direct references).

Upstream findings (for the 2.5.0 gate)

  1. IApplication.RunAsync deadlocks when called after an await that resumed on an ambient SynchronizationContext (e.g. xunit's) — filed as IApplication.RunAsync deadlocks after await on ambient SynchronizationContext Terminal.Gui#5636. The run loop never completes; the input thread spins forever. await ….ConfigureAwait (false) before RunAsync avoids it; TG 2.4.5 did not have this. Worked around in ConfigClet.RunAsync (commented at the call site). Repro: Clet.IntegrationTests.ConfigCletIntegrationTests.RunAsync_WithBadTheme_StopAfterFirstIteration_ReturnsOk with the ConfigureAwait (false) removed.
  2. LinearRange legend rendering regression — filed as LinearRange legend renders stray characters (regression vs 2.4.5) Terminal.Gui#5637: the legend row renders FreenProbrTeam instead of Free Pro Team — stray literal characters drawn with the set-option attribute in the legend spacing cells. Repro: Clet.UITests.CletUiTests.LinearRangeClet_InitialRender_MatchesAnsiGolden (labels Free,Pro,Team).
  3. Unknown "Theme" values are silently ignored by the MEC loader (old CM threw). Apps that surfaced bad-theme errors must re-implement validation (clet now does).

Test results (Windows, local; CI runs ubuntu/macos/windows)

Suite Result
Clet.UnitTests ✅ 314/314
Clet.ConfigTests (rewritten for MEC) ✅ 26/26
Clet.IntegrationTests ✅ 54 (2 pre-existing skips)
Clet.SmokeTests ✅ 14 (1 pre-existing skip)
Clet.UITests (golden renders; not run in CI) ⚠️ 9/19 fail on this box — 5 already fail at baseline (develop + TG 2.4.5, env-dependent goldens); 4 new under 2.5: 3 are benign style diffs (Date/Time/Duration field cursor now underlined instead of inverse) and 1 is the real LinearRange regression above. Goldens intentionally not regenerated — that would bake in an upstream rendering bug and machine-dependent output.

dotnet format --verify-no-changes (CI style gate) and clet --help process smoke: ✅. Release build: ✅ zero warnings.

Follow-up

  • Swap to the public Terminal.Gui 2.5.x package and remove the vendored feed (steps above).
  • Regenerate the UITests goldens once 2.5.x final ships (cursor-style and checkbox-glyph changes) and the LinearRange legend regression is fixed upstream.
  • Terminal.Gui.Editor (2.5.1) and Terminal.Gui.Cli (0.1.0-develop.7) pins deliberately untouched — those repos are being ported separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BVbLXNzbus2MTXmiJDBErL

…tionManager

Port clet to the Terminal.Gui 2.5.0 preview built from tui-cs/Terminal.Gui#5416
(ConfigurationManager removal). Part of the v2.5.0 ecosystem-validation gate
(tui-cs/Terminal.Gui#5630).

- TEMP: vendor Terminal.Gui.2.5.0-tig-remove-cm-followup.2 in ./local_packages
  (nuget.config source "tgui-pr-5416"); swap to the public package once 2.5.x
  ships on nuget.org (pattern: tig/winprint#272).
- Replace ConfigurationManager / [ConfigurationProperty] with a new
  CletConfiguration wrapper around TuiConfigurationBuilder ("clet").
- EditorSettings / FileAccessSettings: bind from nested config sections;
  JSONC-preserving Save now writes the nested "EditorSettings" object.
- ConfigClet: validate syntax via JsonDocument, surface TuiJsonErrors, and
  explicitly reject unknown "Theme" values (the MEC loader ignores them).
- Default config template rewritten to the nested 2.5+ shape (dotted
  top-level keys are treated as legacy and skipped).
- Work around a TG 2.5 preview deadlock: RunAsync hangs when invoked after an
  await that resumed on an ambient SynchronizationContext (ConfigureAwait
  (false) on the pre-UI file read).
- Rewrite Clet.ConfigTests for the MEC-based configuration; drop the CM
  reflection proxies.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVbLXNzbus2MTXmiJDBErL
tig and others added 2 commits August 22, 2026 18:33
…ng line comment

FindLastJsonTokenPosition treated only whole-line comments as comments, so
when the insertion point's preceding value carried a trailing // comment,
the separating comma was inserted inside the comment text and the required
comma after the value was lost — Save produced invalid JSON that the
configuration loader then rejected. Now the helper detects trailing line
comments (string-aware, so URLs like the $schema value are unaffected) and
places the comma directly after the value. Covers both insertion paths:
appending missing keys inside an existing "EditorSettings" section and
inserting the whole section at the top level.

Test-first: Save_SectionEndsWithTrailingLineComment_ProducesValidJsonc and
Save_TopLevelEndsWithTrailingLineComment_ProducesValidJsonc failed before
the fix (JsonNode.Parse threw on the written file) and pass after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVbLXNzbus2MTXmiJDBErL
The deadlock found during PR 5416 validation is now filed upstream as
tui-cs/Terminal.Gui#5636; point the workaround comment at the issue.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVbLXNzbus2MTXmiJDBErL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant