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

Removes emojis from messages on Windows, adds 'SystemInfo' class to retain imutable information about the SO environment #93

Merged
merged 8 commits into from
Feb 2, 2025

Conversation

edassis
Copy link
Contributor

@edassis edassis commented Jan 21, 2025

Hi,

This is a patch originated from the desire to fix the messages logs with broken emojis when running on Windows, as it's console doesn't use UTF-8 encoding (good reference about cmd it here: https://stackoverflow.com/a/75788701/8903027, documented this link in the Log class for future reference).

To make it work, the Log.Output() class now checks if the system running is Windows, if it is, removes from the message all leading non-ASCII (emojis) chars before printing.

To do this, the Log class needs system information. The way I approached it, avoiding changing a bunch of methods/interfaces signatures, was to create a class that holds these informations, and that's how SystemInfo static class came about. The idea it's that the information inside it should be ready when the program starts (class initialization) and should not change during run-time. I thought of making it a record, but as it has a constructor, I keep it as a class (but maybe we can refactor it to something more elegant or that better fit with the code). Anyway, I think it's a new idea in the codebase that others systems could benefit of.

The abstraction SystemInformation was created, containing CPU and OS information that should not change during runtime. I tried to create it as a static class previously to avoid having to change signatures in multiple layers, but it showed very cumbersome to manage the SystemInfo lifecycle and to mock it during tests. So I scratched that and now, it's a normal class created at the main method that is being propagated to the others objects from there.

Another change was in the logs. Changed the Info() color to cyan to make it more visible, adjusted install command messages to make them more concise and dense:

  • Each step has a log saying what is about to happen, defined as Info (cyan);
  • Details intrinsic of the step it's printed normally (white). Some messages that could be considered details of the step were being printed as Info, but this diminishes the importance of the real important Info messages (as it tends to fall into normality for the human eyes). So, I tried to use more sparingly the Info type in the messages;
  • At the end of the step, the confirmation message it's printed, defined as Success.

Most of these points are already there, just did I touch in consistency. If these changes in the log style are well welcomed we can look to extend it to all the CLI logs and not just the install command.

Windows preview

Main branch:
Captura de tela 2025-01-21 160649

Patched:
Captura de tela 2025-01-21 160837

Linux preview

Main branch:
Captura de tela 2025-01-21 160503

Patched:
Captura de tela 2025-01-21 160357

One point I'm having some difficult to understand it's how the progress text works for the Godot extraction process. During my tests, seems to me that the string message sent by Progress<double>((percent) => { ... } stays in the stream output, and clashes with the output of the next message. But I think I circumvented it by making log.Print("") to output a new line followed by log.ClearCurrentLine() to reset the cursor to the beginning of the line.

Another bug that I may be found: the extraction process not reaches 100%, despite the process having completed the text doesn't reach 100%:

Extracting text not reaches 100%

image

This PR delivers a fix in the Windows symlink creation routine. At the beginning, we were creating a symbolic link to point to Godot's binary, but to offer desktop shortcut support, we added the creation of hard links used by the desktop shortcut, and the symbolic link stayed. As having the hardlink covers the previous usage for the symbolic link, I removed the symbolic link creation on Windows and standardized that: on Windows, if it's not a directory link, it will be a hard link.

WIP:

  • Code clean up;
  • Code Tests;
  • Test on Mac (help wanted, I don't have a Mac :/).

Let me know what you think.

Hope the holidays were good for you! 😎

@edassis edassis changed the title Removes emojis from messages on Windows, adds global 'SystemInfo' to retain imutable information about the SO environment Removes emojis from messages on Windows, adds 'SystemInfo' class to retain imutable information about the SO environment Jan 21, 2025
@jolexxa
Copy link
Member

jolexxa commented Jan 21, 2025

Hey, thanks for tackling this one. I'm happy to test this on mac once you get this cleaned up and passing CI.

Make logs messages more concise during 'install' cmd. Small tweaks on
messages spacing and new lines to turn output more dense and cohesive.

Fixes messages printed right after progress display clashing with it.
'SystemInfo' has runtime information about the system, like the OS,
CPU architecture.
@edassis
Copy link
Contributor Author

edassis commented Jan 25, 2025

Ready for review.

@edassis edassis marked this pull request as ready for review January 25, 2025 20:57
@jolexxa
Copy link
Member

jolexxa commented Jan 30, 2025

@edassis Thank you for tackling all of this, it seems like a lot of really nice (but painful to implement) quality-of-life improvements. I'm going to try and get to testing this locally on my mac in the next few days — just been really busy.

@edassis
Copy link
Contributor Author

edassis commented Jan 31, 2025

Okay :), no problem at all. Let me know in case it needs some adjustments.

@jolexxa
Copy link
Member

jolexxa commented Jan 31, 2025

@edassis I've got a big ol' sticky note on my desk reminding me to get to reviews for this tonight / this weekend. That you for all the awesome contributions. I imagine there will be a few things we'll need to adjust, but nothing major.

Copy link
Member

@jolexxa jolexxa left a comment

Choose a reason for hiding this comment

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

This cleaned up really nicely. The only really refactor I'd like to see is putting SystemInfo in the execution context so you don't have to pass it in to create logs. Other than that and a few stragglers, we're looking really good here.

GodotEnv/src/common/models/ExecutionContext.cs Outdated Show resolved Hide resolved
GodotEnv/src/common/models/OSFamily.cs Show resolved Hide resolved
GodotEnv/src/common/utilities/ProcessRunner.cs Outdated Show resolved Hide resolved
GodotEnv/src/features/godot/domain/GodotRepository.cs Outdated Show resolved Hide resolved
@edassis edassis requested a review from jolexxa February 2, 2025 17:58
Copy link
Member

@jolexxa jolexxa left a comment

Choose a reason for hiding this comment

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

thank you 💜

@jolexxa jolexxa merged commit ad2f53f into chickensoft-games:main Feb 2, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants