Skip to content

Clear proxy config on logout to prevent auto-start without auth#455

Merged
AnthonyRonning merged 1 commit intomasterfrom
devin/1772686431-clear-proxy-config-on-logout
Mar 5, 2026
Merged

Clear proxy config on logout to prevent auto-start without auth#455
AnthonyRonning merged 1 commit intomasterfrom
devin/1772686431-clear-proxy-config-on-logout

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 5, 2026

Summary

When a user enables proxy auto-start, logs out, and reopens the app, the proxy would auto-start unnecessarily since the saved config (~/.config/maple/proxy_config.json) persisted across sessions. This PR resets the proxy config to defaults on every sign-out path, stopping the proxy if running and clearing the auto_start flag and API key.

Changes:

  • Added stopAndResetProxy() to ProxyService — stops the running proxy (if any) and saves a default config to disk
  • Called stopAndResetProxy() before os.signOut() in all 4 sign-out paths: AccountMenu, DeleteAccountDialog, GuestPaymentWarningDialog, VerificationModal
  • All calls are wrapped in try/catch so sign-out still succeeds even if proxy cleanup fails

Review & Testing Checklist for Human

  • Desktop end-to-end test: Log in → start proxy with auto-start enabled → log out → reopen app → verify proxy does not auto-start and config file is reset
  • Web platform: Verify that sign-out on the web app still works without errors or noticeable delay (the dynamic import of proxyService will invoke Tauri commands that throw on web — both are caught, but check that console noise is acceptable)
  • Consider centralizing: The proxy cleanup block is duplicated across 4 files. If new sign-out paths are added in the future, this could be missed. A shared signOutWithCleanup() utility could reduce this risk — flag if this is preferred before merging.

Notes


Open with Devin

Summary by CodeRabbit

  • Bug Fixes
    • Improved sign-out and account deletion flows to include proper cleanup steps, ensuring configuration is properly reset when users sign out or delete their accounts.

- Add stopAndResetProxy() method to proxyService that stops the running
  proxy and resets saved config to defaults (clearing auto_start and API key)
- Call stopAndResetProxy() in all sign-out paths: AccountMenu,
  DeleteAccountDialog, GuestPaymentWarningDialog, VerificationModal
- This prevents the proxy from auto-starting on next app launch when
  no user is logged in

Co-Authored-By: tony@opensecret.cloud <TonyGiorgio@protonmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: d66c181
Status: ✅  Deploy successful!
Preview URL: https://05eb8bfc.maple-ca8.pages.dev
Branch Preview URL: https://devin-1772686431-clear-proxy.maple-ca8.pages.dev

View logs

Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@AnthonyRonning
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

This pull request adds proxy service cleanup across multiple sign-out and account deletion flows. A new stopAndResetProxy() method is added to the ProxyService class, which is then dynamically imported and called in AccountMenu, DeleteAccountDialog, GuestPaymentWarningDialog, and VerificationModal before proceeding with sign-out or deletion operations.

Changes

Cohort / File(s) Summary
Proxy cleanup in sign-out flows
frontend/src/components/AccountMenu.tsx, frontend/src/components/DeleteAccountDialog.tsx, frontend/src/components/GuestPaymentWarningDialog.tsx, frontend/src/components/VerificationModal.tsx
Each component now dynamically imports proxyService and calls stopAndResetProxy with error handling before executing their existing sign-out or deletion logic. Pattern is consistent across all four components.
ProxyService enhancement
frontend/src/services/proxyService.ts
Adds new public method stopAndResetProxy(): Promise<void> that stops a running proxy and resets its configuration to defaults (disables auto_start and api_key). Uses separate error handling for stop and reset operations.

Sequence Diagram

sequenceDiagram
    participant Component as UI Component
    participant PS as ProxyService
    participant OS as OpenSecret
    
    Component->>Component: User initiates sign-out/delete
    Component->>PS: Dynamically import & call stopAndResetProxy()
    PS->>PS: Check proxy status & stop if running
    PS->>PS: Reset to default configuration
    PS-->>Component: Return (with or without error logged)
    Component->>OS: Call signOut()
    OS-->>Component: Sign-out complete
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A proxy to stop, a config to reset,
Before signing out, we clean up the nest!
Four components aligned in harmonious way,
Clean slate upon logout—hip hip hooray! 🎉

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the changeset: clearing proxy configuration on logout to prevent unwanted auto-start without authentication.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1772686431-clear-proxy-config-on-logout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/components/AccountMenu.tsx (1)

267-273: Extract this repeated proxy-cleanup block into a shared sign-out helper.

The same cleanup snippet is now duplicated across four sign-out/deletion flows. Centralizing it will reduce drift and keep behavior consistent.

