Skip to content

fix(redis): comprehensive Redis plugin overhaul#377

Closed
datlechin wants to merge 12 commits intomainfrom
fix/redis-plugin-overhaul
Closed

fix(redis): comprehensive Redis plugin overhaul#377
datlechin wants to merge 12 commits intomainfrom
fix/redis-plugin-overhaul

Conversation

@datlechin
Copy link
Owner

@datlechin datlechin commented Mar 19, 2026

Summary

Comprehensive fix for the Redis plugin addressing 60+ issues discovered during deep analysis of GitHub issue #374 (Redis queries load forever).

  • Fix infinite loading bug: Replace serial per-key fetchValuePreview (200-600 round-trips) with pipelined batch (2 pipeline calls). Add scan result cache for pagination.
  • Fix data corruption: Fix tokenizer escape sequences (\n/\t/\r), empty string tokens, ZADD flag parsing (NX/XX/GT/LT/CH/INCR), ZRANGE modern syntax (BYSCORE/BYLEX/REV/LIMIT). Make statement generator type-aware (HSET for hash, RPUSH for list, etc.).
  • Harden connection layer: Add 10s connect timeout, 30s command timeout, TCP keepalive, ACL/username auth (Redis 6+), fix SSL context leak, add SNI hostname, fix binary-unsafe strdup, fix thread-safety races in context pointer and cancellation flag.
  • Fix UI integration: Skip SQL SELECT COUNT(*) and enum fetching for Redis, add Redis write/dangerous query detection, skip MULTI/EXEC wrapping for saves, add race guard on database switching, return FLUSHDB for truncate, show empty databases in sidebar.
  • Add ~40 missing commands: HSCAN/SSCAN/ZSCAN, MGET/MSET, INCR/DECR, LPOP/RPOP, SPOP/SMOVE, ZSCORE/ZRANGEBYSCORE, XADD/XREAD/XREVRANGE, AUTH, FLUSHALL, EXPIRE NX/XX/GT/LT flags. Improve zset preview (with scores) and stream preview (with entries).
  • Review fixes: Store EXAT/PXAT SET options (were silently dropped), fix cancellation race across multi-pipeline operations.

Closes #374

Test plan

  • Connect to Redis with 10k+ keys — keys load in 2-3s, not hang
  • Paginate through pages — page 2+ loads instantly from cache
  • SET key "hello\nworld" stores actual newline
  • SET key "" stores empty string
  • ZADD myset NX 1.0 member parses successfully
  • Edit a hash key value in UI, save — remains hash type
  • Wrong host/port times out in ~10s
  • Redis 6+ ACL auth works
  • No SQL errors in logs when opening Redis tabs
  • Empty databases visible in sidebar
  • FLUSHDB triggers dangerous-query warning
  • SET key value detected as write in read-only mode
  • Sidebar "Truncate" runs FLUSHDB, not SQL
  • Zset keys show scores in browse view
  • Stream keys show entries, not just count

Summary by CodeRabbit

  • New Features

    • Added Cloudflare D1 database support, enabling users to connect to and query D1 databases directly from TablePro with full schema browsing, data editing, EXPLAIN queries, and database management capabilities.
    • Enhanced Redis plugin with improved command parsing, SSL certificate verification control, username/password authentication, better connection timeouts, and optimized key browsing with result caching.
  • Documentation

    • Added comprehensive Cloudflare D1 connection and usage guides in English, Vietnamese, and Chinese.

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request introduces Cloudflare D1 database support to TablePro by adding a complete D1 driver plugin with HTTP API communication, expanding Redis driver capabilities with enhanced command parsing and connection handling, introducing a new apiOnly connection mode, and extending the plugin infrastructure with D1 metadata and configuration. The changes span the D1 driver implementation, UI updates, Redis improvements, project configuration, and multi-language documentation.

Changes

