8000
Skip to content

fix(desktop): start receive server when launched hidden to tray - #3196

Open
davidboulay wants to merge 3 commits into
localsend:mainfrom
davidboulay:fix/start-server-when-hidden
Open

fix(desktop): start receive server when launched hidden to tray#3196
davidboulay wants to merge 3 commits into
localsend:mainfrom
davidboulay:fix/start-server-when-hidden

Conversation

@davidboulay
@davidboulay davidboulay commented Jul 18, 2026
Copy link
Copy Markdown

Summary

Fixes #3195.

When LocalSend is launched hidden to the tray on desktop (e.g. autostart with --hidden), the device is discoverable but cannot receive files until the main window is opened once.

Root cause: multicast discovery is started early in preInit (isolate setup), but the HTTP(S) receive server is only started from postInit(), which runs from HomePage.initState. When the app starts hidden, the home page is never built, so postInit() never fires and the server never binds — UDP discovery is up, but the TCP receive port is down.

Fix: start the receive server during preInit on desktop, decoupled from the home page. startServer() already guards against double-start, so the later postInit() call becomes a no-op when the window is eventually opened.

Verified on Linux: launched with --hidden, the TCP server binds (ss -ltnup shows LISTEN :53317), GET /api/localsend/v2/info returns 200, and a real transfer from another device completes with the window never shown.

Second commit: receive notification (desktop)

While testing the hidden path I noticed there is no feedback at all when a file is received while the window is hidden — the file just silently lands in the destination folder. The second commit adds a native desktop notification on receive completion, with an "Open folder" action that reveals the received file(s).

  • Uses local_notifier (from the same leanflutter family as the already-used window_manager / tray_manager).
  • On Linux the platform plugin does not deliver notification body clicks, so an explicit action button ("Open folder") is used. The Dart-side body-click handler (onClick) is also wired for the other desktop platforms, where the plugin does deliver it.
  • New user-facing strings are added to en.json only; other locales fall back to English until translated.

The two changes are kept as separate commits so they can be split if you'd prefer to land them independently.

Test plan

  • Launch hidden on Linux → receive server binds, /info returns 200, real file transfer completes with no window shown
  • Receive a file while hidden → desktop notification appears
  • Click the notification's "Open folder" action → destination folder opens with the file highlighted
  • flutter analyze clean on changed files
  • Windows / macOS — not tested; I only have Linux. The changes are desktop-guarded and reuse the same cross-platform plugin API, so they should apply, but a maintainer with those platforms should confirm.

davidboulay and others added 3 commits July 18, 2026 17:12
When the app autostarts hidden (e.g. --hidden), HomePage is never built,
so postInit() — which starts the HTTP receive server — never runs. Multicast
discovery still runs (in the isolate), so the device looks discoverable but
cannot actually receive files until the window is opened once.

Start the server from preInit() after isolate setup, guarded to desktop.
startServer() already guards against double-start, so the later postInit()
call is a harmless no-op.
Show a native desktop notification when a transfer completes so the user
gets visible feedback even when the window is hidden (e.g. started in the
tray). The notification exposes an "Open folder" action that reveals the
received file(s) in the file manager.

On Linux the platform notification plugin does not deliver notification
body clicks, so an explicit action button is used; macOS/Windows also wire
the body click to the same handler.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

Desktop: files cannot be received when launched hidden to tray until the window is opened once

1 participant

0