Skip to content

Conversation

@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 80.52326% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.21%. Comparing base (b9f55a5) to head (944a530).
⚠️ Report is 2 commits behind head on v2_develop.

Files with missing lines Patch % Lines
Terminal.Gui/App/ApplicationImpl.Run.cs 86.81% 3 Missing and 9 partials ⚠️
Terminal.Gui/Views/CharMap/CharMap.cs 0.00% 8 Missing ⚠️
Terminal.Gui/App/ApplicationImpl.Lifecycle.cs 78.12% 5 Missing and 2 partials ⚠️
Terminal.Gui/App/Keyboard/KeyboardImpl.cs 25.00% 2 Missing and 4 partials ⚠️
Terminal.Gui/Drivers/OutputBufferImpl.cs 68.42% 4 Missing and 2 partials ⚠️
Terminal.Gui/ViewBase/View.Layout.cs 61.53% 0 Missing and 5 partials ⚠️
Terminal.Gui/ViewBase/View.Navigation.cs 0.00% 3 Missing and 2 partials ⚠️
Terminal.Gui/App/ApplicationImpl.cs 71.42% 1 Missing and 1 partial ⚠️
Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs 33.33% 0 Missing and 2 partials ⚠️
Terminal.Gui/Views/Color/ColorPicker.Prompt.cs 0.00% 2 Missing ⚠️
... and 11 more
Additional details and impacted files
@@               Coverage Diff               @@
##           v2_develop    #4422       +/-   ##
===============================================
+ Coverage       64.85%   77.21%   +12.35%     
===============================================
  Files             388      386        -2     
  Lines           44984    44685      -299     
  Branches         6343     6276       -67     
===============================================
+ Hits            29176    34504     +5328     
+ Misses          13894     8327     -5567     
+ Partials         1914     1854       -60     
Files with missing lines Coverage Δ
Terminal.Gui/App/Application.Lifecycle.cs 82.35% <100.00%> (-17.65%) ⬇️
Terminal.Gui/App/Application.Run.cs 82.35% <100.00%> (-9.08%) ⬇️
Terminal.Gui/App/Application.Screen.cs 75.00% <ø> (+8.33%) ⬆️
Terminal.Gui/App/Application.TopRunnable.cs 100.00% <100.00%> (ø)
Terminal.Gui/App/ApplicationImpl.Screen.cs 94.39% <100.00%> (+3.82%) ⬆️
Terminal.Gui/App/Runnable/SessionToken.cs 100.00% <100.00%> (+19.04%) ⬆️
Terminal.Gui/Drawing/Color/StandardColors.cs 100.00% <100.00%> (+18.42%) ⬆️
Terminal.Gui/Drawing/Scheme.cs 95.41% <100.00%> (+5.50%) ⬆️
...Drivers/AnsiHandling/EscSeqUtils/EscSeqRequests.cs 93.18% <ø> (+93.18%) ⬆️
Terminal.Gui/Drivers/InputImpl.cs 91.66% <100.00%> (ø)
... and 36 more

... and 153 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 151aa60...944a530. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tig added 12 commits November 28, 2025 15:02
Refactored `StandardColors` to use lazy initialization for static fields, improving performance and avoiding static constructor convoy effects. Introduced `NamesValueFactory` and `MapValueFactory` methods for encapsulated initialization logic.

Simplified `GetColorNames` to directly return `_names.Value`. Improved `TryParseColor` by clarifying default value usage and adopting object initializer syntax. Updated `TryNameColor` to use `_argbNameMap.Value`.

Refactored `GetArgb` for better readability. Replaced `MultiStandardColorNameResolver` with `StandardColorsNameResolver` in `ColorPicker`. Commented out `app.Init("Fake")` in `ColorPickerTests` for testing purposes.

Made minor formatting improvements, including updated comments and XML documentation for consistency.
Replaced `Toplevel` with `Window` as the primary top-level UI element. Introduced the `IRunnable` interface to modernize the architecture, enabling greater flexibility and testability. Deprecated the static `Application` class in favor of the instance-based `IApplication` model, which supports multiple application contexts.

Updated methods like `Application.Run()` and `Application.RequestStop()` to use `IRunnable`. Removed or replaced legacy `Modal` properties with `IsModal`. Enhanced the `IApplication` interface with a fluent API, including methods like `Run<TRunnable>()` and `GetResult<T>()`.

