You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update CLAUDE.md with stale fixes and missing patterns (#110)
* fix: address code review suggestions for PR #108
1. cellEditBehavior precedence: Move VS Code env config read after state
restoration so extension settings override restored webview state.
If the user changes the setting while a tab is hidden, the new value
takes effect on re-show.
2. Unit tests: Add tests for getNodeFs() (returns fs module in Node.js,
returns same reference on repeated calls) and LogEnvelope processing
(onLog callback invoked with correct args, silent drop without callback).
3. JSDoc cleanup: Remove duplicate processProtocolMessage JSDoc block
in rpc.ts and consolidate into single comment with onLog parameter.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: update CLAUDE.md with 8 stale fixes and missing patterns
Stale fixes:
- Uint8Array serialization: document Base64 format as preferred, array as legacy
- saveCellEdit: fix reference from backendApi.exec() to backendApi.updateCell()
- Web demo paths: website/public/demo/ → website/public/sqlite-viewer/
- Worker loading: webWorker.ts → workerFactory.ts (file doesn't exist)
- Worker logging: document RPC LogEnvelope routing to output channel
- retainContextWhenHidden: now false, document setState/getState flow
Missing content added:
- Key files: json-utils, cancellation-utils, serialization, documentRegistry,
webviewMessageHandler, webview-collection
- Patterns: webview state persistence, getNodeFs(), json_patch() optimization
with runtime fallback, queryBatch for batched IPC
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@@ -280,6 +296,26 @@ Database operations are wrapped in `LoggingDatabaseOperations` which writes all
280
296
281
297
The webview provides a UI to configure SQLite PRAGMAs (e.g., WAL mode, Foreign Keys) directly via `hostBridge.setPragma()`.
282
298
299
+
### Webview State Persistence
300
+
301
+
`retainContextWhenHidden` is `false` — webviews are destroyed when hidden to save memory. State survives via `vscodeApi.setState()`/`getState()`:
302
+
-`persistState()` in `state.js` debounces (500ms) and serializes user-facing state (selected table, scroll position, filters, pins, settings)
303
+
-`viewer.js` restores state on re-initialization, including scroll position after grid render
304
+
- VS Code extension settings (e.g., `cellEditBehavior`) take precedence over restored state
305
+
- Web demo (`web-api.js`) provides no-op stubs since there is no VS Code API
306
+
307
+
### Platform Helpers
308
+
309
+
`getNodeFs()` in `sqlite-db.ts` safely requires the Node.js `fs` module, returning `undefined` in browser environments. Used by `sqlite-db.ts` (file reading, writing) and `tableExporter.ts` (streaming export).
310
+
311
+
### JSON Patch Optimization
312
+
313
+
`updateCell` and `updateCellBatch` in `sqlite-db.ts` probe for SQLite's `json_patch()` at engine construction time (`hasJsonPatch` flag). When available, uses `json_patch(COALESCE(col, '{}'), ?)` in a single UPDATE (no SELECT round-trip). Falls back to JS-side `applyMergePatch()` from `json-utils.ts` when JSON1 extension is unavailable.
314
+
315
+
### Batched IPC
316
+
317
+
`queryBatch` in `nativeWorker.ts` sends multiple SQL queries in a single IPC round-trip. Used for schema fetching (3 queries → 1 call) and pragma reads.
318
+
283
319
### Blob Inspector
284
320
285
321
The Blob Inspector (`core/ui/modules/blob-inspector.js`) provides preview and editing for BLOB data:
0 commit comments