Skip to content

refactor: replace JSON.parse(JSON.stringify()) with structuredClone and extract useTauriEvent hook#3140

Open
ChongBiaoZhang wants to merge 1 commit into
farion1231:mainfrom
ChongBiaoZhang:main
Open

refactor: replace JSON.parse(JSON.stringify()) with structuredClone and extract useTauriEvent hook#3140
ChongBiaoZhang wants to merge 1 commit into
farion1231:mainfrom
ChongBiaoZhang:main

Conversation

@ChongBiaoZhang
Copy link
Copy Markdown

Replace all JSON.parse(JSON.stringify()) deep copy patterns with native
structuredClone() across production source (9 occurrences), tests (11
occurrences), and a hand-rolled deepClone utility in providerConfigUtils.ts.
Add "ES2022" to tsconfig lib for type support.

Extract a useTauriEvent hook to eliminate the repeated Tauri event listener
boilerplate (useEffect + active/disposed flag + async listen) that was
duplicated across App.tsx (3 listeners) and useUsageCacheBridge.ts. The hook
handles async registration, race-condition guards, and cleanup automatically.

…nd extract useTauriEvent hook

Replace all `JSON.parse(JSON.stringify())` deep copy patterns with native
`structuredClone()` across production source (9 occurrences), tests (11
occurrences), and a hand-rolled `deepClone` utility in providerConfigUtils.ts.
Add "ES2022" to tsconfig lib for type support.

Extract a `useTauriEvent` hook to eliminate the repeated Tauri event listener
boilerplate (`useEffect` + `active/disposed` flag + async `listen`) that was
duplicated across App.tsx (3 listeners) and useUsageCacheBridge.ts. The hook
handles async registration, race-condition guards, and cleanup automatically.
@farion1231
Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

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