Skip to content

ci: refactor workflow#17

Merged
Dr1mH4X merged 4 commits into
mainfrom
dev
Mar 18, 2026
Merged

ci: refactor workflow#17
Dr1mH4X merged 4 commits into
mainfrom
dev

Conversation

@Dr1mH4X

@Dr1mH4X Dr1mH4X commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Sourcery 总结

在优化前端错误处理和托盘设置的同时,用统一的多平台构建与发布流水线取代原有的发布工作流,以生成可分发的构建产物,包括 Linux 工件。

增强内容:

  • 抑制来自前端日志调用的错误,避免未处理的 Promise 拒绝。
  • 使托盘图标初始化在缺少默认窗口图标时仍能正常工作,并简化事件监听的设置。

构建:

  • 引入统一的 GitHub Actions 构建工作流,用于为 Windows、Linux 和 macOS 构建并打包 Tauri 二进制文件、同步版本元数据并上传构建工件。
  • 用集成的构建和发布流水线替换之前的发布专用工作流,在有标签的版本上生成更新日志并发布 GitHub Releases。
Original summary in English

Summary by Sourcery

Refine frontend error handling and tray setup while replacing the release workflow with a unified multi-platform build and release pipeline that produces distributable bundles, including Linux artifacts.

Enhancements:

  • Suppress errors from frontend logging calls to avoid unhandled promise rejections.
  • Make tray icon initialization tolerate missing default window icons and simplify event listening setup.

Build:

  • Introduce a consolidated GitHub Actions build workflow that builds and packages Tauri binaries for Windows, Linux, and macOS, synchronizes version metadata, and uploads artifacts.
  • Replace the previous release-specific workflow with an integrated build and release pipeline that generates changelogs and publishes GitHub releases for tagged versions.

Copilot AI review requested due to automatic review settings March 18, 2026 05:09
@sourcery-ai

sourcery-ai Bot commented Mar 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

重构了 Tauri React 前端中的错误日志记录逻辑:忽略来自日志命令的失败,使托盘图标设置在缺少默认图标时也能正常工作,调整事件监听任务对接收端的所有权处理,并用新的跨平台构建与发布流水线(新增 Linux 打包并统一打包方式)替换了之前的 GitHub Release 工作流。

更新后的前端错误日志行为时序图

sequenceDiagram
  participant ReactApp
  participant TauriBackend

  ReactApp->>TauriBackend: invoke(frontend_log, level, message)
  alt logging succeeds
    TauriBackend-->>ReactApp: Promise resolved
  else logging fails
    TauriBackend-->>ReactApp: Promise rejected
    ReactApp->>ReactApp: catch(() => {})
    ReactApp-->>ReactApp: Ignore logging failure
  end
Loading

File-Level Changes

Change Details Files
通过吞掉日志命令失败,使前端日志调用变为非致命。
  • 将初始状态加载错误的日志记录 invoke 包裹在忽略错误的 catch 处理器中
  • 将 toggle_pause 错误日志记录 invoke 包裹在忽略错误的 catch 处理器中
  • 将 open_log_folder 错误日志记录 invoke 包裹在忽略错误的 catch 处理器中
  • 将设置窗口中的错误日志记录 invoke 包裹在忽略错误的 catch 处理器中
src/App.tsx
加固托盘图标初始化逻辑,以应对缺失默认窗口图标的情况。
  • 创建一个预配置了菜单的可变 TrayIconBuilder
  • 仅在存在 default_window_icon 时才设置托盘图标,而不是直接 unwrap
  • 从可能没有图标的 builder 构建托盘图标
src-tauri/src/tray.rs
调整事件监听任务,使其在异步任务体内部取得接收端的所有权。
  • 将 listen_events 修改为接收非可变的 mpsc::Receiver 参数
  • 在 spawn 的异步块中、循环开始前重新引入接收端的可变性
src-tauri/src/events.rs
引入新的统一 CI 工作流,用于构建、打包并发布跨平台制品(包括 Linux),同时移除旧的发布工作流。
  • 新增 .github/workflows/build.yml,其中包含用于元数据解析、Windows/Linux/macOS 矩阵构建、变更日志生成和发布 Release 的多个 job
  • 配置构建 job,在 package.json、tauri.conf.json 和 Cargo.toml 之间同步版本号
  • 使用缓存构建 Tauri 应用,将二进制文件打包到各操作系统专用的安装目录中,并根据平台不同采用不同的制品打包格式(Windows 使用 zip,Linux/macOS 使用 tar.gz)
  • 汇总构建制品,并在基于标签的发布中使用生成的变更日志内容发布 GitHub Releases
  • 移除旧的 .github/workflows/release.yml 工作流
.github/workflows/build.yml
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • 触发新评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 在回复某条评审评论时,请求 Sourcery 从该评论创建 issue。你也可以直接回复该评论 @sourcery-ai issue 来从中创建 issue。
  • 生成 pull request 标题: 在 pull request 标题中任意位置写上 @sourcery-ai,即可在任意时刻生成标题。你也可以在 pull request 中评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 描述正文任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来在任意时刻(重新)生成摘要。
  • 生成评审者指南: 在 pull request 中评论 @sourcery-ai guide,即可在任意时刻(重新)生成评审者指南。
  • 批量解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 清除所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,即可清除所有现有的 Sourcery 评审。特别适合在想要全新开始一次评审时使用——别忘了随后再评论 @sourcery-ai review 来触发新评审!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用评审特性,例如 Sourcery 生成的 pull request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审说明。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Refactors error logging in the Tauri React frontend to ignore failures from the logging command, makes the tray icon setup tolerant of missing default icons, adjusts event listener task ownership, and replaces the previous GitHub release workflow with a new cross-platform build and release pipeline that adds Linux bundles and unified packaging.

Sequence diagram for updated frontend error logging behavior

sequenceDiagram
  participant ReactApp
  participant TauriBackend

  ReactApp->>TauriBackend: invoke(frontend_log, level, message)
  alt logging succeeds
    TauriBackend-->>ReactApp: Promise resolved
  else logging fails
    TauriBackend-->>ReactApp: Promise rejected
    ReactApp->>ReactApp: catch(() => {})
    ReactApp-->>ReactApp: Ignore logging failure
  end
Loading

File-Level Changes

Change Details Files
Make frontend logging invocations non-fatal by swallowing failures of the logging command.
  • Wrap initial-state load error logging invoke in a catch handler that ignores errors
  • Wrap toggle_pause error logging invoke in a catch handler that ignores errors
  • Wrap open_log_folder error logging invoke in a catch handler that ignores errors
  • Wrap settings window error logging invokes in catch handlers that ignore errors
src/App.tsx
Harden tray icon initialization against missing default window icons.
  • Create a mutable TrayIconBuilder with menu preconfigured
  • Conditionally set the tray icon only if default_window_icon is present instead of unwrapping
  • Build tray icon from the possibly icon-less builder
src-tauri/src/tray.rs
Adjust event listener task to take ownership of the receiver inside the async task body.
  • Change listen_events to take a non-mut mpsc::Receiver parameter
  • Reintroduce mutability for the receiver within the spawned async block before the loop
src-tauri/src/events.rs
Introduce a new unified CI workflow that builds, packages, and releases cross-platform artifacts (including Linux) and remove the old release workflow.
  • Add .github/workflows/build.yml with jobs for metadata resolution, matrix builds for Windows, Linux, and macOS, changelog generation, and release publishing
  • Configure build job to sync version across package.json, tauri.conf.json, and Cargo.toml
  • Build Tauri app with caching, bundle binaries into OS-specific install directories, and package artifacts differently per platform (Windows zip, Linux/macOS tar.gz)
  • Aggregate build artifacts and publish GitHub releases with generated changelog content for tag-based releases
  • Remove the legacy .github/workflows/release.yml workflow
.github/workflows/build.yml
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - 我在这里给了一些整体反馈:

  • 新增的对 invoke("frontend_log", ...).catch(() => {}) 调用会静默吞掉错误;至少可以考虑打到 console.error,或者把它封装到一个辅助方法里(例如 safeFrontendLog(...)),这样在调试时才能看得到失败信息。
  • build.yml 中,用 sed 做版本重写的内联逻辑会用相似的正则去改动三个不同的文件;把这部分逻辑集中到一个小脚本中,或者复用单一可信来源,可能会更健壮一些,从而降低这些匹配模式随着时间推移而产生偏差的风险。
给 AI Agent 的提示词
请根据这次代码评审中的评论进行修改:

## 总体评论
- 新增的对 `invoke("frontend_log", ...)``.catch(() => {})` 调用会静默吞掉错误;至少可以考虑打到 `console.error`,或者把它封装到一个辅助方法里(例如 `safeFrontendLog(...)`),这样在调试时才能看得到失败信息。
-`build.yml` 中,用 `sed` 做版本重写的内联逻辑会用相似的正则去改动三个不同的文件;把这部分逻辑集中到一个小脚本中,或者复用单一可信来源,可能会更健壮一些,从而降低这些匹配模式随着时间推移而产生偏差的风险。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • The new .catch(() => {}) calls on invoke("frontend_log", ...) silently swallow errors; consider at least logging to console.error or wrapping this in a helper (e.g. safeFrontendLog(...)) so failures are visible during debugging.
  • In build.yml, the inline sed version-rewrite logic touches three different files with similar regexes; it may be more robust to centralize this into a small script or reuse a single source of truth to reduce the chance of the patterns drifting apart over time.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `.catch(() => {})` calls on `invoke("frontend_log", ...)` silently swallow errors; consider at least logging to `console.error` or wrapping this in a helper (e.g. `safeFrontendLog(...)`) so failures are visible during debugging.
- In `build.yml`, the inline `sed` version-rewrite logic touches three different files with similar regexes; it may be more robust to centralize this into a small script or reuse a single source of truth to reduce the chance of the patterns drifting apart over time.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown

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 hardens error handling in the Tauri frontend/backend integration and refactors the GitHub Actions pipeline by replacing the old release workflow with a unified build+release workflow.

Changes:

  • Prevent unhandled promise rejections from invoke("frontend_log", ...) by explicitly swallowing failures.
  • Avoid panics when a default window icon is unavailable while building the tray icon.
  • Replace .github/workflows/release.yml with a new multi-platform .github/workflows/build.yml that builds on PRs/pushes and publishes releases on v* tags.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/App.tsx Adds .catch(() => {}) on logging invoke calls to avoid unhandled promise rejections.
src-tauri/src/tray.rs Makes tray icon setup resilient to missing default window icon (removes unwrap).
src-tauri/src/events.rs Adjusts receiver mutability handling inside the spawned task.
.github/workflows/release.yml Removes the previous release workflow.
.github/workflows/build.yml Introduces a unified build workflow with tag-based release publishing and added Linux builds.

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

workflow_dispatch:

permissions:
contents: write
@Dr1mH4X Dr1mH4X merged commit 830c540 into main Mar 18, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in RustSyncCV Mar 18, 2026
@Dr1mH4X Dr1mH4X changed the title ci: refactor workflow,add linux bundle ci: refactor workflow Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants