getSessionContext method
Build the session context (nav stack + discovered routes).
Implementation
Map<String, dynamic> getSessionContext() {
if (!_sessionDirty &&
_sessionCache != null &&
!_sessionCache!.isExpired(_sessionTtl)) {
AiLogger.log('Session cache HIT', tag: 'Cache');
return _sessionCache!.value;
}
AiLogger.log('Session cache MISS — rebuilding', tag: 'Cache');
final context = {
'currentRoute': AiNavigatorObserver.currentRoute,
'navigationStack': AiNavigatorObserver.routeStack,
'discoveredRoutes': AiNavigatorObserver.discoveredRoutes.toList(),
};
_sessionCache = _CacheEntry(context);
_sessionDirty = false;
AiLogger.log(
'Session cache rebuilt: route=${context['currentRoute']}, '
'stack=${(context['navigationStack'] as List).length} entries, '
'discovered=${(context['discoveredRoutes'] as List).length} routes',
tag: 'Cache',
);
return context;
}