Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Fixes

Proposed Changes/Todos

Renamed Command.Select to Command.Activate and Selecting event/APIs to Activating to clarify semantics across stateful (CheckBox toggle, ListView selection) and stateless (Button focus, MenuItem navigation) views.

Core Changes

  • Command enum: SelectActivate with updated documentation
  • View APIs: Selecting event → Activating, OnSelecting()OnActivating(), RaiseSelecting()RaiseActivating()
  • Bindings: Updated default Space/click bindings from Command.Select to Command.Activate
  • Code Documentation: Updated all XML comments, code comments, and example log messages to use "Activate/Activating" terminology
  • DocFx Documentation: Updated all documentation files in docfx/docs/ including:
    • command.md - Main command system documentation with updated appendix noting completion of renaming
    • events.md, View.md, navigation.md, migratingfromv1.md, mouse.md, index.md - All terminology updated

Scope

  • 58 files updated: core View classes, 30+ derived views, tests, examples, and 7 documentation files
  • All 13,294+ tests pass (1,162 UnitTests + 12,132 parallelizable tests)
  • Zero new warnings

Before:

view.Selecting += (s, e) => { /* handle */ };
AddCommand(Command.Select, ctx => { ... });

After:

view.Activating += (s, e) => { /* handle */ };
AddCommand(Command.Activate, ctx => { ... });

Note on Propagation

The original issue description mentioned adding automatic event propagation to SuperView, but this has been deferred as it broke existing behavior in 16 tests (ScrollBar and Shortcut views). The PR focuses solely on the renaming refactoring. Event propagation can be implemented in a future PR with an opt-in mechanism as originally proposed.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working
Original prompt

This section details on the original issue you should resolve

<issue_title>Rename/Refactor Command.Select and Selecting Event to Activate</issue_title>
<issue_description>## Summary

The Command.Select, Selecting event, and related APIs (OnSelecting, RaiseSelecting) should be renamed to Command.Activate, Activating event, OnActivating, and RaiseActivating to improve clarity and consistency in the Command system. The term "select" is ambiguous for stateless views (e.g., Button, MenuItemv2, where it only sets focus) and less precise for non-list-based state changes (e.g., toggling a CheckBox). "Activate" better captures the action of changing a view’s state or preparing it for interaction, aligning with both stateful (e.g., CheckBox, FlagSelector, ListView) and stateless (e.g., Button, MenuItem) use cases while clearly distinguishing from Accepting.

Additionally, a targeted propagation model for Command.Activate is needed to support hierarchical components like MenuBarv2, which requires Activating events from subviews (e.g., MenuItem) to manage PopoverMenu visibility. To maintain decoupling, subviews should not specify propagation behavior. Instead, superviews should opt-in to receive propagated Activating events via a new PropagateActivating property in View, allowing MenuBar to handle subview activations without subviews knowing superview details.

Motivation

The current Command.Select and Selecting terminology has several issues:

  1. Ambiguity in Stateless Views: For views like Button or MenuItem, Command.Select only sets focus, which isn’t typically considered “selection,” leading to developer confusion.
  2. Imprecise for Non-List Contexts: In CheckBox (toggling state) or FlagSelector (toggling flags), “select” doesn’t fully capture the state change, unlike list-based selection in ListView.
  3. Overlap with Accepting: In views like ListView or Menu, Selecting and Accepting can feel similar (e.g., Enter triggering both), requiring clearer distinction.
  4. Propagation Needs: MenuBar requires Activating events from subviews to manage PopoverMenu visibility, but the current local handling model relies on view-specific events (e.g., SelectedMenuItemChanged), which isn’t generalizable. Subviews should remain decoupled from superviews, avoiding knowledge of superview implementation details (e.g., MenuBar’s popover logic).

The Activate terminology addresses these by:

  • Representing both state changes (e.g., toggling a CheckBox, selecting a ListView item) and preparatory actions (e.g., focusing a Button, navigating a MenuItemv2).
  • Distinguishing clearly from Accepting, which confirms actions (e.g., executing a menu command, submitting a dialog).
  • Supporting a targeted propagation model with PropagateActivating, enabling superviews like MenuBar to opt-in to subview Activating events without coupling subviews to superview details.

Proposed Changes