Refactored tests and examples to align with the new architecture. Updated documentation to reflect the instance-based model. Deprecated obsolete members and methods, including `Application.Current` and `Application.TopRunnable`.

Improved event handling by replacing the `Accept` event with `Accepting` and using `e.Handled` for event processing. Updated threading examples to use `App?.Invoke()` or `app.Invoke()` for UI updates. Cleaned up redundant code and redefined modal behavior for better consistency.

These changes modernize the `Terminal.Gui` library, improving clarity, usability, and maintainability while ensuring backward compatibility where possible.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

This commit introduces a major architectural update to the `Terminal.Gui` library, replacing the legacy `Toplevel` class with the new `Runnable` class. The changes span the entire codebase, including core functionality, tests, documentation, and configuration files.

- **Core Class Replacement**:
  - Replaced `Toplevel` with `Runnable` as the base class for modal views and session management.
  - Updated all references to `Toplevel` in the codebase, including constructors, methods, and properties.

- **Configuration Updates**:
  - Updated `tui-config-schema.json` to reflect the new `Runnable` scheme.

- **New Classes**:
  - Added `UICatalogRunnable` for managing the UI Catalog application.
  - Introduced `Runnable<TResult>` as a generic base class for blocking sessions with result handling.

- **Documentation and Tests**:
  - Updated documentation to emphasize `Runnable` and mark `Toplevel` as obsolete.
  - Refactored test cases to use `Runnable` and ensure compatibility.

- **Behavioral Improvements**:
  - Enhanced lifecycle management and alignment with the `IRunnable` interface.
  - Improved clarity and consistency in naming conventions.

These changes modernize the library, improve flexibility, and provide a clearer architecture for developers.
@tig tig changed the title Fixes #4419, #4148, #4408 - Bye-Bye Toplevel! Fixes #4419, #4148, #4408 - Toplevel is GONE - Replaced by Runnable Dec 1, 2025
@tig tig marked this pull request as ready for review December 1, 2025 04:23
@tig tig requested review from BDisp, Copilot and tznind December 1, 2025 04:23
Copy link
Collaborator

@BDisp BDisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very glorious works done here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@tig tig requested a review from Copilot December 1, 2025 13:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@tig
Copy link
Collaborator Author

tig commented Dec 1, 2025

I've got a bit more to do here:

  • Except for TopRunningView there should be NO coupling between IApplicaiton/ApplicationImpl and View. TopRunnableView is just a convivence.
  • ColorPicker.Prompt needs updating.

