Skip to content

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++

feat(windows): sidebar header action slot + ConnectionMonitor hook

DangHuynh3ec9e412ba3f
diff --git a/windows/Gridex/SidebarPanel.cpp b/windows/Gridex/SidebarPanel.cpp
index f5ad9c8..7d70334 100644
--- a/windows/Gridex/SidebarPanel.cpp
+++ b/windows/Gridex/SidebarPanel.cpp
@@ -204,6 +204,24 @@ namespace winrt::Gridex::implementation
RenderTree();
}
+ // 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;
diff --git a/windows/Gridex/SidebarPanel.h b/windows/Gridex/SidebarPanel.h
index a1316b7..3138146 100644
--- a/windows/Gridex/SidebarPanel.h
+++ b/windows/Gridex/SidebarPanel.h
@@ -45,6 +45,14 @@ namespace winrt::Gridex::implementation
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 group
std::function<void(const std::wstring& schema)> OnShowERDiagram;
@@ -84,6 +92,9 @@ namespace winrt::Gridex::implementation
void 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.xaml
index 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="&#xE81C;" 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="&#xE950;" FontSize="13" />
+ </Button>
</Grid>
<!-- Search box -->
diff --git a/windows/Gridex/WorkspacePage.cpp b/windows/Gridex/WorkspacePage.cpp
index d145178..7964173 100644
--- a/windows/Gridex/WorkspacePage.cpp
+++ b/windows/Gridex/WorkspacePage.cpp
@@ -23,6 +23,7 @@
#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>
@@ -853,6 +854,22 @@ namespace winrt::Gridex::implementation
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 Diagram
@@ -4340,6 +4357,62 @@ g.er-selected > foreignObject > div.er-card{
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 →
diff --git a/windows/Gridex/WorkspacePage.h b/windows/Gridex/WorkspacePage.h
index 6090219..e72dfee 100644
--- a/windows/Gridex/WorkspacePage.h
+++ b/windows/Gridex/WorkspacePage.h
@@ -181,6 +181,12 @@ namespace winrt::Gridex::implementation
// 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 jobs