Skip to content

Editor: unsaved work can be lost — no Save As menu item, no dirty tracking, stale window title #116

Closed

Description

@matt-edmondson

Problem

Four related file-handling gaps, all of which can cost the user work (Phase 2, item 2 of docs/ROADMAP.md).

1. "Save As" is not in the File menu

The File menu offers New / Open / Save (SchemaEditor.cs:236-248). SaveAs() exists (:323) but is only reachable indirectly: Save() falls through to it when the path is empty (:308), and the "Save Now" button in the unsaved-schema banner calls it (:454). Once a schema has a path there is no way to save a copy elsewhere.

2. No dirty tracking or unsaved-changes prompt

New() (:284) and Open() (:292) both call Reset() and replace CurrentSchema immediately. Unsaved edits are gone with no prompt. Closing the window has the same problem.

UndoRedo.MarkAsSaved() is already called on a successful save (:317), so the undo service knows whether the document is dirty — nothing reads it.

3. The window title is computed once and never updated

private static void Main(string[] _)
{
    string title = nameof(SchemaEditor);
    if (Instance.CurrentSchema is not null && !string.IsNullOrEmpty(Instance.CurrentSchemaPath))
    {
        title += $" - {Path.GetFileName(Instance.CurrentSchemaPath)}";
    }
    ImGuiApp.Start(new() { Title = title, ... });   // SchemaEditor.cs:52-66
}

The title reflects whichever schema was restored at startup, forever. Open a different file and the title still names the old one.

4. No recent-files menu

AppData.CurrentSchemaPath persists exactly one path. Reopening a recent schema means navigating the file browser every time.

Acceptance criteria

  • "Save As…" is a File menu item, always enabled when a schema is open.
  • A dirty indicator appears in the window title (e.g. a trailing *), driven off the undo service's saved state.
  • New / Open / window-close prompt to save when the schema is dirty, with Save / Discard / Cancel.
  • The window title updates whenever the open schema or its path changes.
  • A recent-files list (bounded, persisted in AppData) appears in the File menu, skipping entries that no longer exist.

Activity

  1. added
    enhancement
    on Aug 27, 2026
  2. matt-edmondson commented on Aug 28, 2026

    @matt-edmondson
    ContributorAuthor

    The two remaining bullets are unblocked upstream: ktsu-dev/ImGuiApp#341.

    It adds ImGuiApp.SetWindowTitle(string) (the config's Title is init-only and read once at window creation) and ImGuiAppConfig.OnClosing, a Func<bool> that cancels the close by returning false.

    The close hook cancels by clearing IWindow.IsClosing, which the windowing backend re-reads each iteration of the run loop — so it works on every platform, rather than being Windows-only like the existing HideOnClose, which subclasses the native window to intercept WM_CLOSE.

    Once that lands and a release carries it, the rest of this issue is small here:

    • Live window title — call SetWindowTitle from the render loop with the document name and a trailing * when UndoRedo.HasUnsavedChanges. The dirty state is already tracked and already read for the menu-bar indicator; this just sends it somewhere else too.
    • Window-close prompt — set OnClosing to return false while unsaved changes exist, raising the same Save / Discard / Cancel prompt that New and Open already use, and call ImGuiApp.Stop() when the user confirms. A modal can't be drawn from the callback itself (it returns before the next frame), so it sets the flag the existing prompt already keys off.

    Nothing else in this issue is outstanding — Save As with Ctrl+Shift+S, dirty tracking read off the undo service, New/Open prompting, the bounded recent-files list, and a guarded Exit all shipped in #125.


    Generated by Claude Code

  3. added a commit that references this issue on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions