Skip to content

added presence api update#1489

Open
ArnabChatterjee20k wants to merge 2 commits intomasterfrom
presence-api
Open

added presence api update#1489
ArnabChatterjee20k wants to merge 2 commits intomasterfrom
presence-api

Conversation

@ArnabChatterjee20k
Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 29, 2026

Greptile Summary

This PR adds a createPresence API to the realtime SDK across Android (Kotlin), Apple (Swift), Flutter (Dart), and Web (TypeScript) platforms, and makes the additionalProperties field name configurable via the new x-additional-properties-key OpenAPI extension (updating all model templates across every supported language).

  • P1 — Swift onClose/onError don't drain pendingPresenceRequests: The onClose and onError WebSocketClientDelegate callbacks in Realtime.swift.twig never drain pendingPresenceRequests, so any createPresence caller suspended on withCheckedThrowingContinuation when the socket closes (cleanly or due to a network error) will remain permanently suspended. handleResponseError correctly drains the queue for server-sent error frames, but connection-level closures bypass that path entirely.

Confidence Score: 3/5

Multiple P1 issues exist across platforms (Swift new finding; Flutter/Android/Web from prior rounds) — not safe to merge until all pending-continuation drain gaps are resolved.

There is one new P1 finding (Swift onClose/onError) plus several carryover P1s from previous review rounds that remain unaddressed (Flutter onDone/onError, Android onClosing/onFailure, Web close/disconnect). Multiple P1s across core async paths pull the score below the P1 ceiling of 4.

templates/apple/Sources/Services/Realtime.swift.twig (new P1 — onClose/onError don't drain pendingPresenceRequests); also see prior comments on templates/flutter/lib/src/realtime_mixin.dart.twig, templates/android/library/src/main/java/io/package/services/Realtime.kt.twig, and templates/web/src/services/realtime.ts.twig

Important Files Changed

Filename Overview
src/Spec/Swagger2.php Adds additionalPropertiesKey from the x-additional-properties-key OpenAPI extension, defaulting to 'data'; used consistently across all model templates.
templates/apple/Sources/Services/Realtime.swift.twig Adds createPresence and presence-response handling. handleResponseError correctly drains the queue, but onClose and onError delegate methods do not, leaving pending continuations permanently unresolved on socket close/error.
templates/android/library/src/main/java/io/package/services/Realtime.kt.twig Adds createPresence with FIFO queue; handleResponseError drains the queue. onClosing/onFailure coverage is a known open issue from prior review rounds.
templates/flutter/lib/src/realtime_mixin.dart.twig Adds createPresenceTo and presence-response handling; handleError drains the queue for server errors. onDone/onError WebSocket stream callbacks remain a known open issue.
templates/web/src/services/realtime.ts.twig Adds createPresence and RealtimePresence/RealtimePresenceCreate types; error path drains the queue. Socket close/disconnect drain gap is a known open issue.
templates/dart/lib/src/models/model.dart.twig Replaces hardcoded data field name with additionalPropertiesKey template variable consistently across field declaration, constructor, factory, toMap, and convertTo.

Comments Outside Diff (1)

  1. templates/apple/Sources/Services/Realtime.swift.twig, line 463-489 (link)

    P1 Pending presence continuations not resumed on socket close/error

    Both onClose and onError delegate callbacks stop the heartbeat and forward to higher-level observers but never drain pendingPresenceRequests. Any caller suspended inside createPresence — waiting on a withCheckedThrowingContinuation — will remain permanently suspended when the connection drops (clean close or network error), causing a hang and a continuation leak.

    handleResponseError correctly drains the queue on a server-side error frame, but connection-level close and transport errors bypass that path entirely.

    Add the same drain logic used in handleResponseError to both delegate methods:

    // In onClose and onError:
    var pending: [CheckedContinuation<[String: Any], Swift.Error>] = []
    presenceSync.sync {
        pending = pendingPresenceRequests
        pendingPresenceRequests.removeAll()
    }
    let closeError = AppwriteError(message: "Realtime connection closed.")
    pending.forEach { $0.resume(throwing: closeError) }

Reviews (2): Last reviewed commit: "Add support for customizable additional ..." | Re-trigger Greptile


return completer.future;
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Missing newline at end of file

The file no longer ends with a newline. Most linters and git tools flag this; adding a trailing newline keeps the file consistent with the rest of the codebase.

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