Repository navigation
v5 A1: action registry - #709
Merged
Merged
Conversation
Adds the step 1 appendix to the A1 work plan: the transforms A1 registers with their IDs, display names, categories, config and icons; the functions A1 lifts for E2 to wrap; everything that needs window state, grouped by E2 cluster; and the pure functions left unregistered, with reasons. Also corrects the plan's current-state notes for E1's split of the window, and records that ApplyTextOnlyTemplate reads saved patterns from settings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ActionDescriptor, ITextTransform and IActionRegistry in Text_Grab.Core.Actions, with ActionRegistry as the thread-safe default. The registry rejects duplicate and malformed IDs (textgrab.<area>.<verb>), compares IDs ordinally, and lists actions in registration order. ITextTransform's remarks fix the contract later phases rely on: current culture, case-insensitive JSON config, and failure by exception rather than error text. CoreActions.RegisterAll is empty for now; the pinned-ID test that guards it starts with an empty list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DelegateTextTransform wraps a string-to-string function as an ITextTransform. CoreActions.RegisterAll now registers eight of them under pinned IDs, with the Edit Text Window's menu text and bottom-bar icons: trim lines, single line, remove duplicate lines, shuffle lines, try to make numbers, try to make letters, correct GUID errors and replace reserved characters (keeping its Ctrl+R gesture). Each transform has a test showing it returns what the wrapped function returns. Shuffle is random, so its test compares the lines kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pins the current behavior before A1 lifts the case logic into Core: the first press re-applies the detected case, later presses cycle title, upper, lower; the remembered state carries over to new text; a selection is detected and changed on its own; the window's culture is used; and Spreadsheet mode detects per cell and resets the state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The window's case cycle becomes a pure function of the text, the remembered state and the culture, returning the new text and the next state. The window keeps CaseStatusOfToggle and its culture and calls the function; Spreadsheet mode calls it per cell with no remembered state, as it did before. The characterization tests from the previous commit pass unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pins Split Lines Before / After Each Selection before A1 lifts them into Core: every occurrence of the selection is split, matching is case-sensitive and non-overlapping from the left, and the commands do nothing without a selection or in Spreadsheet mode. Co-Authored-By: Claude Opus 5.5 <[email protected]>
SplitOnSelection and SplitAfterSelection are pure functions of the full text and the selection. The window's two command handlers keep their empty-selection message and call them. They are not registered as transforms because they need a selection; E2 wraps them. The characterization tests from the previous commit pass unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DelegateTextTransform<TConfig> reads an action's JSON config into its config record. Reading is the same for every action: property names in any case, enums by name or number, unknown properties ignored; a missing or null required value, or a wrong JSON type, is an ArgumentException. Five transforms join the pinned list: clean up text (CorrectToLatin, default off), unstack (Columns), unstack groups (Rows), apply pattern (a regex, mode and separator) and apply smart pattern (a built-in recognizer ID, mode, separator and output). Each matches the function it wraps; counts below 1, empty patterns and unknown recognizers throw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
WindowsActions.RegisterAll adds six AI actions, all needing a Copilot+ PC: summarize, meeting notes, translate (TranslateConfig carries the target language) and translate to system language as transforms, and rewrite and convert to table as descriptors only. Those two services return failures as "ERROR: ..." text, which a transform cannot tell from a result. The transforms throw InvalidOperationException with the service's own message when Windows AI cannot produce a result, using the window's fallback wording when there is none. Translation that is not needed returns the input unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The container builds one IActionRegistry, filled from CoreActions and WindowsActions on first resolve, so the app and lower tiers (through ServiceAccess) share it. Nothing in the UI reads it yet. Tests check it resolves as one instance with every Core and Core.Windows action, and that every icon key names a Wpf.Ui SymbolRegular member. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The A1 status row is Done. The phase file gets an A1 outcome section: the types as built and where they differ from the sketch, the step 6 and step 8 outcomes, the two new display names, behavior found while wrapping and left alone, and the tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements v5 phase A1: one registry in Core that describes every action Text Grab can perform on text, as data. It is filled with the pure text transforms and the Windows AI actions, and registered in
AppServices. No UI changes. Nothing reads the registry yet; E2 moves the Edit Text Window onto it.The work plan is
docs/v5/A1-Action-Registry.md. Its new appendix inventories every Edit Text Window action, marking which ones A1 registers and which E2 must convert. Each step is its own commit, and each passed the build and test gates.Registry (
Text_Grab.Core.Actions, Core)ActionDescriptor,ActionKind,ActionCategory,ITextTransformandIActionRegistryfollow the plan's sketch.ActionRegistryis thread-safe, compares IDs ordinally and lists actions in registration order. It rejects duplicate IDs, blank display names, and IDs that don't followtextgrab.<area>.<verb>(three parts, lower camel case).ITextTransform's doc comments set the contract later phases depend on:ArgumentException. A transform that runs but can't produce a result throwsInvalidOperationExceptionwith a message fit to show the user. Cancellation throwsOperationCanceledException.DelegateTextTransformwraps a plain string-to-string function.DelegateTextTransform<TConfig>adds a config record. One internal reader handles config the same way for every action: unknown properties are ignored, and a missing or null required value, or a wrong JSON type, is anArgumentException.Registered actions: 19 IDs, pinned by tests
IDs are stored in users' layouts, workflows and button settings, so they can never be renamed. Tests fail if the list changes.
CoreActions.RegisterAll), 13 transforms:trimLines,makeSingleLine,removeDuplicateLines,shuffleLines,tryMakeNumbers,tryMakeLetters,correctGuidErrors,replaceReservedCharacters(keeps the window'sCtrl+R).cleanUp(CorrectToLatin),unstack(Columns),unstackGroups(Rows),applyPattern(regex, mode, separator) andapplyRecognizer(built-in recognizer ID, mode, separator, output).textgrab.text.*.WindowsActions.RegisterAll), 6 actions undertextgrab.ai.*, all requiring a Copilot+ PC:summarize,meetingNotes,translate(TranslateConfig(TargetLanguage)) andtranslateToSystemLanguage.rewriteandconvertToTable. Their services report failure by returning"ERROR: …"as the text, which a transform can't tell apart from a real result.SymbolRegularnames its bottom-bar buttons use.Lifted out of the Edit Text Window
Characterization tests were written first, passed against the old code, and still pass unchanged:
StringMethods.ToggleCase(text, state, culture), returning the new text and the next state. The window keepsCaseStatusOfToggleand its language. Spreadsheet mode calls the function once per cell, as before. Pinned byEditTextWindowToggleCaseTests(9).StringMethods.SplitOnSelectionandSplitAfterSelection. The window keeps its empty-selection message. Pinned byEditTextWindowSplitOnSelectionTests(7).These are not registered as transforms, because they need window state or a selection. E2 wraps them.
Not done
ApplyTextOnlyTemplateresolves pattern placeholders through the app's settings service, and templates only load through the app-sideGrabTemplateManager, so it couldn't move to Core.applyPatterntakes a regex rather than a saved-pattern ID, for the same reason. APatternIdfield can be added later without breaking stored config.Found while wrapping, not changed
"ERROR: …"into the document when Windows AI fails.PatternExecutordoes.SummarizeParagraphtakes no cancellation token.For review
Plan corrections
The phase file's "Current state" section now records what changed:
ToggleCaseand the split handlers.ApplyTextOnlyTemplateisn't a pure function of the template and the text: it reads settings.Tests
dev@7de19ea)The new tests by suite:
ActionRegistryTests,CoreActionsTests(pinned IDs),DelegateTextTransformTests,CoreTextTransformTestsandCoreConfigTransformTests(each transform checked against the function it wraps),ToggleCaseTests,SplitOnSelectionTests.WindowsActionsTests, covering pinned IDs and how each AI action fails on a device without Windows AI.AppServicesTests, andActionIconKeyTests, which checks that every icon key is a realSymbolRegularname.TierBoundaryTestspasses, and the build has no new compiler warnings. No NuGet packages were added, so there's nothing to check for MSIX.One gate run had a single failure:
WinRtClipboardServiceTests.RealClipboard_RoundTripsText_WithNoUiThread. It uses the real system clipboard and passed on three immediate reruns with the same binaries.Needs checking by hand
🤖 Generated with Claude Code