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++
fix(redis): own flat grid lifecycle
Tobi8d10af533062
diff --git a/macos/App/State/AppState.swift b/macos/App/State/AppState.swiftindex 3329d8c..12f97e0 100644--- a/macos/App/State/AppState.swift+++ b/macos/App/State/AppState.swift@@ -964,8 +964,11 @@ final class AppState: ObservableObject {tabID = tab.idensureTabGroup(for: context.databaseName)}+ let gridState = cachedDataGridState(for: tabID)+ gridState.appState = self+ gridState.bindRedisContext(context)+ gridState.showFilterBar = trueactiveTabId = tabID- cachedDataGridState(for: tabID).showFilterBar = true}func openRedisKeyDetail(key: String) {diff --git a/macos/Presentation/Views/DataGrid/AppKitDataGrid.swift b/macos/Presentation/Views/DataGrid/AppKitDataGrid.swiftindex 4b46376..e377b54 100644--- a/macos/Presentation/Views/DataGrid/AppKitDataGrid.swift+++ b/macos/Presentation/Views/DataGrid/AppKitDataGrid.swift@@ -39,6 +39,8 @@ struct AppKitDataGrid: NSViewRepresentable {tableView.target = context.coordinatorlet menu = NSMenu()+ menu.autoenablesItems = false+ menu.delegate = context.coordinatorlet copyRowItem = NSMenuItem(title: "Copy Row", action: #selector(context.coordinator.copyRow(_:)), keyEquivalent: "")copyRowItem.target = context.coordinatorlet copyCellItem = NSMenuItem(title: "Copy Cell", action: #selector(context.coordinator.copyCell(_:)), keyEquivalent: "")@@ -75,7 +77,7 @@ struct AppKitDataGrid: NSViewRepresentable {// MARK: - Coordinator@MainActor- class Coordinator: NSObject, NSTableViewDataSource, NSTableViewDelegate, NSTextFieldDelegate {+ class Coordinator: NSObject, NSTableViewDataSource, NSTableViewDelegate, NSTextFieldDelegate, NSMenuDelegate {weak var tableView: NSTableView?var onSelectRows: ((Set<Int>) -> Void)?var onFKClick: ((_ refTable: String, _ refColumn: String, _ value: String) -> Void)?@@ -105,6 +107,10 @@ struct AppKitDataGrid: NSViewRepresentable {private var dateColumnIndices: Set<Int> = []private var boolColumnIndices: Set<Int> = []+ private var allowsMutations: Bool {+ viewModel?.allowsMutations == true+ }+private func rebuildPendingChangeCaches() {deletedRows = []modifiedCells = []@@ -338,16 +344,16 @@ struct AppKitDataGrid: NSViewRepresentable {let newAlignment: NSTextAlignment = value.isNumeric ? .right : .leftif cell.textAlignment != newAlignment { cell.textAlignment = newAlignment; dirty = true }- cell.isDateColumn = isDateColumn(col)- cell.isBooleanColumn = isBoolColumn(col)+ cell.isDateColumn = allowsMutations && isDateColumn(col)+ cell.isBooleanColumn = allowsMutations && isBoolColumn(col)let colName = col < columns.count ? columns[col].name : ""cell.foreignKeyTarget = foreignKeyColumns[colName]cell.foreignKeyRefColumn = foreignKeyRefColumns[colName]cell.cellValue = value == .null ? "" : newTextcell.onFKClick = onFKClick- cell.hasDefaultValue = columnDefaults[colName] != nil- cell.hasEnumValues = columnEnumValues[colName] != nil+ cell.hasDefaultValue = allowsMutations && columnDefaults[colName] != nil+ cell.hasEnumValues = allowsMutations && columnEnumValues[colName] != nillet isModified = modifiedCells.contains("\(row):\(colName)")let newBg = isModified ? NSColor.Gridex.cellModified : nil@@ -480,6 +486,7 @@ struct AppKitDataGrid: NSViewRepresentable {}func beginEditing(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView, col < columns.count, row < rows.count else { return }if tableView.subviews.contains(where: { $0 is EditContainerView }) { return }@@ -506,6 +513,7 @@ struct AppKitDataGrid: NSViewRepresentable {}private func beginTextEditing(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView, col < columns.count, row < rows.count else { return }isEditing = true@@ -557,6 +565,7 @@ struct AppKitDataGrid: NSViewRepresentable {private var pendingDateEdit: (row: Int, col: Int)?private func showDateMenu(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView else { return }pendingDateEdit = (row, col)@@ -648,6 +657,10 @@ struct AppKitDataGrid: NSViewRepresentable {}private func commitDateValue(_ value: RowValue) {+ guard allowsMutations else {+ pendingDateEdit = nil+ return+ }guard let edit = pendingDateEdit else { return }pendingDateEdit = nil@@ -683,6 +696,7 @@ struct AppKitDataGrid: NSViewRepresentable {private var pendingDefaultEdit: (row: Int, col: Int)?private func showDefaultMenu(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView else { return }pendingDefaultEdit = (row, col)@@ -739,6 +753,7 @@ struct AppKitDataGrid: NSViewRepresentable {}private func commitDefaultValue(_ value: RowValue, edit: (row: Int, col: Int)) {+ guard allowsMutations else { return }guard edit.row < rows.count, edit.col < columns.count else { return }let oldValue = rows[edit.row][edit.col]@@ -770,6 +785,7 @@ struct AppKitDataGrid: NSViewRepresentable {private var pendingEnumEdit: (row: Int, col: Int)?private func showEnumMenu(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView else { return }pendingEnumEdit = (row, col)@@ -835,6 +851,7 @@ struct AppKitDataGrid: NSViewRepresentable {}private func commitEnumValue(_ value: RowValue, edit: (row: Int, col: Int)) {+ guard allowsMutations else { return }guard edit.row < rows.count, edit.col < columns.count else { return }let oldValue = rows[edit.row][edit.col]@@ -866,6 +883,7 @@ struct AppKitDataGrid: NSViewRepresentable {private var pendingBoolEdit: (row: Int, col: Int)?private func showBooleanMenu(row: Int, col: Int) {+ guard allowsMutations else { return }guard let tableView else { return }pendingBoolEdit = (row, col)@@ -922,6 +940,7 @@ struct AppKitDataGrid: NSViewRepresentable {}private func commitBoolValue(_ value: RowValue, edit: (row: Int, col: Int)) {+ guard allowsMutations else { return }guard edit.row < rows.count, edit.col < columns.count else { return }let oldValue = rows[edit.row][edit.col]@@ -965,12 +984,13 @@ struct AppKitDataGrid: NSViewRepresentable {private func finishEditing(_ editor: NSTextField, commit: Bool, nextCol: Bool = false) {guard let info = objc_getAssociatedObject(editor, &Self.editInfoKey) as? EditInfo else { return }objc_setAssociatedObject(editor, &Self.editInfoKey, nil, .OBJC_ASSOCIATION_RETAIN)+ let shouldCommit = commit && allowsMutations// Save scroll position before any changes — removing the editor// and changing first responder can cause NSTableView to auto-scroll.let savedContentOffset = tableView?.enclosingScrollView?.contentView.bounds.origin- if commit {+ if shouldCommit {if insertedRowIndices.contains(info.row) {viewModel?.commitNewRowEdit(rowIndex: info.row, colIdx: info.col, newText: editor.stringValue)} else {@@ -985,7 +1005,7 @@ struct AppKitDataGrid: NSViewRepresentable {if let tableView,let cellView = tableView.view(atColumn: info.col, row: info.row, makeIfNecessary: false) as? DataGridCellView {cellView.isEditingActive = false- if commit, let vm = viewModel {+ if shouldCommit, let vm = viewModel {rows = vm.rowspendingChanges = vm.changeTracker.pendingChangesrebuildPendingChangeCaches()@@ -1006,7 +1026,7 @@ struct AppKitDataGrid: NSViewRepresentable {isEditing = false// Tab → open next column for editing- if nextCol, commit {+ if nextCol, shouldCommit {let nextColIdx = info.col + 1if nextColIdx < columns.count {beginEditing(row: info.row, col: nextColIdx)@@ -1039,6 +1059,13 @@ struct AppKitDataGrid: NSViewRepresentable {}}+ nonisolated func menuWillOpen(_ menu: NSMenu) {+ MainActor.assumeIsolated {+ menu.items.first(where: { $0.action == #selector(deleteRows(_:)) })?+ .isEnabled = allowsMutations+ }+ }+// MARK: - Copy@objc nonisolated func copyRow(_ sender: Any?) {@@ -1067,7 +1094,7 @@ struct AppKitDataGrid: NSViewRepresentable {@objc nonisolated func deleteRows(_ sender: Any?) {MainActor.assumeIsolated {- guard let vm = viewModel, let tableView else { return }+ guard allowsMutations, let vm = viewModel, let tableView else { return }// If right-clicked row is not in selection, delete just that rowlet clickedRow = tableView.clickedRowif clickedRow >= 0, !tableView.selectedRowIndexes.contains(clickedRow) {diff --git a/macos/Presentation/Views/DataGrid/DataGridView.swift b/macos/Presentation/Views/DataGrid/DataGridView.swiftindex 3f9f1c8..2ac5b0a 100644--- a/macos/Presentation/Views/DataGrid/DataGridView.swift+++ b/macos/Presentation/Views/DataGrid/DataGridView.swift@@ -16,6 +16,7 @@ struct DataGridView: View {let tableName: Stringlet schema: String?let tabId: UUID+ let redisContext: AppState.RedisTabContext?var initialViewMode: String?@EnvironmentObject private var appState: AppState@@ -27,6 +28,7 @@ struct DataGridView: View {DataGridContentView(tableName: tableName,schema: schema,+ redisContext: redisContext,viewModel: viewModel,showDiscardWarning: $showDiscardWarning,viewMode: $viewMode@@ -47,6 +49,7 @@ struct DataGridView: View {private struct DataGridContentView: View {let tableName: Stringlet schema: String?+ let redisContext: AppState.RedisTabContext?@ObservedObject var viewModel: DataGridViewState@Binding var showDiscardWarning: Bool@Binding var viewMode: DataGridViewMode@@ -61,7 +64,7 @@ private struct DataGridContentView: View {// Filter bar — Redis uses pattern-based filter, SQL uses column filterif viewModel.showFilterBar {- if appState.activeConfig?.databaseType == .redis {+ if viewModel.redisContext != nil {RedisFilterBar(initialFilter: viewModel.activeFilter,onApply: { filter in@@ -156,6 +159,9 @@ private struct DataGridContentView: View {}.task {viewModel.appState = appState+ if let redisContext {+ viewModel.bindRedisContext(redisContext)+ }// Skip reload if already loaded (cached from previous tab switch)guard viewModel.columns.isEmpty else { return }await viewModel.load(@@ -195,18 +201,19 @@ private struct DataGridContentView: View {}// Cmd+S: commit changes.onReceive(NotificationCenter.default.publisher(for: .commitChanges)) { _ in- if viewModel.hasPendingChanges {+ if viewModel.allowsMutations && viewModel.hasPendingChanges {viewModel.prepareCommit()}}// Delete selected rows.onReceive(NotificationCenter.default.publisher(for: .deleteSelectedRows)) { _ in+ guard viewModel.allowsMutations else { return }viewModel.deleteSelectedRows()}// Cmd+R: reload (with warning if pending changes). Re-introspects the// schema so external column changes (ADD/DROP COLUMN) take effect..onReceive(NotificationCenter.default.publisher(for: .reloadData)) { _ in- if viewModel.hasPendingChanges {+ if viewModel.allowsMutations && viewModel.hasPendingChanges {showDiscardWarning = true} else {Task { await viewModel.reloadAfterStructureChange() }@@ -231,8 +238,12 @@ private struct DataGridContentView: View {let value = idx < row.count ? row[idx].displayString : ""return (column: col.name, value: value)}+ guard viewModel.allowsMutations else {+ appState.onDetailFieldEdit = nil+ return+ }appState.onDetailFieldEdit = { [weak viewModel] colIdx, newValue in- guard let viewModel else { return }+ guard let viewModel, viewModel.allowsMutations else { return }viewModel.commitCellEdit(rowIndex: rowIndex, colIdx: colIdx, newText: newValue)// Update the details panel to reflect the editif colIdx < viewModel.columns.count {@@ -358,6 +369,21 @@ struct QueryLogEntry: Identifiable {@MainActorfinal class DataGridViewState: ObservableObject {+ struct RowFetchRequest {+ let table: String+ let schema: String?+ let columns: [String]?+ let filter: FilterExpression?+ let orderBy: [QuerySortDescriptor]?+ let limit: Int+ let offset: Int+ }++ typealias RedisRowFetcher = (+ RedisAdapter,+ RowFetchRequest+ ) async throws -> QueryResult+@Published var columns: [ColumnHeader] = []@Published var rows: [[RowValue]] = []@Published var totalRows: Int = 0@@ -392,6 +418,24 @@ final class DataGridViewState: ObservableObject {let changeTracker = DefaultChangeTracker()let pageSize = 300+ private let redisRowFetcher: RedisRowFetcher+ private let redisRequestCoordinator = RedisRequestCoordinator()+ private(set) var redisContext: AppState.RedisTabContext?++ init(redisRowFetcher: @escaping RedisRowFetcher = { adapter, request in+ try await adapter.fetchRows(+ table: request.table,+ schema: request.schema,+ columns: request.columns,+ where: request.filter,+ orderBy: request.orderBy,+ limit: request.limit,+ offset: request.offset+ )+ }) {+ self.redisRowFetcher = redisRowFetcher+ }+/// Pre-computed display strings for the current page — avoids repeated/// `displayString` computation during cell rendering and scrolling.var displayCache: [[String]] = []@@ -407,7 +451,12 @@ final class DataGridViewState: ObservableObject {displayCache[row][col] = rows[row][col].displayString}- var statusRowCount: Int? { totalRows > 0 ? totalRows : nil }+ var statusRowCount: Int? {+ guard redisContext == nil else { return nil }+ return totalRows > 0 ? totalRows : nil+ }++ var allowsMutations: Bool { redisContext == nil }private(set) var adapter: (any DatabaseAdapter)?private(set) var tableName: String = ""@@ -436,6 +485,77 @@ final class DataGridViewState: ObservableObject {metadataCache.removeAll()}+ func bindRedisContext(_ context: AppState.RedisTabContext) {+ guard redisContext != context else { return }++ redisRequestCoordinator.invalidate()+ redisContext = context+ adapter = nil+ columns = []+ rows = []+ totalRows = 0+ currentPage = 0+ isLoading = false+ executionTime = 0+ errorMessage = nil+ tableDescription = nil+ primaryKeyColumns = []+ foreignKeyColumns = [:]+ foreignKeyRefColumns = [:]+ columnDefaults = [:]+ columnEnumValues = [:]+ selectedRows = []+ editingCell = nil+ insertedRowIndices = []+ columnWidths = [:]+ displayCache = []+ changeTracker.discardAll()+ commitSQL = []+ commitError = nil+ showCommitPreview = false+ isCommitting = false+ appState?.selectedRowDetails = nil+ appState?.onDetailFieldEdit = nil+ }++ func performRedisLoad(+ in context: AppState.RedisTabContext,+ page: Int = 0,+ execute: () async -> Result<QueryResult, Error>?+ ) async {+ guard redisContext == context else { return }++ isLoading = true+ totalRows = 0+ errorMessage = nil++ switch await redisRequestCoordinator.perform(for: context, execute: execute) {+ case .current(.success(let result)):+ guard redisContext == context else { return }+ columns = result.columns+ rows = result.rows+ rebuildDisplayCache()+ totalRows = 0+ currentPage = page+ executionTime = result.executionTime+ errorMessage = nil+ computeColumnWidths(columns: result.columns, rows: result.rows)+ isLoading = false+ case .current(.failure(let error)):+ guard redisContext == context else { return }+ totalRows = 0+ errorMessage = (error as? LocalizedError)?.errorDescription+ ?? error.localizedDescription+ isLoading = false+ case .stale:+ guard redisContext == context else { return }+ totalRows = 0+ isLoading = false+ case .superseded:+ break+ }+ }+struct CellID: Equatable {let row: Intlet col: Int@@ -447,6 +567,29 @@ final class DataGridViewState: ObservableObject {self.tableName = tableNameself.schema = schema+ if redisContext != nil || adapter.databaseType == .redis {+ guard let redisContext, let appState else {+ totalRows = 0+ isLoading = false+ return+ }+ let request = RowFetchRequest(+ table: tableName,+ schema: schema,+ columns: nil,+ filter: activeFilter,+ orderBy: nil,+ limit: pageSize,+ offset: 0+ )+ await performRedisLoad(in: redisContext, page: 0) {+ await appState.performRedisOperation(for: redisContext) { redis in+ try await self.redisRowFetcher(redis, request)+ }+ }+ return+ }+isLoading = true// Apply cache immediately if available (before any query)@@ -570,6 +713,7 @@ final class DataGridViewState: ObservableObject {}func reloadStructure() async {+ guard redisContext == nil else { return }guard let adapter else { return }do {tableDescription = try await adapter.describeTable(name: tableName, schema: schema)@@ -580,13 +724,48 @@ final class DataGridViewState: ObservableObject {/// Invalidate cache and reload everything (after structure changes like ADD COLUMN)func reloadAfterStructureChange() async {- Self.metadataCache.removeValue(forKey: cacheKey)+ if redisContext == nil {+ Self.metadataCache.removeValue(forKey: cacheKey)+ }guard let adapter else { return }await load(tableName: tableName, schema: schema, adapter: adapter)}func loadPage(_ page: Int) async {guard let adapter else { return }++ if redisContext != nil || adapter.databaseType == .redis {+ guard let redisContext, let appState else {+ totalRows = 0+ isLoading = false+ return+ }+ let offset = page * pageSize+ let sort: [QuerySortDescriptor]? = if let col = sortColumn {+ [QuerySortDescriptor(+ column: col,+ direction: sortAscending ? .ascending : .descending+ )]+ } else {+ nil+ }+ let request = RowFetchRequest(+ table: tableName,+ schema: schema,+ columns: nil,+ filter: activeFilter,+ orderBy: sort,+ limit: pageSize,+ offset: offset+ )+ await performRedisLoad(in: redisContext, page: page) {+ await appState.performRedisOperation(for: redisContext) { redis in+ try await self.redisRowFetcher(redis, request)+ }+ }+ return+ }+isLoading = truedefer { isLoading = false }@@ -742,6 +921,7 @@ final class DataGridViewState: ObservableObject {// MARK: - Inline Editingfunc commitCellEdit(rowIndex: Int, colIdx: Int, newText: String) {+ guard allowsMutations else { return }guard colIdx < columns.count, rowIndex < rows.count else { return }let col = columns[colIdx]let oldValue = rows[rowIndex][colIdx]@@ -760,6 +940,7 @@ final class DataGridViewState: ObservableObject {}func commitDateEdit(rowIndex: Int, colIdx: Int, newValue: RowValue) {+ guard allowsMutations else { return }guard colIdx < columns.count, rowIndex < rows.count else { return }let col = columns[colIdx]let oldValue = rows[rowIndex][colIdx]@@ -884,10 +1065,11 @@ final class DataGridViewState: ObservableObject {}var hasPendingChanges: Bool {- changeTracker.hasChanges || !insertedRowIndices.isEmpty+ allowsMutations && (changeTracker.hasChanges || !insertedRowIndices.isEmpty)}func discardAllChanges() {+ guard allowsMutations else { return }// Remove inserted rows from end (reverse order to preserve indices)for rowIndex in insertedRowIndices.sorted().reversed() {if rowIndex < rows.count {@@ -905,6 +1087,7 @@ final class DataGridViewState: ObservableObject {// MARK: - Add New Rowfunc addNewRow() {+ guard allowsMutations else { return }let newRow: [RowValue] = columns.map { col inif let def = defaultValueFor(column: col) {return def@@ -925,6 +1108,7 @@ final class DataGridViewState: ObservableObject {}func commitNewRowEdit(rowIndex: Int, colIdx: Int, newText: String) {+ guard allowsMutations else { return }guard colIdx < columns.count, rowIndex < rows.count else { return }// Always use column dataType for inserted rows to ensure correct binding typeslet newValue = parseRowValue(from: newText, columnType: columns[colIdx].dataType)@@ -947,6 +1131,7 @@ final class DataGridViewState: ObservableObject {// MARK: - Delete Rowsfunc deleteSelectedRows() {+ guard allowsMutations else { return }guard !selectedRows.isEmpty else { return }for rowIndex in selectedRows.sorted().reversed() {guard rowIndex < rows.count else { continue }@@ -959,6 +1144,7 @@ final class DataGridViewState: ObservableObject {}func undoDeleteRow(_ rowIndex: Int) {+ guard allowsMutations else { return }let changes = changeTracker.pendingChangesif let idx = changes.firstIndex(where: { $0.row == rowIndex && $0.editType == .delete }) {changeTracker.discardChange(at: idx)@@ -969,6 +1155,7 @@ final class DataGridViewState: ObservableObject {// MARK: - Commit Flowfunc prepareCommit() {+ guard allowsMutations else { return }guard let adapter else { return }// MongoDB: skip SQL generation and preview, commit directly@@ -997,6 +1184,7 @@ final class DataGridViewState: ObservableObject {}func executeCommit() async {+ guard allowsMutations else { return }guard let adapter else { return }isCommitting = truecommitError = nil@@ -1038,6 +1226,7 @@ final class DataGridViewState: ObservableObject {/// MongoDB-specific commit: applies pending changes via insertRow/updateRow/deleteRow/// instead of generating SQL.private func executeCommitMongo(adapter: any DatabaseAdapter) async {+ guard allowsMutations else { return }do {// Inserts (new rows)for rowIndex in insertedRowIndices.sorted() {@@ -1325,7 +1514,7 @@ struct DataGridToolbar: View {var body: some View {HStack(spacing: 12) {// MongoDB: Insert document button- if isMongoDB {+ if isMongoDB && viewModel.allowsMutations {Button {showInsertDocSheet = true} label: {@@ -1345,7 +1534,7 @@ struct DataGridToolbar: View {}// Pending changes indicator- if viewModel.hasPendingChanges {+ if viewModel.allowsMutations && viewModel.hasPendingChanges {HStack(spacing: 6) {Circle().fill(.orange)@@ -1440,7 +1629,7 @@ struct BottomTabBar: View {// Left: Data / Structure tabs (Structure hidden for Redis)HStack(spacing: 0) {tabButton("Data", mode: .data)- if appState.activeConfig?.databaseType != .redis {+ if viewModel.redisContext == nil {tabButton("Structure", mode: .structure)}}@@ -1451,27 +1640,8 @@ struct BottomTabBar: View {Spacer().frame(width: 8)if viewMode == .data {- // + Row / + Key button- if appState.activeConfig?.databaseType == .redis {- Button {- appState.showRedisAddKey = true- } label: {- HStack(spacing: 3) {- Image(systemName: "plus")- .font(.system(size: 10, weight: .medium))- Text("Key")- .font(.system(size: 12))- }- .padding(.horizontal, 10)- .padding(.vertical, 4)- .background(Color(nsColor: .controlBackgroundColor))- .clipShape(RoundedRectangle(cornerRadius: 5))- .overlay(RoundedRectangle(cornerRadius: 5).stroke(Color(nsColor: .separatorColor), lineWidth: 0.5))- }- .buttonStyle(.plain)- .pointerCursor()- .help("Add new Redis key")- } else {+ // Redis's flat key grid is intentionally read-only.+ if viewModel.allowsMutations {Button {viewModel.addNewRow()} label: {@@ -1491,7 +1661,7 @@ struct BottomTabBar: View {.pointerCursor().help("Add new row")}- } else if viewMode == .structure {+ } else if viewMode == .structure && viewModel.allowsMutations {// + Column / + Index buttonsButton { onAddColumn?() } label: {HStack(spacing: 3) {@@ -1540,7 +1710,7 @@ struct BottomTabBar: View {if viewMode == .data {HStack(spacing: 8) {// Pending changes- if viewModel.hasPendingChanges {+ if viewModel.allowsMutations && viewModel.hasPendingChanges {Text("\(viewModel.changeTracker.pendingChanges.count + viewModel.insertedRowIndices.count) pending").font(.system(size: 12)).foregroundStyle(.orange)@@ -1660,6 +1830,10 @@ struct BottomTabBar: View {private var pageText: String {guard !viewModel.rows.isEmpty else { return "No rows" }let start = viewModel.currentPage * viewModel.pageSize + 1+ if viewModel.redisContext != nil {+ let end = start + viewModel.rows.count - 1+ return "\(start)–\(end) rows"+ }let end = min(start + viewModel.rows.count - 1, viewModel.totalRows)return "\(start)–\(end) of \(viewModel.totalRows) rows"}@@ -3646,11 +3820,12 @@ struct CommitPreviewSheet: View {.keyboardShortcut(.cancelAction)Button("Execute") {+ guard viewModel.allowsMutations else { return }Task { await viewModel.executeCommit() }}.buttonStyle(.borderedProminent).keyboardShortcut(.defaultAction)- .disabled(viewModel.isCommitting)+ .disabled(viewModel.isCommitting || !viewModel.allowsMutations)}.padding()}diff --git a/macos/Presentation/Views/Main/MainView.swift b/macos/Presentation/Views/Main/MainView.swiftindex 385a611..a7f51b5 100644--- a/macos/Presentation/Views/Main/MainView.swift+++ b/macos/Presentation/Views/Main/MainView.swift@@ -1049,6 +1049,13 @@ struct WorkspaceView: View {return screenWidth * 0.5}+ private var activeGridAllowsMutations: Bool {+ guard let activeTabId = appState.activeTabId,+ let tab = appState.tabs.first(where: { $0.id == activeTabId }),+ tab.type == .dataGrid else { return true }+ return tab.redisContext == nil+ }+var body: some View {HStack(spacing: 0) {// Sidebar — always in hierarchy; width animates between 0 and sidebarWidth@@ -1142,6 +1149,7 @@ struct WorkspaceView: View {} label: {Image(systemName: "trash")}+ .disabled(!activeGridAllowsMutations).help("Delete Selected Rows")Button {@@ -1149,6 +1157,7 @@ struct WorkspaceView: View {} label: {Image(systemName: "text.insert")}+ .disabled(!activeGridAllowsMutations).help("Commit Changes")// ER Diagram (SQL databases only)@@ -1206,7 +1215,13 @@ struct WorkspaceView: View {appState.activeRedisAdapter(for: context) == nil {redisContextMismatchView} else if let tableName = tab.tableName {- DataGridView(tableName: tableName, schema: tab.schema, tabId: tab.id, initialViewMode: tab.initialViewMode)+ DataGridView(+ tableName: tableName,+ schema: tab.schema,+ tabId: tab.id,+ redisContext: tab.redisContext,+ initialViewMode: tab.initialViewMode+ )}case .queryEditor:QueryEditorView(tabId: tab.id)