A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.
C++
v0.1.6: EE scaffolding + import/boolean/mock-data fixes + PG config getters
haidang18109258a5911766
diff --git a/windows/Gridex/Models/ChangeTracker.h b/windows/Gridex/Models/ChangeTracker.hindex 874c3e7..f628076 100644--- a/windows/Gridex/Models/ChangeTracker.h+++ b/windows/Gridex/Models/ChangeTracker.h@@ -2,7 +2,9 @@#include <string>#include <vector>#include <set>+#include <unordered_map>#include <algorithm>+#include <cwctype>#include "TableRow.h"#include "DatabaseType.h"@@ -118,11 +120,17 @@ namespace DBModelsreturn indices;}- // Generate SQL statements for all pending changes+ // Generate SQL statements for all pending changes.+ // `columnTypes` lets generators emit dialect-correct literals+ // for typed columns (e.g. boolean → unquoted TRUE/FALSE instead+ // of the text '0'/'1' that round-trips through the edit UI).+ // Safe to pass an empty map; callers who have schema info should+ // populate it from the table's ColumnInfo list.std::vector<std::wstring> generateSQL(const std::wstring& table,const std::wstring& schema,- DatabaseType dbType) const+ DatabaseType dbType,+ const std::unordered_map<std::wstring, std::wstring>& columnTypes = {}) const{std::vector<std::wstring> statements;@@ -131,10 +139,10 @@ namespace DBModelsswitch (edit.type){case EditType::Insert:- statements.push_back(generateInsert(table, schema, edit, dbType));+ statements.push_back(generateInsert(table, schema, edit, dbType, columnTypes));break;case EditType::Update:- statements.push_back(generateUpdate(table, schema, edit, dbType));+ statements.push_back(generateUpdate(table, schema, edit, dbType, columnTypes));break;case EditType::Delete:statements.push_back(generateDelete(table, schema, edit, dbType));@@ -168,6 +176,56 @@ namespace DBModelsreturn escaped;}+ // Boolean column detection. Covers the dialect-specific spellings+ // driver metadata actually hands back (PG: "boolean"/"bool";+ // MSSQL: "bit"; MySQL: "tinyint(1)"/"bool"/"boolean"; SQLite:+ // "boolean"). tinyint without (1) is a regular integer, skip.+ static bool isBooleanType(const std::wstring& dataType)+ {+ std::wstring t = dataType;+ std::transform(t.begin(), t.end(), t.begin(),+ [](wchar_t c) { return std::towlower(c); });+ // Strip size/precision so "boolean(1)" / "bit(1)" still match.+ auto paren = t.find(L'(');+ std::wstring head = (paren == std::wstring::npos) ? t : t.substr(0, paren);+ if (head == L"bool" || head == L"boolean" || head == L"bit") return true;+ // tinyint(1) is MySQL's conventional boolean carrier; plain+ // tinyint is a 1-byte int and must keep integer formatting.+ if (head == L"tinyint" && t.find(L"(1)") != std::wstring::npos) return true;+ return false;+ }++ // Map the text the grid round-trips ("0"/"1"/"t"/"f"/"true"/"false"/+ // "TRUE"/"FALSE"/"") to a dialect-appropriate unquoted boolean+ // literal. MSSQL bit wants 0/1 (no TRUE keyword); everyone else+ // accepts TRUE/FALSE.+ static std::wstring booleanLit(const std::wstring& value, DatabaseType dbType)+ {+ if (isNullCell(value)) return L"NULL";+ std::wstring v = value;+ std::transform(v.begin(), v.end(), v.begin(),+ [](wchar_t c) { return std::towlower(c); });+ const bool truthy =+ (v == L"1" || v == L"t" || v == L"true" || v == L"yes" || v == L"y");+ if (dbType == DatabaseType::MSSQLServer)+ return truthy ? L"1" : L"0";+ return truthy ? L"TRUE" : L"FALSE";+ }++ // Type-aware literal: route boolean columns through booleanLit,+ // everything else keeps the existing text-quoted behaviour.+ static std::wstring quoteLitTyped(+ const std::wstring& column,+ const std::wstring& value,+ DatabaseType dbType,+ const std::unordered_map<std::wstring, std::wstring>& columnTypes)+ {+ auto it = columnTypes.find(column);+ if (it != columnTypes.end() && isBooleanType(it->second))+ return booleanLit(value, dbType);+ return quoteLit(value);+ }+static std::wstring qualifiedTable(const std::wstring& table,const std::wstring& schema,DatabaseType dbType)@@ -194,10 +252,12 @@ namespace DBModelsreturn where;}- static std::wstring generateInsert(const std::wstring& table,- const std::wstring& schema,- const PendingEdit& edit,- DatabaseType dbType)+ static std::wstring generateInsert(+ const std::wstring& table,+ const std::wstring& schema,+ const PendingEdit& edit,+ DatabaseType dbType,+ const std::unordered_map<std::wstring, std::wstring>& columnTypes = {}){std::wstring sql = L"INSERT INTO " + qualifiedTable(table, schema, dbType) + L" (";std::wstring vals;@@ -212,7 +272,7 @@ namespace DBModelsif (!isNullCell(val) && val.empty()) continue;if (!first) { sql += L", "; vals += L", "; }sql += quoteId(col, dbType);- vals += quoteLit(val);+ vals += quoteLitTyped(col, val, dbType, columnTypes);first = false;}// All columns blank — use each dialect's all-defaults insert@@ -231,13 +291,16 @@ namespace DBModelsreturn sql;}- static std::wstring generateUpdate(const std::wstring& table,- const std::wstring& schema,- const PendingEdit& edit,- DatabaseType dbType)+ static std::wstring generateUpdate(+ const std::wstring& table,+ const std::wstring& schema,+ const PendingEdit& edit,+ DatabaseType dbType,+ const std::unordered_map<std::wstring, std::wstring>& columnTypes = {}){std::wstring sql = L"UPDATE " + qualifiedTable(table, schema, dbType) + L" SET ";- sql += quoteId(edit.column, dbType) + L" = " + quoteLit(edit.newValue);+ sql += quoteId(edit.column, dbType) + L" = "+ + quoteLitTyped(edit.column, edit.newValue, dbType, columnTypes);sql += L" WHERE " + buildWhere(edit.primaryKey, dbType);return sql;}diff --git a/windows/Gridex/Models/PostgreSQLAdapter.h b/windows/Gridex/Models/PostgreSQLAdapter.hindex e0ab5a7..cb6d9d4 100644--- a/windows/Gridex/Models/PostgreSQLAdapter.h+++ b/windows/Gridex/Models/PostgreSQLAdapter.h@@ -68,9 +68,18 @@ namespace DBModelsstd::wstring quoteSqlLiteral(const std::wstring& value) const override;std::wstring quoteSqlIdentifier(const std::wstring& name) const override;+ // Getters so hosts can open a second "side" connection with the+ // same credentials (used by the EE connection monitor to avoid+ // serializing its pg_stat_activity polling against the user's+ // foreground SQL editor queries on the primary PGconn).+ const ConnectionConfig& getConnectionConfig() const { return storedConfig_; }+ const std::wstring& getStoredPassword() const { return storedPassword_; }+private:PGconn* conn_ = nullptr;bool connected_ = false;+ ConnectionConfig storedConfig_;+ std::wstring storedPassword_;// Helper: convert wstring to UTF-8 for libpqstatic std::string toUtf8(const std::wstring& wstr);diff --git a/windows/Gridex/PostgreSQLAdapter.cpp b/windows/Gridex/PostgreSQLAdapter.cppindex eea2fb4..b7e6ff2 100644--- a/windows/Gridex/PostgreSQLAdapter.cpp+++ b/windows/Gridex/PostgreSQLAdapter.cpp@@ -87,6 +87,12 @@ namespace DBModels{disconnect();+ // Stash creds so callers can spawn side-connections (e.g. the EE+ // connection monitor needs its own PGconn so polling doesn't+ // serialize against the user's foreground queries).+ storedConfig_ = config;+ storedPassword_ = password;+// Build connection stringstd::string connStr;connStr += "host=" + toUtf8(config.host);diff --git a/windows/Gridex/SidebarPanel.cpp b/windows/Gridex/SidebarPanel.cppindex c84c742..7d70334 100644--- a/windows/Gridex/SidebarPanel.cpp+++ b/windows/Gridex/SidebarPanel.cpp@@ -204,6 +204,24 @@ namespace winrt::Gridex::implementationRenderTree();}+ // Extension hook: reveals the "⚡" action button only when a host+ // (e.g. EE WorkspacePage) has wired OnOpenConnectionMonitor. Invoked+ // by SetItems / SetDatabaseType callers after they set the callback.+ // The button click just forwards to the callback; host owns the flow.+ void SidebarPanel::MonitorButton_Click(+ winrt::Windows::Foundation::IInspectable const&,+ mux::RoutedEventArgs const&)+ {+ if (OnOpenConnectionMonitor) OnOpenConnectionMonitor();+ }++ void SidebarPanel::SetMonitorButtonVisible(bool visible)+ {+ MonitorButton().Visibility(visible+ ? mux::Visibility::Visible+ : mux::Visibility::Collapsed);+ }+bool SidebarPanel::MatchesSearch(const DBModels::SidebarItem& item) const{if (searchQuery_.empty()) return true;@@ -446,6 +464,20 @@ namespace winrt::Gridex::implementation{ if (OnImportTable) OnImportTable(exportName, exportSchema); });contextMenu.Items().Append(importItem);+ // Generate Data — optional extension hook. Item only appears+ // when a host wires OnGenerateMockData (e.g. EE build);+ // OSS build leaves callback unset → menu unchanged.+ if (item.type == DBModels::SidebarItemType::Table && OnGenerateMockData)+ {+ muxc::MenuFlyoutItem genItem;+ genItem.Text(L"Generate Data...");+ genItem.Icon(muxc::FontIcon());+ genItem.Icon().as<muxc::FontIcon>().Glyph(L"\xE8BD"); // AutoFillTemplate+ genItem.Click([this, exportName, exportSchema](auto&&, auto&&)+ { if (OnGenerateMockData) OnGenerateMockData(exportName, exportSchema); });+ contextMenu.Items().Append(genItem);+ }+// Truncate + Delete — destructive. Only offered for// real tables (not views) since views can't be truncated// and DROP VIEW needs a different code path. Host showsdiff --git a/windows/Gridex/SidebarPanel.h b/windows/Gridex/SidebarPanel.hindex 7567ff7..3138146 100644--- a/windows/Gridex/SidebarPanel.h+++ b/windows/Gridex/SidebarPanel.h@@ -40,6 +40,19 @@ namespace winrt::Gridex::implementationstd::function<void(const std::wstring& tableName,const std::wstring& schema)> OnImportTable;+ // Extension hook: generic "Generate Data..." menu item on SQL tables.+ // Hidden from the menu when callback is unset (keeps OSS menu clean).+ std::function<void(const std::wstring& tableName,+ const std::wstring& schema)> OnGenerateMockData;++ // Extension hook: sidebar header "⚡" action button (EE-only:+ // opens the Realtime Connection Monitor overlay). Button is+ // Collapsed unless the host wires this callback. Host calls+ // SetMonitorButtonVisible(true) after the Postgres connection+ // is active.+ std::function<void()> OnOpenConnectionMonitor;+ void SetMonitorButtonVisible(bool visible);+// Callback for "Show ER Diagram" on a Database/Schema groupstd::function<void(const std::wstring& schema)> OnShowERDiagram;@@ -79,6 +92,9 @@ namespace winrt::Gridex::implementationvoid SearchBox_TextChanged(winrt::Windows::Foundation::IInspectable const& sender,winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);+ void MonitorButton_Click(+ winrt::Windows::Foundation::IInspectable const& sender,+ winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);private:std::vector<DBModels::SidebarItem> items_;diff --git a/windows/Gridex/SidebarPanel.xaml b/windows/Gridex/SidebarPanel.xamlindex 38c6c31..d6e2cb9 100644--- a/windows/Gridex/SidebarPanel.xaml+++ b/windows/Gridex/SidebarPanel.xaml@@ -13,12 +13,14 @@<RowDefinition Height="Auto" /></Grid.RowDefinitions>- <!-- Tab bar: Items | Queries | History -->+ <!-- Tab bar: Items | Queries | History | (spacer) | Action slot --><Grid Grid.Row="0" Padding="8,6"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" />+ <ColumnDefinition Width="*" />+ <ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><ToggleButton x:Name="ItemsTab" Grid.Column="0"IsChecked="True" Padding="6,4"@@ -41,6 +43,17 @@ToolTipService.ToolTip="Query History"><FontIcon Glyph="" FontSize="13" /></ToggleButton>+ <!-- Right-aligned action button (EE: opens Realtime Connection+ Monitor). Hidden when no callback wired so OSS build has+ no dead button. -->+ <Button x:Name="MonitorButton" Grid.Column="4"+ Padding="6,4"+ Background="Transparent" BorderThickness="0"+ Visibility="Collapsed"+ Click="MonitorButton_Click"+ ToolTipService.ToolTip="Realtime Connection Monitor">+ <FontIcon Glyph="" FontSize="13" />+ </Button></Grid><!-- Search box -->diff --git a/windows/Gridex/WorkspacePage.cpp b/windows/Gridex/WorkspacePage.cppindex 7c82e54..47f875b 100644--- a/windows/Gridex/WorkspacePage.cpp+++ b/windows/Gridex/WorkspacePage.cpp@@ -2,6 +2,7 @@#include "xaml-includes.h"#include <winrt/Windows.UI.Text.h>#include <winrt/Windows.System.h>+#include <unordered_map>#include "WorkspacePage.h"#include "SidebarPanel.h"#include "TabBarControl.h"@@ -17,6 +18,14 @@#include "Models/ERDiagramService.h"#include "Models/AppSettings.h"#include "App.xaml.h"+#ifdef GRIDEX_ENTERPRISE+#include "row-relationship-graph/EERowRelationshipDialog.h"+#include "mock-data-generator/EEMockDataConfigDialog.h"+#include "mock-data-generator/EEMockDataProgressDialog.h"+#include "mock-data-generator/EEMockDataHeuristics.h"+#include "mock-data-generator/EEMockDataGeneratorService.h"+#include "connection-monitor/EEConnectionMonitorPage.h"+#endif#include <winrt/Microsoft.UI.Xaml.Controls.h>#include <winrt/Microsoft.UI.Input.h>#include <winrt/Microsoft.Web.WebView2.Core.h>@@ -159,12 +168,18 @@ namespace winrt::Gridex::implementation// DataGrid callbacksDataGrid().as<DataGridView>()->OnRowSelected = [this](int rowIndex){- if (rowIndex >= 0 && rowIndex < static_cast<int>(state_.currentData.rows.size()))+ const bool valid = rowIndex >= 0+ && rowIndex < static_cast<int>(state_.currentData.rows.size());+ if (valid){Details().as<DetailsPanel>()->ShowRow(state_.currentData.columnNames,state_.currentData.rows[rowIndex]);}+ // Duplicate only makes sense when a row is selected; toggling+ // the button here keeps the enable state in sync with grid+ // selection without a separate subscription.+ DuplicateRowBtn().IsEnabled(valid);};// Delete key on grid → same as Delete toolbar button (mark row@@ -190,6 +205,12 @@ namespace winrt::Gridex::implementationOnTableSelected(refTable, currentSchema_);};+ // Enterprise "View Relationship" menu item is wired in+ // InitializeConnection (per-connection) instead of here, so that+ // switching from a relational DB to Mongo/Redis actually toggles+ // the menu item's visibility. At constructor time we don't yet+ // know the real databaseType.+// Wire structure view ALTER applyStructure().as<StructureView>()->OnApplyAlter = [this](const std::vector<std::wstring>& sqls){@@ -820,6 +841,44 @@ namespace winrt::Gridex::implementationImportDataAsync(tableName, schema);};+#ifdef GRIDEX_ENTERPRISE+ // EE: right-click table → Generate Data. Wired only on SQL+ // databases since the feature requires INSERT + transactions.+ {+ auto dbType = state_.connection.databaseType;+ bool isSql =+ dbType == DBModels::DatabaseType::PostgreSQL ||+ dbType == DBModels::DatabaseType::MySQL ||+ dbType == DBModels::DatabaseType::SQLite;+ if (isSql) {+ Sidebar().as<SidebarPanel>()->OnGenerateMockData =+ [this](const std::wstring& tableName,+ const std::wstring& schema)+ {+ GenerateMockDataAsync(tableName, schema);+ };+ } else {+ Sidebar().as<SidebarPanel>()->OnGenerateMockData = nullptr;+ }+ }++ // EE: sidebar header "⚡" → Realtime Connection Monitor. Postgres+ // only for v1 (the feature depends on pg_stat_activity shape).+ {+ auto dbType = state_.connection.databaseType;+ bool isPg = dbType == DBModels::DatabaseType::PostgreSQL;+ auto sb = Sidebar().as<SidebarPanel>();+ if (isPg) {+ sb->OnOpenConnectionMonitor = [this]() {+ OpenConnectionMonitor();+ };+ } else {+ sb->OnOpenConnectionMonitor = nullptr;+ }+ sb->SetMonitorButtonVisible(isPg);+ }+#endif+// Sidebar ER diagram — right-click Database/Schema group → Show ER DiagramSidebar().as<SidebarPanel>()->OnShowERDiagram = [this](const std::wstring& schema){@@ -990,6 +1049,9 @@ namespace winrt::Gridex::implementationAddRowBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&){ AddNewRow(); });+ DuplicateRowBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)+ { DuplicateSelectedRow(); });+PrevPageBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&){ PrevPage(); });@@ -1350,6 +1412,123 @@ namespace winrt::Gridex::implementationStatusBar().as<StatusBarControl>()->SetStatus(L"Disconnected", L"--", 0, 0.0, 0.0);}++#ifdef GRIDEX_ENTERPRISE+ // Enterprise: wire "View Relationship" based on the ACTIVE+ // connection. Runs on every switch so moving from PG to Mongo+ // clears the callback and DataGridView's Opening handler+ // collapses the menu item (gate: callback != nullptr).+ {+ auto dbType = state_.connection.databaseType;+ bool isRelational =+ dbType == DBModels::DatabaseType::PostgreSQL ||+ dbType == DBModels::DatabaseType::MySQL ||+ dbType == DBModels::DatabaseType::SQLite ||+ dbType == DBModels::DatabaseType::MSSQLServer;++ if (isRelational)+ {+ DataGrid().as<DataGridView>()->OnViewRelationshipsRequested = [this]()+ {+ int rowIdx = DataGrid().as<DataGridView>()->GetSelectedRowIndex();+ if (rowIdx < 0) return;+ if (rowIdx >= static_cast<int>(state_.currentData.rows.size())) return;+ if (!connMgr_.isConnected()) return;++ std::wstring table, schema;+ for (const auto& t : state_.tabs)+ {+ if (t.id == state_.activeTabId+ && t.type == DBModels::TabType::DataGrid)+ {+ table = t.tableName;+ schema = t.schema.empty() ? currentSchema_ : t.schema;+ break;+ }+ }+ if (table.empty()) return;++ auto adapter = connMgr_.getActiveAdapter();+ if (!adapter) return;++ ::Gridex::EE::RowRelationshipGraph::BuildInput input;+ input.adapter = adapter;+ input.dbType = state_.connection.databaseType;+ input.schema = schema;+ input.table = table;+ input.columns = state_.currentColumns;+ input.rowValues = state_.currentData.rows[rowIdx];++ auto projected = winrt::make<+ winrt::Gridex::implementation::EERowRelationshipDialog>();+ auto impl = winrt::get_self<+ winrt::Gridex::implementation::EERowRelationshipDialog>(projected);+ impl->SetInput(std::move(input));++ // Inline overlay inside ContentArea — feels like a+ // workspace page rather than a popup. Capture current+ // visibilities + chrome widths so we can restore them+ // after the user closes the view.+ auto contentArea = ContentArea();++ struct LayoutSnapshot+ {+ std::vector<std::pair<mux::UIElement, mux::Visibility>> children;+ double sidebarWidth = 0;+ double detailsWidth = 0;+ mux::Visibility tabBarVis = mux::Visibility::Visible;+ };+ auto snapshot = std::make_shared<LayoutSnapshot>();+ for (auto const& child : contentArea.Children())+ {+ if (auto fe = child.try_as<mux::UIElement>())+ snapshot->children.push_back({ fe, fe.Visibility() });+ }+ snapshot->sidebarWidth = SidebarColumn().Width().Value;+ snapshot->detailsWidth = DetailsColumn().Width().Value;+ snapshot->tabBarVis = TabBar().Visibility();++ // Hide everything else in ContentArea; collapse side+ // panels so the diagram uses the full width. Keep+ // TopToolbar + StatusBar so the connection name is+ // still visible.+ for (auto& [child, _] : snapshot->children)+ child.Visibility(mux::Visibility::Collapsed);+ SidebarColumn().Width(mux::GridLengthHelper::FromPixels(0));+ DetailsColumn().Width(mux::GridLengthHelper::FromPixels(0));+ TabBar().Visibility(mux::Visibility::Collapsed);++ // Close handler restores the captured layout and+ // detaches the UserControl (triggers its Unloaded →+ // cleanup of the SVG temp file).+ impl->OnCloseRequested = [this, snapshot, projected]()+ {+ auto contentArea = ContentArea();+ uint32_t idx = 0;+ if (contentArea.Children().IndexOf(projected, idx))+ contentArea.Children().RemoveAt(idx);++ for (auto& [child, vis] : snapshot->children)+ child.Visibility(vis);+ SidebarColumn().Width(mux::GridLengthHelper::FromPixels(+ snapshot->sidebarWidth > 0 ? snapshot->sidebarWidth : 280));+ DetailsColumn().Width(mux::GridLengthHelper::FromPixels(+ snapshot->detailsWidth > 0 ? snapshot->detailsWidth : 260));+ TabBar().Visibility(snapshot->tabBarVis);+ };++ contentArea.Children().Append(projected);+ };+ }+ else+ {+ // Mongo / Redis: clear the callback so the menu item+ // returns to Collapsed after a switch away from a+ // relational connection.+ DataGrid().as<DataGridView>()->OnViewRelationshipsRequested = nullptr;+ }+ }+#endif // GRIDEX_ENTERPRISE}// ── Sidebar Data Loading ────────────────────────────@@ -1921,6 +2100,52 @@ namespace winrt::Gridex::implementationUpdatePendingUI();}+ // Clone the currently-selected grid row as a pending INSERT so the+ // user can tweak a couple fields (e.g. unique name) before commit.+ // Mirrors AddNewRow for skipped columns — IDENTITY, SQL-expression+ // PK defaults, and expression defaults like now()/nextval() stay+ // server-generated so the copy doesn't collide with the source.+ void WorkspacePage::DuplicateSelectedRow()+ {+ if (state_.currentColumns.empty()) return;+ auto* sel = DataGrid().as<DataGridView>()->GetSelectedRow();+ if (!sel) return;++ DBModels::TableRow newRow;+ for (auto& col : state_.currentColumns)+ {+ if (col.comment == L"IDENTITY") continue;+ if (col.isPrimaryKey && IsSqlExpression(col.defaultValue)) continue;+ if (IsSqlExpression(col.defaultValue)) continue;++ auto it = sel->find(col.name);+ if (it != sel->end())+ newRow[col.name] = it->second; // copy source value as-is (incl. NULL sentinel)+ else if (!col.defaultValue.empty() && col.defaultValue != L"NULL")+ newRow[col.name] = col.defaultValue;+ else if (col.nullable)+ newRow[col.name] = L"NULL";+ else+ newRow[col.name] = L"";+ }++ // Display row carries the auto-gen placeholders (e.g.+ // "gen_random_uuid()") for skipped columns so the new grid row+ // visually matches a fresh insert.+ DBModels::TableRow displayRow = newRow;+ for (auto& col : state_.currentColumns)+ {+ if (displayRow.find(col.name) == displayRow.end())+ displayRow[col.name] = col.defaultValue;+ }++ state_.currentData.rows.push_back(displayRow);+ int newRowIndex = static_cast<int>(state_.currentData.rows.size()) - 1;+ changeTracker_.trackInsert(newRow, newRowIndex);+ DataGrid().as<DataGridView>()->SetData(state_.currentData);+ UpdatePendingUI();+ }+void WorkspacePage::CommitChanges(){// Flush any in-flight inline cell edit before reading the@@ -1956,8 +2181,16 @@ namespace winrt::Gridex::implementationstd::vector<std::wstring> statements;if (!isMongo){+ // Thread a column-name → dataType map so ChangeTracker can+ // emit dialect-correct boolean literals (unquoted TRUE/FALSE,+ // or 0/1 for MSSQL bit) instead of the text '0'/'1' the grid+ // round-trips for checkbox-style cells.+ std::unordered_map<std::wstring, std::wstring> colTypes;+ colTypes.reserve(state_.currentColumns.size());+ for (auto& c : state_.currentColumns)+ colTypes[c.name] = c.dataType;statements = changeTracker_.generateSQL(- tableName, schema, state_.connection.databaseType);+ tableName, schema, state_.connection.databaseType, colTypes);if (statements.empty()) return;preview = std::to_wstring(statements.size()) + L" statement(s):\n\n";for (auto& s : statements) preview += s + L"\n";@@ -4187,4 +4420,194 @@ g.er-selected > foreignObject > div.er-card{state_.statusRenderTimeMs);UpdatePaginationUI();}++#ifdef GRIDEX_ENTERPRISE+ // Full-page overlay host for the Realtime Connection Monitor.+ // Same snapshot-and-restore pattern as the row-relationship diagram+ // so returning from the monitor drops the user back in their tab+ // layout exactly as they left it.+ void WorkspacePage::OpenConnectionMonitor()+ {+ if (!connMgr_.isConnected()) return;+ auto adapter = connMgr_.getActiveAdapter();+ if (!adapter) return;++ auto projected = winrt::make<+ winrt::Gridex::implementation::EEConnectionMonitorPage>();+ auto impl = winrt::get_self<+ winrt::Gridex::implementation::EEConnectionMonitorPage>(projected);+ impl->SetAdapter(adapter.get());++ auto contentArea = ContentArea();++ struct LayoutSnapshot+ {+ std::vector<std::pair<mux::UIElement, mux::Visibility>> children;+ double sidebarWidth = 0;+ double detailsWidth = 0;+ mux::Visibility tabBarVis = mux::Visibility::Visible;+ };+ auto snapshot = std::make_shared<LayoutSnapshot>();+ for (auto const& child : contentArea.Children()) {+ if (auto fe = child.try_as<mux::UIElement>())+ snapshot->children.push_back({ fe, fe.Visibility() });+ }+ snapshot->sidebarWidth = SidebarColumn().Width().Value;+ snapshot->detailsWidth = DetailsColumn().Width().Value;+ snapshot->tabBarVis = TabBar().Visibility();++ for (auto& [child, _] : snapshot->children)+ child.Visibility(mux::Visibility::Collapsed);+ DetailsColumn().Width(mux::GridLengthHelper::FromPixels(0));+ TabBar().Visibility(mux::Visibility::Collapsed);++ impl->OnCloseRequested = [this, snapshot, projected]() {+ auto ca = ContentArea();+ uint32_t idx = 0;+ if (ca.Children().IndexOf(projected, idx))+ ca.Children().RemoveAt(idx);+ for (auto& [child, vis] : snapshot->children)+ child.Visibility(vis);+ DetailsColumn().Width(mux::GridLengthHelper::FromPixels(+ snapshot->detailsWidth > 0 ? snapshot->detailsWidth : 260));+ TabBar().Visibility(snapshot->tabBarVis);+ };++ contentArea.Children().Append(projected);+ }+#endif++#ifdef GRIDEX_ENTERPRISE+ // ── EE: Mock Data Generator orchestration ─────────────────+ // Flow: describeTable → seed heuristic specs → show config dialog →+ // if Start pressed, run service + show progress dialog → on finish,+ // show error or reload the grid.+ winrt::fire_and_forget WorkspacePage::GenerateMockDataAsync(+ std::wstring tableName, std::wstring schema)+ {+ if (!connMgr_.isConnected()) co_return;+ auto adapter = connMgr_.getActiveAdapter();+ if (!adapter) co_return;++ // Introspect columns. Skip if the table disappeared or returned empty.+ std::vector<DBModels::ColumnInfo> columns;+ std::wstring describeErr;+ try { columns = adapter->describeTable(tableName, schema); }+ catch (const std::exception& e) {+ describeErr = std::wstring(e.what(), e.what() + std::strlen(e.what()));+ }+ catch (...) { describeErr = L"Unknown error describing table."; }+ if (!describeErr.empty()) {+ muxc::ContentDialog err;+ err.Title(winrt::box_value(winrt::hstring{L"Can't describe table"}));+ err.Content(winrt::box_value(winrt::hstring{describeErr}));+ err.CloseButtonText(L"OK");+ err.XamlRoot(this->XamlRoot());+ co_await err.ShowAsync();+ co_return;+ }+ if (columns.empty()) co_return;++ // Heuristic-seed specs.+ std::vector<::Gridex::EE::MockData::EEColumnSpec> specs;+ specs.reserve(columns.size());+ for (const auto& c : columns)+ specs.push_back(::Gridex::EE::MockData::EEMockDataHeuristics::toSpec(c));++ // Build config dialog.+ auto configCtrl = winrt::make<+ winrt::Gridex::implementation::EEMockDataConfigDialog>();+ auto configImpl = winrt::get_self<+ winrt::Gridex::implementation::EEMockDataConfigDialog>(configCtrl);+ configImpl->SetContext(schema, tableName, std::move(specs));++ muxc::ContentDialog cfgDlg;+ cfgDlg.Title(winrt::box_value(winrt::hstring{L"Generate Mock Data"}));+ cfgDlg.Content(configCtrl);+ cfgDlg.PrimaryButtonText(L"Start");+ cfgDlg.CloseButtonText(L"Cancel");+ cfgDlg.DefaultButton(muxc::ContentDialogButton::Primary);+ cfgDlg.XamlRoot(this->XamlRoot());+ // ContentDialog caps width via a theme resource; override so the+ // column list + throttle NumberBoxes don't clip on the right.+ cfgDlg.Resources().Insert(+ winrt::box_value(winrt::hstring{L"ContentDialogMaxWidth"}),+ winrt::box_value(820.0));++ // Intercept Primary: validate + stop close if invalid.+ auto cfgDeferralToken = cfgDlg.PrimaryButtonClick(+ [configImpl](auto const& sender, auto const& args)+ {+ if (!configImpl->BuildConfig().has_value()) {+ args.Cancel(true); // keep dialog open; error shown inline+ }+ });++ auto result = co_await cfgDlg.ShowAsync();+ cfgDlg.PrimaryButtonClick(cfgDeferralToken);+ if (result != muxc::ContentDialogResult::Primary) co_return;++ auto cfgOpt = configImpl->BuildConfig();+ if (!cfgOpt) co_return;++ // Start service (static) — schedules UI-thread DispatcherQueueTimer.+ auto state = ::Gridex::EE::MockData::EEMockDataGeneratorService::start(+ adapter.get(), *cfgOpt);++ // Show progress dialog.+ auto progCtrl = winrt::make<+ winrt::Gridex::implementation::EEMockDataProgressDialog>();+ auto progImpl = winrt::get_self<+ winrt::Gridex::implementation::EEMockDataProgressDialog>(progCtrl);+ progImpl->Attach(state);++ muxc::ContentDialog progDlg;+ progDlg.Title(winrt::box_value(winrt::hstring{L"Generating"}));+ progDlg.Content(progCtrl);+ progDlg.PrimaryButtonText(L"Cancel");+ progDlg.DefaultButton(muxc::ContentDialogButton::Primary);+ progDlg.XamlRoot(this->XamlRoot());++ // Primary button = Cancel while running; changes to "Close" on finish.+ auto cancelToken = progDlg.PrimaryButtonClick(+ [progImpl](auto const&, auto const& args)+ {+ if (!progImpl->IsFinished()) {+ progImpl->RequestCancel();+ args.Cancel(true); // keep dialog open; worker still draining+ }+ });++ progImpl->OnFinished = [&progDlg]()+ {+ // Job done: swap Cancel → Close so the dialog can be dismissed.+ // We deliberately don't auto-Hide; on error the user reads the+ // inline message first, then clicks Close.+ progDlg.PrimaryButtonText(L"Close");+ };++ co_await progDlg.ShowAsync();+ progDlg.PrimaryButtonClick(cancelToken);++ auto err = state->readError();+ if (!err.empty()) {+ muxc::ContentDialog eDlg;+ eDlg.Title(winrt::box_value(winrt::hstring{L"Generation failed"}));+ eDlg.Content(winrt::box_value(winrt::hstring{err}));+ eDlg.CloseButtonText(L"OK");+ eDlg.XamlRoot(this->XamlRoot());+ co_await eDlg.ShowAsync();+ co_return;+ }++ // Refresh the grid if the user is currently viewing the target table.+ if (state_.connection.databaseType != DBModels::DatabaseType::Redis &&+ state_.statusSchema.empty() == false &&+ state_.statusSchema == schema) {+ ReloadCurrentTable();+ } else {+ ReloadCurrentTable();+ }+ }+#endif}diff --git a/windows/Gridex/WorkspacePage.h b/windows/Gridex/WorkspacePage.hindex 947e92e..567f056 100644--- a/windows/Gridex/WorkspacePage.h+++ b/windows/Gridex/WorkspacePage.h@@ -116,6 +116,7 @@ namespace winrt::Gridex::implementation// ── CRUD Operations ─────────────────────────void DeleteSelectedRow();void AddNewRow();+ void DuplicateSelectedRow();void CommitChanges();void DiscardChanges();DBModels::TableRow ExtractPrimaryKey(int rowIndex);@@ -173,6 +174,22 @@ namespace winrt::Gridex::implementationwinrt::fire_and_forget FlushRedisDbAsync();winrt::fire_and_forget BrowseRedisKeysAsync();+#ifdef GRIDEX_ENTERPRISE+ // ── EE Mock Data Generator ────────────────+ // Opens config dialog, spawns the service, shows progress, and+ // reloads the grid on success. Gated because it pulls EE-only+ // headers; the callback itself is never wired in OSS so the+ // menu entry is hidden there.+ winrt::fire_and_forget GenerateMockDataAsync(+ std::wstring tableName, std::wstring schema);++ // ── EE Realtime Connection Monitor ─────────+ // Mounts the WebView2-hosted monitor as a full-page overlay,+ // mirroring EERowRelationshipDialog. Postgres-only entry — the+ // sidebar button is hidden on other DB types.+ void OpenConnectionMonitor();+#endif+// Shared progress state for dump/restore background jobsstruct DumpRestoreJobState{diff --git a/windows/Gridex/WorkspacePage.xaml b/windows/Gridex/WorkspacePage.xamlindex e17a586..93f77c4 100644--- a/windows/Gridex/WorkspacePage.xaml+++ b/windows/Gridex/WorkspacePage.xaml@@ -333,16 +333,29 @@Padding="10,4" /></StackPanel>- <!-- + Row Button -->- <Button x:Name="AddRowBtn" Grid.Column="1" Margin="8,0,0,0"- Padding="6,4"- Background="Transparent" BorderThickness="0"- ToolTipService.ToolTip="Add Row">- <StackPanel Orientation="Horizontal" Spacing="4">- <FontIcon Glyph="" FontSize="10" />- <TextBlock Text="Row" FontSize="11" />- </StackPanel>- </Button>+ <!-- + Row / Duplicate Row Buttons -->+ <StackPanel Grid.Column="1" Orientation="Horizontal"+ Spacing="2" Margin="8,0,0,0">+ <Button x:Name="AddRowBtn"+ Padding="6,4"+ Background="Transparent" BorderThickness="0"+ ToolTipService.ToolTip="Add Row">+ <StackPanel Orientation="Horizontal" Spacing="4">+ <FontIcon Glyph="" FontSize="10" />+ <TextBlock Text="Row" FontSize="11" />+ </StackPanel>+ </Button>+ <Button x:Name="DuplicateRowBtn"+ Padding="6,4"+ Background="Transparent" BorderThickness="0"+ IsEnabled="False"+ ToolTipService.ToolTip="Duplicate selected row (pending — edit before commit)">+ <StackPanel Orientation="Horizontal" Spacing="4">+ <FontIcon Glyph="" FontSize="10" />+ <TextBlock Text="Duplicate" FontSize="11" />+ </StackPanel>+ </Button>+ </StackPanel><!-- Pagination --><StackPanel Grid.Column="3" Orientation="Horizontal" Spacing="4"diff --git a/windows/README.md b/windows/README.mdindex a0fe881..0f0630a 100644--- a/windows/README.md+++ b/windows/README.md@@ -66,29 +66,29 @@ windows/scripts/**Git Bash / MSYS2**:```bashcd /e/dev/be/vura-powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-and-pack.ps1 -Version "0.1.5"+powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-and-pack.ps1 -Version "0.1.6"```**PowerShell (5.1 / 7+)**:```powershellcd E:\dev\be\vura-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.5"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.6"```**CMD**:```cmdcd /d E:\dev\be\vura-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.5"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.6"```Script sẽ:1. Cài/update `vpk` global tool (skip nếu đã có)-2. Build `Gridex.exe` unpackaged, stamp version `0.1.5` vào About section-3. Pack thành `Setup.exe` qua Velopack với metadata version `0.1.5`+2. Build `Gridex.exe` unpackaged, stamp version `0.1.6` vào About section+3. Pack thành `Setup.exe` qua Velopack với metadata version `0.1.6`**Output**: `windows/Releases/`- `Gridex-stable-Setup.exe` — installer user-facing-- `Gridex-0.1.5-stable-full.nupkg` — package Velopack+- `Gridex-0.1.6-stable-full.nupkg` — package Velopack- `releases.stable.json`, `RELEASES-stable` — feed manifests- `Gridex-stable-Portable.zip` — bản portable@@ -140,7 +140,7 @@ powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\install-vppowershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-unpackaged.ps1# Build với version cụ thể — About section hiện đúng string-powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-unpackaged.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-unpackaged.ps1 -Version "0.1.6-test"```**PowerShell**:@@ -149,7 +149,7 @@ powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-unpapowershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1# Build với version cụ thể — About section hiện đúng string-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1 -Version "0.1.6-test"```**CMD**:@@ -158,7 +158,7 @@ REM Dev build — About section hiện "0.0.0-dev"powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1REM Build với version cụ thể — About section hiện đúng string-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-unpackaged.ps1 -Version "0.1.6-test"```Chạy trực tiếp exe để test nhanh mà không cần cài installer:@@ -177,17 +177,17 @@ Chạy trực tiếp exe để test nhanh mà không cần cài installer:**Git Bash / MSYS2**:```bash-powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/pack-velopack.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/pack-velopack.ps1 -Version "0.1.6-test"```**PowerShell**:```powershell-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\pack-velopack.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\pack-velopack.ps1 -Version "0.1.6-test"```**CMD**:```cmd-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\pack-velopack.ps1 -Version "0.1.5-test"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\pack-velopack.ps1 -Version "0.1.6-test"```**Lưu ý**: `-Version` truyền vào `pack-velopack.ps1` **phải khớp** với `-Version` truyền vào `build-unpackaged.ps1`, nếu không thì Velopack sẽ in một số, còn About section của app sẽ in số khác. Dùng `build-and-pack.ps1` ở trên để tránh trường hợp này.@@ -196,10 +196,10 @@ powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\pack-velop- `windows/Gridex/GridexVersion.h` — include unconditional file generated- `windows/Gridex/GridexVersion.generated.h` — **auto-generated, gitignored**, do `build-unpackaged.ps1` ghi mỗi lần chạy- - Có `-Version` → `#define GRIDEX_VERSION L"0.1.5"`+ - Có `-Version` → `#define GRIDEX_VERSION L"0.1.6"`- Không `-Version` → `#define GRIDEX_VERSION L"0.0.0-dev"`- `windows/Gridex/SettingsPage.xaml.cpp` — đọc `GRIDEX_VERSION` và set vào `VersionText` text block-- CI workflow `.github/workflows/windows-release.yml` tự parse version từ git tag (`v0.1.5` → `0.1.5`) và forward sang script+- CI workflow `.github/workflows/windows-release.yml` tự parse version từ git tag (`v0.1.6` → `0.1.6`) và forward sang scriptBuild script chỉ rewrite `GridexVersion.generated.h` khi nội dung khác → không force recompile vô ích.@@ -209,17 +209,17 @@ Mặc định Velopack dùng channel `stable`. Nếu muốn phát hành kênh ri**Git Bash / MSYS2**:```bash-powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-and-pack.ps1 -Version "0.1.5-beta.1" -Channel "beta"+powershell -NoProfile -ExecutionPolicy Bypass -File ./windows/scripts/build-and-pack.ps1 -Version "0.1.6-beta.1" -Channel "beta"```**PowerShell**:```powershell-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.5-beta.1" -Channel "beta"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.6-beta.1" -Channel "beta"```**CMD**:```cmd-powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.5-beta.1" -Channel "beta"+powershell -NoProfile -ExecutionPolicy Bypass -File .\windows\scripts\build-and-pack.ps1 -Version "0.1.6-beta.1" -Channel "beta"```Output sẽ là `Gridex-beta-Setup.exe` + `releases.beta.json` — auto-updater phân luồng theo channel.@@ -253,7 +253,7 @@ Chưa cài đủ vcpkg deps. Xem section "Cài vcpkg deps" ở đầu file.### Gridex.exe crash ngay khi khởi động với `MSVCP140.dll not found`Máy thiếu VC++ 2015-2022 Redistributable. Script `build-unpackaged.ps1` tự copy CRT DLLs vào output folder → nếu vẫn lỗi thì check VS install path / logs script.-### Setup.exe cài xong nhưng About hiện `0.0.0-dev` dù pack với `-Version 0.1.5`+### Setup.exe cài xong nhưng About hiện `0.0.0-dev` dù pack với `-Version 0.1.6`Dùng `build-and-pack.ps1` thay vì gọi `pack-velopack.ps1` trực tiếp. Trường hợp chạy `pack-velopack.ps1` với version khác version lúc build `Gridex.exe` → xóa `windows\Gridex\x64\Release\` rồi build lại đúng thứ tự.### Lỗi `pwsh.exe exited with code 9009` trong vcpkg applocal step@@ -288,8 +288,8 @@ del /q .\windows\Gridex\GridexVersion.generated.hCI tự chạy khi push tag matching `v*.*.*`:```bash-git tag v0.1.5-git push origin v0.1.5+git tag v0.1.6+git push origin v0.1.6```GitHub Actions workflow `windows-release.yml` sẽ tự build + pack + upload assets lên GitHub Release. Xem chi tiết ở `.github/workflows/windows-release.yml`.