Add history import/export functionality - #1844
Draft
paustint wants to merge 1 commit into
Draft
Conversation
paustint
force-pushed
the
feat/add-history-import-export
branch
from
July 1, 2026 15:24
fddf1c2 to
ac41f83
Compare
paustint
force-pushed
the
feat/add-history-import-export
branch
from
August 4, 2026 14:36
ac41f83 to
aace29c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a client-side history backup/restore flow so users can export browser-stored history to a JSON file and later import it back (with “smart merge” behavior to avoid duplicates and preserve favorites), plus a small upsell nudge for non-RecordSync users.
Changes:
- Introduces a versioned
ClientDataExportEnvelope+ Zod schema for validating/sanitizing imported backup files (including prototype-pollution key stripping). - Adds UI-DB export/import implementations that read/write Dexie + localforage datasets and merge on import.
- Adds Settings UI for export/import and updates accepted file types/analytics keys; adds a query-history modal “backup & sync” nudge for free users.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/types/src/lib/ui/types.ts | Adds .json as an InputAcceptType. |
| libs/types/src/lib/ui/types.ts | Defines deploy history item shape (fileKey?) used by export/import. |
| libs/types/src/lib/sync/sync.types.ts | Adds client export/import envelope types + Zod schema (with reserved-key stripping). |
| libs/types/src/lib/sync/tests/sync.types.spec.ts | Adds tests for envelope parsing/date revival/reserved-key stripping. |
| libs/shared/ui-db/src/lib/client-data.db.ts | Ensures Dexie sync disconnect is called when sync is disabled (avoid auto-reconnect). |
| libs/shared/ui-db/src/lib/client-data-merge.utils.ts | Adds pure merge helpers for idempotent-ish merging during import. |
| libs/shared/ui-db/src/lib/client-data-import.db.ts | Implements import (validate, version-check, Dexie upserts, localforage merges). |
| libs/shared/ui-db/src/lib/client-data-export.db.ts | Implements export (Dexie tables + localforage, omit deploy blobs). |
| libs/shared/ui-db/src/lib/tests/client-data-merge.utils.spec.ts | Unit-tests merge helpers and query-history-object derivation. |
| libs/shared/ui-db/src/index.ts | Re-exports new import/export DB APIs. |
| libs/shared/ui-core/src/query/QueryHistory/QueryHistoryModal.tsx | Adds non-RecordSync nudge + analytics event to Billing route. |
| libs/shared/constants/src/lib/shared-constants.ts | Adds JSON accept type constant + analytics keys for settings and nudge click. |
| apps/jetstream/src/app/components/settings/SettingsExportImportHistory.tsx | Adds Settings UI for exporting/importing JSON backups. |
| apps/jetstream/src/app/components/settings/Settings.tsx | Renders the new Settings export/import section. |
Comment on lines
+256
to
+258
| const QueryHistoryItemImportSchema = z | ||
| .object({ key: z.string(), lastRun: DateTimeSchema, createdAt: DateTimeSchema, updatedAt: DateTimeSchema }) | ||
| .catchall(z.unknown()); |
Comment on lines
+48
to
+53
| } catch (ex) { | ||
| logger.error('[SETTINGS] Error importing history', ex); | ||
| fireToast({ | ||
| message: 'We could not import that file. Make sure it is an unmodified Jetstream history export and try again.', | ||
| type: 'error', | ||
| }); |
Comment on lines
+91
to
+97
| const merged: QueryHistoryItem[] = []; | ||
| for (let i = 0; i < imported.length; i++) { | ||
| const item = mergeQueryHistory(existingList[i] ?? undefined, imported[i]); | ||
| item.hashedKey = await getHashedRecordKey(item.key); | ||
| item.isFavoriteIdx = item.isFavorite ? 'true' : 'false'; | ||
| merged.push(item); | ||
| } |
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.
Introduce features for exporting and importing user history data, allowing users to save their browser-stored history to a file and re-import it later. This includes enhancements to the settings interface and updates to file type acceptance.
NOTE: This PR likely needs to be completely re-worked after #1870