feat: enhance magic notes AI comments

This commit is contained in:
lofyer
2026-08-10 22:27:50 +08:00
parent ad79659308
commit 7d15e83153
20 changed files with 1293 additions and 116 deletions
+32 -5
View File
@@ -2065,12 +2065,25 @@ export class AssistantDatabase {
}): MagicNoteDetail {
const database = this.requireDatabase()
const existing = database
.prepare('SELECT note_id FROM magic_note_entries WHERE id = ?')
.get(input.entryId) as { note_id: string } | undefined
.prepare(
`SELECT note_id, comments_json
FROM magic_note_entries
WHERE id = ?`
)
.get(input.entryId) as
| { note_id: string; comments_json: string }
| undefined
if (!existing) {
throw new Error('记录不存在')
}
const now = new Date().toISOString()
const comments = [
...(JSON.parse(existing.comments_json) as MagicNoteComment[]),
...input.comments.map((comment) => ({
...comment,
analyzedAt: now
}))
]
const result = database
.prepare(
`UPDATE magic_note_entries
@@ -2079,7 +2092,7 @@ export class AssistantDatabase {
WHERE id = ? AND revision = ?`
)
.run(
JSON.stringify(input.comments),
JSON.stringify(comments),
now,
now,
input.entryId,
@@ -2156,8 +2169,22 @@ export class AssistantDatabase {
expectedRevision: number
comments: MagicNoteComment[]
}): MagicTodoItem {
const database = this.requireDatabase()
const existing = database
.prepare('SELECT comments_json FROM magic_todos WHERE id = ?')
.get(input.todoId) as { comments_json: string } | undefined
if (!existing) {
throw new Error('待办不存在')
}
const now = new Date().toISOString()
const result = this.requireDatabase()
const comments = [
...(JSON.parse(existing.comments_json) as MagicNoteComment[]),
...input.comments.map((comment) => ({
...comment,
analyzedAt: now
}))
]
const result = database
.prepare(
`UPDATE magic_todos
SET comments_json = ?, analyzed_at = ?,
@@ -2165,7 +2192,7 @@ export class AssistantDatabase {
WHERE id = ? AND revision = ?`
)
.run(
JSON.stringify(input.comments),
JSON.stringify(comments),
now,
now,
input.todoId,