Skip to content

feat: update UI to Include Game Title and Instructions#31

Merged
hmasdev merged 5 commits intomainfrom
feature/add-app-title-and-instruction
Nov 16, 2025
Merged

feat: update UI to Include Game Title and Instructions#31
hmasdev merged 5 commits intomainfrom
feature/add-app-title-and-instruction

Conversation

@hmasdev
Copy link
Copy Markdown
Owner

@hmasdev hmasdev commented Nov 16, 2025

This pull request introduces several improvements and refactorings across the codebase, focusing on clarity, maintainability, and user experience. The most significant updates include adding a game title and instructions display, refactoring factory functions for cleaner type handling, enhancing the stopwatch utility with overloads and documentation, and refining UI feedback and test assertions.

User Experience Enhancements:

  • Added automatic display of the game title and instructions on startup via the title and instructions properties in TypingGame, improving onboarding for users. (simple_typing_application/typing_game.py)
  • The typing target is now preceded by a blank system announcement for visual separation. (simple_typing_application/typing_game.py)

Code Quality and Maintainability:

  • Refactored factory functions (create_key_monitor, create_sentence_generator, create_user_interface) to simplify type assignments and remove redundant type annotations, making the code cleaner and less error-prone. (simple_typing_application/key_monitor/factory.py, simple_typing_application/sentence_generator/factory.py, simple_typing_application/ui/factory.py) [1] [2] [3]
  • Improved the stopwatch_deco decorator by adding overloads and comprehensive docstrings, clarifying its usage and enhancing type safety. (simple_typing_application/utils/stopwatch.py) [1] [2] [3]

Testing and Logging Improvements:

  • Updated test assertions to use assert_called_with instead of assert_called_once_with for system announcements, allowing more flexible verification of UI feedback. (tests/test_typing_game.py) [1] [2] [3]
  • Minor logging and formatting improvements in sentence generation and typing step output. (simple_typing_application/sentence_generator/openai_sentence_generator.py, simple_typing_application/typing_game.py) [1] [2]

These changes collectively improve the application's usability, code readability, and test reliability.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the typing application's user experience by adding automatic display of game title and instructions on startup, while also improving code quality through type annotation refactoring and documentation enhancements.

Key changes:

  • Added title and instructions properties that display automatically when TypingGame is initialized
  • Refactored factory functions to use cleaner type annotation patterns, declaring types once before conditional blocks
  • Enhanced stopwatch_deco with overload signatures and comprehensive docstrings for better type safety and documentation

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_typing_game.py Modified test assertions from assert_called_once_with to assert_called_with for system announcement verification
simple_typing_application/utils/stopwatch.py Added @overload decorators and comprehensive docstrings to stopwatch_deco for improved type hints
simple_typing_application/ui/factory.py Refactored type annotations to declare user_interface_config type once before conditional assignment
simple_typing_application/typing_game.py Added title and instructions properties, displaying them on initialization; added blank announcement before typing targets
simple_typing_application/sentence_generator/openai_sentence_generator.py Minor formatting change to comment placement in ainvoke call
simple_typing_application/sentence_generator/factory.py Refactored type annotations to declare sentence_generator_config type once before conditional assignment
simple_typing_application/key_monitor/factory.py Refactored type annotations to declare key_monitor_config type once before conditional assignment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# assert
typing_game._ui.system_anounce.assert_called_once_with( # type: ignore # noqa
typing_game._ui.system_anounce.assert_called_with( # type: ignore # noqa
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Changing from assert_called_once_with to assert_called_with weakens the test assertion. This test should verify that __skip_typing_step calls system_anounce exactly once with "SKIP!". The proper fix is to reset the mock before calling the method under test:

typing_game._ui.system_anounce.reset_mock()  # Add this line
typing_game._TypingGame__skip_typing_step()  # type: ignore

# assert
typing_game._ui.system_anounce.assert_called_once_with(  # Keep the original assertion
    "SKIP!",
    color=typing_game._system_anounce_color,
)

This ensures the test validates that the specific method only calls system_anounce once, regardless of earlier calls during initialization.

Copilot uses AI. Check for mistakes.

# assert
typing_game._ui.system_anounce.assert_called_once_with( # type: ignore # noqa
typing_game._ui.system_anounce.assert_called_with( # type: ignore # noqa
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Changing from assert_called_once_with to assert_called_with weakens the test assertion. This test should verify that __done_typing_step calls system_anounce exactly once with "DONE!". The proper fix is to reset the mock before calling the method under test:

typing_game._ui.system_anounce.reset_mock()  # Add this line
typing_game._TypingGame__done_typing_step()  # type: ignore

# assert
typing_game._ui.system_anounce.assert_called_once_with(  # Keep the original assertion
    "DONE!",
    color=typing_game._system_anounce_color,
)

This ensures the test validates that the specific method only calls system_anounce once, regardless of earlier calls during initialization.

Copilot uses AI. Check for mistakes.

# assert
typing_game._ui.system_anounce.assert_called_once_with( # type: ignore
typing_game._ui.system_anounce.assert_called_with( # type: ignore
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Changing from assert_called_once_with to assert_called_with weakens the test assertion. This test should verify that __exit_typing_step calls system_anounce exactly once with "EXIT!". The proper fix is to reset the mock before calling the method under test:

typing_game._ui.system_anounce.reset_mock()  # Add this line
typing_game._TypingGame__exit_typing_step()  # type: ignore

# assert
typing_game._ui.system_anounce.assert_called_once_with(  # Keep the original assertion
    "EXIT!",
    color=typing_game._system_anounce_color,
)

This ensures the test validates that the specific method only calls system_anounce once, regardless of earlier calls during initialization.

Copilot uses AI. Check for mistakes.
@hmasdev hmasdev merged commit 115c3e4 into main Nov 16, 2025
23 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