Cohort / File(s) Summary
Cloudflare D1 Driver Plugin
Plugins/CloudflareD1DriverPlugin/CloudflareD1Plugin.swift, Plugins/CloudflareD1DriverPlugin/CloudflareD1PluginDriver.swift, Plugins/CloudflareD1DriverPlugin/D1HttpClient.swift, Plugins/CloudflareD1DriverPlugin/Info.plist
New D1 driver plugin with plugin metadata, database driver implementation (query execution, schema introspection, database switching), HTTP client for D1 API (request/response handling, error mapping), and plugin configuration file.
Plugin Infrastructure & Connection Mode
Plugins/TableProPluginKit/ConnectionMode.swift, TablePro/Models/Connection/DatabaseConnection.swift
Added new apiOnly connection mode case and cloudflareD1 database type to support non-traditional connection paradigms.
Plugin Registry & Metadata
TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift
Added D1-specific dialect configuration, column type mappings, and registry defaults including auth fields, URL scheme, and explain variants.
Connection UI & Validation
TablePro/Views/Connection/ConnectionFormView.swift
Updated form conditionals to distinguish .apiOnly connections with dedicated "Database" input section, adjusted auth field visibility, changed password label to "API Token", and extended validation logic for API-only requirements.
Redis Driver Enhancements
Plugins/RedisDriverPlugin/RedisCommandParser.swift, Plugins/RedisDriverPlugin/RedisPlugin.swift, Plugins/RedisDriverPlugin/RedisPluginConnection.swift, Plugins/RedisDriverPlugin/RedisPluginDriver.swift, Plugins/RedisDriverPlugin/RedisQueryBuilder.swift, Plugins/RedisDriverPlugin/RedisStatementGenerator.swift
Extended Redis command parsing with additional command variants, flags, and error handling; enhanced SSL/auth configuration with verifyPeer and username support; improved connection lifecycle and timeout handling; added SCAN result caching and per-key type preview; refactored statement generation for type-specific commands.
Coordinator Navigation & Query Analysis
TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift, TablePro/Views/Main/Extensions/MainContentCoordinator+QueryAnalysis.swift, TablePro/Views/Main/Extensions/MainContentCoordinator+QueryHelpers.swift, TablePro/Views/Main/Extensions/MainContentCoordinator+SaveChanges.swift, TablePro/Views/Main/MainContentCoordinator.swift
Added task cancellation for Redis database switch operations, implemented Redis-specific write/dangerous query detection, added conditional row-count strategy based on SQL vs. non-SQL, and conditional transaction wrapping based on database type.
Xcode Project Configuration
TablePro.xcodeproj/project.pbxproj
Added new native target for CloudflareD1DriverPlugin with build phases, bundle configuration, and framework linking.
Asset & Localization
TablePro/Assets.xcassets/cloudflare-d1-icon.imageset/Contents.json, TablePro/Resources/Localizable.xcstrings
Added Cloudflare D1 vector icon asset and new localizable string keys for "Account ID" and "API Token".
Build Workflow
.github/workflows/build-plugin.yml
Updated tag parsing regex to support plugin names with digits/hyphens and added cloudflare-d1 plugin mapping configuration.
Changelog & Tests
CHANGELOG.md, TableProTests/Core/CloudflareD1/*
Added unreleased changelog entry for D1 support and comprehensive test suites validating D1 driver helpers, metadata, API response parsing, and value decoding.
Documentation
docs/databases/cloudflare-d1.mdx, docs/vi/databases/cloudflare-d1.mdx, docs/zh/databases/cloudflare-d1.mdx
Added multi-language documentation covering installation, setup flow, connection fields, credential acquisition, database creation, capabilities, troubleshooting, and limitations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 A cloudflare d1 dreams in the sky,
With api tokens and accounts on high,
Redis keys hop about in their cache,
Forms shift and shape with each splash,
New modes bloom where connection paths fly!

🚥 Pre-merge checks | ✅ 1 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'fix(redis): comprehensive Redis plugin overhaul' is misleading. The changeset includes substantial new Cloudflare D1 plugin implementation (plugin files, tests, documentation) which is not a 'fix' but a feature addition. Redis changes are only part of the overall changeset. Revise title to reflect both major additions: e.g., 'feat(plugins): add Cloudflare D1 plugin and Redis overhaul' or split into separate PRs for D1 (feature) and Redis (fixes).
Linked Issues check ⚠️ Warning The PR substantially exceeds issue #374 scope. While #374 requests Redis support, the changeset also adds complete Cloudflare D1 plugin implementation with driver, HTTP client, tests, and documentation—none of which is mentioned in the linked issue. Either link all relevant issues or split this PR. At minimum, link an issue for Cloudflare D1 feature or clarify D1 was in-scope for #374.
Out of Scope Changes check ⚠️ Warning Cloudflare D1 implementation (plugin files, tests, documentation, asset catalog, build configuration) is out of scope for issue #374 which only requests Redis support. The D1 feature appears to be a separate feature addition bundled with Redis changes. Extract Cloudflare D1 changes into a separate PR linked to its own issue, or document that D1 was approved in-scope for #374 and update linked issues accordingly.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/redis-plugin-overhaul
📝 Coding Plan
  • Generate coding plan for human review comments

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

@datlechin datlechin closed this Mar 19, 2026
@datlechin datlechin deleted the fix/redis-plugin-overhaul branch March 19, 2026 09:19
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.

feat: Add Redis support

1 participant