Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(windows): kmshell switch handling for the installing state #12956

Merged
merged 5 commits into from
Jan 30, 2025

Conversation

rc-swag
Copy link
Contributor

@rc-swag rc-swag commented Jan 21, 2025

This improves the switch handling around the installing state. Previously, the SM did a no-op and let the commands go through.
Now when in the installing state and the following modes are set "fmInstallTip, fmInstallTipsForPackages, fmRegisterTip, fmUpgradeKeyboards, fmUpgradeMnemonicLayout" skip being sent to the SM but all other messages are sent through. This then allows us to detect whne kmshell is trying to run as if successuly installed but state machine is still in the installing state.

This is also adds ProcessBackroundUpdate for neatness and readablity of code it is not inteded to change the functionality.
A seperate issue #12994 will add a -boot switch.

User Testing

We will just test there is no regression.

TEST_INSTALL_UPDATE

  1. Install Keyman attached the PR
  2. Install the Gff_Amharic 3.1.1 version keyboard.
  3. Open the Keyman Configuration dialog.
  4. Navigate to the "Keyboard Layouts tab".
  5. Verified that the installed keyboard shows an older version.
  6. Navigate to the "Update" tab.
  7. Open the "C:\Users"yourusername"\AppData\Local\Keyman\UpdateCache" folder.
  8. Open the regedit window (Computer\HKEY_CURRENT_USER\SOFTWARE\Keyman\Keyman Engine).
    WinR type regedit Go the current user key update state
    Press F5 to keep it refreshing it.
    The state will go to usDownloading to usInstalling at the same time keep checking the UpdateCache folder.
  9. Select the "update state"
  10. In Keyman Configuration press the "Check for new updates" button.
  11. Verified that the "UpdateCache" folder is updating or adding files)
  12. On Regedit window. Verify the state is changes from usUpdateAvailable--> usDownloading --> usWaitingRestart
  13. Click the "Apply update now" button. Click the "Update" button on the "Keyman Update" popup.
  14. Verified that the "UpdateCache" folder has the cache.json and the keyboard gff_amharic. and a Keyman.version.exe if avaialable.
  15. On Regedit window. the state is changing to "usldle"
  16. Restart the machine by clicking the "Yes" button on the "Keyman setup" dialog.
  17. Login to the machine.
  18. Click ˘the "Yes" button on the "Do you want to allow to make the change?"
  19. Keyman Installation is completed successfully.
  20. Open the configuration window.
  21. On the Keyboard Layouts: verify gff_amharic keyboard is updated.
  22. On the Update Tab: verify there are no update available.

TEST_INSTALL_IDLE_CLEARED

In this test we will manipulate the registry update state to test the handling of receiving an kmshell request not expected in the installing state.

  1. Install Keyman attached the PR
  2. Install the Gff_Amharic 3.1.1 version keyboard.
  3. Run Keyman
  4. Open the Keyman Configuration dialog.
  5. Navigate to the "Keyboard Layouts tab".
  6. Verified that the installed keyboard shows an older version.
  7. Navigate to the "Update" tab.
  8. Open the "C:\Users"yourusername"\AppData\Local\Keyman\UpdateCache" folder.
  9. Open the regedit window (Computer\HKEY_CURRENT_USER\SOFTWARE\Keyman\Keyman Engine).
    WinR type regedit Go the current user key update state
    Press F5 to keep it refreshing it.
    The state will go to usDownloading to usInstalling at the same time keep checking the UpdateCache folder.
  10. Select the "update state"
  11. In Keyman Configuration press the "Check for new updates" button.
  12. Verified that the "UpdateCache" folder is updating or adding files)
  13. On Regedit window. Verify the state is changed from usUpdateAvailable--> usDownloading --> usWaitingRestart
  14. Use the Regedit to manually modify update state to "usInstalling"
  15. Open a command prompt (kbd>WinR type cmd)
  16. Change to the directory where kmshell is installed
    cd "c:\Program Files (x86)\Keyman\Keyman Desktop"
  17. Type kmshell.exe -a
  18. Looking at the registry editor the state should have changed to usIdle press F5 to refresh
  19. The UpdatedCache folder should be empty

Also handle the case where the SM seems to be stuck in the installing
state. MSI may have failed.
@rc-swag rc-swag self-assigned this Jan 21, 2025
@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Jan 21, 2025
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Jan 21, 2025

User Test Results

Test specification and instructions

Test Artifacts

@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S20 milestone Jan 21, 2025
@rc-swag rc-swag requested a review from mcdurdin January 21, 2025 05:03
@rc-swag rc-swag changed the base branch from master to feat/windows/test-online-update January 21, 2025 05:36
UserCanceled := False;
if BUpdateSM.ReadyToInstall and
(not FSilent and (FMode in [fmStart, fmSplash, fmMain, fmAbout, fmHelp,
fmShowHelp, fmSettings])) then
Copy link
Contributor Author

@rc-swag rc-swag Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcdurdin I have added fmShowHelp, and fmSettings as gui's where we could notify the user we can pop keyman update is ready to install. select update, or close.

