-
Notifications
You must be signed in to change notification settings - Fork 0
Claude/fix oauth redirect k2p8t #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 修復 HTML 結構:調整 </details> 和 </div> 的順序 - 移除未使用的 SYNC_KEYS 常數
- 移除 setTimeout(100ms) 競合:同步完成後立即更新 UI - 新增 showSyncError:同步失敗時顯示用戶可見的錯誤訊息 - 移除不可靠的 beforeunload,只使用 visibilitychange
Summary of ChangesHello @GJRobert, 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 primarily focuses on enhancing the robustness and user experience of the cloud synchronization mechanism. It streamlines the synchronization logic, provides clearer error feedback to users, and ensures more reliable data persistence when a page is closed or hidden. Additionally, a minor HTML structural correction is included. Highlights
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Code Review for PR #195: Fix OAuth RedirectI've reviewed the changes in this PR and have the following feedback: ✅ Positive Changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
這份 PR 對雲端同步功能做了幾項很棒的改進。它重構了 UI 更新的邏輯,讓程式碼結構更清晰;為同步失敗的情況增加了使用者可見的錯誤通知;並且透過移除有問題的 beforeunload 事件監聽器,提高了頁面關閉時資料同步的可靠性。此外,也修正了 HTML 的結構。整體而言,這些都是能提升程式碼品質與使用者體驗的正面變更。我只對新的錯誤提示函式有一點建議,希望能讓它在處理連續快速的錯誤時更加穩健。
| function showSyncError(message) { | ||
| // 使用現有的 cloudSyncBtn 顯示 tooltip 風格的錯誤訊息 | ||
| const cloudSyncBtn = document.getElementById('cloudSyncBtn'); | ||
| if (!cloudSyncBtn) return; | ||
|
|
||
| const originalTitle = cloudSyncBtn.title; | ||
| cloudSyncBtn.title = message; | ||
|
|
||
| // 3 秒後恢復原本的 title | ||
| setTimeout(() => { | ||
| cloudSyncBtn.title = originalTitle; | ||
| }, 3000); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前的 showSyncError 實作在快速連續觸發時,可能存在 race condition。如果函式在 3 秒的 timeout 結束前被多次呼叫,會導致按鈕的 title 最終停留在舊的錯誤訊息,而無法還原到最初的狀態。這是因為 originalTitle 變數會捕獲到呼叫當下、可能是前一個錯誤訊息的 title。
為了讓此函式更加穩健,建議將「真正的」原始 title 儲存在元素的 dataset 中,並將 timeout ID 也附加到元素上管理。這樣可以確保即使函式被多次呼叫,timeout 也能被正確重置,且 UI 最終能回到正確的非錯誤狀態。
function showSyncError(message) {
// 使用現有的 cloudSyncBtn 顯示 tooltip 風格的錯誤訊息
const cloudSyncBtn = document.getElementById('cloudSyncBtn');
if (!cloudSyncBtn) return;
// 如果已有錯誤提示的 timeout,先清除,避免舊的 timeout 覆蓋新的狀態
if (cloudSyncBtn.syncErrorTimeout) {
clearTimeout(cloudSyncBtn.syncErrorTimeout);
} else {
// 如果沒有,表示這是新的錯誤提示,儲存當前的 title 做為原始 title
cloudSyncBtn.dataset.originalTitle = cloudSyncBtn.title;
}
cloudSyncBtn.title = message;
// 設定新的 timeout 來還原 title
cloudSyncBtn.syncErrorTimeout = setTimeout(() => {
// 還原 title,並清除暫存的屬性
if (cloudSyncBtn.dataset.originalTitle) {
cloudSyncBtn.title = cloudSyncBtn.dataset.originalTitle;
delete cloudSyncBtn.dataset.originalTitle;
}
delete cloudSyncBtn.syncErrorTimeout;
}, 3000);
}- OAuth redirect 保留 query parameters(腔調、級別、類別等狀態) - syncToCloud() 失敗時顯示錯誤通知 - showSyncError() 使用 dataset 避免 race condition
Deploying hakspring with
|
| Latest commit: |
40b9937
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5a205f0a.hakspring.pages.dev |
| Branch Preview URL: | https://claude-fix-oauth-redirect-k2.hakspring.pages.dev |
Pull Request Review: Fix OAuth RedirectSummaryThis PR fixes the OAuth redirect flow to preserve query parameters and improves the cloud sync error handling and UI update logic. Overall, the changes are well-implemented with good attention to user experience. Code Quality & Best Practices ✅Positive Changes:
Potential Issues & Concerns
|
No description provided.