Conversation
Optimized `getNativeBinaryPath` to use `fs.promises.access` instead of `fs.existsSync`. This prevents blocking the event loop during extension initialization, improving responsiveness, especially on slow file systems. Updated `isNativeAvailable` and `createNativeDatabaseConnection` to be async, and propagated changes to `src/workerFactory.ts`. Benchmark results (10k iterations): - Sync: ~53ms total - Async: ~1030ms total While async has higher overhead, it is non-blocking, which is preferred for UI responsiveness. The impact on single execution is negligible (<0.1ms). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Add a new test suite `tests/unit/tracker_serialization.test.ts` to verify the serialization and deserialization of `ModificationTracker`. The tests cover: - Basic serialization of tracker state. - Proper handling of `Uint8Array` data using `binaryReplacer`/`binaryReviver`. - Preservation of checkpoint index. - Handling of empty tracker state. This ensures data integrity during hot exit and backup scenarios. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
…nd add tests. - Extracted `cancelTokenToAbortSignal` from `src/helpers.ts` to `src/core/cancellation-utils.ts` to decouple from `vscode` module runtime dependency. - Updated `src/helpers.ts` to re-export the function. - Added unit tests in `tests/unit/cancellation-utils.test.ts`. - Fixed type signature of `cancelTokenToAbortSignal` to correctly reflect return type when input is null/undefined. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Extracted `WebviewCollection` class to `src/webview-collection.ts` to isolate it from `vscode` module dependency. - Updated `src/helpers.ts` to re-export `WebviewCollection`. - Added comprehensive unit tests in `tests/unit/webview_collection.test.ts`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Added `tests/unit/helpers.test.ts` to test `getUriParts`. - Created `tests/mocks/vscode.ts` to mock VS Code API for tests. - Created `tsconfig.test.json` to configure path mapping for tests. - Updated `package.json` to use `tsconfig.test.json` for tests. - Fixed `src/platform/cryptoShim.ts` to use optional chaining for `import.meta.env` to prevent crashes in Node.js test environment. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Replaced loop of single-row inserts with a batched INSERT statement in `undoModification`. - Implemented `insertRowBatch` method in `WasmDatabaseEngine` to handle chunked inserts (max 999 parameters/chunk) for SQLite compatibility. - Updated `DatabaseOperations` interface and worker endpoint. - Measured ~4.4x performance improvement (62ms -> 14ms for 1000 rows). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Refactor `natives/native-worker.js` to extract `executeQuery` logic. - Add `queryBatch` command to `natives/native-worker.js` for executing multiple queries. - Update `src/nativeWorker.ts` to use `queryBatch` for fetching pragmas. - Reduced pragma fetching time by ~3.4x (benchmark: 9.76ms -> 2.85ms per batch). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Refactored `updateCellBatch` in `src/hostBridge.ts` to implement parallel execution for updates when the backend does not support native batching. This replaces the previous sequential fallback loop. Additionally, extracted JSON patch generation logic into a private helper method `tryGeneratePatch` to reduce code duplication between `updateCell` and `updateCellBatch`. The fallback implementation now correctly fires a single batch modification event instead of individual events per cell. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Added validation check in `readFile` to ensure the target table or view exists in `sqlite_schema`. - Replaced placeholder `isTable` variable with actual SQL query. - Throws `FileSystemError.FileNotFound` if the target is invalid. This prevents errors when accessing non-existent tables or views and fulfills the TODO item. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Added `checkJsonPatchSupport` to `WasmDatabaseEngine` to detect native `json_patch` availability. - Optimized `updateCell` to use `json_patch` SQL function when available. - Optimized `updateCellBatch` to use `json_patch` SQL function for batch updates when available. - Ensured JS fallback is used when native function is unavailable. - Handled object inputs for patches by stringifying them before binding. - Added comprehensive unit tests in `tests/unit/json_patch_optimization.test.ts`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This commit addresses a security vulnerability where deeply nested or cyclic JSON objects could cause a stack overflow in `generateMergePatch` and `applyMergePatch`. - Introduces a `MAX_DEPTH` limit of 1000 for recursion in `src/core/json-utils.ts`. - Updates `generateMergePatch` and `applyMergePatch` to throw an error if the depth limit is exceeded. - Adds comprehensive tests in `tests/unit/json_utils_security.test.ts` to verify the fix and ensure no regressions. This change ensures the extension is robust against malicious or accidentally deep JSON structures. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Refactored `undoModification` and `redoModification` in `src/core/sqlite-db.ts` to use `updateCellBatch` instead of iterating and executing single cell updates. This resolves the N+1 query performance issue. Measured Improvement: - Baseline: ~486ms for undoing 50,000 cell updates. - Optimized: ~215ms for undoing 50,000 cell updates. - Speedup: ~2.2x faster. Added regression test case in `tests/unit/undo_redo_integration.test.ts`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This commit introduces a memory limit to the `ModificationTracker` to prevent unbounded memory growth in the undo history. Changes: - Added `calculateSize` helper to estimate the memory footprint of modifications. - Updated `ModificationTracker` to track total size of history entries. - Added `maxMemory` configuration (default 50MB). - Implemented eviction logic in `record()` to remove oldest entries when memory limit is exceeded. - Updated `deserialize` to recalculate entry sizes. - Added unit tests in `tests/unit/undo_memory_limit.test.ts`. This fixes a potential security vulnerability where large modifications could cause the extension to consume excessive memory. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Replaced synchronous `exec` with iterative `iterateStatements` + `step` loop in `WasmDatabaseEngine`. Added `queryTimeout` configuration to `DatabaseInitConfig` and `WasmDatabaseEngine` (default 50s). Implemented timeout check during row iteration to interrupt long-running queries (e.g., infinite CTEs). Ensured statement resources are freed on timeout/error. Preserved backward compatibility with `exec` behavior (parameter binding to first statement, result format). Fixes security vulnerability where malicious queries could freeze the WASM worker. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Added comprehensive unit tests for `WasmDatabaseEngine.updateCellBatch` in `src/core/sqlite-db.ts`. The tests cover: - Standard batch updates for multiple rows and columns. - JSON patch updates using RFC 7396 merge patch logic. - Mixed updates combining standard value updates and JSON patches. - Graceful handling of empty update arrays. - Transaction atomicity ensuring that errors during a batch update trigger a rollback. This improves test coverage for critical data modification logic and ensures reliability of batch operations. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Added tests/unit/sqlite-db.test.ts - Verified various scenarios including default values and SQL injection prevention. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Replaced `fs.readFileSync` with `fs.promises.readFile` in `src/core/sqlite-db.ts`. - Replaced `fs.statSync` with `fs.promises.stat`. - Added `tests/performance/benchmark.ts` to measure event loop blocking. - Verified performance: Event loop ticks increased from ~8 to ~3881 during a 500MB file read, confirming non-blocking behavior. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This commit addresses a potential security vulnerability where strings containing NUL bytes (`\0`) were not being correctly escaped for SQL export. Raw NUL bytes in SQL scripts can be misinterpreted by some tools (e.g., C-based CLI tools) as string terminators, potentially leading to truncated queries or SQL injection. The fix involves detecting NUL bytes in strings and encoding such strings as hex BLOBs, then casting them back to TEXT using `CAST(X'...' AS TEXT)`. This ensures that the generated SQL script contains only safe ASCII characters and preserves the original data integrity. Tests have been added to `tests/unit/sql-utils.test.ts` to verify the fix and ensure no regressions. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Refactored `toDatasetAttrs`, `toBoolString`, and `toDashCase` from `src/helpers.ts` to a new `src/html-utils.ts` module to remove dependency on `vscode` module during testing. - Added comprehensive unit tests in `tests/unit/html-utils.test.ts`. - Updated `src/helpers.ts` to re-export the utilities to maintain backward compatibility. - Updated `package-lock.json` to match `package.json` version (1.2.7). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Introduces unit tests for `SQLiteFileSystemProvider.writeFile` to improve test coverage for core file system operations. - Created `tests/mocks/vscode.ts` to mock `vscode` module dependencies (`Uri`, `FileSystemError`, etc.). - Created `tsconfig.test.json` to map `vscode` imports to the mock implementation during tests. - Added `tests/unit/virtualFileSystem.test.ts` covering: - Happy path for text content updates. - Handling of binary content (invalid UTF-8). - Error handling for invalid Row IDs and permission checks (`__create__.sql`). - Updated `package.json` test script to use `tsconfig.test.json` for all unit tests. This enables testing of `src/virtualFileSystem.ts` which was previously untestable due to direct `vscode` imports. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Refactored the data grid and other UI components to eliminate the need for 'unsafe-inline' in the Content Security Policy style-src directive. Key changes: - Removed `cspUtil.inlineStyle` from `src/editorController.ts`. - Replaced inline styles with CSS classes in `core/ui/modules/grid.js` and `core/ui/modules/ui.js`. - Replaced inline styles with CSS classes in `core/ui/viewer.template.html`. - Added new utility classes to `core/ui/viewer.css` to support the changes. - Updated `package-lock.json` to match `package.json` version (1.2.7). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Extracted switch cases into private helper methods to improve readability and maintainability. Added new tests for cell_update and row_insert undo/redo in tests/unit/undo_redo_integration.test.ts. Updated tests/unit/undo_redo_integration.test.ts to use beforeEach/afterEach for better isolation. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Refactored `buildSelectQuery` and `buildCountQuery` in `src/core/query-builder.ts` to use a shared helper function `buildFilterConditions`. This change reduces code duplication and fixes a potential bug where applying a global filter with an empty column list would generate invalid SQL (`WHERE ()`). - Extracted filter generation logic to `buildFilterConditions`. - Added safety check for empty columns in global filter generation. - Updated unit tests to reflect the bug fix (safe behavior for empty columns). Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Extract serialization logic to `src/core/serialization.ts`. - Extract webview message handling to `src/webviewMessageHandler.ts`. - Simplify `resolveCustomEditor` in `src/editorController.ts` by delegating to `WebviewMessageHandler`. - Add unit tests for serialization and message handling. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Removed unused and unserializable function proxies from `initializeDatabase` return value. These functions were causing `DataCloneError` when sent over RPC and were not used by the consumer (`workerFactory.ts`). Updated `DatabaseInitResult` interface to make `operations` optional. Added regression test `tests/unit/worker_endpoint_serialization.test.ts`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
Refactored `updateCell` in `src/core/sqlite-db.ts` to delegate to `updateCellBatch`, eliminating duplicated logic for cell updates and JSON patching. Also updated `undoModification` and `redoModification` to use `updateCellBatch` for batch operations, removing explicit transaction loops and preventing nested transaction errors. Enhanced `updateCellBatch` with row ID validation and improved JSON object detection. Added unit tests in `tests/unit/cell_update_refactor.test.ts`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Defined `WasmPreparedStatement` interface matching sql.js API - Updated `WasmDatabaseInstance.prepare` to return `WasmPreparedStatement` - Refactored `WasmDatabaseEngine` methods (`fetchTableData`, `updateCellBatch`) to use the new interface - Added API coverage tests for `fetchTableData` and `updateCellBatch` Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
- Removed `hostBridge` parameter from `BlobInspector` constructor. - Removed unused `this.hostBridge` property. - Updated `BlobInspector` to rely on the imported `backendApi` singleton for all RPC calls, ensuring proper `Uint8Array` serialization. - Updated `initEdit` in `edit.js` to instantiate `BlobInspector` without arguments. - Updated comments to reflect the direct usage of `backendApi`. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This commit introduces comprehensive unit tests for `SQLiteFileSystemProvider.readFile` in `src/virtualFileSystem.ts`.
It achieves this by:
1. Creating a mock for the `vscode` module in `tests/unit/mocks/vscode.ts`.
2. Creating a setup file `tests/unit/vscode_mock_setup.ts` to intercept `vscode` imports and inject the mock.
3. Implementing `tests/unit/virtualFileSystem.test.ts` covering:
- URI parsing and document resolution.
- Handling of `__create__.sql` special files.
- Reading regular table cells (strings, nulls, blobs).
- Error handling for invalid URIs, missing documents, and database errors.
This ensures the core file reading functionality is reliable and regression-proof.
Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This was referenced Feb 7, 2026
zknpr
added a commit
that referenced
this pull request
Feb 7, 2026
Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR merges the v1.3.0 branch into main, incorporating 28 PRs from Jules AI assistant plus additional bug fixes and improvements.
Merged PRs from Jules
Security Fixes
Performance Improvements
Code Quality & Refactoring
Testing Improvements
Additional Changes (Post-Merge)
New Features
sqliteExplorer.queryTimeoutsetting (default 30s)sqliteExplorer.maxUndoMemorysetting (default 50MB)Bug Fixes
Documentation
Test Results
All 132 unit tests pass.
Closes
Closes #32, #33, #34, #35, #36, #37, #38, #40, #41, #42, #43, #44, #45, #47, #48, #49, #50, #51, #52, #53, #54, #55, #56, #57, #58, #59, #60, #61, #62, #63, #64
🤖 Generated with Claude Code