-
Notifications
You must be signed in to change notification settings - Fork 9
fix(ci): invalidate Gradle cache when Tauri config or capabilities ch… #331
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
206be8e
14dbb12
78668f4
3ae17e8
b337026
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,32 +106,53 @@ function LoginPage() { | |
| }; | ||
|
|
||
| const handleGitHubLogin = async () => { | ||
| setError(null); | ||
| const platform = isIOSPlatform ? "iOS" : "Android/Desktop"; | ||
| setError(`[DEBUG] GitHub click detected. Tauri=${isTauriEnv}, Platform=${platform}`); | ||
|
Comment on lines
+109
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug code from production or gate behind a feature flag. The code uses
Additionally, multiple sequential Apply this pattern to remove debug const handleGitHubLogin = async () => {
- setError(null);
- const platform = isIOSPlatform ? "iOS" : "Android/Desktop";
- setError(`[DEBUG] GitHub click detected. Tauri=${isTauriEnv}, Platform=${platform}`);
-
try {
+ setError(null);
console.log("[OAuth] Using", isTauriEnv ? "Tauri" : "web", "flow");
+ console.log("[OAuth] Platform:", isIOSPlatform ? "iOS" : "Android/Desktop");If you need to keep debug traces for troubleshooting production issues, gate them behind a feature flag: const DEBUG_OAUTH = import.meta.env.DEV || sessionStorage.getItem('debug_oauth') === 'true';
if (DEBUG_OAUTH) {
setError(`[DEBUG] GitHub click detected. Tauri=${isTauriEnv}, Platform=${platform}`);
}Also applies to: 173-175, 363-365 🤖 Prompt for AI Agents |
||
|
|
||
| try { | ||
| console.log("[OAuth] Using", isTauriEnv ? "Tauri" : "web", "flow"); | ||
|
|
||
| if (isTauriEnv) { | ||
| // For Tauri (desktop or mobile), redirect to the web app's desktop-auth route | ||
| let desktopAuthUrl = "https://trymaple.ai/desktop-auth?provider=github"; | ||
|
|
||
| // If there's a selected plan, add it to the URL | ||
| if (selected_plan) { | ||
| desktopAuthUrl += `&selected_plan=${encodeURIComponent(selected_plan)}`; | ||
| } | ||
|
|
||
| // If there's a redemption code, add it to the URL | ||
| if (code) { | ||
| desktopAuthUrl += `&code=${encodeURIComponent(code)}`; | ||
| } | ||
|
|
||
| // Use the opener plugin by directly invoking the command | ||
| // This works for both desktop and mobile (iOS/Android) | ||
| console.log("[OAuth] Opening URL in external browser:", desktopAuthUrl); | ||
| invoke("plugin:opener|open_url", { url: desktopAuthUrl }).catch((error: Error) => { | ||
| console.error("[OAuth] Failed to open external browser:", error); | ||
| setError("Failed to open authentication page in browser"); | ||
| }); | ||
| setError(`[DEBUG] Attempting to open: ${desktopAuthUrl}`); | ||
|
|
||
| try { | ||
| const result = await invoke("plugin:opener|open_url", { url: desktopAuthUrl }); | ||
| console.log("[OAuth] invoke result:", result); | ||
| setError(`[DEBUG] invoke succeeded, result: ${JSON.stringify(result)}`); | ||
| } catch (invokeError) { | ||
| const errMsg = | ||
| invokeError instanceof Error ? invokeError.message : JSON.stringify(invokeError); | ||
| console.error("[OAuth] invoke failed:", invokeError); | ||
| setError(`[ERROR] invoke failed: ${errMsg}`); | ||
|
|
||
| // Try fallback with plugin import | ||
| try { | ||
| setError(`[DEBUG] Trying fallback with plugin import...`); | ||
| const { openUrl } = await import("@tauri-apps/plugin-opener"); | ||
| await openUrl(desktopAuthUrl); | ||
| setError(`[DEBUG] Fallback openUrl succeeded`); | ||
| } catch (fallbackError) { | ||
| const fbErrMsg = | ||
| fallbackError instanceof Error | ||
| ? fallbackError.message | ||
| : JSON.stringify(fallbackError); | ||
| console.error("[OAuth] Fallback also failed:", fallbackError); | ||
| setError(`[ERROR] Both methods failed. invoke: ${errMsg} | fallback: ${fbErrMsg}`); | ||
| } | ||
| } | ||
|
Comment on lines
+128
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sequential setError calls will not work as intended. The code attempts to trace execution by calling If you need step-by-step debugging visibility, consider:
Example with accumulated debug messages (if feature-flagged): const debugMessages: string[] = [];
try {
debugMessages.push(`Attempting to open: ${desktopAuthUrl}`);
const result = await invoke("plugin:opener|open_url", { url: desktopAuthUrl });
debugMessages.push(`invoke succeeded: ${JSON.stringify(result)}`);
if (DEBUG_OAUTH) setError(debugMessages.join('\n'));
} catch (invokeError) {
// ...
}However, console logging remains the cleaner approach for debugging. 🤖 Prompt for AI Agents🛠️ Refactor suggestion | 🟠 Major Extract the two-step opener pattern to eliminate code duplication. The same two-step opener logic (invoke → fallback with dynamic import) is duplicated across all three OAuth handlers (GitHub, Google, Apple non-iOS). This violates the DRY principle and creates a maintenance burden. Extract the shared logic into a reusable helper function: async function openTauriUrl(url: string): Promise<void> {
console.log("[OAuth] Opening URL in external browser:", url);
try {
const result = await invoke("plugin:opener|open_url", { url });
console.log("[OAuth] invoke result:", result);
} catch (invokeError) {
console.error("[OAuth] invoke failed, trying fallback:", invokeError);
// Fallback: dynamically import and use plugin-opener
const { openUrl } = await import("@tauri-apps/plugin-opener");
await openUrl(url);
console.log("[OAuth] Fallback openUrl succeeded");
}
}Then simplify each handler: if (isTauriEnv) {
let desktopAuthUrl = `https://trymaple.ai/desktop-auth?provider=github`;
if (selected_plan) {
desktopAuthUrl += `&selected_plan=${encodeURIComponent(selected_plan)}`;
}
if (code) {
desktopAuthUrl += `&code=${encodeURIComponent(code)}`;
}
await openTauriUrl(desktopAuthUrl);
}This reduces ~75 lines of duplicated code to a single reusable function. Also applies to: 192-217, 378-403 🤖 Prompt for AI Agents |
||
| } else { | ||
| // Web flow remains unchanged | ||
| const { auth_url } = await os.initiateGitHubAuth(""); | ||
| if (selected_plan) { | ||
| sessionStorage.setItem("selected_plan", selected_plan); | ||
|
|
@@ -142,38 +163,59 @@ function LoginPage() { | |
| window.location.href = auth_url; | ||
| } | ||
| } catch (error) { | ||
| const errMsg = error instanceof Error ? error.message : JSON.stringify(error); | ||
| console.error("Failed to initiate GitHub login:", error); | ||
| setError("Failed to initiate GitHub login. Please try again."); | ||
| setError(`[ERROR] Outer catch: ${errMsg}`); | ||
| } | ||
|
Comment on lines
+166
to
169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove [ERROR] prefix from user-facing error messages. While extracting the error message properly (using Apply this diff: } catch (error) {
const errMsg = error instanceof Error ? error.message : JSON.stringify(error);
console.error("Failed to initiate GitHub login:", error);
- setError(`[ERROR] Outer catch: ${errMsg}`);
+ setError(errMsg || "Failed to initiate GitHub login. Please try again.");
}Also applies to: 229-232 🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| const handleGoogleLogin = async () => { | ||
| setError(null); | ||
| const platform = isIOSPlatform ? "iOS" : "Android/Desktop"; | ||
| setError(`[DEBUG] Google click detected. Tauri=${isTauriEnv}, Platform=${platform}`); | ||
|
Comment on lines
+173
to
+175
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Same debug pattern in Prompt To Fix With AIThis is a comment left during a code review.
Path: frontend/src/routes/login.tsx
Line: 173:175
Comment:
**logic:** Same debug pattern in `handleGoogleLogin` - displays debug info to users.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| try { | ||
| console.log("[OAuth] Using", isTauriEnv ? "Tauri" : "web", "flow"); | ||
|
|
||
| if (isTauriEnv) { | ||
| // For Tauri (desktop or mobile), redirect to the web app's desktop-auth route | ||
| let desktopAuthUrl = "https://trymaple.ai/desktop-auth?provider=google"; | ||
|
|
||
| // If there's a selected plan, add it to the URL | ||
| if (selected_plan) { | ||
| desktopAuthUrl += `&selected_plan=${encodeURIComponent(selected_plan)}`; | ||
| } | ||
|
|
||
| // If there's a redemption code, add it to the URL | ||
| if (code) { | ||
| desktopAuthUrl += `&code=${encodeURIComponent(code)}`; | ||
| } | ||
|
|
||
| // Use the opener plugin by directly invoking the command | ||
| // This works for both desktop and mobile (iOS/Android) | ||
| console.log("[OAuth] Opening URL in external browser:", desktopAuthUrl); | ||
| invoke("plugin:opener|open_url", { url: desktopAuthUrl }).catch((error: Error) => { | ||
| console.error("[OAuth] Failed to open external browser:", error); | ||
| setError("Failed to open authentication page in browser"); | ||
| }); | ||
| setError(`[DEBUG] Attempting to open: ${desktopAuthUrl}`); | ||
|
|
||
| try { | ||
| const result = await invoke("plugin:opener|open_url", { url: desktopAuthUrl }); | ||
| console.log("[OAuth] invoke result:", result); | ||
| setError(`[DEBUG] invoke succeeded, result: ${JSON.stringify(result)}`); | ||
| } catch (invokeError) { | ||
| const errMsg = | ||
| invokeError instanceof Error ? invokeError.message : JSON.stringify(invokeError); | ||
| console.error("[OAuth] invoke failed:", invokeError); | ||
| setError(`[ERROR] invoke failed: ${errMsg}`); | ||
|
|
||
| try { | ||
| setError(`[DEBUG] Trying fallback with plugin import...`); | ||
| const { openUrl } = await import("@tauri-apps/plugin-opener"); | ||
| await openUrl(desktopAuthUrl); | ||
| setError(`[DEBUG] Fallback openUrl succeeded`); | ||
| } catch (fallbackError) { | ||
| const fbErrMsg = | ||
| fallbackError instanceof Error | ||
| ? fallbackError.message | ||
| : JSON.stringify(fallbackError); | ||
| console.error("[OAuth] Fallback also failed:", fallbackError); | ||
| setError(`[ERROR] Both methods failed. invoke: ${errMsg} | fallback: ${fbErrMsg}`); | ||
| } | ||
| } | ||
| } else { | ||
| // Web flow remains unchanged | ||
| const { auth_url } = await os.initiateGoogleAuth(""); | ||
| if (selected_plan) { | ||
| sessionStorage.setItem("selected_plan", selected_plan); | ||
|
|
@@ -184,8 +226,9 @@ function LoginPage() { | |
| window.location.href = auth_url; | ||
| } | ||
| } catch (error) { | ||
| const errMsg = error instanceof Error ? error.message : JSON.stringify(error); | ||
| console.error("Failed to initiate Google login:", error); | ||
| setError("Failed to initiate Google login. Please try again."); | ||
| setError(`[ERROR] Outer catch: ${errMsg}`); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -317,25 +360,47 @@ function LoginPage() { | |
| setError(errorMessage); | ||
| } | ||
| } else if (isTauriEnv) { | ||
| // For Tauri desktop and Android, redirect to the web app's desktop-auth route | ||
| setError( | ||
| `[DEBUG] Apple click (non-iOS Tauri). Platform=${isIOSPlatform ? "iOS" : "Android/Desktop"}` | ||
| ); | ||
|
Comment on lines
+363
to
+365
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Same debug pattern in Prompt To Fix With AIThis is a comment left during a code review.
Path: frontend/src/routes/login.tsx
Line: 363:365
Comment:
**logic:** Same debug pattern in `handleAppleLogin` - displays debug info to users.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| let desktopAuthUrl = "https://trymaple.ai/desktop-auth?provider=apple"; | ||
|
|
||
| // If there's a selected plan, add it to the URL | ||
| if (selected_plan) { | ||
| desktopAuthUrl += `&selected_plan=${encodeURIComponent(selected_plan)}`; | ||
| } | ||
|
|
||
| // If there's a redemption code, add it to the URL | ||
| if (code) { | ||
| desktopAuthUrl += `&code=${encodeURIComponent(code)}`; | ||
| } | ||
|
|
||
| // Use the opener plugin by directly invoking the command | ||
| console.log("[OAuth] Opening URL in external browser:", desktopAuthUrl); | ||
| invoke("plugin:opener|open_url", { url: desktopAuthUrl }).catch((error: Error) => { | ||
| console.error("[OAuth] Failed to open external browser:", error); | ||
| setError("Failed to open authentication page in browser"); | ||
| }); | ||
| setError(`[DEBUG] Attempting to open: ${desktopAuthUrl}`); | ||
|
|
||
| try { | ||
| const result = await invoke("plugin:opener|open_url", { url: desktopAuthUrl }); | ||
| console.log("[OAuth] invoke result:", result); | ||
| setError(`[DEBUG] invoke succeeded, result: ${JSON.stringify(result)}`); | ||
| } catch (invokeError) { | ||
| const errMsg = | ||
| invokeError instanceof Error ? invokeError.message : JSON.stringify(invokeError); | ||
| console.error("[OAuth] invoke failed:", invokeError); | ||
| setError(`[ERROR] invoke failed: ${errMsg}`); | ||
|
|
||
| try { | ||
| setError(`[DEBUG] Trying fallback with plugin import...`); | ||
| const { openUrl } = await import("@tauri-apps/plugin-opener"); | ||
| await openUrl(desktopAuthUrl); | ||
| setError(`[DEBUG] Fallback openUrl succeeded`); | ||
| } catch (fallbackError) { | ||
| const fbErrMsg = | ||
| fallbackError instanceof Error | ||
| ? fallbackError.message | ||
| : JSON.stringify(fallbackError); | ||
| console.error("[OAuth] Fallback also failed:", fallbackError); | ||
| setError(`[ERROR] Both methods failed. invoke: ${errMsg} | fallback: ${fbErrMsg}`); | ||
| } | ||
| } | ||
| } else { | ||
| // Web flow - use AppleAuthProvider component which will initiate the flow | ||
| console.log("[OAuth] Using web flow for Apple Sign In (Web only)"); | ||
|
|
||
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.
logic: Debug code displaying
[DEBUG]messages to users viasetError(). The commit message says "Login Debug - delete after" - this should be removed before merging to production.Prompt To Fix With AI