-
Notifications
You must be signed in to change notification settings - Fork 5
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?
Conversation
…ange The Gradle cache was causing production builds to use old capabilities even after changes were committed. This happened because: 1. Gradle cache included the built APK (gen/android/app/build) 2. Cache key only checked gradle files, not tauri config/capabilities 3. When capabilities changed, CI restored old cached build 4. Result: Production APKs had old permissions, missing OAuth URLs Fix: - Add tauri.conf.json to Gradle cache key - Add capabilities/** directory to cache key - Now cache invalidates when these files change - Ensures CI always builds with current configuration This fixes Android OAuth not working in production releases despite working in local builds. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughExpand CI Gradle cache hashing and add a Gradle cache-clean step; add Tauri opener-first OAuth flow with a dynamic-import fallback, extensive runtime debug logging, and richer error propagation; pin/downstream changes to the Tauri opener dependency in frontend manifests. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant TauriPlugin as Tauri plugin
participant DynImport as Dynamic importer
participant OAuth as OAuth Provider
User->>Frontend: Click "Sign in"
Frontend->>Frontend: setDebugState / log(click)
alt Tauri environment
Frontend->>TauriPlugin: opener.open(authURL)
alt plugin succeeds
TauriPlugin->>OAuth: Open auth URL (native)
OAuth-->>User: Show auth UI
else plugin missing/fails
Frontend->>DynImport: import `@tauri-apps/plugin-opener`
DynImport-->>Frontend: opener API
Frontend->>DynImport: openUrl(authURL)
DynImport->>OAuth: Open auth URL (native)
OAuth-->>User: Show auth UI
end
else Web environment
Frontend->>OAuth: window/tab open(authURL)
OAuth-->>User: Show auth UI
end
alt any error
Frontend->>Frontend: setError(detail) / log
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2025-03-25T19:50:07.925ZApplied to files:
📚 Learning: 2025-03-25T19:50:07.925ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (2)
Comment |
Deploying maple with
|
| Latest commit: |
b337026
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0402b44c.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-ci-gradle-cache-invalida.maple-ca8.pages.dev |
Greptile OverviewGreptile SummaryThis PR fixes Android OAuth issues caused by stale Gradle cache and a broken opener plugin version. The CI cache key now includes
Confidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant LoginPage
participant TauriOpener
participant ExternalBrowser
participant OAuthProvider
User->>LoginPage: Click OAuth login (GitHub/Google/Apple)
LoginPage->>LoginPage: setError("[DEBUG] click detected...")
LoginPage->>TauriOpener: invoke("plugin:opener|open_url")
alt invoke succeeds
TauriOpener->>ExternalBrowser: Open auth URL
ExternalBrowser->>OAuthProvider: Navigate to provider
LoginPage->>LoginPage: setError("[DEBUG] invoke succeeded...")
else invoke fails
LoginPage->>LoginPage: setError("[DEBUG] Trying fallback...")
LoginPage->>TauriOpener: import openUrl from plugin
TauriOpener->>ExternalBrowser: Open auth URL (fallback)
end
|
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.
2 files reviewed, no comments
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.
3 files reviewed, 3 comments
| setError(null); | ||
| const platform = isIOSPlatform ? "iOS" : "Android/Desktop"; | ||
| setError(`[DEBUG] GitHub click detected. Tauri=${isTauriEnv}, Platform=${platform}`); |
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 via setError(). The commit message says "Login Debug - delete after" - this should be removed before merging to production.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/routes/login.tsx
Line: 109:111
Comment:
**logic:** Debug code displaying `[DEBUG]` messages to users via `setError()`. The commit message says "Login Debug - delete after" - this should be removed before merging to production.
How can I resolve this? If you propose a fix, please make it concise.| setError(null); | ||
| const platform = isIOSPlatform ? "iOS" : "Android/Desktop"; | ||
| setError(`[DEBUG] Google click detected. Tauri=${isTauriEnv}, Platform=${platform}`); |
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: Same debug pattern in handleGoogleLogin - displays debug info to users.
Prompt To Fix With AI
This 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.| setError( | ||
| `[DEBUG] Apple click (non-iOS Tauri). Platform=${isIOSPlatform ? "iOS" : "Android/Desktop"}` | ||
| ); |
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: Same debug pattern in handleAppleLogin - displays debug info to users.
Prompt To Fix With AI
This 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.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.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/routes/login.tsx(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use 2-space indentation, double quotes, and a 100-character line limit for formatting
Use camelCase for variable and function names
Use try/catch with specific error types for error handling
Files:
frontend/src/routes/login.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use strict TypeScript typing and avoid
anywhen possible
Files:
frontend/src/routes/login.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: AnthonyRonning
Repo: OpenSecretCloud/Maple PR: 23
File: frontend/src-tauri/src/lib.rs:14-16
Timestamp: 2025-03-25T19:50:07.925Z
Learning: In Tauri applications, updater security configurations (including endpoints, public key for verification, and dialog settings) should be defined in the tauri.conf.json file rather than duplicated in the code. When initialized with tauri_plugin_updater::Builder::new().build(), the plugin automatically reads and uses these settings from the configuration file.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build-android
- GitHub Check: build-macos (universal-apple-darwin)
- GitHub Check: build-linux
- GitHub Check: build-ios
| setError(null); | ||
| const platform = isIOSPlatform ? "iOS" : "Android/Desktop"; | ||
| setError(`[DEBUG] GitHub click detected. Tauri=${isTauriEnv}, Platform=${platform}`); |
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.
Remove debug code from production or gate behind a feature flag.
The code uses setError to display debug messages directly to users via the AlertDestructive component. This is inappropriate for production:
- Users will see technical debug messages like
[DEBUG] GitHub click detected. Tauri=true, Platform=iOS - This violates the purpose of error messaging which should communicate actionable user-facing information
Additionally, multiple sequential setError calls throughout these handlers will overwrite each other due to React's state batching, making the debug traces unreliable.
Apply this pattern to remove debug setError calls and rely solely on console logging:
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
In frontend/src/routes/login.tsx around lines 109-111 (and similarly at 173-175
and 363-365), remove the debug setError calls that write debug strings into
user-facing error state; instead log debug information to console
(console.debug/console.log) or gate the debug setError behind a runtime feature
flag (e.g., DEBUG_OAUTH derived from DEV env or sessionStorage) so that non-dev
users never see technical messages; ensure you consolidate multiple sequential
debug setError calls into a single gated log and keep user-facing setError
messages reserved for actionable errors only.
| 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}`); | ||
| } | ||
| } |
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.
Sequential setError calls will not work as intended.
The code attempts to trace execution by calling setError multiple times sequentially (lines 128, 133, 138, 142, 145, 152). Due to React's state batching, only the final setError call in each synchronous execution block will take effect. The intermediate debug traces will be lost.
If you need step-by-step debugging visibility, consider:
- Accumulating messages in an array and displaying all at once
- Using console logging exclusively (recommended)
- Implementing a dedicated debug message array state separate from error state
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
frontend/src/routes/login.tsx lines 128-154: the code uses multiple sequential
setError(...) calls for debug tracing which will be batched by React so
intermediate messages are lost; replace the debug setError calls with
console.log/debug statements (or, if you must display multiple steps, collect
messages into a local array and call setError once with the joined string or use
a separate debugMessages state) and keep a single setError call for the final
error message that includes both invoke and fallback error details.
🛠️ 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
frontend/src/routes/login.tsx around lines 128-154 (also apply same change at
192-217 and 378-403): the two-step opener logic (invoke → fallback dynamic
import) is duplicated across three OAuth handlers; extract it to a single helper
async function openTauriUrl(url: string) that (1) logs the URL, (2) attempts
invoke("plugin:opener|open_url", { url }), (3) on invoke failure dynamically
imports @tauri-apps/plugin-opener and calls openUrl(url), and (4) if both
methods fail throws a new Error that includes both error messages; then replace
the duplicated blocks in each handler with await openTauriUrl(desktopAuthUrl)
wrapped in try/catch in the handler so setError/console.error behavior is
preserved, and keep the existing desktopAuthUrl query param encoding logic
unchanged.
| 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}`); | ||
| } |
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.
Remove [ERROR] prefix from user-facing error messages.
While extracting the error message properly (using instanceof Error check) is good, the [ERROR] Outer catch: prefix should be removed from production code. Users don't need to see technical debugging markers.
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
In frontend/src/routes/login.tsx around lines 166-169 and 229-232, remove the
technical “[ERROR] Outer catch:” prefix from user-facing error strings; instead
set the error state to the extracted message only (use errMsg or the same
extracted string variable) and keep console.error for debugging. Update both
locations to call setError(errMsg) (or a short user-friendly variant) rather
than prepending the “[ERROR]” tag, ensuring consistent messages shown to users
while retaining the detailed console.error logs for developers.
The org.gradle.caching=true setting (added Nov 12) was causing Gradle to cache task outputs. When config files changed, Gradle served stale builds. Changes: - Disable org.gradle.caching in gradle.properties - Add explicit cache clearing step before Android builds in CI Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Android 11+ (API 30+) requires apps to declare which intents they want to resolve using <queries> in the manifest. Without this, startActivity with implicit intents for opening URLs can silently fail. Added queries for http:// and https:// URL schemes. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.
5 files reviewed, no comments
Reverting to the version before Nov 3 update to test if the newer version is causing OAuth URLs to not open in CI builds. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.
7 files reviewed, no comments
…ange
The Gradle cache was causing production builds to use old capabilities even after changes were committed. This happened because:
Fix:
This fixes Android OAuth not working in production releases despite working in local builds.
Summary by CodeRabbit
Chores
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.