Sitelet https://github.com/shift-editor/shift/pull/495
Skip to content

feat(desktop): reopen documents on their last glyph after interruptions - #495

Merged
kostyafarber merged 10 commits into
mainfrom
feat/restore-editor-route
Oct 3, 2026
Merged

kostyafarber merged 10 commits into
mainfrom
feat/restore-editor-route

Conversation

@kostyafarber

@kostyafarber kostyafarber commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • After a crash, forced termination or update restart, the documents that were open reopen on the next launch, each on the glyph it last showed. Cmd+Q still starts fresh, and ordinary opens still land on Home. This matches macOS document apps.
  • Crash and render-failure reopen also return to the last glyph.
  • Save as Shift keeps the open glyph. Source glyph IDs are now derived from the canonical source path and glyph name (SourceGlyphIds), so a preview and the document converted from it agree on every ID. Glyphs created while editing still get random IDs.
  • Fixes Glyphs with extra UFO layers fail to open after Save as Shift #493: converted UFO glyphs with background or support layers (A, B, E, … in MutatorSans) now open. Glyph records sent to the editor list only layers on master sources, matching getSources(); the other layers stay in the document. Before this, conversion bounced to Home, which hid the bug.
  • Where state lives:
    • Main tracks only which documents are open, as a mark on RecentDocuments. Only an ordinary quit (AppLifecycle.quitReason === "quit") or closing the document clears it.
    • Reopened windows load #/home?resume.
    • The renderer remembers each document's last glyph in localStorage (DocumentViews, keyed by DocumentId or the untitled workspace) and restores it only when it sees resume. View state is personal, so it never goes into the .shift file.

Issue

Refs #492

Closes #493

Not covered here: catalog query, filters, language and scroll, and the editor camera. Those come in a follow-up as more fields on DocumentView.

Testing

Passed:

  • pnpm typecheck, pnpm lint:check, pnpm format:check, node scripts/check-e2e-projects.mjs
  • pnpm --filter @shift/desktop test (1226 tests), including the new WorkspaceHost test that converts a preview against the native bridge and asserts every glyph keeps its ID
  • cargo test -p shift-font -p shift-backends -p shift-workspace, cargo clippy, cargo fmt
  • Manual, dev build:
    • Kill the main process with a saved document open on a glyph: it reopens on that glyph.
    • Two open documents, killed: both reopen as they were.
    • Cmd+Q, then relaunch: the launcher opens.
    • Close one of two documents, then kill: only the other reopens.
    • Kill the renderer and choose Reopen: it lands on the same glyph.
    • Save as Shift from a preview with a glyph open: it stays on that glyph.

Not run locally (left to CI):

  • New E2E tests:
    • document-crash.spec.ts: a crashed renderer reopens on its glyph.
    • document-recovery.spec.ts: a clean document reopens on its glyph after forced termination.
    • document-lifecycle.spec.ts: "Save As keeps a preview glyph route in the new workspace" replaces the old test that expected conversion to bounce to Home.
  • Existing affected E2E specs: application-quit.spec.ts (the signal-kill tests now go through the reopen path), document-recovery.spec.ts, variable-font-recovery.spec.ts.
  • Update restart: unit-tested only (AppLifecycle.quitReason and the recents open mark). No N → N+1 installed-build check.

🤖 Generated with Claude Code

A reopened crashed window loads the editor route the old window showed.
Source glyph IDs are now derived from the canonical source path and
glyph name, so a preview and the document converted from it agree on
every ID and the route survives conversion without remapping. Glyphs
created while editing still get random IDs.
…update

Documents open when Shift stops without an ordinary quit now reopen on
the next launch, as in macOS document apps: a crash, forced termination
or update restart restores them, while Cmd+Q starts fresh. Recent
documents carry an open mark that only an ordinary quit or closing the
document clears.

Each reopened window, including crash reopen, returns to the glyph it
last showed. The renderer remembers that per document in localStorage,
since view state is personal and never belongs in the .shift file, and
restores it only when main loads the window with the resume flag, so
ordinary opens still land on Home.
Comment thread apps/desktop/src/renderer/src/lib/workspace/documentViews.ts Outdated
@kostyafarber kostyafarber added the release: nightly Run a Nightly build after this pull request merges label Oct 3, 2026
@kostyafarber

Copy link
Copy Markdown
Collaborator Author

cc @teyepe this should restore windows with your opened glyphs in various scenarios, crashing/restarts/updates/saving, i'm gonna open another PR for camera and viewport and any home state (search queries, filters etc).

A UFO's background and support layers import as layer sources, which
the editor does not model, but glyph records still listed their layers.
The editor could not resolve those sources and failed to open the
glyph. Glyph records now list only layers on master sources, matching
the sources the editor sees; the other layers stay in the document.

Closes #493
Font::masters and Font::master_layers now define the sources and layers
the editor works with. The bridge reads sources, glyph records, and
glyph snapshots through them, so the renderer can no longer receive a
layer whose source it was not given. Snapshots also stop sending state
for background and support layers the editor never attaches.
@kostyafarber
kostyafarber added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 1942499 Oct 3, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: nightly Run a Nightly build after this pull request merges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Glyphs with extra UFO layers fail to open after Save as Shift

1 participant