MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / setMemoryFeatureEnabled

Method setMemoryFeatureEnabled

chat/app.js:4237–4276  ·  view source on GitHub ↗
(enabled, options = {})

Source from the content-addressed store, hash-verified

4235
4236 if (!session.inferenceBackend) {
4237 this.inferenceService.ensureSessionBackend(session);
4238 needsSave = true;
4239 }
4240
4241 if (this.normalizeSessionCouncilState(session)) {
4242 needsSave = true;
4243 }
4244
4245 if (needsSave) {
4246 sessionsToSave.push(session);
4247 }
4248 }
4249
4250 // Save all migrations in parallel (non-blocking)
4251 if (sessionsToSave.length > 0) {
4252 Promise.all(sessionsToSave.map(s => chatDB.saveSession(s)))
4253 .catch(err => console.warn('Session migration failed:', err));
4254 }
4255 }
4256
4257 /**
4258 * Generates a unique ID for sessions and messages using ULID.
4259 * Format: 5-5-5-6 lowercase (e.g., 01j7x-kqnp2-4mvwt-ghr85c)
4260 * Uses 21 chars: 10 timestamp (48-bit) + 11 random (55-bit)
4261 * @returns {string} Unique ULID with dashes for readability
4262 */
4263 generateId() {
4264 const raw = generateSessionId();
4265 return `${raw.slice(0,5)}-${raw.slice(5,10)}-${raw.slice(10,15)}-${raw.slice(15)}`;
4266 }
4267
4268 /**
4269 * Normalize an ID for comparison/lookup (strip dashes, uppercase).
4270 * Handles both old format and new ULID format with dashes.
4271 * @param {string} id - ID to normalize
4272 * @returns {string} Normalized ID
4273 */
4274 normalizeId(id) {
4275 return id.replace(/-/g, '').toUpperCase();
4276 }
4277
4278 /**
4279 * Formats a timestamp for display.

Tested by

no test coverage detected