Skip to content

Feature/idempotent session sync - #3

Merged
Harshit4847 merged 7 commits into
mainfrom
feature/idempotent-session-sync
Sep 11, 2026
Merged

Feature/idempotent session sync#3
Harshit4847 merged 7 commits into
mainfrom
feature/idempotent-session-sync

Conversation

@Harshit4847

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings September 11, 2026 05:38
@Harshit4847
Harshit4847 merged commit 63a5b23 into main Sep 11, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Resolve the API contract mismatch and add coverage for partial or empty acknowledgements.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds deterministic client session IDs and acknowledgement handling for idempotent session uploads.

Changes:

  • Renames the upload identifier to clientSessionId.
  • Marks sessions sent based on accepted server IDs.
  • Updates the API DTOs and synchronization tests.

The API response currently conflicts with the documented endpoint contract (critical, 3 votes), and partial or empty acknowledgements lack test coverage (critical, 2 votes).

File summaries
File Summary
app/src/main/java/com/harshit/crossdevicetracker/SessionUploadMapper.kt Maps local IDs to client session IDs.
app/src/main/java/com/harshit/crossdevicetracker/SessionUploadDto.kt Defines the client session ID field.
app/src/main/java/com/harshit/crossdevicetracker/SessionSyncService.kt Processes accepted sessions; needs partial/empty acknowledgement tests.
app/src/main/java/com/harshit/crossdevicetracker/SessionApi.kt Uses the acknowledgement response type, which conflicts with the documented endpoint contract.
app/src/main/java/com/harshit/crossdevicetracker/AcceptedTimeLogsResponse.kt Defines the acknowledgement response model.
app/src/androidTest/java/com/harshit/crossdevicetracker/SessionSyncServiceTest.kt Updates synchronization tests and fake API responses.
Review details

Suppressed comments (1)

app/src/main/java/com/harshit/crossdevicetracker/SessionSyncService.kt:40

  • A 2xx response with no body or an empty acknowledgement is treated as a permanent failure for every session in the batch. markSessionFailed removes records from getPendingSessions() (the query only selects PENDING), so a missing acknowledgement does not leave these sessions retryable even though it does not prove that the server rejected them. Keep them pending and stop/report a protocol error, or only mark sessions failed when the server explicitly identifies rejected IDs.
                    if (acceptedIdSet == null || acceptedPendingCount == 0) {
                        val errMsg = "Successful sync response did not accept any pending session ids"
                        for (session in pendingSessions) {
                            sessionRepository.markSessionFailed(session.id, errMsg)
                        }
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Header("Authorization") authToken: String,
@Body sessions: List<SessionUploadDto>
): Response<Unit>
): Response<AcceptedTimeLogsResponse>
Comment on lines +32 to +36
val acceptedIds = response.body()?.acceptedClientSessionIds
val acceptedIdSet = acceptedIds?.toHashSet()
val acceptedPendingCount = acceptedIdSet?.count { id -> pendingSessions.any { it.id == id } } ?: 0

if (acceptedIdSet == null || acceptedPendingCount == 0) {
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