MCPcopy Create free account
hub / github.com/Dhravya/notty / beginEditSession

Method beginEditSession

src/durable-objects/user-notes.ts:329–339  ·  view source on GitHub ↗
(noteId: string)

Source from the content-addressed store, hash-verified

327 // Identical to head → nothing to record
328 if (head?.content_hash && head.content_hash === hash) return null;
329
330 // Defense-in-depth: never record an accidental wipe as a version. A
331 // transient empty doc (load race, reconnect, stale beacon) snapshotted
332 // over real content is what corrupts history into "deleted everything"
333 // diffs. If the new content is blank but the previous version had text,
334 // skip — the client-side guard should already prevent this, but old
335 // clients and the unmount beacon can still slip an empty doc through.
336 // Fail closed: if we can't read the previous version (R2 blip), don't
337 // record the empty doc either.
338 if (head && isEmptyDoc(content)) {
339 let prevContent: string;
340 try {
341 prevContent = await this.reconstructVersion(head.id, noteId, { strict: true });
342 } catch {

Callers 1

fetchMethod · 0.95

Calls 2

getNoteMethod · 0.95
getCurrentBranchMethod · 0.95

Tested by

no test coverage detected