From 25fa9a5b6df9d173fe81d0304beac284ed9b44e0 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Mon, 16 Nov 2026 14:51:31 -0500 Subject: [PATCH] Quit is last in the menu again, through a declared menu place #1812 moved Quit into the shared module, and declaration order put it fourth. MenuPlace (a DeclaredOrder) says where a member sits: InMenu by default through ApplicationAction, LastInMenu on Quit. menu() orders by place and keeps declaration order within a place, so Qt gets the same last item. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016gZLdupVQyBzHTmHBC9Cyn --- src/toad/client/application_actions.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/toad/client/application_actions.py b/src/toad/client/application_actions.py index 393213f49..920ff4608 100644 --- a/src/toad/client/application_actions.py +++ b/src/toad/client/application_actions.py @@ -13,6 +13,7 @@ from agent_comms.nominal.declared_family import ( DeclaredFamily, + DeclaredOrder, FamilyMeta, declared_words, ) @@ -148,7 +149,19 @@ def require_unwritten(cls, name: str, writers: tuple[type, ...]) -> None: pass -class ApplicationAction(DeclaredAction[ClientApplication], affix="Action"): +class MenuPlace(DeclaredOrder): + """Where a member sits in the menu and the palette; within a place, declaration order.""" + + +class InMenu(MenuPlace): + """The menu's body.""" + + +class LastInMenu(MenuPlace): + """After every other member, wherever it is declared.""" + + +class ApplicationAction(DeclaredAction[ClientApplication], InMenu, affix="Action"): """Declared application shortcuts resolve before an editor takes the key.""" binding_prefix = "app." @@ -160,9 +173,10 @@ def exclusive_claims[Binding](cls, bindings: tuple[Binding, ...]) -> tuple[Bindi @classmethod def menu(cls, app: ClientApplication) -> tuple[tuple[ApplicationAction, str], ...]: - """Every offered member under its label, in declaration order.""" + """Every offered member under its label, by menu place, then in declaration order.""" return tuple((command, command.label(app)) - for member in cls.members_with(cls) for command in member.offered(app)) + for member in sorted(cls.members_with(cls), key=MenuPlace.position_of) + for command in member.offered(app)) # Declaration order is the order of the menu and the palette. @@ -193,7 +207,7 @@ async def apply(self, app: ClientApplication) -> None: app.session_navigation.direct_messages() -class QuitAction(ReplacesFrameworkAction, ApplicationAction): +class QuitAction(LastInMenu, ReplacesFrameworkAction, ApplicationAction): """Save preferences and quit the application.""" keys = {InputMode: ("ctrl+q",)}