fix: Fallback to cached session ID in session_note_add

When session_id is not provided, falls back to getSessionId() which
reads from CLAUDE_SESSION_ID env or ~/.cache/session-memory/current_session.
Fixes NOT NULL constraint violation on session_notes.session_id.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-02-04 21:02:12 +02:00
parent 6cbb5ce6cb
commit bd5d95beff
2 changed files with 4 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ import * as os from 'os';
/** /**
* Get current session ID from environment or cache file * Get current session ID from environment or cache file
*/ */
function getSessionId(): string { export function getSessionId(): string {
// Check environment first // Check environment first
if (process.env.CLAUDE_SESSION_ID) { if (process.env.CLAUDE_SESSION_ID) {
return process.env.CLAUDE_SESSION_ID; return process.env.CLAUDE_SESSION_ID;

View File

@@ -3,6 +3,7 @@
import { query, queryOne, execute } from '../db.js'; import { query, queryOne, execute } from '../db.js';
import { getEmbedding, formatEmbedding } from '../embeddings.js'; import { getEmbedding, formatEmbedding } from '../embeddings.js';
import { getSessionId } from './crud.js';
// ============================================================================ // ============================================================================
// SESSION NOTES // SESSION NOTES
@@ -32,7 +33,8 @@ interface SessionNote {
* Auto-generates embedding for semantic search * Auto-generates embedding for semantic search
*/ */
export async function sessionNoteAdd(args: SessionNoteAddArgs): Promise<string> { export async function sessionNoteAdd(args: SessionNoteAddArgs): Promise<string> {
const { session_id, note_type, content } = args; const { session_id: providedSessionId, note_type, content } = args;
const session_id = providedSessionId || getSessionId();
// Generate embedding for semantic search // Generate embedding for semantic search
const embedding = await getEmbedding(content); const embedding = await getEmbedding(content);