Follow ons:

  • With this new model, it should be possible to just make Popover an IRunnable that's transparent. This will be a follow up PR.
  • Relating to Prompt, in a future PR (See Add Prompt that's like MessageBox but with input. #2443) we can esaily use RunnableWrapper to make a generic Prompt API.

tig added 14 commits December 1, 2025 08:25
…tionImpl

- Made Runnable<TResult> inherit from Runnable (eliminating ~180 LOC duplication)
- Moved View init/layout/cursor logic from ApplicationImpl to Runnable lifecycle events
- ApplicationImpl.Begin now operates purely on IRunnable interface

Related to gui-cs#4419
the type-specific check for `View` with a more general check for
`IDisposable`. This ensures proper disposal of any `IDisposable`
object, improving robustness.

Removed the `FrameworkOwnedRunnable` property from the `ApplicationImpl`
class in `ApplicationImpl.cs` and the `IApplication` interface in
`IApplication.cs`. This eliminates the need to manage this property,
reducing complexity and improving maintainability.

Updated `application.md` to reflect the removal of the
`FrameworkOwnedRunnable` property, ensuring the documentation aligns
with the updated codebase.
with the `IDisposable` pattern, ensuring proper resource cleanup
and simplifying the API. The `Dispose()` method is now the
recommended way to release resources, with `using` statements
encouraged for automatic disposal.

Key changes:
- Marked `Shutdown()` as obsolete; it now internally calls `Dispose()`.
- Updated the fluent API to remove `Shutdown()` from chaining.
- Enhanced session lifecycle management for thread safety.
- Updated tests to validate proper disposal and state reset.
- Improved `IRunnable` integration with automatic disposal for
  framework-created runnables.
- Maintained backward compatibility for the legacy static
  `Application` singleton.
- Refactored documentation and examples to reflect modern practices
  and emphasize `Dispose()` usage.

These changes modernize the `Terminal.Gui` lifecycle, improve
testability, and encourage alignment with .NET conventions.
Refactor how the application context is set for `runnable` objects
by introducing a new `SetApp` method in the `IRunnable` interface.
This replaces the previous logic of directly setting the `App`
property for `View` objects, making the process more generic and
encapsulated within `IRunnable` implementations.

Simplify `Mouse.UngrabMouse()` by removing the conditional check
and calling it unconditionally.

Make a minor formatting adjustment in the generic constraint of
`Run<TRunnable>` in `ApplicationImpl`.

Add `SetApp(IApplication app)` to the `IRunnable` interface and
implement it in the `Runnable` class to set the `App` property
to the provided application instance.
Reorganized and updated `CONTRIBUTING.md`:
- Added **Key Architecture Concepts** section and reordered the table of contents.
- Updated testing requirements to discourage legacy patterns.
- Added instructions for replicating CI workflows locally.
- Clarified PR guidelines and coding style expectations.

Enhanced `README.md` with detailed CI/CD workflow documentation.

Refactored `ColorPicker.Prompt` to use `IApplication` for improved modularity and testability.

Introduced `IApplicationScreenChangedTests` for comprehensive testing of `ScreenChanged` events and `Screen` property.

Refactored `ApplicationScreenTests` and `TextView.PromptForColors` to align with modern patterns.

Updated `Terminal.sln` to include `.github/workflows/README.md`.

Performed general cleanup:
- Removed outdated documentation links.
- Improved XML documentation and coding consistency.
Refactored `OutputBufferImpl.cs` to enhance thread safety by locking shared resources and adding bounds checks for columns and rows. Improved handling of wide characters and removed outdated TODO comments.

Updated `Runnable.cs` to call `SetNeedsDraw()` on modal state changes, ensuring proper layout and drawing updates. Simplified layout handling in `ApplicationImpl.Run.cs` by replacing redundant comments with a `LayoutAndDraw()` call.

Added a check in `AllViewsTester.cs` to skip creating instances of `RunnableWrapper` types with unsatisfiable generic constraints, logging a warning when encountered.

Enhanced `ListViewTests.cs` by adding explicit `app.LayoutAndDraw()` calls to validate visual output and ensure tests reflect the updated application state.

These changes improve robustness, prevent race conditions, and ensure consistent behavior across the application.
Updated the `Border` class to use `Command.Quit` instead of
`Command.QuitToplevel` in the `CloseButton.Accept` handler.

Renamed test methods in `GetViewsAtLocationTests.cs` to replace
"Toplevel" with "Runnable" for consistency. Updated `Runnable<bool>`
instances to use "topRunnable" as the `Id` property.

These changes align the codebase with updated naming conventions
and improve clarity.
`MouseDragTests` with improved structure and coverage. Updated
tests to use `Application.Create`, `app.Begin`, and `app.End`
for better resource management and lifecycle handling.

Replaced direct event handling with `app.Mouse.RaiseMouseEvent`
to align with the application's event-handling mechanism. Added
`Runnable` objects to ensure views are properly initialized and
disposed of within the application context.

Enhanced tests to include assertions for minimum width and
height constraints during resize operations. Removed redundant
tests and streamlined logic to reduce duplication and improve
maintainability.
Updated namespaces in `ArrangementTests.cs` and `MouseDragTests.cs` for better organization. Enhanced `ArrangementTests.cs` with additional checks for arrangement flags. Reformatted and re-added `MouseDragTests.cs` and `SchemeTests.cs` with modern C# features like nullable annotations and object initializers. Ensured no functional changes while improving code clarity and consistency.
Updated `app.End` calls to use the null-forgiving operator (`!`)
on `app.SessionStack` to ensure it is treated as non-null.
This change addresses potential nullability warnings and
improves code safety and clarity. Applied consistently across
all relevant test cases in the `MouseDragTests` class.
@tig tig self-assigned this Dec 1, 2025
@tig tig merged commit a84b2c4 into gui-cs:v2_develop Dec 1, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants