Skip to content

feat(Git Sync): Persist insomnia git file hashes in workspace metadata#9873

Open
gatzjames wants to merge 1 commit intoKong:developfrom
gatzjames:feat/store-git-sync-times-in-workspace-metadata
Open

feat(Git Sync): Persist insomnia git file hashes in workspace metadata#9873
gatzjames wants to merge 1 commit intoKong:developfrom
gatzjames:feat/store-git-sync-times-in-workspace-metadata

Conversation

@gatzjames
Copy link
Copy Markdown
Contributor

Overview

Currently we only store synced times in the metadata which leads to some files being re-imported while their contents are still the same.

This PR persists the hash to the workspace metadata alongside the sync time so that app restarts won't trigger re-imports if the file hashes are the same.

@gatzjames gatzjames requested a review from CurryYangxx April 28, 2026 18:09
@gatzjames gatzjames self-assigned this Apr 28, 2026
Copilot AI review requested due to automatic review settings April 28, 2026 18:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent unnecessary workspace re-imports after app restarts by persisting git-sync tracking state (file hash + last sync time) into workspace metadata.

Changes:

  • Persist gitFileLastSyncHash and gitFileLastSyncTime to WorkspaceMeta during DB→FS flushes and FS→DB imports.
  • Restore persisted mtime/hash into the watcher’s in-memory tracking maps during startup to allow skipping unchanged files.
  • Extend WorkspaceMeta model defaults/types to include the new persisted hash field.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/insomnia/src/sync/git/repo-file-watcher.ts Persists and restores per-workspace git file hash/mtime to reduce redundant imports across restarts.
packages/insomnia/src/insomnia-data/src/models/workspace-meta.ts Adds gitFileLastSyncHash to the workspace meta model and initialization defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +350 to +352
// Persist tracking state so the maps can be restored after a restart
const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id));
await services.workspaceMeta.update(workspaceMeta, {
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

gitFileLastSyncHash/gitFileLastSyncTime are persisted here, but gitFilePath is not. If meta.gitFilePath is null/undefined (which can happen for DB-created workspaces before any FS→DB import), loadKnownGitFilePaths() will ignore this meta record and the persisted hash/time won’t be restored on restart. Consider persisting gitFilePath (e.g. the computed default/rel path) when it’s missing, or adjusting the restore logic to fall back to the default filename when gitFilePath is null.

Suggested change
// Persist tracking state so the maps can be restored after a restart
const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id));
await services.workspaceMeta.update(workspaceMeta, {
// Persist tracking state so the maps can be restored after a restart.
// Store the resolved gitFilePath as well so workspaces that previously
// had no explicit meta.gitFilePath can restore their last sync state.
const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id));
await services.workspaceMeta.update(workspaceMeta, {
gitFilePath,

Copilot uses AI. Check for mistakes.
@gatzjames gatzjames force-pushed the feat/store-git-sync-times-in-workspace-metadata branch from 85de117 to 697da9d Compare April 29, 2026 14:03
Co-authored-by: Copilot <copilot@github.com>
@gatzjames gatzjames force-pushed the feat/store-git-sync-times-in-workspace-metadata branch from 697da9d to 2b8dd60 Compare April 30, 2026 14:33
@gatzjames gatzjames requested a review from pavkout April 30, 2026 15:20
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