Add shell command action with root mode support and test functionality#1850
Merged
Add shell command action with root mode support and test functionality#1850
Conversation
Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add action for executing shell command with trigger
Add shell command action with root mode support and test functionality
Oct 19, 2025
sds100
requested changes
Oct 19, 2025
base/src/main/java/io/github/sds100/keymapper/base/actions/ShellCommandActionScreen.kt
Show resolved
Hide resolved
|
|
||
| testResult = when (result) { | ||
| is Success -> State.Data(result.data) | ||
| is KMError -> State.Data("Error: ${formatError(result)}") |
Collaborator
There was a problem hiding this comment.
@copilot use KMError.getFullMessage() which requires a ResourceProvider
Contributor
Author
There was a problem hiding this comment.
Updated error handling to use KMError.getFullMessage(resourceProvider) for consistent, localized error messages. Added ResourceProvider to ViewModel constructor. (commit: in progress)
base/src/main/java/io/github/sds100/keymapper/base/actions/ActionData.kt
Show resolved
Hide resolved
Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
…the ShellCommandActionScreen
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.
Shell Command Action Feature Implementation ✅
Requirements from Issue
Recent Changes
ShellCommandActionStatedata class instead of separate parametersKMError.getFullMessage()with ResourceProvider for better error messagesImplementation Summary
The shell command action feature has been fully implemented with the following capabilities:
User Interface:
Technical Implementation:
ShellCommandActionStatedata class for cleaner state managementShellAdapterfor normal shell commandsSuAdapterfor root commands (requires root permission)KMError.getFullMessage()for consistent localizationFiles Modified/Created:
ActionId.kt- Added SHELL_COMMAND action IDActionData.kt- Added ShellCommand data classActionUtils.kt- Added category, title, icon mappings, and isEditableCreateActionDelegate.kt- Added configuration logicPerformActionsUseCase.kt- Added execution logicstrings.xml- Added new string resourcesShellCommandActionScreen.kt- Full-screen UI with ShellCommandActionStateConfigShellCommandViewModel.kt- ViewModel with state management and ResourceProviderNavDestination.kt- Added ConfigShellCommand navigation destinationBaseMainNavHost.kt- Registered shell command screen in navigationSuAdapter.kt- Added executeWithOutput method for root commands with output captureActionUiHelper.kt- Added shell command description display logicShellCommandActionTest.kt- Unit tests for shell command actionActionEntity.kt- Added SHELL_COMMAND type and ACTION_FLAG_SHELL_COMMAND_USE_ROOT flagActionDataEntityMapper.kt- Added conversion logic for database persistenceOriginal prompt
Fixes #661
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.