Skip to content

[Fixes] Packaged desktop: connector redirect + linux launcher icon#1429

Merged
MODSetter merged 7 commits into
MODSetter:devfrom
CREDO23:fix-desktop-redirects
May 23, 2026
Merged

[Fixes] Packaged desktop: connector redirect + linux launcher icon#1429
MODSetter merged 7 commits into
MODSetter:devfrom
CREDO23:fix-desktop-redirects

Conversation

@CREDO23
Copy link
Copy Markdown
Contributor

@CREDO23 CREDO23 commented May 22, 2026

Description

  • Fix auth redirect problem on connectors connection flow
  • Fix the linux icon launcher

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR fixes two critical bugs in the packaged desktop application: corrects OAuth connector redirect issues that were stranding users off-app during authentication flows, and resolves Linux launcher icon display problems by providing proper multi-resolution icon assets and configuration. The core fix is OAuth callbacks, adds URL rewrite filters for hosted frontend domains, implements cold-start deep-link handling for Windows/Linux, and introduces runtime environment variable overrides for self-hosted deployments. Additionally, it includes diagnostic event tracking for OAuth redirects and updates agent documentation to clarify desktop-specific behavior.

⏱️ Estimated Review Time: 30-90 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_desktop/.env.example
2 surfsense_desktop/src/modules/server.ts
3 surfsense_desktop/src/modules/window.ts
4 surfsense_desktop/src/modules/deep-links.ts
5 surfsense_desktop/electron-builder.yml
6 surfsense_desktop/assets/icons/16x16.png
7 surfsense_desktop/assets/icons/32x32.png
8 surfsense_desktop/assets/icons/48x48.png
9 surfsense_desktop/assets/icons/64x64.png
10 surfsense_desktop/assets/icons/128x128.png
11 surfsense_desktop/assets/icons/256x256.png
12 surfsense_desktop/assets/icons/512x512.png
13 surfsense_desktop/assets/icons/1024x1024.png
14 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_desktop.md
⚠️ Inconsistent Changes Detected
File Path Warning
surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_desktop.md This backend agent documentation change appears unrelated to the main PR purpose of fixing desktop OAuth redirects and Linux icons. It's a clarification about chunk_ids behavior in desktop mode, which is not mentioned as part of the bug fixes.

Need help? Join our Discord

CREDO23 added 7 commits May 22, 2026 17:24
The citations fix (cacb27e) added a "Chunk citations in your prose"
section to system_prompt_desktop.md telling the KB subagent to always
leave `evidence.chunk_ids` null and emit no `[citation:...]` markers in
desktop mode, but left the pre-existing line declaring that
`chunk_ids` apply to `<priority_documents>` hits. The two rules
contradicted each other; the model picked one per turn.

Strike the stale conditional clause and point at the dedicated section
as the single source of truth. Matches the parallel line in
system_prompt_cloud.md and the already-consistent
system_prompt_readonly_desktop.md.
setupDeepLinks() only listened for second-instance and open-url events.
On Windows/Linux a fresh launch via `surfsense://` delivers the URL in
argv of the first instance, where it was silently dropped. Scan argv on
setup so the existing handlePendingDeepLink() pass picks it up.
Linux registered the scheme via desktop-file MIME, but mac.extendInfo
never declared CFBundleURLTypes, leaving install-time LaunchServices
unaware of the protocol. The runtime app.setAsDefaultProtocolClient
call still runs as a fallback.
…d self-hosters

The interceptor previously matched a strict `${HOSTED_FRONTEND_URL}/*`
prefix and did a naive String.replace, which broke whenever the backend
NEXT_FRONTEND_URL differed at all (apex vs www, http vs https, or a
self-hosted domain). Now:

- Match by host: apex + www. sibling, both http and https.
- Rewrite via URL parsing so only protocol/host change; query strings
  containing the host as a value are left intact.
- Read HOSTED_FRONTEND_URL through getHostedFrontendUrl() which honors
  a SURFSENSE_HOSTED_FRONTEND_URL_OVERRIDE env var, letting self-hosters
  point their builds at their own frontend without rebuilding.

Default behavior is identical when override is unset and backend host
matches the baked-in value.
Adds two diagnostic events to surface OAuth-redirect failures we can't
reproduce on Linux:

- desktop_oauth_redirect_intercepted fires from inside onBeforeRequest
  with the original host, path, and target port — confirms the rewrite
  actually ran.
- desktop_oauth_redirect_missed fires from a read-only onCompleted
  listener when a /dashboard/*/connectors/callback URL lands off-localhost,
  meaning the rewrite filter didn't catch it. This is the smoking-gun
  event for "connector OAuth dies on mac/win" reports.

Read-only; no behavior change.
… stable

Setting HOSTNAME=0.0.0.0 made Next.js standalone canonicalize request.url to
http://0.0.0.0:PORT. The connector OAuth callback's NextResponse.redirect built
its Location from that URL, so navigating it flipped window.location.origin from
http://localhost:PORT to http://0.0.0.0:PORT. The backend CORS allowlist matches
localhost/127.0.0.1 only, blocking every subsequent API call until app restart —
producing the "no internet" / app-down state after connecting any connector.
electron-builder was given a single 2048x2048 icon.png and dumped it into
hicolor/2048x2048/apps/, a bucket no Linux desktop environment indexes —
launchers and taskbar fell back to a generic placeholder. Pre-render the
standard sizes (16, 32, 48, 64, 128, 256, 512, 1024) and point linux.icon
at the directory so each PNG lands in the matching hicolor/NxN/apps/ slot.

Tray icon was unaffected (loaded at runtime via Electron's Tray API from
bundled resources, no theme lookup).
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca5ed375-21c2-4262-84bd-6386afa899c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@MODSetter MODSetter merged commit 69388fc into MODSetter:dev May 23, 2026
8 of 12 checks passed
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.

2 participants