feat: add file-backed canvas notes

Magic Notes previously supported rich-text records without a paged drawing or
PDF annotation workflow. Add the integrated PeopleLib Fabric and Quill editor
with flowing text, pen/highlighter, object transforms, images, paper templates,
PDF backgrounds with native text extraction, and raster PDF export. Saves are
manual; undo/redo remains scoped to an annotation page or Quill mode.

Analyze drafts, saved canvases and canvas-source todos with page images and
text when the default model supports images, or an explicitly labelled
text-only fallback. Keep successful saves when automatic analysis fails and
prevent MCP plain-text replacement of canvas records.

Move entry bodies and binary assets into local note files with schema 38
migration and verified readback. SQLite retains metadata, indexes, revisions,
todos and comments. Backups must coordinate SQLite and the adjacent notes
directory while writes are paused or the app is closed; no one-click backup
action is included.

Show a continuous record stream with independent collapsible record index and
AI pane, real first-page thumbnails, and scroll-only record navigation. Open a
blank text/canvas composer by default and reset it after creation. Protect
unsaved drafts and establish normalized editor baselines after saving so clean
records do not prompt again when leaving.

Validation: latest recorded focused run passed 149 tests across five files;
typecheck, lint and git diff --check passed. The prior user-reported full run
passed 4,713 tests before later corrections and UI changes; it is not a full
validation of this final snapshot. Tests were not rerun for this commit, as
requested; independent systematic review follows the commit.

Release note: Create paged notes with handwriting, flowing text and PDF
annotations, browse records through thumbnails, and request AI comments with
an explicit text-only fallback. Existing notes migrate to local file storage;
backups now need both the database and notes directory.
This commit is contained in:
mesalogo
2026-09-19 11:54:23 +08:00
parent c7a93803c9
commit 17186b0c11
58 changed files with 8240 additions and 429 deletions
+18 -13
View File
@@ -378,7 +378,7 @@ import type {
} from './goodbuddy-config-service'
import {
magicNotePlainText,
validateMagicNoteRichContent
validateMagicNoteContent
} from './magic-notes/rich-content'
import { weixinVerificationInputSchema } from '../shared/weixin-channel-contracts'
import type { RemoteChannelActivity } from '../shared/remote-channel-contracts'
@@ -7929,7 +7929,7 @@ export function registerIpcHandlers(
(event, input: unknown) => {
assertTrustedSender(event, window)
const parsed = magicNoteEntryCreateSchema.parse(input)
const content = validateMagicNoteRichContent(parsed.content)
const content = validateMagicNoteContent(parsed.content)
return assistantDatabase.createMagicNoteEntry({
noteId: parsed.noteId,
content,
@@ -7943,7 +7943,7 @@ export function registerIpcHandlers(
(event, input: unknown) => {
assertTrustedSender(event, window)
const parsed = magicNoteEntryUpdateSchema.parse(input)
const content = validateMagicNoteRichContent(parsed.content)
const content = validateMagicNoteContent(parsed.content)
return assistantDatabase.updateMagicNoteEntry({
entryId: parsed.entryId,
expectedRevision: parsed.expectedRevision,
@@ -7966,7 +7966,7 @@ export function registerIpcHandlers(
ipcChannels.magicNotesAnalyze,
async (event, input: unknown) => {
assertTrustedSender(event, window)
const { entryId, requestId, direction, format } =
const { entryId, requestId, direction, format, canvasImages } =
magicNoteAnalyzeSchema.parse(input)
const entry = assistantDatabase.getMagicNoteEntry(entryId)
const note = assistantDatabase.getMagicNoteContext(entry.noteId)
@@ -7987,7 +7987,7 @@ export function registerIpcHandlers(
const comments = await analyzeMagicNoteEntry(
analysisRuntime,
entry,
{ requestId, direction, format },
{ requestId, direction, format, canvasImages },
format === 'structured'
? undefined
: (delta) => {
@@ -8004,7 +8004,8 @@ export function registerIpcHandlers(
)
}
},
persistModelUsage
persistModelUsage,
{ supportsImageInput: settings.supportsImageInput === true }
)
const analyzedNote = assistantDatabase.saveMagicNoteAnalysis({
entryId,
@@ -8034,14 +8035,14 @@ export function registerIpcHandlers(
async (event, input: unknown) => {
assertTrustedSender(event, window)
const parsed = magicNoteDraftAnalyzeSchema.parse(input)
const content = validateMagicNoteRichContent(parsed.content)
const content = validateMagicNoteContent(parsed.content)
const plainText = magicNotePlainText(content)
const settings = await settingsStore.getResolvedSettings()
const analysisRuntime = createDefaultModelRuntime(
settings.workspacePath,
settings
)
const { requestId, direction, format } = parsed
const { requestId, direction, format, canvasImages } = parsed
assistantDatabase.createTask({
id: requestId,
title: '分析未保存笔记草稿',
@@ -8054,7 +8055,7 @@ export function registerIpcHandlers(
const comments = await analyzeMagicNoteDraft(
analysisRuntime,
plainText,
{ requestId, direction, format },
{ requestId, direction, format, canvasImages },
format === 'structured'
? undefined
: (delta) => {
@@ -8071,12 +8072,14 @@ export function registerIpcHandlers(
)
}
},
persistModelUsage
persistModelUsage,
{ supportsImageInput: settings.supportsImageInput === true, content }
)
assistantDatabase.updateTaskStatus(requestId, 'completed')
return {
id: randomUUID(),
comments,
inputMode: comments[0]?.inputMode,
analyzedAt: new Date().toISOString()
}
} catch (error) {
@@ -8129,9 +8132,10 @@ export function registerIpcHandlers(
ipcChannels.magicTodosAnalyze,
async (event, input: unknown) => {
assertTrustedSender(event, window)
const { todoId, requestId, direction, format } =
const { todoId, requestId, direction, format, canvasImages } =
magicTodoIdSchema.parse(input)
const todo = assistantDatabase.getMagicTodo(todoId)
const entry = assistantDatabase.getMagicNoteEntry(todo.entryId)
const settings = await settingsStore.getResolvedSettings()
const analysisRuntime = createDefaultModelRuntime(
settings.workspacePath,
@@ -8149,7 +8153,7 @@ export function registerIpcHandlers(
const comments = await analyzeMagicTodo(
analysisRuntime,
todo,
{ requestId, direction, format },
{ requestId, direction, format, canvasImages },
format === 'structured'
? undefined
: (delta) => {
@@ -8166,7 +8170,8 @@ export function registerIpcHandlers(
)
}
},
persistModelUsage
persistModelUsage,
{ supportsImageInput: settings.supportsImageInput === true, content: entry.content }
)
const analyzedTodo = assistantDatabase.saveMagicTodoAnalysis({
todoId,