OpenFini

Docs / Guides

Doctor: diagnose and repair

The Doctor checks .ofini projects and the app itself, explains each finding in plain language and repairs what can be repaired safely. It has two surfaces that share one pure module, app/src/core/doctor/:

  • In the app: Help ▸ Doctor… and Settings ▸ Troubleshooting ▸ Doctor. When an .ofini file cannot be opened, OpenFini shows why and offers Repair with Doctor instead of only failing.
  • In a terminal: ofini doctor (cli.md).

File checks#

Every finding has a severity (error, warning, note), an explanation and, where possible, a fix. Safe fixes never remove what someone made: they fill in defaults, rebuild the container, drop bytes nothing refers to or re-number duplicates. The other fixes can remove broken layers or clips and are applied only when asked (--fix=all, or per item in the app).

CheckFindingFix (safe unless marked)
ContainerEmpty file, not a ZIP, over the limits (100,000 parts, 1 GiB per part, 2 GiB, as in security.md)none
ContainerTruncated file or damaged central directory: the local file headers are scanned and every part whose data inflates and matches its CRC-32 is recovered; damaged parts are listedrecover-entries
ContainerPart names with .., a leading /, a drive letter, a backslash or NULdrop-unsafe
Type markermimetype missing, wrong, compressed or not firstmimetype
Contentdocument.json missing (the remaining parts can still be extracted), not JSON, not an objectnone
ContentStray bytes around the JSON (byte order mark, NUL padding, a partial write)json-clean
FormatMissing or wrong format; unreadable, missing (very old) or newer versionformat-field; version-reset (not safe)
StructureMissing or mistyped pages, masters, assets, stories, styles, swatches, settings, comments, web, office; no pages; a page without a layer tree or without its settings (position, margins, columns, gutter, bleed, guides)structure
IdsPages or layers without an id, duplicate idsids
ValuesInvalid numbers (JSON turns NaN into null), transforms that are not six numbers, negative sizes, opacity outside 0 to 1, page sizes that are not positivevalues
LayersUnreadable layers (not an object, no type)drop-invalid
LayersTrees nested more than 200 levels deepdrop-deep (not safe)
ReferencesImage layers whose picture is missingdrop-broken-images (not safe)
ReferencesText layers whose story is missing; unreadable storiesstories (an empty story)
ReferencesPages using a master page that does not exist; text using paragraph or character styles that do not existrefs
AssetsPicture records without bytes; pictures whose bytes do not match their type; parts over 64 MiBnone (reported)
AssetsStored files nothing refers to (assets/, pixels/, office/, web/files/)prune-orphans
AssetsAsset records no layer usesprune-unused (not safe: a picture may be kept on purpose)
Pixel layersMissing or damaged pixel images (PNG signature, chunk CRCs, end chunk)none (the layer opens empty)
WebsiteFiles listed in the website manifest but missingweb
OfficeMedia records whose file is missingoffice
SceneCompositions that contain themselves, directly or through othersscene-cycle
SceneClips whose composition or media is missingscene-refs (not safe)
PreviewA damaged thumbnail.png (the app writes a new one on the next save)thumbnail
OtherUnknown partsnone (kept as they are)

Other files get a short report: ZIP-based files (DOCX, XLSX, PPTX, ODF, ORA, KRA, Sketch, ZIP) are checked and recovered like the project container; PNG (chunk CRCs), JPEG (start and end markers), PDF (header and end marker), JSON-based files (Excalidraw, tldraw), SVG and text (UTF-8) are checked for damage.

What the Doctor cannot fix. A document.json that is not JSON even after the stray bytes are removed, parts whose compressed data is damaged, and the pixels of a damaged pixel layer. ofini extract --assets still saves every readable picture and media file of such a project.

In the app#

Help ▸ Doctor… checks the open document exactly as Save would write it. Repair in a new tab applies the safe fixes to a copy and opens it; Repair everything in a new tab applies all fixes after a confirmation; the Fix button of a finding applies only that fix. The original document and file are never changed. When an .ofini file fails to open, the dialog offers Repair with Doctor (opens a repaired copy) and Details (the Doctor for that file).

In a terminal#

ofini doctor file.ofini                      # report, exit code 1 on errors
ofini doctor --fix file.ofini                # safe fixes → file.repaired.ofini
ofini doctor --fix=all file.ofini            # all fixes
ofini doctor --fix=prune-orphans,thumbnail file.ofini
ofini doctor --fix --out fixed.ofini file.ofini
ofini doctor --fix --in-place file.ofini     # replaces the file, keeps file.ofini.bak
ofini doctor --json *.ofini                  # findings for machines

The repaired copy is never written over the original without --in-place, and --in-place refuses to replace an existing .bak without --force.

App checks#

The in-app Doctor also checks the environment. Each check that can be fixed has a Fix button; Fix all safe issues runs the safe ones (and repairs the open document in a new tab when it has safe fixes).

AreaCheckFix
StorageQuota usage (warning at 70 %, error at 90 %); whether stored data is persistentAsk the browser to keep data
StorageThe local database (IndexedDB) opens; entries that cannot be readRemove unreadable entries
RecoveryAutosaved documents that are damaged and would be skipped on restore; recent files without a stored copyRemove unreadable recovery entries
OfflineService worker registered; caches from earlier versionsRe-register; remove old caches; clear the offline cache (asks first)
CapabilitiesWebGL, WebGPU, WebCodecs, OffscreenCanvas, listing installed fontsnone (explains the fallback)
FontsAdded fonts that failed to loadnone
WorkersThe worker pool answers a tiny job within 8 secondsnone
ExtensionsExtensions in an error state or hung; registered enginesRestart failed extensions
AIThe selected provider exists; addresses are https or on this device; providers that need a key have one; the provider's address answersnone (Settings ▸ Artificial intelligence)
SettingsSaved settings parse and have the types of the defaultsBack up and reset settings (the old ones stay in this browser under openfini.prefs.v1.backup)

Privacy. No check reads key values or document contents into the result. The reachability check is a plain HEAD request to the provider's own address, without credentials, cookies or a referrer, and is skipped in offline mode. Copy report and Save report contain the findings with layer, asset, file and provider names replaced by "…" in the document section and user names removed from paths; they contain no file contents and no keys.

Vibe#

run_doctor (read-only, Diagnostics and security group) returns the app and document findings with their fix ids. It repairs nothing; the assistant points you to Help ▸ Doctor to apply fixes.

For developers#

  • core/doctor/zip.js: strict ZIP reading with the limits, the local-header recovery scan, CRC-32, the container writer.
  • core/doctor/file.js: diagnoseFile(bytes, { name }) and repairFile(bytes, { name, fixes }). One walk does both: a requested fix is applied to the working copy where the problem is found, then the copy is written and checked again. Messages are English templates marked with a local N_ for the i18n extractor.
  • core/doctor/env.js: evaluateEnvironment(status), pure; core/doctor/collect.js collects the status in the browser and runs the fixes.
  • ui/doctor-dialog.js: the dialog and the "could not be opened" dialog. Both load lazily (tests/architecture/guardrails.test.js ▸ LAZY_AREAS).
  • Tests: tests/core/doctor-file.test.js (broken fixtures built in the test), tests/core/doctor-env.test.js, tests/packaging/ofini-cli.test.js.

To add a check: add the finding where the walk reaches the data, a fix id in FIXES when it can be repaired, a test with a broken fixture, a row in the table above and the German text in de.json.

Edit on GitHub → docs/doctor.md