Repository navigation
feat: add session tracking - #25
Conversation
WalkthroughIntroduces a new SessionService that manages session lifecycle (AppState tracking, last-activity persistence, pending message handling) and integrates it into Clix core and NotificationService, with an optional Changes
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8f2b38f21
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/services/SessionService.ts`:
- Around line 47-70: handleAppStateChange can run concurrently because of the
async delay, causing duplicate SESSION_START events; update this.lastAppState
eagerly at the start of handleAppStateChange (before the await) or add a simple
boolean guard (e.g., isHandlingStateChange) to short-circuit re-entrant calls;
specifically modify the handleAppStateChange method to set this.lastAppState =
nextAppState immediately (or acquire/set isHandlingStateChange true at entry and
clear it on exit) so the subsequent logic (timeout check, updateLastActivity,
startNewSession) cannot run concurrently for the same transition.
- Around line 97-99: The SessionService.cleanup() subscriber removal is never
invoked because Clix lacks a teardown path; add a public deinitialize() (or
similar) method on the Clix class that calls sessionService.cleanup() (and any
other services' cleanup/shutdown methods), expose it on the SDK API so consumers
can call it, and ensure any internal code paths that recreate Clix instances
call deinitialize() before reinitializing to prevent AppState listener
accumulation.
🧹 Nitpick comments (1)
src/services/SessionService.ts (1)
27-45: Duplicate session-continuation logic instart()andhandleAppStateChange().Lines 33–43 and 54–64 share identical read-lastActivity / check-elapsed / continue-or-start logic. Extracting this into a private helper (e.g.,
resumeOrStartSession()) would reduce duplication and make future changes less error-prone.Also applies to: 54-64
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
SessionServicetracksSESSION_STARTevents using React Native'sAppStateAPI for lifecycle detection (background→active)sessionTimeoutMs(default 30s, minimum 5s enforced)pendingMessageIdthroughNotificationServicesessionTimeoutMstoClixConfigChanges
src/services/SessionService.ts—SessionServicewithAppStatelistener,SessionEventenumsrc/core/Clix.ts— Initialize and startSessionServicesrc/core/ClixConfig.ts— AddsessionTimeoutMsfield (default 30000)src/services/NotificationService.ts— SetpendingMessageIdon push tap for session attributionSpec
Summary by CodeRabbit