Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jan 14, 2026

Summary

Cleans up session-related data from SQLite (db.sqlite) before the main LocalPersister loads, to prevent stale folder_id values from conflicting with the SessionPersister.

The following tables are cleared when sessions exist:

  • sessions
  • mapping_session_participant
  • tags
  • mapping_tag_session
  • transcripts
  • enhanced_notes

Implementation approach: The json-mode persister stores the entire store as a single JSON blob in SQLite, so we cannot delete individual rows using SQL. Additionally, modifying the main store directly would trigger other persisters (like SessionPersister) to react to the deletions. Instead, we use a separate temporary store instance:

  1. Create a temporary TinyBase store with the same schema via createMergeableStore()
  2. Create a LocalPersister for the temporary store
  3. Load SQLite data into the temporary store
  4. Delete session-related rows using store.delRow() within a transaction
  5. Save the modified data back to SQLite and destroy the persister
  6. This happens before the main store loads, so it never sees the session data

Updates since last revision

  • Changed from modifying the main store directly to using a separate temporary store instance
  • Cleanup now runs before the main store's persister is created, avoiding triggering other persisters

Review & Testing Checklist for Human

  • Verify tags table deletion is correct - The tags table is included in cleanup, but tags might be shared across other entities. Confirm that deleting all tags is the intended behavior.
  • Verify schema references - The temporary store uses SCHEMA.table and SCHEMA.value from @hypr/store. Confirm these match the main store's schema.
  • Verify timing of cleanup - The cleanup now happens before the main store loads. Confirm that SessionPersister already has the data persisted to the file system before this cleanup occurs.
  • Test with existing SQLite data - Test with a database that has session data to ensure the migration works correctly and no data is lost.

Test Plan

  1. Start with a database that has sessions stored in SQLite
  2. Launch the app and verify sessions are loaded correctly from the file system persister
  3. Check that SQLite no longer contains session-related data after the app loads
  4. Restart the app and verify sessions still load correctly

Notes

…ister

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit 0413b61
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/6967856adecf800008320625

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for hyprnote-storybook canceled.

Name Link
🔨 Latest commit 0413b61
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/6967856b99c3ac0008abad91

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for howto-fix-macos-audio-selection canceled.

Name Link
🔨 Latest commit 0413b61
🔍 Latest deploy log https://app.netlify.com/projects/howto-fix-macos-audio-selection/deploys/6967856b88197c00082882d0

Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue

Review with Devin

- Remove incorrect approach that deleted from store before SessionPersister could save
- Add cleanupSqliteSessions() that runs after all persisters initialize
- Delete directly from SQLite using SQL commands, not from the store
- This ensures sessions are migrated to file system before being deleted from SQLite

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue

Review with Devin

Comment on lines 26 to 32
const SESSION_TABLES = [
"sessions",
"mapping_session_participant",
"tags",
"mapping_tag_session",
"transcripts",
"enhanced_notes",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔴 Tags table deletion may delete non-session-related tags

The SESSION_TABLES array at initialize.ts:26-32 includes the tags table, and the cleanup deletes all entries matching tags/% from SQLite.

However, tags might be a shared resource used by entities other than sessions. Deleting all tags when cleaning up session data could cause data loss for other features that rely on tags.

The PR description explicitly calls this out: "Verify tags table deletion is correct - The tags table is included in SESSION_TABLES, but tags might be shared across other entities. Confirm that deleting all tags is the intended behavior."

Recommendation: Review whether tags are session-specific or shared. If shared, remove 'tags' from SESSION_TABLES or only delete tags that are linked to sessions via the mapping_tag_session table.

🛟 Review with Devin


Was this helpful? React with 👍 or 👎 to provide feedback.

…of SQL

The json-mode persister stores the entire store as a single JSON blob,
so we can't delete individual rows using SQL. Instead, we need to:
1. Load the store from SQLite
2. Delete session-related rows using store.delRow()
3. Save the modified store back to SQLite

This follows the same pattern as migrateWordsAndHintsToTranscripts.

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

1 similar comment
@devin-ai-integration
Copy link
Contributor Author

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

@devin-ai-integration devin-ai-integration bot changed the title feat: delete sessions from SQLite after migration to file system persister fix: cleanup sessions from LocalPersister using store.delRow instead of SQL Jan 14, 2026
Creates a temporary TinyBase store instance to perform the cleanup,
avoiding modifications to the main store that would trigger other
persisters (like SessionPersister) to react to the changes.

The cleanup now:
1. Creates a temporary store with the same schema
2. Loads SQLite data into the temporary store
3. Deletes session data from the temporary store
4. Saves back to SQLite and destroys the persister
5. This happens BEFORE the main store loads, so it never sees the session data

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration devin-ai-integration bot changed the title fix: cleanup sessions from LocalPersister using store.delRow instead of SQL fix: cleanup sessions from SQLite using separate store instance Jan 14, 2026
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