Skip to content

feat: add Macros (reusable action lists) to DIY - #1419

Open
jawzf wants to merge 4 commits into
sameerasw:developfrom
jawzf:feat/004-macros
Open

jawzf wants to merge 4 commits into
sameerasw:developfrom
jawzf:feat/004-macros

Conversation

@jawzf

@jawzf jawzf commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds Macros to DIY: a macro is a named list of actions you save once and reuse anywhere actions can be picked.

Before: the same action sequence had to be rebuilt in every automation, button remap, lockscreen shortcut or gesture that needed it, and changing it meant editing each copy.

After:

  • Automations | Macros switch at the top of the DIY tab, styled like the bottom taskbar (selected item grows into a pill with its label; content slides between the two).
  • Macros view: list of macros with their action count; tap to edit, long press for Test and Delete. The + button opens a new macro here (content description "New macro"), and a new automation in the Automations view.
  • Macro editor: a name plus the existing action list editor. Save shows only when there's a name and at least one action; back asks before discarding changes.
  • Run macro action: every action picker ends with a Macros category (hidden when there are none): automations, button remap, lockscreen shortcuts, action shortcut, and the single-action gesture pickers for Island long press, Duo and Status Glance. Picked macros show by name ("Run macro · Morning", or the name on its own in gesture descriptions and the automation list).
  • Macros are saved by id, so renaming or editing a macro updates every place that uses it. If a macro is deleted, places that use it show "Deleted macro", and running it posts the usual automation failure notice ("Run macro: The macro was deleted") without crashing.
  • Macros can't contain macros in this version (the category is hidden inside the macro editor), so loops are impossible.

How:

  • Macro(id, name, actions) in domain/diy/Macro.kt; DIYRepository saves macros under a new saved_macros key in the same prefs, using the existing Action Gson adapter.
  • Action.RunMacro(macroId) runs through CombinedActionExecutor.executeAll, so each inner action gets the same permission check and failure notice as a normal sequence.
  • ActionRegistry.getMacroCategory() builds the picker category; Action.displayName(context) gives the macro's name for RunMacro and the title for everything else.
  • Gesture pickers used to match the current action by class, which would mark every macro as selected; they now use Action.matches, which compares RunMacro by id and everything else by class as before.
  • Most of the DIYScreen.kt diff is indentation from wrapping the content in AnimatedContent; it's easier to read with whitespace changes hidden.

Type of change

  • Bug fix
  • New feature
  • UI / visual update
  • Performance improvement
  • Refactoring / cleanup
  • Translations
  • Build / CI tooling

UI changes

diy-switch-automations

The DIY tab with the Automations | Macros switch.

diy-switch-macros

The Macros view.

diy-switch.mp4

Switching between Automations and Macros.

macro-editor

The macro editor: a name and the usual action list.

action-picker-macros

The Macros category at the end of an automation's add-action sheet.

gesture-picker-macros

The Island long-press picker with the Macros category; only the assigned macro is selected.

Checklist

  • The base branch is set to develop (not main).
  • The app builds cleanly locally with ./gradlew assembleDebug (and assembleRelease).
  • Unit tests pass with ./gradlew testDebugUnitTest (5 new tests in MacroJsonTest: RunMacro round trip in an action list, type-only JSON loads with an empty id, two macros round-trip through DIYRepository, invalid JSON gives an empty list, unknown action types inside a macro are skipped).
  • Tested on the Android 17 emulator: create, edit, rename, test and delete macros; macros survive a force-stop; Macros category in the automation editor and action shortcut (runs from the launcher shortcut), not inside the macro editor; renaming updates labels; a deleted macro shows "Deleted macro" and posts the failure notice; Island, Duo and Status Glance pickers list macros, select only the assigned one and show its name; Duo and Status Glance double taps run the macro; the + button's label follows the view, including after rotation.
  • Reuses ActionSequenceEditor, RoundedCardContainer, EssentialsFloatingToolbar, SegmentedDropdownMenu and the existing failure notifier.
  • New strings are in strings.xml (English only).
  • No new settings, so nothing to register in FeatureRegistry.kt.
  • No new dependencies or permissions; the only manifest change is the macro editor activity.

🤖 Generated with Claude Code

@sameerasw

Copy link
Copy Markdown
Owner

Hi @jawzf can you address the conflcits

@jawzf

jawzf commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sameerasw this is done!

sameerasw and others added 4 commits October 22, 2026 22:00
A macro is a named list of actions saved once and reused anywhere
actions can be picked. DIY gets a taskbar-style Automations | Macros
switch, a macro list with test and delete, and a macro editor built on
the existing action sequence editor.

Every action picker gains a Macros category (automations, button remap,
lockscreen shortcuts, action shortcut, and the Island, Duo and Status
Glance gesture pickers). Action.RunMacro stores the macro id, so edits
apply everywhere; it runs through executeAll, and a deleted macro shows
"Deleted macro" and posts the failure notice. Macros can't nest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants