fix(stage-tamagotchi): programmtical resize#913
Conversation
Summary of ChangesHello @abr-Projects, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request provides a workaround for a known Electron bug affecting transparent, frameless windows by implementing a custom, manual resizing solution. It establishes a robust communication channel between the renderer and main processes, allowing the user interface to control window dimensions directly. This change restores essential window management functionality, ensuring a consistent user experience despite the underlying platform limitation. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a manual window resizing mechanism for frameless, transparent Electron windows, which is a solid workaround for a known platform-specific bug. The implementation spans the main process, a preload script, and new Vue components on the renderer side. My review focuses on a few key areas to enhance the code's robustness and maintainability. I've identified a potential bug in the preload script that could lead to API conflicts, an opportunity to improve type safety by removing a @ts-ignore, and a suggestion regarding constant placement for better visibility. Addressing these points will make the solution more robust and easier to maintain.
| const minWidth = 100 | ||
| const minHeight = 200 |
There was a problem hiding this comment.
While it's good that you've used constants for minWidth and minHeight, these could be defined at the module level (outside the function) to make them more visible and to signal that they are static configuration values for this functionality. This improves maintainability by grouping constants together.
| // @ts-ignore | ||
| window.api?.resizeWindow(deltaX, deltaY, direction) |
There was a problem hiding this comment.
The use of @ts-ignore should be avoided. To ensure type safety for the API exposed via contextBridge, you should declare the shape of window.api in a global d.ts file. This will provide TypeScript with the necessary information to type-check the call and offer autocompletion, improving developer experience and code quality.
For example, you could add a file like src/renderer/api.d.ts with:
export interface IPreloadApi {
resizeWindow: (deltaX: number, deltaY: number, direction: string) => Promise<void>;
}
declare global {
interface Window {
api: IPreloadApi;
}
}| // @ts-ignore | |
| window.api?.resizeWindow(deltaX, deltaY, direction) | |
| window.api?.resizeWindow(deltaX, deltaY, direction) |
⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.
Hey, @nekomeowww, @sumimakito, @luoling8192, @LemonNekoGH, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏 |
--------- Co-authored-by: Neko Ayaka <neko@ayaka.moe>
Description
Electron windows with
transparent: trueandframe: falsecannot be resized due to a bug. This approach is based on the approach used in Cherry StudioLinked Issues
https://github.com/CherryHQ/cherry-studio/pull/11766/files