Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/services/sync/ChromaSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,54 @@ export class ChromaSync {
await this.addDocuments(documents);
}

/**
* Bug #1914: Sync a raw observation database row to Chroma.
* Used by the import handler where we have database rows, not ParsedObservation objects.
* The row format matches SELECT * FROM observations.
*/
async syncObservationRow(row: {
id: number;
memory_session_id: string;
project: string;
merged_into_project?: string | null;
text: string | null;
type: string;
title: string | null;
subtitle: string | null;
facts: string | null;
narrative: string | null;
concepts: string | null;
files_read: string | null;
files_modified: string | null;
prompt_number: number;
discovery_tokens: number;
created_at: string;
created_at_epoch: number;
Comment on lines +385 to +402
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 prompt_number declared non-nullable here but import payload allows null

SessionStore.importObservation accepts prompt_number: number | null, so an imported observation may have prompt_number: null. syncObservationRow's inline parameter type declares prompt_number: number, creating a TypeScript type mismatch at the call site in DataRoutes.ts. TypeScript will infer the element type from the import schema's nullable field and flag the mismatch.

Suggested change
async syncObservationRow(row: {
id: number;
memory_session_id: string;
project: string;
merged_into_project?: string | null;
text: string | null;
type: string;
title: string | null;
subtitle: string | null;
facts: string | null;
narrative: string | null;
concepts: string | null;
files_read: string | null;
files_modified: string | null;
prompt_number: number;
discovery_tokens: number;
created_at: string;
created_at_epoch: number;
prompt_number: number | null;

Fix in Claude Code

}): Promise<void> {
const stored: StoredObservation = {
id: row.id,
memory_session_id: row.memory_session_id,
project: row.project,
merged_into_project: row.merged_into_project ?? null,
text: row.text,
type: row.type,
title: row.title,
subtitle: row.subtitle,
facts: row.facts,
narrative: row.narrative,
concepts: row.concepts,
files_read: row.files_read,
files_modified: row.files_modified,
prompt_number: row.prompt_number,
discovery_tokens: row.discovery_tokens,
created_at: row.created_at,
created_at_epoch: row.created_at_epoch
};

const documents = this.formatObservationDocs(stored);
await this.addDocuments(documents);
}

/**
* Sync a single summary to Chroma
* Blocks until sync completes, throws on error
Expand Down
Loading
Loading