However, I am still not happy that we are missing the all-important case when Keyman starts with Windows which is simply kmshell.exe -s I propose we update this to have a switch -on-boot so kmshell.exe -s -on-boot then we could determine this is a case where the UI can be run. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc

This isn't me!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kmshell -s means 'silent' so that means no UI is intended to be shown there... We could change that to kmshell.exe -boot, but we'd have to fixup existing installations -- we'd need to make sure that that change was applied during the upgrade (this is quite doable, just more work and testing).

I think that'd be good because it'd be clearer than the current -s which could be used any time and is ambiguous.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@_marc

This isn't me!

yikes

Base automatically changed from feat/windows/test-online-update to master January 21, 2025 23:47
…h-handling

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed and removed user-test-missing User tests have not yet been defined for the PR labels Jan 28, 2025
@rc-swag rc-swag marked this pull request as ready for review January 28, 2025 13:48
@rc-swag rc-swag requested a review from ermshiperete as a code owner January 28, 2025 13:48
// Result = exit straight away as we are installing (MSI installer)
// need to just do a no-op keyman will it maybe using kmshell to install
// packages.
// Should not be called while in installing state MSI installer may have
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a period missing after "state"? I have a hard time parsing the sentence as it is.

windows/src/desktop/kmshell/main/initprog.pas Outdated Show resolved Hide resolved
windows/src/desktop/kmshell/main/initprog.pas Outdated Show resolved Hide resolved
@dinakaranr
Copy link

Test Results

I tested this issue with the attached "Keyman-18.0.175-alpha-test-12956" build(30/01/2025) on Windows 10. I'm sharing my observation here.

  • TEST_INSTALL_UPDATE (Passed):
  1. Install Keyman attached the PR
  2. Install the Gff_Amharic 3.1.1 version keyboard.
  3. Open the Keyman Configuration dialog.
  4. Navigate to the "Keyboard Layouts tab".
  5. Verified that the installed keyboard shows an older version.
  6. Navigate to the "Update" tab.
  7. Open the "C:\Users"yourusername"\AppData\Local\Keyman\UpdateCache" folder.
  8. Open the regedit window (Computer\HKEY_CURRENT_USER\SOFTWARE\Keyman\Keyman Engine).
    WinR type regedit Go the current user key update state
    Press F5 to keep it refreshing it.
    The state will go to usDownloading to usInstalling at the same time keep checking the UpdateCache folder.
  9. Select the "update state"
  10. In Keyman Configuration press the "Check for new updates" button.
  11. Verified that the "UpdateCache" folder is updating or adding files)
  12. On Regedit window. Verify the state is changes from usUpdateAvailable--> usDownloading --> usWaitingRestart
  13. Click the "Apply update now" button. Click the "Update" button on the "Keyman Update" popup.
  14. Verified that the "UpdateCache" folder has the cache.json and the keyboard gff_amharic. and a Keyman.version.exe if available.
  15. On Regedit window. the state is changing to "usldle"
  16. Restart the machine by clicking the "Yes" button on the "Keyman setup" dialog.
  17. Login to the machine.
  18. Click ˘the "Yes" button on the "Do you want to allow to make the change?"
  19. Keyman Installation is completed successfully.
  20. Open the configuration window.
  21. On the Keyboard Layouts: verify gff_amharic keyboard is updated.
  22. On the Update Tab: Verified there are no updates available.
  • TEST_INSTALL_IDLE_CLEARED (Passed):
  1. Install Keyman attached the PR
  2. Install the Gff_Amharic 3.1.1 version keyboard.
  3. Run Keyman
  4. Open the Keyman Configuration dialog.
  5. Navigate to the "Keyboard Layouts tab".
  6. Verified that the installed keyboard shows an older version.
  7. Navigate to the "Update" tab.
  8. Open the "C:\Users"yourusername"\AppData\Local\Keyman\UpdateCache" folder.
  9. Open the regedit window (Computer\HKEY_CURRENT_USER\SOFTWARE\Keyman\Keyman Engine).
    WinR type regedit Go the current user key update state
    Press F5 to keep it refreshing it.
    The state will go to usDownloading to usInstalling at the same time keep checking the UpdateCache folder.
  10. Select the "update state"
  11. In Keyman Configuration press the "Check for new updates" button.
  12. Verified that the "UpdateCache" folder is updating or adding files)
  13. On Regedit window. Verify the state is changed from usUpdateAvailable--> usDownloading --> usWaitingRestart
  14. Use the Regedit to manually modify the update state to "usInstalling"
  15. Open a command prompt (kbd>WinR type cmd)
  16. Change to the directory where kmshell is installed
    cd "c:\Program Files (x86)\Keyman\Keyman Desktop"
  17. Type kmshell.exe -a
  18. Looking at the registry editor the state should have changed to "usIdle". press F5 to refresh
  19. Verified that the "UpdatedCache" folder is empty.
    It works well. Thank you.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Jan 30, 2025
@rc-swag rc-swag merged commit adb095b into master Jan 30, 2025
6 checks passed
@rc-swag rc-swag deleted the feat/windows/kmshell-switch-handling branch January 30, 2025 23:59
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.182-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants