Skip to content

feat: add SQL file open, save, and save-as (#475)#501

Merged
datlechin merged 5 commits intomainfrom
feat/sql-file-save
Mar 29, 2026
Merged

feat: add SQL file open, save, and save-as (#475)#501
datlechin merged 5 commits intomainfrom
feat/sql-file-save

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • Open .sql files via Cmd+O (NSOpenPanel)
  • Save file-backed tabs via Cmd+S (writes back to source file)
  • Save As via Cmd+Shift+S (NSSavePanel for new or untitled queries)
  • Native macOS window title bar integration: proxy icon, unsaved-changes dot
  • File-dirty tracking on query tabs
  • Fix: sourceFileURL was lost on app restart (persistence bug)

Closes #475

Changes

  • SQLFileService (new): stateless file I/O service — read, write, open panel, save panel
  • QueryTab: added savedFileContent + isFileDirty for dirty tracking
  • TabPersistenceCoordinator: fixed convertToPersistedTab() dropping sourceFileURL
  • MainContentCommandActions: extended saveChanges() decision tree, added saveFileToSourceURL(), saveFileAs(), openSQLFile(); hasUnsavedChanges now includes file dirty state
  • TableProApp: "Open File..." (Cmd+O) and "Save As..." (Cmd+Shift+S) menu items
  • KeyboardShortcutModels: new .openFile and .saveAs shortcut actions
  • MainContentView: toolbar Save button enables for file-dirty tabs; window.representedURL and window.isDocumentEdited for native title bar
  • MainEditorContentView: updates isDocumentEdited on query text change

Test plan

  • Cmd+O → NSOpenPanel appears, selecting .sql file opens it in new tab
  • Edit content in file-backed tab → title bar shows unsaved dot, Save button enables
  • Cmd+S on file-backed tab → file written to disk, dot disappears
  • Cmd+Shift+S on untitled query → NSSavePanel, file created, tab becomes file-backed
  • Cmd+click proxy icon in title bar → reveals file path in Finder
  • Close tab with unsaved file changes → confirmation dialog appears
  • Quit + relaunch → file-backed tabs restore correctly
  • Double-click .sql in Finder → opens in TablePro (existing, still works)
  • Open same file twice → deduplication (focuses existing tab)
  • Cmd+S with data grid changes → saves grid, not file (grid takes priority)

@datlechin datlechin merged commit 278ca12 into main Mar 29, 2026
2 checks passed
@datlechin datlechin deleted the feat/sql-file-save branch March 29, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL file save

1 participant