Skip to content

Simplify nearby discovery: follow the app lifecycle and remove duplicate controls - #20

Merged
CodePandaaAI merged 1 commit into
masterfrom
refactor
Sep 8, 2026
Merged

Simplify nearby discovery: follow the app lifecycle and remove duplicate controls#20
CodePandaaAI merged 1 commit into
masterfrom
refactor

Conversation

@CodePandaaAI

@CodePandaaAI CodePandaaAI commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Why this change exists

You open Sync360 because you want to send text or a file to another device. Finding that device should feel like a natural part of sharing.

Previously, discovery had a 60-second window. When that window ended, scanning stopped while device advertising could remain active.

Reload button on send screen restarted only discovery scan, while Repair button on settings screen followed another path to recreate discovery and advertising.

Those distinctions had reasons in the code, but they gave users—and the maintainer—more things to understand.

This change asks a smaller question: what behavior does nearby sharing actually need?

The thinking behind it

Earlier changes to Sync360 questioned whether every interaction needed an approval step. Text moved toward direct delivery, files adopted a receive-code flow, and navigation moved toward showing one screen at a time.

Those are earlier changes, not features newly implemented in this PR. Their lesson shaped this work: sometimes the useful improvement comes from removing a decision or process altogether.

For discovery, that meant questioning the expiring scan and overlapping recovery controls.

We also learned that a simple explanation does not automatically produce simple code. An early implementation included connectivity monitoring and automatic refreshes after network changes. That added address tracking, callbacks, timing, and coordination beyond the behavior we wanted to establish.

That machinery was removed. The current scope is deliberately focused on app visibility and explicit user control.

The new Android behavior

Discovery stays active while Sync360 is visible, without a 60-second expiry.

When the app moves into the background, a two-second grace period is scheduled after Android's process lifecycle reports backgrounding. If the user returns before the pending stop runs, it is cancelled.

This avoids repeatedly tearing down discovery when someone briefly switches apps or rapidly backgrounds and reopens Sync360.

If the user stays away, discovery and advertising stop and clean up. Returning after cleanup allows a fresh session to start.

An explicit manual Stop is respected across background/foreground transitions until Start is pressed or a fresh app process launches.

Desktop retains its existing availability while minimized. iOS visibility integration is outside this change.

Fewer controls in a clearer place

Start and Stop live inside Nearby devices.

Reload and the separate Repair action have been removed. Repair had become another way to request a discovery restart, which users can already accomplish by stopping discovery and starting it again.

Because Repair was the only Settings item, its screen and the associated Troubleshoot shortcuts were removed too.

Actual start or cleanup failures still offer Try again.

The Nearby devices section now uses compact device rows and a straightforward empty state. Device taps continue through the existing sending flow; this change does not introduce a new pairing or selection protocol.

What happens after a network change?

The app does not inspect network changes or automatically refresh discovery.

If devices disappear after changing Wi-Fi or hotspot connections, users can stop discovery, wait for it to stop, and start it again.

This is an intentional tradeoff. Automatic recovery may be revisited later, after the existing behavior is better understood and validated.

Technical changes

  • Added a small Android process-lifecycle observer with one cancellable delayed stop.
  • Removed connectivity monitoring and network-address tracking.
  • Centralized discovery intent in the shared controller.
  • Reduced the platform contract to starting and stopping discovery and advertising.
  • Removed the separate Repair command, refresh flag, and related presentation wiring.
  • Gave Android scans explicit ownership of listeners and resolved results.
  • Queued Android 13 legacy resolution.
  • Checked late results against the active session and service instance.
  • Kept failed callback cleanup retryable instead of pretending resources were released.
  • Preserved the existing ownership of HTTP and file-transfer listeners.

The app still needs careful native cleanup. Simplification does not mean deleting necessary callback, socket, or resource handling.

exec-40cf9328-bf83-404c-a08c-a66543c83ef2

People open Sync360 to share something, not to manage a discovery timer
or choose between several buttons that restart similar operations.

Replace the 60-second discovery window with discovery that follows
Android app visibility. Keep it active while the app is visible, schedule
cleanup after a short background grace period, and cancel the pending
stop when the user returns quickly.

Keep explicit Start/Stop controls beside nearby devices. Respect manual
Stop across background/foreground transitions within the same process.

Remove Reload, the separate Repair command, its Settings screen, and
Troubleshoot shortcuts. Keep Try again for actual operation failures.

Keep this implementation focused on app visibility. Remove connectivity
monitoring, network-address tracking, and automatic network-change
refreshes. Users can stop and restart discovery themselves when needed.

Centralize discovery intent in the shared controller. Give Android scans
explicit callback ownership, queue legacy Android 13 resolution, and
preserve failed cleanup for retry. Keep discovery lifetime separate from
transfer listeners and received content.

Simplify Nearby devices into compact rows with contextual controls and
a clear empty state. Desktop discovery remains active when minimized.

The aim is understandable behavior and maintainable code, rather than
reducing line count for its own sake. Upcoming work prioritizes code
review, failure handling, and validation toward a stable 1.0. Further
native discovery implementations are under consideration, without a
confirmed schedule.

Validation: static review and whitespace checks completed. New Android
and Windows builds and lifecycle scenarios still require validation
before the intended 0.5.0 preview release.
@CodePandaaAI
CodePandaaAI merged commit 9d33f97 into master Sep 8, 2026
3 of 4 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.

1 participant