Skip to content

fix: unify sidebar and data grid save pipelines#344

Merged
datlechin merged 1 commit intomainfrom
fix/unified-sidebar-save-pipeline
Mar 16, 2026
Merged

fix: unify sidebar and data grid save pipelines#344
datlechin merged 1 commit intomainfrom
fix/unified-sidebar-save-pipeline

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@datlechin datlechin commented Mar 16, 2026

Summary

  • Root cause: Sidebar save path (saveSidebarEdits) had its own parallel statement generation pipeline that only handled Redis specifically and fell through to SQLStatementGenerator for everything else. When data grid edits synced to the sidebar via externallyModifiedColumns, Cmd+S took the sidebar path (checked before data grid path), generating SQL UPDATE statements for NoSQL databases like etcd/MongoDB.
  • Fix: Extract DataChangeManager.generateSQL(for:) as a parameterized entry point, route sidebar edits through it. Both data grid and sidebar now use the same plugin dispatch → NoSQL guard → SQL fallback pipeline.
  • Priority fix: saveChanges() now checks changeManager.hasChanges before editState.hasEdits, so data grid edits always use the data grid save path.
  • Bonus: CellFieldEditor.performKeyEquivalent commits inline edits on Cmd+S before menu fires (mirrors existing OverlayTextView behavior).

Before (165 lines, 4 duplication points in SidebarSave):

  • Own plugin-vs-SQL branching, own PluginRowChange construction, own SQLStatementGenerator setup, dead Redis-specific code, no coverage validation

After (54 lines, 0 duplication):

  • Sidebar converts edits to [RowChange], calls changeManager.generateSQL(for:) — one line
  • New drivers automatically work for both data grid and sidebar saves

Test plan

  • Edit a cell in data grid → Enter → Cmd+S → should save without error (etcd, Redis, SQL)
  • Edit a cell in data grid → Cmd+S while still editing → should commit and save
  • Edit a field in sidebar inspector → Cmd+S → should save correctly
  • Multi-row select → edit in sidebar → save → applies to all selected rows
  • Verify MySQL/PostgreSQL sidebar edits still work (SQL fallback path)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Command+S keyboard shortcut to commit inline cell edits before menu actions execute.
  • Improvements

    • Enhanced change detection to better track pending data grid modifications during save operations.
    • Optimized the save pipeline for improved reliability when handling multiple concurrent changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 16, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Refactored SQL generation to use a unified pipeline: extracted a centralized helper method in DataChangeManager, replaced per-row statement generation with a changes array approach in sidebar save flow, improved change detection logic in command actions, and added keyboard shortcut handling for committing cell edits.

Changes

Cohort / File(s) Summary
Change Tracking Infrastructure
TablePro/Core/ChangeTracking/DataChangeManager.swift
Extracted new internal helper method generateSQL(for:insertedRowData:deletedRowIndices:insertedRowIndices:) that centralizes SQL generation logic, handling both plugin-based and SQLStatementGenerator fallback paths with post-generation validation. Existing public method now delegates to this helper.
Save Pipeline Refactoring
TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarSave.swift
Replaced per-row Redis/SQL statement generation with unified changes pipeline. Removes separate branches for Redis and SQL generators; now builds a single RowChange array and delegates to centralized changeManager.generateSQL() for statement generation, then executes via executeSidebarChanges().
Command Actions
TablePro/Views/Main/MainContentCommandActions.swift
Enhanced saveChanges flow to treat data grid changes as pending when coordinator?.changeManager.hasChanges is true OR pendingTruncates/pendingDeletes are non-empty, replacing sole reliance on right panel hasEdits check. Added separate branch to save right panel edits when no data grid changes are present.
UI Input Handling
TablePro/Views/Results/CellTextField.swift
Added keyboard shortcut handling in CellFieldEditor to commit inline edits when Cmd+S is pressed. Overrides performKeyEquivalent to resign first responder and blur editor before menu actions fire, ensuring edits are recorded.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A unified pipeline flows so clean,
No more branches forking between—
Changes tracked, SQL generated bright,
Keyboard shortcuts make edits right!
Refactored paths, the code runs lean. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main objective of the changeset: unifying the sidebar and data grid save pipelines to eliminate duplication and fix a bug where sidebar edits used an incorrect path for NoSQL databases.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/unified-sidebar-save-pipeline
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@datlechin datlechin merged commit 592879e into main Mar 16, 2026
2 of 3 checks passed
@datlechin datlechin deleted the fix/unified-sidebar-save-pipeline branch March 16, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant