Skip to content

feat: add reset() and deprecate removeUserId() - #12

Merged
gunoooo merged 3 commits into
mainfrom
CLIX-121
Feb 19, 2026
Merged

gunoooo merged 3 commits into
mainfrom
CLIX-121

Conversation

@gunoooo

@gunoooo gunoooo commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add reset() method for logout support and deprecate removeUserId().

Changes

  • Add reset() method that clears all local SDK state (device ID, session) without server calls
  • Deprecate removeUserId() — use reset() instead
  • Bump version to 0.1.0

Spec

https://docs.google.com/document/d/1ET-KqAFQlODNEm08YDXehzfWuqKZsOhnr4NJG-f0P9k/edit?tab=t.0#bookmark=id.9awmqjhnpii6

Summary by CodeRabbit

  • New Features

    • Added reset() to clear all local SDK state, including device ID. SDK will reinitialize after reset.
  • Changed

    • Package version updated to 0.1.0.
  • Deprecated

    • removeUserId() is deprecated; use reset() instead.

- Add reset() to clear all local SDK state including device ID
- Deprecate removeUserId() in favor of reset()
@coderabbitai

coderabbitai Bot commented Feb 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds version 0.1.0, introduces Clix.reset() to clear local SDK state (including device ID), deprecates removeUserId() in favor of reset(), and makes the internal _initCompleter reassignable to support resetting/reinitialization.

Changes

Cohort / File(s) Summary
Release metadata
CHANGELOG.md, pubspec.yaml
Bumps package to 0.1.0 and documents the new reset() entry in the changelog.
Core SDK implementation
lib/src/core/clix.dart
Added public static Future<void> reset() to clear stored device/session state and require re-initialization; changed static final _initCompleter to mutable static Completer<void> to allow reassignment; marked removeUserId() as @Deprecated('Use reset() instead').

Possibly related PRs

  • feat: add session tracking #7: Modifies the same Clix core implementation and session initialization wiring — likely related to session/device state management.

Suggested reviewers

  • pitzcarraldo
  • nyanxyz
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main changes: adding a reset() method and deprecating removeUserId().
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch CLIX-121

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ced52fda3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/core/clix.dart
Comment thread lib/src/core/clix.dart

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/src/core/clix.dart (1)

158-161: Consider documenting concurrency expectations.

The docstring could clarify that callers should ensure no other SDK operations are in-flight when calling reset(), as concurrent operations may encounter null references if they're past the initialization check.

📝 Suggested docstring enhancement
 /// Resets all local SDK state including device ID.
 ///
 /// After calling this method, you must call [initialize] again before using the SDK.
 /// Use this when a user logs out and you want to start fresh with a new device identity.
+///
+/// **Important:** Ensure no other SDK operations are in progress when calling this method.
 static Future<void> reset() async {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/src/core/clix.dart` around lines 158 - 161, Update the documentation for
the reset() method to state concurrency expectations: callers must ensure no
other SDK operations are in-flight when calling reset() (i.e., serialize or
await any ongoing calls that rely on initialization), because concurrent
operations may observe null/cleared state after reset() even if they passed an
earlier initialization check; mention that initialize() must be called again
before using other SDK methods and recommend using external synchronization or
awaiting pending futures around reset()/initialize() to avoid races.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 17-19: The CHANGELOG deprecation guidance and the `@Deprecated`
annotation in clix.dart disagree about the replacement for removeUserId(); align
them to the intended replacement reset(): update the CHANGELOG entry that
currently says "use setUserId(null) instead" to say "use reset() instead" (or
equivalent wording) so it matches the `@Deprecated` message in clix.dart (line
with removeUserId()/@Deprecated) and the PR objective that reset() is the
correct replacement.

In `@lib/src/core/clix.dart`:
- Around line 162-173: The reset() method currently nullifies _shared before
allowing services to perform cleanup; modify reset() to first await
service-level teardowns by calling _shared!._notificationService?.reset() and
_shared!._tokenService?.reset() (and any other service reset methods) and await
their completion, then clear storage keys via
_shared!._storageService?.remove(...), and only after all resets succeed set
_shared = null and reset _isInitializing/_initCompleter; keep the existing catch
that throws ClixError.unknownErrorWithReason on failure, and explicitly decide
whether to clear persistent config fields (project_id, api_key, clix_config) or
leave a comment documenting they persist for re-initialization.

---

Duplicate comments:
In `@lib/src/core/clix.dart`:
- Around line 148-156: The `@Deprecated` message on removeUserId is inconsistent
with the CHANGELOG; change the annotation text on the static method removeUserId
to recommend the correct replacement used in the CHANGELOG (setUserId(null)) or
update the CHANGELOG to match reset(); ensure the deprecation string references
the exact replacement method name (e.g., "Use setUserId(null) instead" or "Use
reset() instead") so the intent in removeUserId, _waitForInitialization, and the
call to _shared!._deviceService!.removeProjectUserId() is clear and consistent.

---

Nitpick comments:
In `@lib/src/core/clix.dart`:
- Around line 158-161: Update the documentation for the reset() method to state
concurrency expectations: callers must ensure no other SDK operations are
in-flight when calling reset() (i.e., serialize or await any ongoing calls that
rely on initialization), because concurrent operations may observe null/cleared
state after reset() even if they passed an earlier initialization check; mention
that initialize() must be called again before using other SDK methods and
recommend using external synchronization or awaiting pending futures around
reset()/initialize() to avoid races.

Comment thread CHANGELOG.md Outdated
Comment thread lib/src/core/clix.dart
@gunoooo
gunoooo merged commit ac966ae into main Feb 19, 2026
3 checks passed
@gunoooo
gunoooo deleted the CLIX-121 branch February 19, 2026 10:02
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