Skip to content

Add history import/export functionality - #1844

Draft
paustint wants to merge 1 commit into
mainfrom
feat/add-history-import-export
Draft

Add history import/export functionality#1844
paustint wants to merge 1 commit into
mainfrom
feat/add-history-import-export

Conversation

@paustint

@paustint paustint commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread libs/shared/ui-db/src/lib/client-data-import.db.ts
@paustint
paustint force-pushed the feat/add-history-import-export branch from fddf1c2 to ac41f83 Compare July 1, 2026 15:24
@paustint
paustint force-pushed the feat/add-history-import-export branch from ac41f83 to aace29c Compare August 4, 2026 14:36
Copilot AI lite review requested due to automatic review settings August 4, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}
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.

2 participants