feat: add persistent document handling and protect note drafts
Add HTTP PaddleOCR-VL settings and shared document previews for chat and knowledge imports. Preserve attachment originals and parsed assets across drafts, messages and queues; support explicit image OCR, selecting document images into a conversation draft, and restoring queued input for editing. Protect unsaved note bodies and titles during navigation and asynchronous updates. Match canvas analysis to source revisions, invalidate affected comments, preserve annotations during pagination, and provide a resizable record index with saved width preferences. Existing OCR settings retain local behavior. Historical attachments without saved originals are not reconstructed. Advanced OCR options depend on the configured service; image sending depends on the effective model and Runtime. Validation: full typecheck and lint passed; 477 focused tests passed across 12 files; staged whitespace checks passed. The full repository suite was not rerun for this commit. Release note: Keep note drafts safe while switching workspaces, resize the record index, and revisit saved document attachments with OCR previews and selected images in chat.
This commit is contained in:
@@ -81,7 +81,7 @@ import type {
|
||||
VectorSearchOptions
|
||||
} from './types'
|
||||
|
||||
const DATABASE_VERSION = 12
|
||||
const DATABASE_VERSION = 13
|
||||
const MAX_ID_LENGTH = 128
|
||||
const MAX_NAME_LENGTH = 512
|
||||
const MAX_LOCATION_LENGTH = 8192
|
||||
@@ -1952,6 +1952,11 @@ export class KnowledgeDatabase {
|
||||
return this.requiredDocument(id)
|
||||
}
|
||||
|
||||
getDocumentByParsedResultId(id: string): Document | undefined {
|
||||
const row = this.requireDatabase().prepare("SELECT * FROM documents WHERE json_extract(metadata, '$.parsedResultId') = ?").get(id)
|
||||
return row ? mapDocument(row) : undefined
|
||||
}
|
||||
|
||||
getDocument(id: string): Document | undefined {
|
||||
const normalizedId = requiredString(id, 'id', MAX_ID_LENGTH)
|
||||
const row = this.requireDatabase()
|
||||
@@ -4622,6 +4627,10 @@ export class KnowledgeDatabase {
|
||||
database.prepare('INSERT INTO schema_migrations (version, applied_at) VALUES (?, ?)')
|
||||
.run(12, new Date().toISOString())
|
||||
}
|
||||
if (currentVersion < 13) {
|
||||
database.exec("CREATE INDEX IF NOT EXISTS documents_parsed_result ON documents(json_extract(metadata, '$.parsedResultId'))")
|
||||
database.prepare('INSERT INTO schema_migrations (version, applied_at) VALUES (?, ?)').run(13, new Date().toISOString())
|
||||
}
|
||||
database.exec(`PRAGMA user_version = ${DATABASE_VERSION}`)
|
||||
database.exec('COMMIT')
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user