Commit Graph

48 Commits

Author SHA1 Message Date
2d2dcdc4a8 fix: resolve all 25 ESLint react-hooks and react-refresh violations
Replace useEffect-based state resets in dialogs with React's render-time
state adjustment pattern. Wrap ref assignments in hooks with useEffect.
Suppress known third-party library warnings (shadcn CVA exports,
TanStack Table). Remove warn downgrades from eslint config.
2026-04-08 07:41:34 +03:00
9237c7dd8e perf: optimize HTTP client, DB queries, and clean up dead code
- Make reqwest::Client a LazyLock singleton instead of per-call allocation
- Parallelize 3 independent DB queries in get_index_advisor_report with tokio::join!
- Eliminate per-iteration Vec allocation in snapshot FK dependency loop
- Hoist try_local_pg_dump() call in SampleData clone mode to avoid double execution
- Evict stale schema cache entries on write to prevent unbounded memory growth
- Remove unused ValidationReport struct and config_path field
- Rename IndexRecommendationType variants to remove redundant suffix
2026-04-06 13:13:03 +03:00
6b925d6260 style: apply rustfmt, fix clippy warnings, and minor code cleanup
Reformat Rust code with rustfmt, suppress clippy::too_many_arguments
for Tauri IPC commands, derive Default for AppSettings, fix unused
variable pattern in TableDataView, and add unit tests for utils.
2026-04-06 13:12:52 +03:00
1e002d801a chore: update build config, linting, and add test infrastructure
Replace install -D with mkdir -p + install for macOS portability,
add vitest with jsdom and testing-library, configure eslint for
react-hooks v7 warnings, and add tokio test deps for Rust.
2026-04-06 13:12:43 +03:00
f8dd94a6c7 chore: remove node_modules prerequisite from make dev 2026-04-06 10:27:24 +03:00
4e5714b291 feat: redesign UI with Twilight design system
Outfit + JetBrains Mono typography, soft dark palette with blue
undertones, electric teal primary, purple-branded AI features,
noise texture, glow effects, glassmorphism, and refined grid/tree.
2026-04-06 10:27:20 +03:00
64e27f79a4 ci: configure Gitea Actions for Docker-based runner
Some checks failed
CI / lint-and-build (push) Failing after 2s
Use explicit ubuntu:22.04 container instead of marketplace actions
that may not work on self-hosted Gitea runners. Install Node.js and
Rust toolchain directly via curl/rustup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 15:38:00 +03:00
ab898262dd ci: add Gitea Actions workflows for Linux-only CI and release
Some checks failed
CI / lint-and-test (push) Failing after 1m20s
CI / build (push) Has been skipped
Adapt GitHub Actions workflows for Gitea with Docker runner:
- Linux-only builds (no macOS/Windows matrix)
- Manual `npm run tauri build` instead of tauri-action
- Release creation via Gitea API with asset upload

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:30:40 +03:00
e984bf233e ci: add cross-platform builds for Linux, macOS (Intel + ARM), and Windows
Some checks failed
CI / lint-and-test (push) Failing after 27s
CI / build (, tusk-linux-x64, ubuntu-22.04, ) (push) Has been skipped
CI / build (, tusk-windows-x64, windows-latest, ) (push) Has been skipped
CI / build (--target aarch64-apple-darwin, tusk-macos-arm64, macos-latest, aarch64-apple-darwin) (push) Has been skipped
CI / build (--target x86_64-apple-darwin, tusk-macos-x64, macos-13, x86_64-apple-darwin) (push) Has been skipped
- Add macOS Intel build (macos-13 / x86_64-apple-darwin) to CI matrix
- Add artifact upload step to CI build job
- Add release workflow triggered by v* tags with draft GitHub Release
- Add AppImage to Linux bundle targets

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 17:21:09 +03:00
34c80809f1 fix: prevent snapshot hang caused by u8 overflow in progress calculation
When creating/restoring snapshots with 4+ tables, the progress percentage
calculation overflowed u8 (e.g. 4*80=320 > 255), causing a panic that left
the IPC call unresolved. Also deduplicate fetch_foreign_keys_raw call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 17:45:58 +03:00
a3b05b0328 feat: add AI data validation, test data generator, index advisor, and snapshots
Four new killer features leveraging AI (Ollama) and PostgreSQL internals:

- Data Validation: describe quality rules in natural language, AI generates
  SQL to find violations, run with pass/fail results and sample violations
- Test Data Generator: right-click table to generate realistic FK-aware test
  data with AI, preview before inserting in a transaction
- Index Advisor: analyze pg_stat tables + AI recommendations for CREATE/DROP
  INDEX with one-click apply