Refactor direction
-      try {
-        const { proxyService } = await import("@/services/proxyService");
-        await proxyService.stopAndResetProxy();
-      } catch (error) {
-        console.error("Error clearing proxy config:", error);
-      }
+      await signOutWithProxyCleanup();
// e.g. frontend/src/services/signOutCleanup.ts
export async function signOutWithProxyCleanup(): Promise<void> {
  try {
    const { proxyService } = await import("@/services/proxyService");
    await proxyService.stopAndResetProxy();
  } catch (error) {
    console.error("Error clearing proxy config:", error);
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/AccountMenu.tsx` around lines 267 - 273, Extract the
repeated proxy-cleanup block into a single helper (e.g. export async function
signOutWithProxyCleanup() in a new frontend/src/services/signOutCleanup.ts) that
performs the dynamic import of { proxyService } and calls
proxyService.stopAndResetProxy() inside the try/catch used today; then replace
the duplicated try/catch in AccountMenu.tsx and the other three
sign-out/deletion flows with a call to signOutWithProxyCleanup(), keeping
existing error handling behavior centralized via that helper and referencing
proxyService.stopAndResetProxy to locate the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/services/proxyService.ts`:
- Around line 97-99: The cleanup code in stopAndResetProxy is silently
swallowing errors from stopProxy(), so failures are hidden; change the try/catch
blocks around stopProxy() (and the other similar block) to let errors propagate
to callers instead of ignoring them—either remove the empty catch or rethrow the
caught error (optionally log it via the existing logger before rethrowing) so
callers can observe cleanup failures while sign-out continues; target the
stopAndResetProxy function and the explicit stopProxy() invocation(s) to
implement this change.

---

Nitpick comments:
In `@frontend/src/components/AccountMenu.tsx`:
- Around line 267-273: Extract the repeated proxy-cleanup block into a single
helper (e.g. export async function signOutWithProxyCleanup() in a new
frontend/src/services/signOutCleanup.ts) that performs the dynamic import of {
proxyService } and calls proxyService.stopAndResetProxy() inside the try/catch
used today; then replace the duplicated try/catch in AccountMenu.tsx and the
other three sign-out/deletion flows with a call to signOutWithProxyCleanup(),
keeping existing error handling behavior centralized via that helper and
referencing proxyService.stopAndResetProxy to locate the logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c8951fa-f18b-4bc5-9f0a-6e2d5fa1930a

📥 Commits

Reviewing files that changed from the base of the PR and between ea3e330 and d66c181.

📒 Files selected for processing (5)
  • frontend/src/components/AccountMenu.tsx
  • frontend/src/components/DeleteAccountDialog.tsx
  • frontend/src/components/GuestPaymentWarningDialog.tsx
  • frontend/src/components/VerificationModal.tsx
  • frontend/src/services/proxyService.ts

Comment on lines +97 to +99
} catch {
// Proxy may not be running, that's fine
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Do not silently swallow cleanup failures in stopAndResetProxy.

At Line 97, all status/stop errors are ignored. If stopProxy() fails while running, logout can complete with the proxy still active.
Surface cleanup failures to callers (they already catch) so failures are observable while sign-out still proceeds.

Proposed fix
   async stopAndResetProxy(): Promise<void> {
+    let cleanupError: unknown = null;
     try {
       // Check if proxy is running and stop it
       const status = await this.getProxyStatus();
       if (status.running) {
         await this.stopProxy();
       }
-    } catch {
-      // Proxy may not be running, that's fine
+    } catch (error) {
+      cleanupError ??= error;
+      console.error("Failed to stop proxy during sign-out cleanup:", error);
     }
 
     try {
       // Save default config to clear auto_start and API key
       await this.saveProxySettings({
@@
         auto_start: false
       });
     } catch (error) {
+      cleanupError ??= error;
       console.error("Failed to reset proxy config:", error);
     }
+
+    if (cleanupError) {
+      throw cleanupError;
+    }
   }

Also applies to: 111-113

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/services/proxyService.ts` around lines 97 - 99, The cleanup code
in stopAndResetProxy is silently swallowing errors from stopProxy(), so failures
are hidden; change the try/catch blocks around stopProxy() (and the other
similar block) to let errors propagate to callers instead of ignoring
them—either remove the empty catch or rethrow the caught error (optionally log
it via the existing logger before rethrowing) so callers can observe cleanup
failures while sign-out continues; target the stopAndResetProxy function and the
explicit stopProxy() invocation(s) to implement this change.

@AnthonyRonning AnthonyRonning merged commit 200b09d into master Mar 5, 2026
14 checks passed
@AnthonyRonning AnthonyRonning deleted the devin/1772686431-clear-proxy-config-on-logout branch March 5, 2026 05:56
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.

1 participant