-
-
Notifications
You must be signed in to change notification settings - Fork 1
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(github): Modal for GitHub issue #73
Conversation
This PR was not deployed automatically as @Alc-Alc does not have access to the Railway project. In order to get automatic PR deploys, please add @Alc-Alc to the project inside the project settings page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Type: Enhancement
PR Summary: This pull request introduces a new modal for creating GitHub issues directly from the Discord interface, leveraging Discord's UI features for a more interactive and user-friendly experience. It includes the implementation of a GitHubIssue
modal class, modifications to the command group for invoking this modal, and updates to the context menu to trigger the modal. The changes aim to streamline the process of reporting issues by filling out a structured form within Discord, which then automatically creates a GitHub issue in the specified repository.
Decision: Comment
📝 Type: 'Enhancement' - not supported yet.
- Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
✅ Small diff: the diff is small enough to approve with confidence.
No details provided.
General suggestions:
- Consider exploring alternative naming conventions or strategies to avoid attribute conflicts, such as the
title
attribute renamed totitle_
in theGitHubIssue
modal class. A more consistent and clear naming convention could enhance code readability and maintainability. - Given the significant increase in complexity introduced by the new modal class, including new concepts and more sophisticated error handling, it's worth evaluating if the same objectives could be achieved with simpler constructs. Simplifying the implementation could reduce the cognitive load for developers and minimize the potential for bugs.
- Ensure comprehensive testing coverage for the new modal functionality, including unit tests for the modal's behavior and integration tests for the end-to-end user interaction flow. This is crucial for verifying the modal's correct operation under various conditions and ensuring the reliability of the GitHub issue creation process.
- Review the changes to the command group and context menu to ensure they align with the overall design and user experience goals. It's important that these changes do not inadvertently affect the functionality of existing commands or the usability of the interface.
Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨
title_ = TextInput[Self](label="title", placeholder="Title") | ||
description = TextInput[Self]( | ||
label="Description", | ||
style=TextStyle.paragraph, | ||
placeholder="Please enter an description of the bug you are encountering.", | ||
) | ||
mcve = TextInput[Self]( | ||
label="MCVE", | ||
style=TextStyle.paragraph, | ||
placeholder="Please provide a minimal, complete, and verifiable example of the issue.", | ||
) | ||
logs = TextInput[Self]( | ||
label="Logs", style=TextStyle.paragraph, placeholder="Please copy and paste any relevant log output." | ||
) | ||
version = TextInput[Self]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (llm): The renaming of the title
attribute to title_
to avoid conflict is a pragmatic solution. However, it's worth considering if there could be a more elegant approach to handle such conflicts, perhaps by namespacing or using a different attribute naming convention that reduces the likelihood of such conflicts in the first place.
|
||
from byte.lib.utils import is_byte_dev, mention_role, mention_user | ||
from server.domain.github.helpers import github_client | ||
|
||
__all__ = ("LitestarCommands", "setup") | ||
|
||
|
||
class GitHubIssue(Modal, title="Create GitHub Issue"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (llm): While the introduction of a GitHubIssue
modal class leverages Discord's UI features for a more interactive experience, it significantly increases the complexity of the code. This is due to the addition of new concepts such as Modal
, TextInput
, and TextStyle
, along with more sophisticated error handling and asynchronous logic. Additionally, the increased number of dependencies and the custom initialization logic in the GitHubIssue
class add further complexity.
To maintain simplicity and ease of maintenance, consider keeping the interaction logic within a function instead of introducing a modal class. This approach can reduce the cognitive load for developers and minimize the potential for bugs, while still achieving the goal of creating GitHub issues from Discord messages. Simplifying the code in this manner can make it more accessible to other developers and easier to maintain in the long run.
|
||
from byte.lib.utils import is_byte_dev, mention_role, mention_user | ||
from server.domain.github.helpers import github_client | ||
|
||
__all__ = ("LitestarCommands", "setup") | ||
|
||
|
||
class GitHubIssue(Modal, title="Create GitHub Issue"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (llm): I noticed the new GitHubIssue
modal class has been introduced, but there are no unit tests accompanying this addition. It's crucial to ensure that the modal's behavior, especially the on_submit
method, works as expected under various conditions. Could you add unit tests to cover the initialization of this modal, its submission behavior, and error handling? This would include testing the successful creation of a GitHub issue as well as failure scenarios, such as API errors.
class LitestarCommands(Cog): | ||
"""Litestar command cog.""" | ||
|
||
def __init__(self, bot: Bot) -> None: | ||
"""Initialize cog.""" | ||
self.bot = bot | ||
self.__cog_name__ = "Litestar Commands" # type: ignore[misc] | ||
self.context_menu = app_commands.ContextMenu(name="Create GitHub Issue", callback=self.create_github_issue) | ||
self.context_menu = app_commands.ContextMenu( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (llm): It's great to see the context menu being updated to trigger the new GitHub issue modal. However, I didn't find any integration tests that simulate the user interaction with this context menu and subsequently the modal. Testing this end-to-end flow is important to ensure that the modal is correctly invoked and that the interaction flow works as intended. Could you add such integration tests?
bot.tree.add_command(self.context_menu) | ||
|
||
@group(name="litestar") | ||
@is_byte_dev() | ||
async def litestar(self, ctx: Context) -> None: | ||
async def litestar(self, ctx: Context[Bot]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (llm): I see that the litestar
command group and its subcommands have been modified. While this change might not directly relate to testing the GitHub issue modal, it's important to ensure that these modifications do not inadvertently affect the functionality of the commands. If not already done, could you ensure that there are adequate tests for these command group changes, including any new behavior or edge cases introduced?
@@ -87,33 +160,15 @@ | |||
|
|||
await ctx.send(embed=embed) | |||
|
|||
async def create_github_issue(self, interaction: Interaction, message: Message) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (llm): The removal of the create_github_issue
method and its replacement with create_github_issue_modal
is a significant change. It's essential to verify through tests that the new modal-based approach achieves the same end goal as the previous implementation. Specifically, tests should cover the modal's successful submission leading to a GitHub issue creation and handle any potential errors gracefully. If such tests are missing, please consider adding them to ensure the new implementation's reliability.
ebe141f
to
5216b92
Compare
Closed #57 |
* feat(github): Modal for GitHub issue * fix: update modal submission wrapping --------- Co-authored-by: Alc-Alc <alc@localhost> Co-authored-by: Jacob Coffee <jacob@z7x.org>
Pull Request Checklist
Description
Close Issue(s)