- Data Snapshots: export selected tables to JSON (FK-ordered), restore from
  file with optional truncate in a transaction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 13:27:41 +03:00
d507162377 fix: harden security, reduce duplication, and improve robustness
- Fix SQL injection in data.rs by wrapping get_table_data in READ ONLY transaction
- Fix SQL injection in docker.rs CREATE DATABASE via escape_ident
- Fix command injection in docker.rs by validating pg_version/container_name
  and escaping shell-interpolated values
- Fix UTF-8 panic on stderr truncation with char_indices
- Wrap delete_rows in a transaction for atomicity
- Replace .expect() with proper error propagation in lib.rs
- Cache AI settings in AppState to avoid repeated disk reads
- Cap JSONB column discovery at 50 to prevent unbounded queries
- Fix ERD colorMode to respect system theme via useTheme()
- Extract AppState::get_pool() replacing ~19 inline pool patterns
- Extract shared AiSettingsFields component (DRY popover + sheet)
- Make get_connections_path pub(crate) and reuse from docker.rs
- Deduplicate check_docker by delegating to check_docker_internal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 11:41:14 +03:00
baa794b66a feat: fallback to ctid for editing tables without primary key
When a table has no PRIMARY KEY, use PostgreSQL's ctid (physical row ID)
to identify rows for UPDATE/DELETE operations instead of blocking edits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 16:14:26 +03:00
e76a96deb8 feat: add unified Settings sheet, MCP indicator, and Docker host config
- Add AppSettingsSheet (gear icon in Toolbar) with MCP, Docker, and AI sections
- MCP Server: toggle on/off, port config, status badge, endpoint URL with copy
- Docker: local/remote daemon selector with remote URL input
- AI: moved Ollama settings into the unified sheet
- MCP status probes actual TCP port for reliable running detection
- Docker commands respect configurable docker host (-H flag) for remote daemons
- MCP server supports graceful shutdown via tokio watch channel
- Settings persisted to app_settings.json alongside existing config files
- StatusBar shows MCP indicator (green/gray dot) with tooltip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 09:04:12 +03:00
20b00e55b0 fix: improve Docker clone reliability and log display
- Use bash with pipefail instead of sh to detect pg_dump failures in pipes
- Switch full clone from binary format (pg_dump -Fc | pg_restore) to plain
  text (pg_dump | psql) for reliable transfer through docker exec
- Add --no-owner --no-acl flags to avoid errors from missing roles
- Extract shared run_pipe_cmd helper with proper error handling
- Remove shell commands from progress events to prevent credential leaks
- Fix process log layout overflow with break-all and block-level details

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:41:59 +03:00
1ce5f78de8 feat: add Clone Database to Docker functionality
Clone any database to a local Docker PostgreSQL container with schema
and/or data transfer via pg_dump. Supports three modes: schema only,
full clone, and sample data. Includes container lifecycle management
(start/stop/remove) in the Admin panel, progress tracking with
collapsible process log, and automatic connection creation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:27:16 +03:00
f68057beef fix: remove duplicate app name from toolbar
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 16:38:57 +03:00
94df94db7c feat: add ER diagram and enhance TableStructure with FK details, triggers, comments
- Add interactive ER diagram with ReactFlow + dagre auto-layout, accessible
  via right-click context menu on schema nodes in the sidebar
- Enhance TableStructure: column comments, FK referenced table/columns,
  ON UPDATE/DELETE rules, new Triggers tab
- Backend: rewrite get_table_constraints using pg_constraint for proper
  composite FK support, add get_table_triggers and get_schema_erd commands

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 16:37:38 +03:00
b44254bb29 fix: preserve tab state when switching between tabs
Render all tabs simultaneously with display:none for inactive ones,
instead of conditionally rendering only the active tab. This prevents
React from unmounting/remounting components on tab switch, preserving
query results, editor cursor, AI explanations, and other local state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 19:45:45 +03:00
a71afe8d5e fix: enable horizontal scroll in entity lookup and increase timeout to 120s
Replace Radix ScrollArea with plain overflow-auto div to allow nested
horizontal scrolling in lookup result tables. Add overflow-auto to
table containers. Increase per-database search timeout from 30s to 120s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 19:26:33 +03:00
f8a53e1166 fix: add PostgreSQL array type support in pg_value_to_json
Handle _BOOL, _INT2, _INT4, _INT8, _FLOAT4, _FLOAT8, _TEXT, _VARCHAR,
_CHAR, _BPCHAR, _NAME, _UUID, _JSON, _JSONB array types so they render
as JSON arrays instead of "<unsupported type>".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 19:17:50 +03:00
c8ba0eac81 fix: enable text selection in results panel and preserve AI prompt
Add select-text to override global user-select:none on results table,
JSON view, error messages, and AI explanation. Also keep AI prompt text
after generation with a clear button.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 19:10:36 +03:00
3ad0ee5cc3 feat: add AI Explain Query and Fix Error via Ollama
Extract shared call_ollama_chat helper from generate_sql to reuse
settings loading and Ollama API call logic. Add two new AI commands:
- explain_sql: explains what a SQL query does in plain language
- fix_sql_error: suggests corrected SQL based on the error and schema