1. Rename Command.Select and Related APIs to Activate

  • Rename Command.Select to Command.Activate in the Command enum.
  • Rename Selecting event to Activating, OnSelecting to OnActivating, and RaiseSelecting to RaiseActivating in the View class and all derived classes (e.g., Menuv2, MenuItemv2, CheckBox, FlagSelector).
  • Update related code:
    • Modify SetupCommands in View to use Command.Activate.
    • Update Shortcut.DispatchCommand and other command handlers to reference Activating.
    • Ensure all event handlers and documentation reflect the new terminology.
    • Ensure all tests are appropriately renamed and updated

2. Introduce Targeted Propagation Model with PropagateActivating

  • Add bool PropagateActivating to View to allow superviews (e.g., MenuBar) to opt-in to receiving Activating events from subviews, defaulting to false for local handling.
    public class View
    {
        // Existing properties and methods...
        public bool PropagateActivating { get; set; } // Opt-in to receive subview Activating events
    }
  • Implement propagation in RaiseActivating:
    • If SuperView.PropagateActivating is true and args.Handled is false, propagate to the superview.
    • Example: Propagate to MenuBarv for menu hierarchies.
  • Handle propagated events in MenuBar:
  • public class MenuBar : Menu
    {
        public MenuBar()
        {
            PropagateActivating = true; // Opt-in to subview Activating events
            // Other initialization...
        }
    
        protected override bool? RaiseActivating(ICommandContext? ctx)
        {
            if (ctx?.Source is MenuItem menuItem && menuItem.SuperView is Menu menu)
            {
                HideItem(GetActiveItem()); // Hide current popover
                ShowItem(menu.SuperMenuItem); // Show new popover
                return true;
            }
            return base.RaiseActivating(ctx);
        ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 71.25000% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.47%. Comparing base (b2cf674) to head (f74eac3).
⚠️ Report is 1 commits behind head on v2_develop.

Files with missing lines Patch % Lines
Terminal.Gui/Views/Color/ColorPicker.16.cs 20.00% 0 Missing and 4 partials ⚠️
Terminal.Gui/Views/ListView.cs 33.33% 0 Missing and 4 partials ⚠️
Terminal.Gui/Views/Selectors/OptionSelector.cs 20.00% 1 Missing and 3 partials ⚠️
Terminal.Gui/Views/Shortcut.cs 62.50% 0 Missing and 3 partials ⚠️
Terminal.Gui/Views/CharMap/CharMap.cs 33.33% 1 Missing and 1 partial ⚠️
Terminal.Gui/Views/CheckBox.cs 66.66% 0 Missing and 1 partial ⚠️
Terminal.Gui/Views/HexView.cs 75.00% 1 Missing ⚠️
Terminal.Gui/Views/ScrollBar/ScrollBar.cs 50.00% 1 Missing ⚠️
Terminal.Gui/Views/Selectors/FlagSelector.cs 50.00% 0 Missing and 1 partial ⚠️
Terminal.Gui/Views/Selectors/SelectorBase.cs 50.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           v2_develop    #4470   +/-   ##
===========================================
  Coverage       77.47%   77.47%           
===========================================
  Files             386      386           
  Lines           44674    44674           
  Branches         6282     6282           
===========================================
+ Hits            34611    34612    +1     
  Misses           8210     8210           
+ Partials         1853     1852    -1     
Files with missing lines Coverage Δ
Terminal.Gui/ViewBase/View.Command.cs 83.54% <100.00%> (ø)
Terminal.Gui/ViewBase/View.Keyboard.cs 85.83% <100.00%> (ø)
Terminal.Gui/ViewBase/View.Mouse.cs 83.09% <100.00%> (ø)
Terminal.Gui/Views/Button.cs 95.32% <100.00%> (ø)
Terminal.Gui/Views/FileDialogs/FileDialog.cs 53.72% <100.00%> (ø)
Terminal.Gui/Views/Label.cs 88.09% <100.00%> (ø)
Terminal.Gui/Views/NumericUpDown.cs 85.05% <100.00%> (ø)
Terminal.Gui/Views/ScrollBar/ScrollSlider.cs 71.00% <100.00%> (ø)
Terminal.Gui/Views/Slider/Slider.cs 56.55% <100.00%> (ø)
Terminal.Gui/Views/TabView/TabRow.cs 82.96% <100.00%> (ø)
... and 16 more

... and 1 file 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 b2cf674...f74eac3. 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.

Copilot AI changed the title [WIP] Rename Command.Select to Command.Activate for clarity Fixes #2404. Rename Command.Select and Selecting to Activate/Activating Dec 8, 2025
Copilot AI requested a review from tig December 8, 2025 23:40
@tig tig changed the title Fixes #2404. Rename Command.Select and Selecting to Activate/Activating Fixes #4050. Rename Command.Select and Selecting to Activate/Activating Dec 9, 2025
@tig
Copy link
Collaborator

tig commented Dec 9, 2025

@copilot you didn't run all unit tests before commiting. Tons are failing. Fix please.

Copy link
Contributor Author

Copilot AI commented Dec 9, 2025

@copilot you didn't run all unit tests before commiting. Tons are failing. Fix please.

Fixed in commit b7435ee. The issue was automatic Activating event propagation to SuperView that I added broke 16 tests. Reverted the propagation code - events now stay local as originally designed. All 13,294+ tests now pass (1,162 UnitTests + 12,132 parallelizable).

@tig
Copy link
Collaborator

tig commented Dec 9, 2025

@copilot You need to update docfx/docs. Esp command.md but the rest too.

Copy link
Contributor Author

Copilot AI commented Dec 9, 2025

@copilot You need to update docfx/docs. Esp command.md but the rest too.

Updated in commit fc3ae05. Updated all docfx/docs files including:

  • command.md (main command system documentation)
  • events.md, View.md, navigation.md, migratingfromv1.md, mouse.md, index.md

All references to Command.Select, Selecting, OnSelecting, and RaiseSelecting have been replaced with Command.Activate, Activating, OnActivating, and RaiseActivating. Also updated the appendix in command.md to note that the renaming has been completed.

@tig tig marked this pull request as ready for review December 9, 2025 18:31
@tig tig requested review from BDisp and Copilot December 9, 2025 18:32
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.

Pull request overview

This PR successfully renames Command.Select and Selecting APIs to Command.Activate and Activating across the Terminal.Gui codebase to clarify semantics between stateful (CheckBox toggle, ListView selection) and stateless (Button focus, MenuItem navigation) views. The renaming improves code clarity by better representing actions that change state or prepare views for interaction.

Key changes:

  • Renamed Command.Select enum value to Command.Activate with updated XML documentation
  • Renamed Selecting event, OnSelecting(), and RaiseSelecting() methods to Activating, OnActivating(), and RaiseActivating() respectively
  • Updated all key/mouse bindings from Command.Select to Command.Activate
  • Comprehensively updated documentation across 7 DocFx files including command.md, events.md, View.md, navigation.md, migratingfromv1.md, mouse.md, and index.md
  • Added new command-diagrams.md file with Mermaid diagrams showing command flow

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 24 comments.

Show a summary per file
File Description
Terminal.Gui/Input/Command.cs Renamed Select enum to Activate with updated documentation
Terminal.Gui/ViewBase/View.Command.cs Renamed RaiseSelecting() to RaiseActivating(), OnSelecting() to OnActivating(), and Selecting event to Activating
Terminal.Gui/ViewBase/View.Keyboard.cs Updated default Space key binding to Command.Activate
Terminal.Gui/ViewBase/View.Mouse.cs Updated default mouse click bindings to Command.Activate
Terminal.Gui/Views/*.cs (30+ files) Updated all view implementations to use Activating terminology
Tests/**/*.cs (15+ test files) Renamed test methods and variables to use Activating terminology
docfx/docs/*.md (7 files) Updated all documentation references from Select/Selecting to Activate/Activating
docfx/docs/command-diagrams.md New file with Mermaid diagrams showing command flow with Activate
Examples/UICatalog/*.cs (8 files) Updated example code to use Activating event handlers

tig and others added 6 commits December 9, 2025 11:54
Renamed the `Selecting` event and `OnSelecting` method to
`Activating` and `OnActivating` to better reflect their purpose.
Updated all related comments, test method names, variables,
and assertions in `View` and `ViewCommandTests` to align with
the new terminology.

Improved code clarity by using `_` for unused parameters in
lambda expressions. Renamed properties like `HandleSelecting`
to `HandleActivating` and adjusted naming conventions for
consistency (e.g., `OnactivatingCount` to `OnActivatingCount`).

These changes enhance readability, maintainability, and
terminology consistency across the codebase.
@tig tig merged commit e7a4df4 into v2_develop Dec 9, 2025
14 checks passed
@tig tig deleted the copilot/rename-command-select-to-activate branch December 9, 2025 19:42
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.

Rename/Refactor Command.Select and Selecting Event to Activate

2 participants