[PR #9926] [MERGED] Introduce serialization for actions #27810

Open
opened 2026-01-31 09:24:24 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/9926
Author: @carlos-zamora
Created: 4/23/2021
Status: Merged
Merged: 5/20/2021
Merged by: @undefined

Base: mainHead: dev/cazamor/tsm/am/serialization


📝 Commits (10+)

  • c434ee6 Implement action serialization
  • 586b977 handle and test nested and unbound commands
  • 0741c94 update spell check
  • 9cb377e fix global summon
  • b506817 Update Command::Copy()
  • 07cd343 address Mike feedback
  • 815890f bugfix: add 'movefocus' (de)serializer; sort list
  • 3682f36 Merge branch 'main' into dev/cazamor/tsm/am/serialization
  • 4ac4e10 address some Dustin feedback
  • 280073c revert Command.cpp iterator change

📊 Changes

14 files changed (+847 additions, -277 deletions)

View changed files

📝 .github/actions/spelling/expect/expect.txt (+2 -0)
📝 src/cascadia/LocalTests_SettingsModel/SerializationTests.cpp (+154 -6)
📝 src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp (+83 -91)
📝 src/cascadia/TerminalSettingsModel/ActionAndArgs.h (+1 -0)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.cpp (+92 -92)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.h (+376 -72)
📝 src/cascadia/TerminalSettingsModel/ActionMap.h (+4 -0)
📝 src/cascadia/TerminalSettingsModel/ActionMapSerialization.cpp (+42 -0)
📝 src/cascadia/TerminalSettingsModel/AllShortcutActions.h (+27 -0)
📝 src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp (+0 -10)
📝 src/cascadia/TerminalSettingsModel/Command.cpp (+60 -0)
📝 src/cascadia/TerminalSettingsModel/Command.h (+2 -0)
📝 src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp (+1 -5)
📝 src/cascadia/TerminalSettingsModel/JsonUtils.h (+3 -1)

📄 Description

Summary of the Pull Request

This PR builds on the ActionMap PR (#6900) by leveraging ActionMap to serialize actions. From the top down, the process is now as follows:

  • CascadiaSettings: remove the hack of copying whatever we had for actions before.
  • GlobalAppSettings: serialize the ActionMap to "actions": []
  • ActionMap: iterate over the internal _ActionMap (list of actions) and serialize each Command
  • Command: THIS IS WHERE THE MAGIC HAPPENS! For each key mapping, serialize an action. Only the first one needs to include the name and icon.
  • ActionAndArgs: Find the relevant IActionArgs parser and serialize the ActionAndArgs.
  • ActionArgs: ANNOYING CHANGE Serialize any args that are set. We need each setting to be saved as a std::optional. As with inheritance, this allows us to distinguish an explicit setting to the default value (sometimes null) vs an implicit "give me the default value". This allows us to serialize only the relevant details of each action, rather than writing all of the args.

References

  • #8100: Inheritance/Layering for lists
    • This tracks layering and better serialization for color schemes and actions. This PR resolves half of that issue. The next step is to apply the concepts used in this PR (and #9621) to solve the similar problem for color schemes.
  • #6900: Actions page

Validation Steps Performed

Tests added!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/9926 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 4/23/2021 **Status:** ✅ Merged **Merged:** 5/20/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/cazamor/tsm/am/serialization` --- ### 📝 Commits (10+) - [`c434ee6`](https://github.com/microsoft/terminal/commit/c434ee65da11b23d460e5dfffa93a9f5b088caea) Implement action serialization - [`586b977`](https://github.com/microsoft/terminal/commit/586b977f2552c510f1e74234de0f16d784ef0e45) handle and test nested and unbound commands - [`0741c94`](https://github.com/microsoft/terminal/commit/0741c94f30834029cd2e05dea3a3e39cbbda56a6) update spell check - [`9cb377e`](https://github.com/microsoft/terminal/commit/9cb377e8854e071da6aa5b1b0c11db4c3f40e7b3) fix global summon - [`b506817`](https://github.com/microsoft/terminal/commit/b506817508da9a4d5cd403a9ce1ba9f738eb65d6) Update Command::Copy() - [`07cd343`](https://github.com/microsoft/terminal/commit/07cd343acf7a9f800d65e1b5de0f56d1d17c85c1) address Mike feedback - [`815890f`](https://github.com/microsoft/terminal/commit/815890fb12f7ef6dad1eff322296482e6ee4580c) bugfix: add 'movefocus' (de)serializer; sort list - [`3682f36`](https://github.com/microsoft/terminal/commit/3682f361b016d8e609ade188919344cc8fbbdb94) Merge branch 'main' into dev/cazamor/tsm/am/serialization - [`4ac4e10`](https://github.com/microsoft/terminal/commit/4ac4e103a4fa4815c81b4bfcfa7206892b6e2c7b) address some Dustin feedback - [`280073c`](https://github.com/microsoft/terminal/commit/280073cf7b0f02c0d6ba04dd446a632bfa8ea8dd) revert Command.cpp iterator change ### 📊 Changes **14 files changed** (+847 additions, -277 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/expect/expect.txt` (+2 -0) 📝 `src/cascadia/LocalTests_SettingsModel/SerializationTests.cpp` (+154 -6) 📝 `src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp` (+83 -91) 📝 `src/cascadia/TerminalSettingsModel/ActionAndArgs.h` (+1 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.cpp` (+92 -92) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.h` (+376 -72) 📝 `src/cascadia/TerminalSettingsModel/ActionMap.h` (+4 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionMapSerialization.cpp` (+42 -0) 📝 `src/cascadia/TerminalSettingsModel/AllShortcutActions.h` (+27 -0) 📝 `src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp` (+0 -10) 📝 `src/cascadia/TerminalSettingsModel/Command.cpp` (+60 -0) 📝 `src/cascadia/TerminalSettingsModel/Command.h` (+2 -0) 📝 `src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp` (+1 -5) 📝 `src/cascadia/TerminalSettingsModel/JsonUtils.h` (+3 -1) </details> ### 📄 Description ## Summary of the Pull Request This PR builds on the `ActionMap` PR (#6900) by leveraging `ActionMap` to serialize actions. From the top down, the process is now as follows: - `CascadiaSettings`: remove the hack of copying whatever we had for actions before. - `GlobalAppSettings`: serialize the `ActionMap` to `"actions": []` - `ActionMap`: iterate over the internal `_ActionMap` (list of actions) and serialize each `Command` - `Command`: **THIS IS WHERE THE MAGIC HAPPENS!** For _each_ key mapping, serialize an action. Only the first one needs to include the name and icon. - `ActionAndArgs`: Find the relevant `IActionArgs` parser and serialize the `ActionAndArgs`. - `ActionArgs`: **ANNOYING CHANGE** Serialize any args that are set. We _need_ each setting to be saved as a `std::optional`. As with inheritance, this allows us to distinguish an explicit setting to the default value (sometimes `null`) vs an implicit "give me the default value". This allows us to serialize only the relevant details of each action, rather than writing _all_ of the args. ## References - #8100: Inheritance/Layering for lists - This tracks layering and better serialization for color schemes _and_ actions. This PR resolves half of that issue. The next step is to apply the concepts used in this PR (and #9621) to solve the similar problem for color schemes. - #6900: Actions page ## Validation Steps Performed Tests added! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:24:24 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27810