UI additions: "AI Explain" toolbar button, "Explain" and "Fix with AI"
action buttons on query errors, inline explanation display in results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:48:39 +03:00
c001ad597f feat: add schema caching with 5-min staleTime and refresh button
Reduce unnecessary re-fetches on large DWH by caching schema/management
queries for 5 minutes, and add a refresh button in the sidebar to
force-reload when needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:32:18 +03:00
e8d99c645b feat: add Greenplum 7 compatibility and AI SQL generation
Greenplum 7 (PG12-based) compatibility:
- Auto-detect GP via version() string, store DbFlavor per connection
- connect returns ConnectResult with version + flavor
- Fix pg_total_relation_size to use c.oid (universal, safer on both PG/GP)
- Branch is_identity column query for GP (lacks the column)
- Branch list_sessions wait_event fields for GP
- Exclude gp_toolkit schema in schema listing, completion, lookup, AI context
- Smart StatusBar version display: GP shows "GP 7.0.0 (PG 12.4)"
- Fix connection list spinner showing on all cards during connect

AI SQL generation (Ollama):
- Add AI settings, model selection, and generate_sql command
- Frontend AI panel with prompt input and SQL output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:24:06 +03:00
d5cff8bd5e feat: add cross-database entity lookup for searching column values across all databases
Enables searching for a specific column value (e.g. carrier_id=123) across all databases on a PostgreSQL server. The backend creates temporary connection pools per database (semaphore-limited to 5), queries information_schema for matching columns, and executes read-only SELECTs with real-time progress events. Results are grouped by database/table in a new "Entity Lookup" tab.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 17:28:33 +03:00
a2371f00df feat: add JSON view mode toggle for query results
Add a Table/JSON segmented toggle to both the query workspace and
table data viewer, allowing users to switch between tabular and
pretty-printed JSON display of results without exporting to a file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 13:05:52 +03:00
e02225a3b9 fix: use tauri::async_runtime::spawn for MCP server
tokio::spawn panics in .setup() because Tauri's Tokio reactor isn't
active yet at that point. tauri::async_runtime::spawn handles this.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 14:03:26 +03:00
4b6c547bcf fix: use --no-bundle in build/install, split bundle targets
- `make build` now uses --no-bundle so install doesn't fail on
  platform-specific bundlers (e.g. linuxdeploy for AppImage)
- Separate `make bundle-*` targets for deb, rpm, appimage, macos, windows
- `make bundle` still builds everything for the current platform

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 13:49:10 +03:00
32486b0524 feat: add embedded MCP server and Makefile
Add an MCP (Model Context Protocol) server that starts on 127.0.0.1:9427
at app launch, sharing connection pools with the Tauri IPC layer. This
lets Claude (or any MCP client) query PostgreSQL through Tusk's existing
connections.

MCP tools: list_connections, execute_query, list_schemas, list_tables,
describe_table.

Also add a Makefile with targets for dev, build (cross-platform),
install/uninstall, lint, and formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 13:24:25 +03:00
ded35d8c40 docs: add CLAUDE.md with project architecture and dev commands
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 12:18:20 +03:00
9d54167023 feat: add column sort, SQL formatter, table stats, insert dialog, saved queries & sessions monitor
- Column sort by header click in table view (ASC/DESC/none cycle, server-side)
- SQL formatter with Format button and Shift+Alt+F keybinding (sql-formatter)
- Table size and row count display in schema tree via pg_class
- Insert row dialog with column type hints and auto-skip for identity columns
- Saved queries (bookmarks) with CRUD backend, sidebar panel, and save dialog
- Active sessions monitor (pg_stat_activity) with auto-refresh, cancel & terminate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 11:52:05 +03:00
ab72eeee80 feat: add reconnect button to toolbar
Add a refresh/reconnect button next to the connection selector.
Clicking it disconnects and reconnects the active connection, then
invalidates all cached queries to refresh schema, tables, roles, etc.
Shows a spinning animation while reconnecting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 01:12:45 +03:00
47b040fadf feat: add DSN input mode to connection dialog
Add Fields/DSN toggle in New Connection dialog. DSN mode accepts a
PostgreSQL connection string (postgresql://user:pass@host:port/db?sslmode=...)
and auto-parses it into individual fields. Switching between modes
syncs the data bidirectionally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 22:19:38 +03:00
cebe2a307a feat: add database, role & privilege management
Add Admin sidebar tab with database/role management panels, role manager
workspace tab, and privilege dialogs. Backend provides 10 new Tauri
commands for CRUD on databases, roles, and privileges with read-only
mode enforcement. Context menus on schema tree nodes allow dropping
databases and viewing/granting table privileges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 22:11:02 +03:00
d3b98f9261 fix: widen connection selector to fit environment badge
Changed from fixed w-[200px] to w-auto max-w-[280px] so the trigger
sizes to its content without clipping the environment badge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:44:48 +03:00
c0a108a132 fix: remove duplicate color dot from connection selector trigger
SelectValue already renders the color dot from the selected item,
so the explicit one in the trigger was redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:44:01 +03:00
106e2497df fix: remove duplicate environment badges from toolbar
SelectValue already renders the badge from the selected item content,
so the explicit badge in the trigger and the standalone toolbar badge
were redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:42:34 +03:00
7f82ffe7f1 feat: add environment labels (local/dev/stage/prod) for connections
Visual badges help distinguish environments across the UI to prevent
running dangerous queries on production. Environment color takes
priority over custom connection color for the toolbar border.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:40:50 +03:00
ebc6a7e51a feat: add CSV/JSON export buttons to query results and table data view
Export dropdown (CSV/JSON) appears in the WorkspacePanel toolbar when
query results are available, and in the TableDataView toolbar for table
data. Uses the Tauri save dialog for file path selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:23:07 +03:00
3b3e225e8f feat: add connection colors, query history, SQL autocomplete, and EXPLAIN visualizer
Add four developer/QA features:
- Connection color coding: color picker in dialog, colored indicators across toolbar, tabs, status bar, and connection selectors
- Query history: Rust backend with JSON file storage (500 entry cap), sidebar panel with search/clear, auto-recording from workspace
- Schema-aware SQL autocomplete: backend fetches column metadata, CodeMirror receives schema namespace with public tables unprefixed
- EXPLAIN ANALYZE visualizer: recursive tree view with cost-colored bars, expand/collapse nodes, buffers info, Results/Explain tab toggle

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 20:22:10 +03:00
72c362dfae feat: add per-connection read-only mode
Connections default to read-only. SQL editor wraps queries in a
read-only transaction so PostgreSQL rejects mutations. Data mutation
commands (update_row, insert_row, delete_rows) are blocked at the
Rust layer. Toolbar toggle with confirmation dialog lets users
switch to read-write. Badges shown in workspace, table viewer, and
status bar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:36:19 +03:00
9b9d2cee94 feat: add table data viewer, structure inspector, and export
Add TableDataView with pagination, filtering, and inline editing,
TableStructure with columns/constraints/indexes tabs,
PaginationControls, and ExportDialog for CSV/JSON export.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:54 +03:00
13a8535b5c feat: add SQL editor, query results, and workspace panels
Add CodeMirror 6 SQL editor with Ctrl+Enter execution, ResultsTable
with virtual scrolling and resizable columns, ResultsPanel, EditableCell,
WorkspacePanel (editor + results split), and TabContent router.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:48 +03:00
d333732346 feat: add schema browser sidebar and app layout
Add SchemaTree with database/schema/category hierarchy, Sidebar with
search, Toolbar, TabBar, StatusBar, and full app layout with
resizable panels.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:42 +03:00
734b84b525 feat: add connection management UI
Add TypeScript types, typed Tauri invoke wrappers, Zustand store,
TanStack Query hooks, and connection components: ConnectionDialog
(create/edit/test), ConnectionList (sheet panel), ConnectionSelector
(toolbar dropdown).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:35 +03:00
9b675babd5 feat: add Tauri v2 Rust backend with PostgreSQL support
Add Rust backend: AppState with connection pool management,
TuskError handling, ConnectionConfig model, and all commands
for connections, schema browsing, query execution, data CRUD,
and CSV/JSON export via sqlx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:27 +03:00
27bdbf0112 feat: scaffold Tauri v2 + React + TypeScript + shadcn/ui project
Set up Vite + React 19 + TypeScript, Tauri v2, Tailwind v4,
shadcn/ui (dark theme), and all core frontend dependencies
(Zustand, TanStack Query/Table/Virtual, CodeMirror, lucide-react).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:06:20 +03:00