fix: lazy-load full values for truncated columns in detail pane#446
fix: lazy-load full values for truncated columns in detail pane#446
Conversation
…umns in detail pane
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds UI and state plumbing to lazy-load full values for excluded/truncated LONGTEXT/MEDIUMTEXT/CLOB columns: state flags, coordinator DB fetch, main view async flow to apply results, editor UI changes to show truncated/loading states, tests, and changelog/localization entries. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as MainContentView
participant State as MultiRowEditState
participant Coordinator as MainContentCoordinator
participant DB as Database
participant Editor as EditableFieldView
UI->>State: configure(excludedColumnNames: Set)
State->>State: mark fields with isTruncated=true\nisLoadingFullValue=true
Note over UI: single-row selection
UI->>Coordinator: fetchFullValuesForExcludedColumns(table, pkCol, pkVal, excluded)
Coordinator->>DB: execute parameterized SELECT for excluded columns
DB-->>Coordinator: row with full values
Coordinator-->>UI: [columnName: value] dictionary
UI->>State: applyFullValues(fullValues)
State->>State: update originalValue\nset isTruncated=false\nset isLoadingFullValue=false
State-->>Editor: propagate flags and values
Editor->>Editor: render full value / spinner / truncated badge
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@TablePro/Views/Main/Extensions/MainContentCoordinator`+LazyLoadColumns.swift:
- Around line 14-15: The extension for MainContentCoordinator lacks an explicit
access control modifier; update the extension declaration (extension
MainContentCoordinator) to include the repository's required modifier (for
example use "internal extension MainContentCoordinator") so the extension itself
has an explicit access level while leaving individual members unchanged; locate
the extension containing the function fetchFullValuesForExcludedColumns and add
the access modifier there.
- Line 41: Remove the hardcoded "LIMIT 1" from the SQL string built with
quotedCols, quotedTable, quotedPK and placeholder in the query assignment so the
code does not rely on a SQL dialect-specific clause (the primary-key predicate
already guarantees a single row); also add an explicit access control modifier
to the extension declaration by changing the extension to "private extension
MainContentCoordinator {" (or "internal"/"public" if broader visibility is
required).
In `@TablePro/Views/Main/MainContentView.swift`:
- Around line 937-956: The error handler can modify fields of a new selection if
the row changed while the lazyLoadTask awaited; to fix, capture an immutable
identifier for the targeted selection (e.g., pkValue or a generated
selectionToken) before calling
capturedCoordinator.fetchFullValuesForExcludedColumns in the Task and then, in
both the success path (before applyFullValues) and the catch path (before
clearing isLoadingFullValue on capturedEditState.fields), check that the current
selection still matches that captured identifier; only applyFullValues or reset
loading flags when the identifiers match, otherwise no-op to avoid touching the
new selection’s fields (update code near lazyLoadTask,
capturedCoordinator.fetchFullValuesForExcludedColumns,
capturedEditState.applyFullValues and the catch block that iterates
capturedEditState.fields).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: be5b25cd-94ff-48ab-9985-d777fadf6a61
📒 Files selected for processing (9)
CHANGELOG.mdTablePro.xcodeproj/project.pbxprojTablePro/Models/UI/MultiRowEditState.swiftTablePro/Resources/Localizable.xcstringsTablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swiftTablePro/Views/Main/MainContentView.swiftTablePro/Views/RightSidebar/EditableFieldView.swiftTablePro/Views/RightSidebar/RightSidebarView.swiftTableProTests/Models/MultiRowEditStateTruncationTests.swift
TablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swift
Outdated
Show resolved
Hide resolved
TablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
TablePro/Models/UI/MultiRowEditState.swift (1)
224-225: Declare the new mutation API's access level explicitly.
applyFullValues(_:)currently relies on Swift's defaultinternal. Please spell the intended visibility out here so this new edit-state entry point follows the repo convention, then rerunswiftlint lint --strict. As per coding guidelines, "Always use explicit access control modifiers (private,internal,public). Specify access modifier on extension, not individual members".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@TablePro/Models/UI/MultiRowEditState.swift` around lines 224 - 225, The new mutation API method applyFullValues(_:) currently has implicit internal visibility; update the access control by adding an explicit access modifier to the extension that contains applyFullValues (e.g., mark the extension as internal or public per the repo convention) rather than annotating individual members so the new edit-state entry point follows the guideline "Specify access modifier on extension, not individual members", then re-run swiftlint lint --strict to verify.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@TablePro/Models/UI/MultiRowEditState.swift`:
- Around line 125-138: The pending-edit preservation is comparing
oldField.originalValue to the rebuilt truncated originalValue (causing saved
edits to be dropped after applyFullValues(_:)); update the preservation check in
MultiRowEditState (inside the configure/field-rebuild logic) to compare
oldField.originalValue against the effective preservedOriginalValue used when
preserving full values (and still verify oldField.hasMultipleValues ==
hasMultipleValues) so pendingValue/isPendingNull/isPendingDefault are copied
only when oldField matches the actual preserved original value rather than the
truncated one.
---
Nitpick comments:
In `@TablePro/Models/UI/MultiRowEditState.swift`:
- Around line 224-225: The new mutation API method applyFullValues(_:) currently
has implicit internal visibility; update the access control by adding an
explicit access modifier to the extension that contains applyFullValues (e.g.,
mark the extension as internal or public per the repo convention) rather than
annotating individual members so the new edit-state entry point follows the
guideline "Specify access modifier on extension, not individual members", then
re-run swiftlint lint --strict to verify.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 96b1e79a-d42b-48e2-aafc-df1297af9288
📒 Files selected for processing (4)
TablePro/Models/UI/MultiRowEditState.swiftTablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swiftTablePro/Views/Main/MainContentView.swiftTablePro/Views/RightSidebar/EditableFieldView.swift
🚧 Files skipped from review as they are similar to previous changes (3)
- TablePro/Views/RightSidebar/EditableFieldView.swift
- TablePro/Views/Main/MainContentView.swift
- TablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swift
Summary
ColumnExclusionPolicytruncatesLONGTEXT/MEDIUMTEXT/CLOBcolumns to 256 chars viaSUBSTRING()in browse queries for performance. The detail pane (right sidebar) displayed these truncated values for editing — saving would silently overwrite the full DB value with truncated data.SELECT col FROM table WHERE pk = ?to fetch full values for excluded columns, then patch them into the sidebar edit state.getEditedFields()prevents saving any field still marked as truncated.Test plan
MultiRowEditStateTruncationTests— all passMultiRowEditStateTests— all pass (no regressions)ColumnExclusionPolicyTests— all passSummary by CodeRabbit
New Features
Bug Fixes
Documentation