refactor(app): extract event listener / sync toast hooks and tighten ref typing#3786
Open
RainyNight9 wants to merge 2 commits into
Open
refactor(app): extract event listener / sync toast hooks and tighten ref typing#3786RainyNight9 wants to merge 2 commits into
RainyNight9 wants to merge 2 commits into
Conversation
pnpm 10+ 默认阻止依赖的安装期脚本,但 esbuild(Vite 工具链)和 msw(Vitest 测试 mock)需要运行 install/postinstall 步骤来准备 平台二进制,否则本地安装/测试可能异常或构建降级。 - pnpm-workspace.yaml: 在 onlyBuiltDependencies 中追加 esbuild、msw - 行为不变;只解除 pnpm 对这两个包的脚本拦截
只做结构与类型收敛,不改变任何运行时行为: - 新增 useProviderSwitchListener(activeApp, onRefetch) 统一管理 providersApi.onSwitched 订阅与卸载,替代 App 内的内联 useEffect - 新增 useAutoSyncErrorToast(eventName, queryClient, t, toastI18nKey) 合并 WebDAV/S3 自动同步失败 toast 的重复逻辑 - 收紧 Panel ref 类型:PromptPanelRef/McpPanelRef/SkillsPageRef/ UnifiedSkillsPanelRef 改为 useRef<...Handle | null>(null) 取代此前的 useRef<any>,调用点改用可选链避免运行时空方法 - 不新增组件文件,限制在 App.tsx 内重构,便于评审
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 概述
背景
App.tsx 承担了过多职责(事件订阅/卸载、toast 通用化、ref 强类型),本 PR 仅做结构与类型收敛,不改变任何运行时行为。后续想帮忙继续优化一下前端代码。
变更(2 个 commit)
1.
chore(pnpm): allow esbuild and msw in onlyBuiltDependenciespnpm-workspace.yaml的onlyBuiltDependencies中追加esbuild、msw,仅解除 pnpm 对这两个包的脚本拦截。2.
refactor(app): 抽出事件订阅与 auto-sync toast 通用 hook,并收紧 ref 类型useProviderSwitchListener(activeApp, onRefetch),统一管理providersApi.onSwitched订阅与卸载,替代 App 内的内联useEffect。useAutoSyncErrorToast(eventName, queryClient, t, toastI18nKey),合并 WebDAV/S3 自动同步失败 toast 的重复逻辑。PromptPanelRef/McpPanelRef/SkillsPageRef/UnifiedSkillsPanelRef改为useRef<...Handle | null>(null),取代此前的useRef<any>,调用点改用可选链避免运行时空方法。App.tsx内重构,便于评审。兼容性
纯重构,无 API/行为变更;不引入新依赖,不修改 i18n 文案。
Related Issue / 关联 Issue
Fixes #
Screenshots / 截图
Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)