Repository navigation
Conversation
Contributor
🤖 Pull request artifacts
|
capcom6
force-pushed
the
gateway/explicit-registration
branch
2 times, most recently
from
August 21, 2026 12:00
8c7f581 to
f541c0f
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
2 times, most recently
from
August 25, 2026 02:00
87c23d4 to
565a464
Compare
capcom6
added a commit
that referenced
this pull request
Aug 26, 2026
When explicit registration completes with a null FCM token, SSE starts as the fallback transport. The later FCM token update via RegistrationWorker set the token but never tore down the SSE stream, leaving both transports active and causing duplicate cloud-event delivery. Tear down SSE in updateDevice when a non-null push token is set. Fixes Greptile review blocker on PR #430.
capcom6
added a commit
that referenced
this pull request
Aug 26, 2026
…M token Symmetrize SSE management in EventsReceiver: when a DeviceRegisteredEvent is processed after the FCM token has been recorded, stop the SSE foreground service instead of leaving it running alongside FCM. Prevents duplicate cloud-event delivery reported by Greptile on PR #430.
capcom6
added a commit
that referenced
this pull request
Aug 26, 2026
Capture the application context up front and use nullable activity access for the progress bar so an in-flight explicit registration no longer throws from requireContext()/requireActivity() if the user navigates away, which would abort SSE startup and service.start() for an already-registered device. Addresses Greptile P1 'Fragment detachment aborts SSE startup' on PR #430.
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
August 26, 2026 07:05
78258ec to
60d3114
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
August 29, 2026 00:02
0c955cf to
ded47f7
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
2 times, most recently
from
August 31, 2026 07:44
f470387 to
4fd3ab9
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
September 2, 2026 01:02
f409d7b to
cde7b68
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
2 times, most recently
from
September 4, 2026 00:08
66ddd2b to
98643d2
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
September 8, 2026 01:17
98643d2 to
7b4ea1b
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
September 10, 2026 03:05
737b291 to
e91c1fd
Compare
Contributor
|
This PR is stale because it has been open for 7 days with no activity. |
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
September 25, 2026 01:45
e91c1fd to
e6f3568
Compare
This comment has been minimized.
This comment has been minimized.
capcom6
force-pushed
the
gateway/explicit-registration
branch
3 times, most recently
from
October 1, 2026 07:57
2a863f2 to
3de2a03
Compare
Contributor
|
This PR is stale because it has been open for 7 days with no activity. |
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
October 9, 2026 03:36
3de2a03 to
f939ba7
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
October 12, 2026 00:52
f939ba7 to
7f46a89
Compare
capcom6
force-pushed
the
gateway/explicit-registration
branch
from
October 14, 2026 08:25
6300e40 to
13f9dcf
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds explicit cloud register / unregister controls in cloud server settings and reworks the SSE/FCM lifecycle coordination so realtime delivery stays correct across registration, account replacement, and unregister.
Key changes:
GatewayService.registerDevicepersists the new identity, then emitsDeviceRegisteredEvent.Success; SSE credentials are resolved fresh on everySSEManager.connect(no cached stale token).isDisconnectingflag checked in every callback.RegistrationWorkeris narrowed to updating an existing device with the FCM token (background refresh only).CloudServerSettingsFragmentstops the gateway pipeline before registering, restores it after, and swallows non-fatal post-success UI errors.CancellationException).PushService.onMessageReceivedand the receiver-sideMessagesExportRequestedEventcollector drop cloud commands whenregistrationInfo == null, so an unregistered device stops acting on commands.HomeFragmentis now single-flight across sign-up / sign-in / sign-in-by-code, and lifecycle cancellation is rethrown instead of being reported as a failure against a detached fragment.Why
Previously registration was implicit/automatic; users could not intentionally (re)register or unregister, and several lifecycle races could leave SSE bound to a stale account or drop the registration event for SSE-only devices.
Known limitations (deferred)
GatewayService.start()revives the workers and the events receiver but does not start SSE.DeviceRegisteredEvent.Successis emitted while the receiver is stopped, so it has no collector at that moment. SSE therefore resumes only indirectly, when the FCMRegistrationWorkerre-runsupdateDevice()and re-emits the event to the already-restarted receiver.This is left as-is for now. The interim workaround is the restart-app hint in
device_registered_successfully; the gap is recorded in a comment on theCancellationExceptionbranch ofregisterDeviceInternaland is being tracked separately. Explicitly startingSSEForegroundServiceon both the success and rollback paths would close it.Unregister is local-only. The device cannot be detached from its account with the current server contract, verified against the server source:
PATCH /mobile/v1/devicecannot clear the push token.MobileUpdateRequest.PushTokenis a plainstring, andlo.EmptyableToPtr(req.PushToken)maps both an absent and an empty value tonil; the repository then omitspush_tokenfrom the update and answers204 No Content. Sending""is a silent no-op that is indistinguishable from success, so it was deliberately not used here.DELETE /mobile/v1/device. Adding one is not an option:devicesis the parent ofmessages,webhooksandinboxviaON DELETE CASCADE, andSoftDeletableModel.DeletedAtis a plain*time.Timerather thangorm.DeletedAt, so removal is a hard delete that would take the device's message history with it.Consequence: the server keeps the push token and can still deliver commands for the previous registration once the user registers again, because
registrationInfobecomes non-null. The entry-point guards close the unregistered window only. Closing this needs a server contract change — an explicitclearPushTokenflag on the mobile PATCH request would do it without changing behavior for existing clients — and is tracked as a follow-up.Test plan
./gradlew test- green on all variants, matching the CI step in.github/workflows/build-apk.yml.SSEManagerTest- not written yet. CI does run unit tests, so the concurrency rework inSSEManagerwould be guarded by them; the coverage gap is ours to close and is deferred to a follow-up, not blocked by tooling.The PR is not yet safe to merge because SSE teardown can reopen a connection and obsolete authenticated sources can still forward commands after account replacement.
Summary
The PR adds explicit cloud registration and local unregister controls, refreshes FCM registration behavior, and reworks SSE teardown and credential resolution.
Reviews (43) · Last reviewed commit: "[gateway] explicit registration, unregis..." · Reviewed by Greptile