getSessionId method

Future<String> getSessionId()

Returns the current session ID from storage. Falls back to generating one if none exists (e.g. if called before initialize).

Implementation

Future<String> getSessionId() async {
  final storage = HiveStorageService.instance;
  final existing = await storage.getSessionId();
  if (existing != null) return existing;

  // Safety fallback — should not happen in normal flow.
  final sessionId = const Uuid().v4();
  await storage.setSessionId(sessionId);
  await storage.setSessionTimestamp(DateTime.now().millisecondsSinceEpoch);
  return sessionId;
}