Repository navigation
Keep a session's changes until they are saved, and never delete recordings on an unreadable setting. - #99
Merged
Conversation
…t be. - A failed doc.json write leaves the changes unsaved (it used to mark them saved first), tries again after 1, 5, 15 and then every 60 seconds, and the next flush or quit writes them. - An unsaved session is never unloaded, so the in-memory copy is not dropped. - The failure shows in Activity with the reason in plain words, Retry and Open, until a write lands. The save rules are in docSave.ts, with unit tests.
- An unreadable settings file, or an audioRetentionDays the schema refuses, used to fall back to 30 days and the startup sweep deleted older audio. Now recordings are kept (the value reads as Keep forever) until it is chosen again, and the sweep skips. - Activity says why, naming the copy of the unreadable file. - parseSettings now reports which fields fell back (readSettings); unit tests cover a corrupt file and bad values.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3 of 4 tasks
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the two data-loss findings from the 2026-11-28 audit (LYRA-CONS-001, LYRA-CONS-002), plus the missing failure-path tests (LYRA-TEST-001).
What was wrong
doc.jsonfailed (disk full, the folder became read-only, a sync client or antivirus holding the file on Windows), Lyra marked the change as saved before the write ran and only logged the failure. Nothing retried it. When you left the session (it unloads 30 s later) or quit, the in-memory copy was dropped, so the edits to notes, title, summary or speaker names were gone. No message appeared.settings.jsoncouldn't be read, or its "Keep audio" value was one this build can't use (a hand edit, or a value a newer Lyra allows), Lyra quietly fell back to the 30-day default. The startup sweep then permanently deleted every recording older than 30 days, even for someone who had chosen "Keep forever".What changed
src/main/docSave.ts(new, pure, unit-tested) holds the save rules:writeFailureReason()turns the error code into plain words ("the disk is full", "Lyra isn't allowed to write to the notes folder", …).sessionStore.tsuses it:save:<pageId>, kindsave) with the reason and Retry / Open. It stays until a write succeeds, then clears.flushAllSessions(quit, folder switch) also flushes sessions that a folder change closed while they were unsaved.settings.ts,settingsFile.ts,shared/settings.ts):readSettings()now also reports which fields fell back to their defaults.audioRetentionDayswas rejected, "Keep audio" is treated as Keep forever in memory, andsweepAudioskips.settings:retention) says no recordings are deleted until you choose again in Settings → Keep audio, and names thesettings.corrupt-….jsoncopy when there is one.How it was tested
pnpm install --frozen-lockfile: OK.pnpm checkinapps/lyra(typecheck, lint,config:check, vitest): 87 files, 659 tests pass (646 on main).docSave.test.ts(9): fails once then succeeds, retries with backoff, a retry writes the newest document, a later write covers an earlier failure, plain-words reasons.settingsFile.test.ts(4 new): a corrupt file, and"forever",-1and99999as retention values, aren't trusted. A valid value, or a field that was never written, is trusted.docSave.ts, 5 of the 9docSavetests fail.pnpm smoke:uiandpnpm smoke(they launch Electron; CI runs them). The website wasn't touched. I didn't add a smoke case for a failing disk, because making a folder read-only doesn't behave the same on Windows and macOS CI.Needs manual verification
UI changes can't be checked visually here. Please click through:
<notes>/.sessions/<id>/read-only (chmod 555on macOS), type again, and wait about a second.doc.jsonshould hold the text."audioRetentionDays": "forever"insettings.json(or break the JSON), keep an old session with audio, and start Lyra.For the reviewer to decide
Left out
saveWork, which also stops a recording in progress. That needs a product decision.Checks
pnpm typecheck(and the rest ofpnpm check).changeset/save-failures.md, patch)pnpm smoke/pnpm smoke:ui: not run locally (CI runs them)