Optimize P0-P2 stability, performance, and packaging#58
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Also adds a local Tauri packaging script that builds the sidecar and skips updater signing for developer machines without release secrets. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 688 |
| Duplication | 83 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Summary of ChangesHello, 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 significantly improves the application's stability, performance, and maintainability by addressing critical areas from backend infrastructure to frontend user experience. It introduces robust error handling, optimizes resource usage, and streamlines the development and deployment workflows, ensuring a more reliable and efficient application for both desktop and web environments. Highlights
Ignored Files
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant enhancements to backend security and frontend performance. Key changes include the implementation of strict reference image validation (size, count, and file type), refactored worker pool logic with panic recovery, and optimized HTTP server timeouts to support SSE long-connections. On the frontend, performance was improved through virtualized rendering in the template market, lazy-loaded i18n bundles, and a bounded localStorage cache for history records. Additionally, Zustand subscriptions were optimized using useShallow to minimize unnecessary re-renders. Review feedback focuses on reducing code duplication in validation handlers, externalizing hardcoded magic numbers in the grid layout logic, and moving helper functions outside of hooks to improve code organization.
| if err := validateReferenceImageCount(len(refImageBytes) + 1); err != nil { | ||
| Error(c, http.StatusBadRequest, 400, err.Error()) | ||
| return | ||
| } | ||
| if err := validateReferenceImageSize(file.Name, int64(len(file.Content))); err != nil { | ||
| Error(c, http.StatusBadRequest, 400, err.Error()) | ||
| return | ||
| } | ||
| if err := validateReferenceImagesTotalBytes(totalReferenceImageBytes(refImageBytes) + int64(len(file.Content))); err != nil { | ||
| Error(c, http.StatusBadRequest, 400, err.Error()) | ||
| return | ||
| } | ||
| refImageBytes = append(refImageBytes, file.Content) | ||
| } | ||
| } |
There was a problem hiding this comment.
Fixed in 47d6182. The repeated reference image byte validation path now goes through appendReferenceImageBytes/validateReferenceImageBytesAppend, so count, per-file size, and total-size checks stay centralized before adding content.
| typeof window !== 'undefined' | ||
| ? window.innerWidth || document.documentElement.clientWidth | ||
| : width; | ||
| const columnCount = width > 0 ? getTemplateColumnCount(width, viewportWidth) : 2; |
There was a problem hiding this comment.
Fixed in 617f729. Template grid columns and breakpoints are now named constants (TEMPLATE_GRID_COLUMNS / TEMPLATE_GRID_BREAKPOINTS) instead of inline magic numbers.
| const isTextInputTarget = (target: EventTarget | null) => { | ||
| const element = target as HTMLElement | null; | ||
| return Boolean( | ||
| element && | ||
| ((element as any).isContentEditable || | ||
| element.tagName === 'INPUT' || | ||
| element.tagName === 'TEXTAREA') | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Already fixed in fbaab63. isTextInputTarget remains module-scoped outside the hook and now uses instanceof HTMLElement instead of unsafe casts.
| const nextLanguage = language === 'system' ? languageResolved : language; | ||
| if (!nextLanguage) return; | ||
| if (i18n.language !== nextLanguage) { | ||
| void changeAppLanguage(nextLanguage); |
There was a problem hiding this comment.
Suggestion: This fire-and-forget language switch introduces a race condition: if language changes happen quickly, an older async call can finish last and overwrite the newer selection, leaving UI language out of sync with store state. Serialize or cancel in-flight language changes (or await the latest request) so only the newest selection is applied. [race condition]
Severity Level: Major ⚠️
- ⚠️ Desktop UI language may not match selected language.
- ⚠️ i18n instance can diverge from config store state.
- ⚠️ Users quickly toggling language see inconsistent translations.Steps of Reproduction ✅
1. Start the desktop app so that `App` from `desktop/src/App.tsx` mounts and subscribes to
the config store's `language` and `languageResolved` at lines 12–13, and note that the
language change effect at lines 18–25 calls `void changeAppLanguage(nextLanguage);` when
`i18n.language !== nextLanguage` (line 23).
2. Open the Settings UI that renders `SettingsModal` from
`desktop/src/components/Settings/SettingsModal.tsx` (file referenced by Grep) and rapidly
change the language selection in the `<select>` control twice (e.g., from `zh-CN` to
`system` and then quickly to another concrete language), causing `handleLanguageChange` at
lines ~663–678 (see Grep output) to be invoked multiple times in quick succession.
3. Each `handleLanguageChange` invocation updates the Zustand config store via
`setLanguage(...)` / `setLanguageResolved(...)` and then performs a fire‑and‑forget
language switch by calling `void changeAppLanguage(...)` at `SettingsModal.tsx:666` and
`:676`, and `App.tsx:23` also issues its own `void changeAppLanguage(nextLanguage);` based
on the updated store state, resulting in multiple concurrent `changeAppLanguage` calls for
different target languages.
4. In `desktop/src/i18n/index.ts:26–30`, each `changeAppLanguage` call asynchronously
loads translations (`await localeLoaders[lang]()` at lines 21–22 via
`ensureLanguageResource`) and then calls `await i18n.changeLanguage(normalized);`; because
these asynchronous operations can complete in any order, an earlier call (for the first
language the user briefly selected) can finish last and set `i18n.language` back to the
outdated value while the config store still holds the latest language, leaving the UI text
(which reads from `i18n`) out of sync with the stored `language`/`languageResolved` until
some later action happens to trigger another correction.Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** desktop/src/App.tsx
**Line:** 23:23
**Comment:**
*Race Condition: This fire-and-forget language switch introduces a race condition: if language changes happen quickly, an older async call can finish last and overwrite the newer selection, leaving UI language out of sync with store state. Serialize or cancel in-flight language changes (or await the latest request) so only the newest selection is applied.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
User description
Summary
Verification
cd backend && go test ./... && go vet ./...cd desktop && npm run type-check && npm run buildcd frontend && npm run type-check && npm run builddocker compose configcd desktop && PATH="$HOME/.cargo/bin:$PATH" npm run tauri:build:localNotes
v2.8.4has been pushed.desktop/src-tauri/target/release/bundle/dmg/大香蕉 AI_2.8.4_aarch64.dmg.CodeAnt-AI Description
Tighten app stability, speed up template browsing, and make image handling safer
What Changed
Impact
✅ Faster template browsing✅ Fewer upload failures from oversized reference images✅ Clearer provider error messages🔄 Retrigger CodeAnt AI Review
Details
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.