Replace native engine saves and engine/MCP exports atomically, preserving private permissions during staging and cleaning up failed writes. Add regressions for long filenames and caught writer unwinding.
Fixes#436.
Co-authored-by: aiongg <aiongtaigi@gmail.com>
Co-authored-by: skylar taylor-barrick <hi@skylar.cc>
Resolve conflicts keeping both sides: doc gains both `cjk` and
`datamerge` modules; file.open resolves data-merge sources and loads the
document's fonts; DocState keeps preview_stash/preview_record and fonts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Font menus list Western (and other-script) families first, then
Japanese, Simplified Chinese, Traditional Chinese and Korean families,
each group alphabetical by the name shown, with a separator between
groups. The group comes from the font's own data, strongest signal
first: the meta table's dlng (else slng) languages, family names in a
CJK language (Windows and Macintosh language IDs), OS/2 code pages (JIS,
Chinese Simplified, Korean Wansung, Chinese Traditional, Korean Johab);
a font declaring none of these goes by what it covers (kana, Hangul,
ideographs). Ties go Japanese, Simplified, Traditional, Korean. Loaded faces are classified
once; installed fonts by the font scan, which also reads their OS/2 and
meta tables (and cmap only for fonts declaring nothing), capped.
CJK families show their family name in their language, the English
name on hover; Preferences > Type > Show Font Names in English
(prefs.set {showFontNamesInEnglish}, off by default) shows English
names. Search matches either name; documents store the English name.
The Character panel, Control bar, Properties, style dialogs, Find Font
and Glyphs panel lists all follow this order. The main font menu stays
open while searching or starring (it closed on any click inside).
Font previews don't draw DesignCraft's missing-glyph box for fonts
whose .notdef is empty.
The fonts in a document's Document Fonts folder are registered under a
font scope that the document holds while it is open (Document::font_scope,
runtime only; DocState keeps the scope alive and closes it when the last
copy of the state goes: file.close, closing a tab, revert, a book
chapter's export, the session ending). Composition, preflight, font.list,
Package and the font menus, Glyphs panel and previews look fonts up
through FontDb::scoped(scope): the document's own faces first, then the
shared ones. Other open documents don't see them, and two documents with
fonts of the same name each set text in their own. Composite fonts'
member fonts and the fallback for kenten marks are looked up the same
way.
Font files stay in memory for the session (FaceRef keeps faces for the
process); a document opened again reuses the faces of its unchanged files
(same path, length and modification time) instead of reading them again.
The composition cache's signature includes the scope; the word cache and
the outline and PDF font caches are keyed by face. Variable font
instances are kept per base face.
A family's installed faces join the shared fonts all at once, and a
face two lookups load at the same time is kept once, so a parallel
fallback lookup never takes a family's bold before its regular has
loaded.
Select, update, and remove a linked source. Placeholders cover text,
images, QR codes, and hyperlinks. Preview fills one record in the
session and is left out of save and recovery. Merge copies the template
into a new document, one record per page, or tiles frames on a single
non-facing page. A missing or changed file is marked and the cached
rows are still used. The template undo stack is left as it was.
A command that documents ids (object.textFrameOptions, transform.rotate, ...)
acts on the objects a call names, yet its enabled check looked only at the
selection. With a text caret or nothing selected, {"ids": [5]} failed with:
command `object.textFrameOptions` is not available right now: nothing selected
Execute now lets such a call through when every named object exists, and
says "no object with id N" when one doesn't. transform.set, object.arrange
and edit.stepAndRepeat, which already acted on ids, now document them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Session::execute runs each command inside catch_unwind: a panic that escapes
(any edit, import or export, from the UI, CLI, MCP or control channel)
becomes EngineError::Internal, the document and selection are restored to
before the command, and crash recovery is saved when enabled. The first
Session installs a panic hook that logs the message and location.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commands return errors instead of expect()/unreachable!() (book, library,
undo/redo, paste, find/replace, Pathfinder, tables, QR, select, swatches,
anchors, articles, transform again, XML import). The sample document builder
propagates errors. Commands that add a key to their parameters no longer
panic when a caller (control channel, MCP, script) passes an array or a
string, and corrupt crash-recovery metadata is ignored. engine, mcp and
tools now deny unwrap/expect/panic/unimplemented/todo/unreachable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The active layer lives on DocState, outside the undo snapshots, and
nothing re-checked it when the document's layers changed. After New
Layer → Undo (or Delete Layer / Delete Unused Layers / Merge Layers on
the active layer) it kept pointing at a layer that no longer exists, and
every object created next (frames, lines, placed images, pasted items)
was put on that phantom layer: not drawn on the canvas, missing from PDF
export, ItemLayer referencing an undefined layer in IDML, and preflight
reported nothing.
After each command, if the active layer is gone, make the top layer
active (as on opening a document).
Test: active_layer_survives_undoing_new_layer.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
prefs.set (application) and document.preferences (units, increments, grids; undoable).
Scaling applies to content: paths and placed graphics take the scale, stroke weights follow
with Include Stroke Weight. X/Y/W/H and transform.set measure the stroke's outer edge.
The command palette becomes Quick Apply and lists styles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Edit › Paste Into (⌥⌘V): copied objects (with their stories and images) become the selected
frame's content, clipped by it; Item::is_group / has_nested_items; renderer and PDF draw fill,
clipped content, stroke; IDML nests the items inside the frame both ways (verified in
InDesign 2026) (+ tests)
- Polygon Settings: sides and star inset as engine preferences used by the polygon tools and
frame.create; double-click the Polygon tool (+ test)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- engine::recovery: unsaved documents written to a recovery folder (atomic write + metadata),
reopened as unsaved documents that remember their files; entries dropped on save/close
(+ tests); file.recovery.list/save/open, file.revert, file.saveACopy (+ test)
- app: recovery folder per platform, recovered on launch with a status message; UI writes
recovery data every 30 s while documents are unsaved; File › Save a Copy…, Revert
- parity: recovery, revert, save a copy done
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- doc: Story::extract / insert_story carry formats, footnotes, cross-references, index markers
and tables through copy and paste
- engine: edit.copy/cut on text keep a formatted slice; edit.paste uses it while the system
clipboard matches (else plain text, no smart quotes); edit.pasteWithoutFormatting (⇧⌘V);
type.changeCase (upper/lower/title/sentence, run formats kept)
- UI: canvas copy/cut/paste go through the engine; Type › Insert Special Character (Symbols,
Markers, Hyphens and Dashes, Quotation Marks, Other), Insert White Space, Insert Break
Character, Change Case; nested submenus in the menu parser (+ test)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>