Skip to content

Commit 89be5ae

Browse files
committed
fix: conversation capture — catch any editNote error, fall through to create
The previous code matched specific error types (isNoteNotFoundError) to decide whether to fall back to writeNote. The error format from callTool didn't match, so writeNote never fired — zero conversations captured. Fix: try append, if it fails for ANY reason, create the note. Also adds Conversation schema frontmatter (type: Conversation, date) to created notes. Fixes #22
1 parent 9ab86e1 commit 89be5ae

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

bm-client.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -855,22 +855,33 @@ export class BmClient {
855855
"---",
856856
].join("\n")
857857

858+
// Try append first — if it fails for ANY reason, fall through to create
858859
try {
859860
await this.editNote(title, "append", entry)
860861
log.debug(`appended conversation to: ${title}`)
862+
return
861863
} catch (err) {
862-
if (!this.isNoteNotFoundError(err)) {
863-
log.error("conversation append failed", err)
864-
return
865-
}
864+
log.debug(`append failed, will create: ${getErrorMessage(err)}`)
865+
}
866866

867-
const content = [`# Conversations ${dateStr}`, "", entry].join("\n")
868-
try {
869-
await this.writeNote(title, content, "conversations")
870-
log.debug(`created conversation note: ${title}`)
871-
} catch (createErr) {
872-
log.error("conversation index failed", createErr)
873-
}
867+
// Create the note with frontmatter and first entry
868+
const content = [
869+
"---",
870+
`title: Conversations ${dateStr}`,
871+
"type: Conversation",
872+
`date: "${dateStr}"`,
873+
"---",
874+
"",
875+
`# Conversations ${dateStr}`,
876+
"",
877+
entry,
878+
].join("\n")
879+
880+
try {
881+
await this.writeNote(title, content, "conversations")
882+
log.debug(`created conversation note: ${title}`)
883+
} catch (err) {
884+
log.error("conversation index failed", err)
874885
}
875886
}
876887

0 commit comments

Comments
 (0)