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(mcp): Activity tab detail pane — full audit record on row click

DangHuynh80cff1ea9165
diff --git a/windows/Gridex/MCPPage.cpp b/windows/Gridex/MCPPage.cpp
index 4afb8d3..58a28ee 100644
--- a/windows/Gridex/MCPPage.cpp
+++ b/windows/Gridex/MCPPage.cpp
@@ -14,6 +14,7 @@
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
#include <winrt/Windows.UI.h>
#include <winrt/Microsoft.UI.Xaml.Shapes.h>
+#include <winrt/Windows.UI.Text.h>
#include <nlohmann/json.hpp>
#include <fstream>
#include <shlobj.h>
@@ -634,6 +635,13 @@ namespace winrt::Gridex::implementation
const std::wstring q = std::wstring(ActSearchBox().Text());
const int statusIdx = ActStatusCombo().SelectedIndex();
+ // Build the filtered list first and cache it so click
+ // handlers can look up the full record by index. We need
+ // stable indices — rebuilding the cache on every refresh
+ // is fine because the table is also rebuilt each time.
+ cachedActivity_.clear();
+ cachedActivity_.reserve(entries.size());
+
int shown = 0;
for (const auto& e : entries)
{
@@ -658,6 +666,9 @@ namespace winrt::Gridex::implementation
lower(sqlW).find(qL) == std::wstring::npos) continue;
}
+ const int cacheIdx = static_cast<int>(cachedActivity_.size());
+ cachedActivity_.push_back(e);
+
Grid row;
row.Padding(Thickness{ 12, 6, 12, 6 });
row.ColumnSpacing(12);
@@ -701,12 +712,158 @@ namespace winrt::Gridex::implementation
Border wrap; wrap.Child(row);
wrap.BorderBrush(SolidColorBrush(ColorHelper::FromArgb(30, 128, 128, 128)));
wrap.BorderThickness(Thickness{ 0, 0, 0, 1 });
+ wrap.Background(SolidColorBrush(ColorHelper::FromArgb(0, 0, 0, 0)));
+ // Row click → populate detail pane. Uses Tapped rather
+ // than PointerPressed so touch + mouse both fire one
+ // event with click semantics.
+ wrap.Tapped([this, cacheIdx](auto&&, auto&&) {
+ SelectActivityEntry(cacheIdx);
+ });
panel.Children().Append(wrap);
++shown;
}
ActEmptyState().Visibility(shown == 0
? mux::Visibility::Visible : mux::Visibility::Collapsed);
+
+ // Auto-select the first entry so the detail pane isn't empty
+ // on load. Skipped when nothing passed the filter.
+ if (!cachedActivity_.empty()) SelectActivityEntry(0);
+ }
+
+ // Populate the right-side detail panel for a given cached entry.
+ // Mirrors the Form sections in macOS MCPActivityView.detailPanel:
+ // Event, Client, Connection, Result, SQL, Error.
+ void MCPPage::SelectActivityEntry(int index)
+ {
+ using namespace winrt::Microsoft::UI::Xaml;
+ using namespace winrt::Microsoft::UI::Xaml::Controls;
+ using namespace winrt::Microsoft::UI::Xaml::Media;
+ using namespace winrt::Windows::UI;
+
+ auto panel = ActDetailPanel();
+ if (!panel) return;
+ if (index < 0 || index >= static_cast<int>(cachedActivity_.size())) return;
+ const auto& e = cachedActivity_[index];
+
+ panel.Children().Clear();
+
+ auto addHeader = [&](winrt::hstring text) {
+ TextBlock h;
+ h.Text(text);
+ h.FontSize(13);
+ h.FontWeight(Windows::UI::Text::FontWeights::SemiBold());
+ h.Margin(Thickness{ 0, 8, 0, 2 });
+ panel.Children().Append(h);
+ };
+
+ auto addRow = [&](const wchar_t* label, winrt::hstring value, bool mono = false) {
+ Grid g; g.ColumnSpacing(8);
+ ColumnDefinition l; l.Width(GridLengthHelper::FromPixels(100));
+ ColumnDefinition v; v.Width(GridLengthHelper::FromValueAndType(1, GridUnitType::Star));
+ g.ColumnDefinitions().Append(l);
+ g.ColumnDefinitions().Append(v);
+
+ TextBlock lb; lb.Text(label); lb.FontSize(11);
+ lb.Foreground(SolidColorBrush(ColorHelper::FromArgb(255, 150, 150, 150)));
+ Grid::SetColumn(lb, 0); g.Children().Append(lb);
+
+ TextBlock vb; vb.Text(value); vb.FontSize(12);
+ vb.TextWrapping(TextWrapping::Wrap);
+ vb.IsTextSelectionEnabled(true);
+ if (mono) vb.FontFamily(winrt::Microsoft::UI::Xaml::Media::FontFamily(L"Consolas"));
+ Grid::SetColumn(vb, 1); g.Children().Append(vb);
+
+ panel.Children().Append(g);
+ };
+
+ auto addBlock = [&](const wchar_t* label, winrt::hstring value, bool mono = true) {
+ TextBlock lb; lb.Text(label); lb.FontSize(11);
+ lb.Foreground(SolidColorBrush(ColorHelper::FromArgb(255, 150, 150, 150)));
+ lb.Margin(Thickness{ 0, 4, 0, 2 });
+ panel.Children().Append(lb);
+
+ Border b;
+ b.Padding(Thickness{ 8, 6, 8, 6 });
+ b.CornerRadius(winrt::Microsoft::UI::Xaml::CornerRadius{ 4, 4, 4, 4 });
+ b.Background(SolidColorBrush(ColorHelper::FromArgb(255, 28, 28, 30)));
+ TextBlock vb; vb.Text(value); vb.FontSize(12);
+ vb.TextWrapping(TextWrapping::Wrap);
+ vb.IsTextSelectionEnabled(true);
+ if (mono) vb.FontFamily(winrt::Microsoft::UI::Xaml::Media::FontFamily(L"Consolas"));
+ b.Child(vb);
+ panel.Children().Append(b);
+ };
+
+ // Format full timestamp.
+ auto fullTime = [](std::chrono::system_clock::time_point tp) {
+ const std::time_t t = std::chrono::system_clock::to_time_t(tp);
+ std::tm tm{};
+ localtime_s(&tm, &t);
+ wchar_t buf[32];
+ wcsftime(buf, 32, L"%Y-%m-%d %H:%M:%S", &tm);
+ return std::wstring(buf);
+ };
+
+ addHeader(L"Event");
+ addRow(L"Tool", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(e.tool)), true);
+ addRow(L"Tier", winrt::hstring(L"Tier " + std::to_wstring(e.tier)));
+ addRow(L"Time", winrt::hstring(fullTime(e.timestamp)));
+ if (!e.eventId.empty())
+ {
+ std::string shortId = e.eventId.size() > 8 ? e.eventId.substr(0, 8) + "..." : e.eventId;
+ addRow(L"Event ID", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(shortId)), true);
+ }
+
+ addHeader(L"Client");
+ addRow(L"Name", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(e.client.name)));
+ addRow(L"Version", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(e.client.version)));
+ addRow(L"Transport", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(e.client.transport)));
+
+ if (e.connectionId.has_value() || e.connectionType.has_value())
+ {
+ addHeader(L"Connection");
+ if (e.connectionType.has_value())
+ addRow(L"Database", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(*e.connectionType)));
+ if (e.connectionId.has_value())
+ {
+ const auto& cid = *e.connectionId;
+ std::string shortId = cid.size() > 8 ? cid.substr(0, 8) + "..." : cid;
+ addRow(L"ID", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(shortId)), true);
+ }
+ }
+
+ addHeader(L"Result");
+ addRow(L"Status", winrt::hstring(statusLabel(e.result.status)));
+ addRow(L"Duration", winrt::hstring(std::to_wstring(e.result.durationMs) + L" ms"));
+ if (e.result.rowsReturned.has_value())
+ addRow(L"Rows returned", winrt::hstring(std::to_wstring(*e.result.rowsReturned)));
+ if (e.result.rowsAffected.has_value())
+ addRow(L"Rows affected", winrt::hstring(std::to_wstring(*e.result.rowsAffected)));
+
+ if (e.input.sqlPreview.has_value() && !e.input.sqlPreview->empty())
+ {
+ addBlock(L"SQL", winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(*e.input.sqlPreview)));
+ }
+
+ if (e.error.has_value() && !e.error->empty())
+ {
+ TextBlock lb; lb.Text(L"Error"); lb.FontSize(11);
+ lb.Foreground(SolidColorBrush(ColorHelper::FromArgb(255, 220, 53, 69)));
+ lb.Margin(Thickness{ 0, 8, 0, 2 });
+ panel.Children().Append(lb);
+
+ Border b;
+ b.Padding(Thickness{ 8, 6, 8, 6 });
+ b.CornerRadius(winrt::Microsoft::UI::Xaml::CornerRadius{ 4, 4, 4, 4 });
+ b.Background(SolidColorBrush(ColorHelper::FromArgb(255, 40, 20, 22)));
+ TextBlock vb; vb.Text(winrt::hstring(DBModels::MCPToolHelpers::fromUtf8(*e.error)));
+ vb.FontSize(12); vb.TextWrapping(TextWrapping::Wrap);
+ vb.IsTextSelectionEnabled(true);
+ vb.Foreground(SolidColorBrush(ColorHelper::FromArgb(255, 255, 180, 180)));
+ b.Child(vb);
+ panel.Children().Append(b);
+ }
}
void MCPPage::ActFilter_Changed(
diff --git a/windows/Gridex/MCPPage.h b/windows/Gridex/MCPPage.h
index 8a845e6..7be920b 100644
--- a/windows/Gridex/MCPPage.h
+++ b/windows/Gridex/MCPPage.h
@@ -1,6 +1,8 @@
#pragma once
#include "MCPPage.g.h"
+#include "Models/MCP/MCPAuditEntry.h"
+#include <vector>
namespace winrt::Gridex::implementation
{
@@ -65,6 +67,11 @@ namespace winrt::Gridex::implementation
void ApplyStartStopButton(bool running);
void RefreshConnectionsTab();
void RefreshActivityTab();
+ void SelectActivityEntry(int index);
+
+ // Cache tailed audit entries so a click on a row can look
+ // up the full record by index. Populated by RefreshActivityTab.
+ std::vector<DBModels::MCPAuditEntry> cachedActivity_;
};
}
diff --git a/windows/Gridex/MCPPage.xaml b/windows/Gridex/MCPPage.xaml
index b0569cb..bfaebc8 100644
--- a/windows/Gridex/MCPPage.xaml
+++ b/windows/Gridex/MCPPage.xaml
@@ -306,14 +306,19 @@
</PivotItem>
<PivotItem Header="Activity">
+ <!-- Outer grid: filter bar + detail split + footer.
+ The split row (*) contains a 2-column grid — the
+ audit table on the left and the selected-entry
+ detail pane on the right, same layout mac's
+ HSplitView uses. -->
<Grid RowSpacing="0">
<Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
+ <!-- Filter bar -->
<Grid Grid.Row="0" Padding="4,6,4,10" ColumnSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MaxWidth="280" />
@@ -340,49 +345,83 @@
</Button>
</Grid>
- <Border Grid.Row="1" Padding="12,8"
- Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
- CornerRadius="6,6,0,0"
- BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
- BorderThickness="1,1,1,0">
- <Grid ColumnSpacing="12">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="90" />
- <ColumnDefinition Width="*" MinWidth="160" />
- <ColumnDefinition Width="120" />
- <ColumnDefinition Width="80" />
- <ColumnDefinition Width="70" />
- </Grid.ColumnDefinitions>
- <TextBlock Grid.Column="0" Text="Time" FontSize="12" FontWeight="SemiBold" />
- <TextBlock Grid.Column="1" Text="Tool" FontSize="12" FontWeight="SemiBold" />
- <TextBlock Grid.Column="2" Text="Client" FontSize="12" FontWeight="SemiBold" />
- <TextBlock Grid.Column="3" Text="Status" FontSize="12" FontWeight="SemiBold" />
- <TextBlock Grid.Column="4" Text="Duration" FontSize="12" FontWeight="SemiBold" />
- </Grid>
- </Border>
+ <!-- Table + detail split -->
+ <Grid Grid.Row="1" ColumnSpacing="12">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" MinWidth="440" />
+ <ColumnDefinition Width="360" />
+ </Grid.ColumnDefinitions>
- <ScrollViewer Grid.Row="2"
- BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
- BorderThickness="1,0,1,1"
- CornerRadius="0,0,6,6">
- <StackPanel x:Name="ActRowsPanel" Spacing="0" />
- </ScrollViewer>
+ <!-- Left: audit table -->
+ <Grid Grid.Column="0" RowSpacing="0">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ </Grid.RowDefinitions>
- <StackPanel x:Name="ActEmptyState" Grid.Row="2"
- VerticalAlignment="Center" HorizontalAlignment="Center"
- Spacing="8"
- Visibility="Collapsed">
- <FontIcon Glyph="&#xE9D9;" FontSize="36"
- Foreground="{ThemeResource TextFillColorTertiaryBrush}" />
- <TextBlock Text="No activity yet"
- HorizontalAlignment="Center" FontSize="14" />
- <TextBlock Text="MCP tool invocations will appear here once a client connects."
- HorizontalAlignment="Center" FontSize="12"
- Foreground="{ThemeResource TextFillColorSecondaryBrush}"
- TextWrapping="Wrap" MaxWidth="380" TextAlignment="Center" />
- </StackPanel>
+ <Border Grid.Row="0" Padding="12,8"
+ Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
+ CornerRadius="6,6,0,0"
+ BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
+ BorderThickness="1,1,1,0">
+ <Grid ColumnSpacing="12">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="90" />
+ <ColumnDefinition Width="*" MinWidth="160" />
+ <ColumnDefinition Width="120" />
+ <ColumnDefinition Width="80" />
+ <ColumnDefinition Width="70" />
+ </Grid.ColumnDefinitions>
+ <TextBlock Grid.Column="0" Text="Time" FontSize="12" FontWeight="SemiBold" />
+ <TextBlock Grid.Column="1" Text="Tool" FontSize="12" FontWeight="SemiBold" />
+ <TextBlock Grid.Column="2" Text="Client" FontSize="12" FontWeight="SemiBold" />
+ <TextBlock Grid.Column="3" Text="Status" FontSize="12" FontWeight="SemiBold" />
+ <TextBlock Grid.Column="4" Text="Duration" FontSize="12" FontWeight="SemiBold" />
+ </Grid>
+ </Border>
+
+ <ScrollViewer Grid.Row="1"
+ BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
+ BorderThickness="1,0,1,1"
+ CornerRadius="0,0,6,6">
+ <StackPanel x:Name="ActRowsPanel" Spacing="0" />
+ </ScrollViewer>
+
+ <StackPanel x:Name="ActEmptyState" Grid.Row="1"
+ VerticalAlignment="Center" HorizontalAlignment="Center"
+ Spacing="8"
+ Visibility="Collapsed">
+ <FontIcon Glyph="&#xE9D9;" FontSize="36"
+ Foreground="{ThemeResource TextFillColorTertiaryBrush}" />
+ <TextBlock Text="No activity yet"
+ HorizontalAlignment="Center" FontSize="14" />
+ <TextBlock Text="MCP tool invocations will appear here once a client connects."
+ HorizontalAlignment="Center" FontSize="12"
+ Foreground="{ThemeResource TextFillColorSecondaryBrush}"
+ TextWrapping="Wrap" MaxWidth="380" TextAlignment="Center" />
+ </StackPanel>
+ </Grid>
+
+ <!-- Right: detail pane (populated on row click) -->
+ <Border Grid.Column="1"
+ Padding="16"
+ Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
+ CornerRadius="6"
+ BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
+ BorderThickness="1">
+ <ScrollViewer>
+ <StackPanel x:Name="ActDetailPanel" Spacing="12">
+ <TextBlock x:Name="ActDetailPlaceholder"
+ Text="Click a row on the left to see the full audit entry (SQL preview, client info, error message, etc.)."
+ FontSize="12"
+ TextWrapping="Wrap"
+ Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
+ </StackPanel>
+ </ScrollViewer>
+ </Border>
+ </Grid>
- <TextBlock Grid.Row="3" x:Name="ActPathText"
+ <TextBlock Grid.Row="2" x:Name="ActPathText"
FontSize="11"
Foreground="{ThemeResource TextFillColorTertiaryBrush}"
IsTextSelectionEnabled="True"