Skip to content

Desktop: using Maple chat disrupts the local API proxy (proxy stops and saved API key is scrubbed) #780

Description

@AnthonyRonning

User report (not yet reproduced)

A user reports that when they run the local OpenAI-compatible proxy built into the Maple desktop app and then use Maple chat in the same desktop app, the chat disrupts the API proxy. This has not been reproduced yet; this issue captures a code-level investigation so the repro work is better informed.

Investigated at commit 3f605ab7 (master, 2026-08-11).

What the code shows

Per AGENTS.md, research chat and Agent Mode do not route through the local proxy, so there is no intentional network-level interaction. The plausible coupling is instead the shared auth lifecycle, which can tear down the proxy as a side effect of chat-adjacent flows:

  1. frontend/src/routes/__root.tsx (~L44, L52-56): the root route computes userId = auth.user?.user.id || null and calls transitionAgentAuthUser(userId) on every change.
  2. frontend/src/services/agentRuntimeService.ts (~L455-478): the AgentAuthLifecycleCoordinator cleanup callback runs on any transition away from the current user and calls proxyService.stopAndResetProxy().
  3. frontend/src/services/proxyService.ts (~L196-236) -> Rust stop_and_reset_proxy in frontend/src-tauri/src/proxy.rs: this aborts the proxy server task AND clears api_key, sets enabled = false and auto_start = false, then persists that to proxy_config.json. So the proxy is not just stopped - it is de-configured, and the user must create/enter a new API key to recover.

Chat-adjacent flows that trigger that cleanup path:

  • Guest on free plan tries to chat -> GuestPaymentWarningDialog ("Subscription Required", shown from frontend/src/routes/index.tsx ~L117-127) -> its Log Out path calls proxyService.stopAndResetProxy(userId, os.deleteApiKey) (GuestPaymentWarningDialog.tsx ~L57-58), which also remotely revokes tracked keys.
  • Unverified (non-guest) account -> VerificationModal blocks the home/settings routes (__root.tsx ~L101) -> its Log Out path also calls stopAndResetProxy (VerificationModal.tsx ~L137-138).
  • Guest -> full account conversion or account switch changes user.id, so the root effect runs the previous account's cleanup and scrubs the proxy.
  • Any transient auth.user === undefined (e.g. a failed refetchUser, session loss during/after a chat) flips userId to null, which also runs the full cleanup and scrubs the proxy.

So a plausible reading of the report: the user starts the proxy (manually created API key, saved in proxy_config.json), then uses chat, hits one of the flows above (payment wall, verification, account transition, or session hiccup), and the proxy is stopped with its saved credential wiped - looking like "the chat broke the proxy".

Related history (this area has been touched repeatedly)

The scrub-on-logout behavior is intentional; the suspicion here is that chat flows trigger it unexpectedly, or that scrubbing the manually configured credential is too destructive when the proxy was set up by hand.

Info that would help a repro

  1. Account type: guest/anonymous or full account? Email verified?
  2. Did a "Subscription Required" or "Verify Your Email" dialog appear around the time chat was used?
  3. After the disruption: is the proxy process stopped (connection refused on 127.0.0.1:8080), and is api_key empty / enabled: false in proxy_config.json (app config dir, or legacy ~/.config/maple/proxy_config.json)?
  4. OS, app version, and app logs from a session where it happened.
  5. Was the proxy started manually from Settings, or auto-started / Agent-managed?

Possible directions (not a proposed fix)

  • Decouple proxy teardown from generic auth-user transitions: only scrub credentials on explicit sign-out / account deletion, and consider stopping the listener without wiping a manually configured api_key.
  • Distinguish Agent-owned proxy keys from manually created ones when deciding what to scrub/revoke (partially exists via the tracked-key registry in proxyService.ts).
  • Regression test: start the local proxy, send a chat message (incl. guest/free-plan and unverified-account variants), assert the proxy is still running and its config is intact.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions