fix(editor): convert create-table tab in place on commit and wire Cmd+S#1664
Conversation
401b220 to
38a4e11
Compare
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 401b2204fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| || tab.hasUserActiveSort { | ||
| return false | ||
| } | ||
| if tab.tabType == .createTable { return true } |
There was a problem hiding this comment.
Protect populated Create Table drafts from sidebar navigation
When the active tab is a Create Table tab with a filled-in draft, this unconditional true makes any sidebar table open reuse the tab and replace it with the clicked table. That loses the user's in-progress table definition without a prompt; before this change, the same sidebar navigation would open/select a table tab without treating the create-table draft as disposable. Consider only forcing reuse for the post-create flow, or gating this on !toolbarState.hasCreateTablePending/an explicit discard confirmation.
Useful? React with 👍 / 👎.
38a4e11 to
5685bdb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5685bdb1c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| || tab.hasUserActiveSort { | ||
| return false | ||
| } | ||
| if tab.tabType == .createTable { return !toolbarState.hasCreateTablePending } |
There was a problem hiding this comment.
Protect incomplete create-table drafts before reuse
When the selected Create Table tab is not yet ready to create, this returns true, so sidebar navigation replaces the tab in place. A user who has typed a table name or started a column but has not filled a valid name+type yet has hasCreateTablePending == false, and that draft is silently discarded when they click a table in the sidebar. Consider tracking draft dirtiness separately from create readiness, or only reusing truly empty create-table tabs.
Useful? React with 👍 / 👎.
Problem
Two defects in the create-table flow:
Root causes
isActiveTabReusablehad no case for.createTable, soopenTableTab()skipped the in-placereplaceTabContentpath and spawned a new NSWindow tab. The refresh also fired before the tab transform, so the refresh subscriber bailed on the still-.createTabletab.updateToolbarPendingStateknew nothing about them), andsaveChanges()had no.createTablebranch.Fix
.createTabletabs are now reusable: on success the creation tab converts in place into the new table's data tab (one tab, same window), matching TablePlus behavior and HIG Save semantics (commit in place, never spawn a second surface).createTable()now transforms the tab before sending the refresh, so the sidebar and grid pick up the new table immediately.CreateTableViewregisters acreateTableActionon the coordinator (same pattern asStructureViewActionHandler), and ahasCreateTablePendingflag enables the menu item only when the form has a name, at least one valid column, and no create in flight. The flag observes the readiness condition itself, so edits made in any order (name first or columns first) update the menu state.CreateTableActionHandlerheld weakly by the coordinator (same lifetime semantics asStructureViewActionHandler), andcreateTable()guards against reentry while a create is in flight.Error handling
A failed CREATE TABLE (SQL error, duplicate name) keeps the creation tab untouched; the error path never reaches the tab conversion.
Tests
OpenTableTabTests: createTable tab is reusable;openTableTabconverts it in place.CommandActionsDispatchTests:saveChanges()dispatchescreateTableActionfor createTable tabs (and is a no-op without one).PendingChangeTriggerTests: equality covers the new field (suite rewritten with a factory helper to stay within line limits).Note:
insertQueryFromAI_appendsToExistingfails at origin/main too (stale test expecting append behavior the app no longer has); verified pre-existing with a clean stash run, not touched here.UI automation: the full flow needs a live database connection, so no deterministic UI test was added.
Docs
CHANGELOG under Unreleased (Fixed),
docs/features/keyboard-shortcuts.mdx,docs/features/table-structure.mdx.Out of scope
Cmd+W on a creation tab with unsaved work still closes silently (pre-existing: the unsaved-changes check never flags creation tabs). Doing it properly needs an async create-then-close flow; can follow up separately.