Skip to content

CLUE-368 extracts Firestore history saving#2713

Merged
scytacki merged 3 commits intomasterfrom
CLUE-368-extract-firestore-history-saving
Jan 20, 2026
Merged

CLUE-368 extracts Firestore history saving#2713
scytacki merged 3 commits intomasterfrom
CLUE-368-extract-firestore-history-saving

Conversation

@scytacki
Copy link
Copy Markdown
Member

CLUE-368

This extracts the Firestore history saving from the CLUE history system.

There are a few reasons to do this:

  • it reduces the tree-manager.ts file size
  • CODAP is using this tree-manager.ts but has modified removed the references to Firestore so that CODAP doesn't depend on Firestore. So this extraction means CODAP can use the tree-manager.ts without changes.
  • this approach means that the upcomging group documents can experiment with different approaches for saving the history just for specific document types. It can do that adding a different onHistoryEntryComplete listener.
  • this should also make it easier to test the TreeManager without Firestore by just not adding a onHistoryEntryComplete listener.

@cypress
Copy link
Copy Markdown

cypress Bot commented Jan 14, 2026

collaborative-learning    Run #17354

Run Properties:  status check passed Passed #17354  •  git commit 3a374cf360: CLUE-368 fix circular dependency issue
Project collaborative-learning
Branch Review CLUE-368-extract-firestore-history-saving
Run status status check passed Passed #17354
Run duration 02m 59s
Commit git commit 3a374cf360: CLUE-368 fix circular dependency issue
Committer Scott Cytacki
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
View all changes introduced in this branch ↗︎

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 91.37931% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.74%. Comparing base (5f83728) to head (3a374cf).
⚠️ Report is 39 commits behind head on master.

Files with missing lines Patch % Lines
src/models/history/firestore-history-manager.ts 90.19% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2713      +/-   ##
==========================================
- Coverage   86.75%   86.74%   -0.02%     
==========================================
  Files         809      810       +1     
  Lines       43316    43331      +15     
  Branches    11098    11097       -1     
==========================================
+ Hits        37580    37587       +7     
- Misses       5405     5413       +8     
  Partials      331      331              
Flag Coverage Δ
cypress ?
cypress-regression 78.31% <90.56%> (+<0.01%) ⬆️
cypress-smoke 44.19% <90.56%> (+0.01%) ⬆️
jest 49.16% <10.34%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 extracts Firestore history-saving functionality from the TreeManager into a new FirestoreHistoryManager class, improving separation of concerns and enabling different document types to implement custom history-saving strategies.

Changes:

  • Created new FirestoreHistoryManager class to handle Firestore-specific history saving
  • Replaced direct Firestore references in TreeManager with a listener pattern using HistoryEntryCompletedListener
  • Updated document initialization to instantiate and register the Firestore history manager

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/models/history/history-firestore.ts Added FirestoreHistoryManager class with methods moved from TreeManager
src/models/history/tree-manager.ts Removed Firestore-specific code and added listener pattern for history entry completion
src/models/stores/documents.ts Instantiated FirestoreHistoryManager and registered it as a listener

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

Comment thread src/models/history/history-firestore.ts Outdated
Comment thread src/models/history/history-firestore.ts Outdated
@scytacki
Copy link
Copy Markdown
Member Author

@kswenson you might be interested in this one too. It is moving towards a better separation of the firestore history syncing from the core history system. This ought to reduce the number of changes CODAP has to make to the tree-manager.ts file.

@scytacki scytacki marked this pull request as ready for review January 19, 2026 13:16
@kswenson
Copy link
Copy Markdown
Member

@kswenson you might be interested in this one too. It is moving towards a better separation of the firestore history syncing from the core history system. This ought to reduce the number of changes CODAP has to make to the tree-manager.ts file.

We'd love to adopt this and any other CLUE improvements into CODAP, but probably in the 3.1 time frame at the earliest.

Copy link
Copy Markdown
Contributor

@tealefristoe tealefristoe left a comment

Choose a reason for hiding this comment

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

Looks good 👍

This was a good opportunity for me to get a glimpse into this part of the codebase. I noticed that there's now an import cycle, but I don't know if that's a problem or not.

Comment thread src/models/history/history-firestore.ts Outdated
import { UserContextProvider } from "../stores/user-context-provider";
import { HistoryEntry, HistoryEntrySnapshot } from "./history";
import { TreeAPI } from "./tree-api";
import { CDocumentType } from "./tree-manager";
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.

This creates an import cycle.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, I refactored it to take care of this.

@scytacki scytacki merged commit d2bd3f9 into master Jan 20, 2026
25 of 27 checks passed
@scytacki scytacki deleted the CLUE-368-extract-firestore-history-saving branch January 20, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants