Skip to content

Refactor: Improve Python 3.8+ compatibility & Fix bg_tasks memory leak#90

Open
1822520752 wants to merge 7 commits intoringhyacinth:masterfrom
1822520752:master
Open

Refactor: Improve Python 3.8+ compatibility & Fix bg_tasks memory leak#90
1822520752 wants to merge 7 commits intoringhyacinth:masterfrom
1822520752:master

Conversation

@1822520752
Copy link

@1822520752 1822520752 commented Mar 16, 2026

Description
This PR introduces several stability improvements and compatibility enhancements:

  1. Python 3.8+ Compatibility:

    • Refactored type hints (replaced X | Y with Union[X, Y] and Optional[X]) in backend/app.py, scripts/smoke_test.py, and webp_to_spritesheet.py.
    • Updated READMEs (EN/CN/JP) to reflect the lower Python requirement (3.8+ instead of 3.10+).
  2. Memory Leak Fix:

    • Implemented _cleanup_bg_tasks in backend/app.py to auto-remove stale background tasks older than 1 hour.
  3. Agent Push Script Optimization:

    • Removed hardcoded /root/ paths in office-agent-push.py for better cross-platform support.
    • Added colored logging for better user experience.
    • Synced changes to frontend/office-agent-push.py.
  4. **Maintenance:

    • Updated .gitignore to exclude IDE configs (.vscode, .idea) and temporary files.

    Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (no functional changes, no api changes)
  • Documentation update

New Enhancements (Batch 3):
4. Frontend Architecture Optimization:

  • Decoupled STATES and BUBBLE_TEXTS from game.js to layout.js for easier customization.
  • Refactored speech bubble UI to use dynamic pixel-width calculation instead of hardcoded magic numbers, ensuring perfect background fit for all languages.
  1. UX Improvements:
    • Refined researching area coordinates to provide better visual feedback during state transitions.
    • Optimized loading overlay animations for a snappier user experience.

@1822520752
Copy link
Author

描述 本PR引入了多项稳定性改进和兼容性增强:

  1. Python 3.8+ 兼容性:

    • 在 、 和 中重构型提示(用 和 替换)。X | Y``Union[X, Y]``Optional[X]``backend/app.py``scripts/smoke_test.py``webp_to_spritesheet.py
    • 更新了README(EN/CN/JP),以反映较低的Python要求(3.8+,而非3.10+)。
  2. 内存泄漏修复:

    • 该功能实现了自动移除超过1小时的陈旧背景任务。_cleanup_bg_tasks``backend/app.py
  3. 代理推送脚本优化:

    • 移除了硬编码路径,以便更好地跨平台支持。/root/``office-agent-push.py
    • 增加了彩色日志以提升用户体验。
    • 同步更改到 .frontend/office-agent-push.py
  4. **维护:

    • 已更新,排除了IDE配置(、)和临时文件。.gitignore``.vscode``.idea

    变更类型

  • 漏洞修复(非破坏性修改,修复了某个问题)
  • 重构(不做功能变更,不做 API 变更)
  • 文档更新

Description
This PR introduces a comprehensive set of improvements focusing on stability, cross-platform compatibility, and community growth.

Key Changes:

  1. Python 3.8+ Compatibility:

    • Refactored type hints (replaced X | Y with Union[X, Y] and Optional[X]) in backend/app.py, scripts/smoke_test.py, and webp_to_spritesheet.py.
    • Updated READMEs (CN/EN/JP) to reflect the broader environment support.
  2. Stability & Performance:

    • Added _cleanup_bg_tasks in backend/app.py to auto-remove stale background tasks older than 1 hour, preventing potential memory leaks.
    • Added detailed debugging logs to the /agent-push endpoint for easier troubleshooting.
  3. Cross-Platform & Path Cleanup:

    • Removed hardcoded /root/ and user-specific absolute paths in:
      • resize_map.py (added argparse support)
      • repack_star_working.py
      • convert_to_webp.py
      • healthcheck.sh
    • Scripts now dynamically resolve paths or accept command-line arguments.
  4. Agent Push Script Enhancement:

    • Re-designed office-agent-push.py with colored logging and robust automatic path discovery for state.json.
  5. Community & Documentation:

    • Added a "Contributing" section to READMEs in all three languages to guide new contributors.
    • Refined .gitignore to exclude IDE-specific configurations.

    Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (performance/stability improvement, no functional changes)
  • Documentation update

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