Skip to content

Add created/modified timestamps to analyses - #209

Merged
alex-rawlings-yyc merged 9 commits into
mainfrom
185-analysis-timestamps
Aug 11, 2026
Merged

Add created/modified timestamps to analyses#209
alex-rawlings-yyc merged 9 commits into
mainfrom
185-analysis-timestamps

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This change is Reviewable

Summary by CodeRabbit

  • New Features

    • Added creation and modification timestamps to analysis records and links.
    • Timestamps now update consistently when analyses are created, edited, approved, shared, forked, or removed.
    • Older saved projects and drafts receive fallback timestamps when needed.
  • Bug Fixes

    • Preserved existing timestamps during data loading and migration.
    • Clarified that timestamps do not affect analysis identity.
  • Tests

    • Added comprehensive coverage for timestamp creation, updates, preservation, and fallback behavior.

@alex-rawlings-yyc alex-rawlings-yyc self-assigned this Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96ba6496-d366-4af1-92b4-659f6447a8d5

📥 Commits

Reviewing files that changed from the base of the PR and between 382a02c and 9897ebe.

📒 Files selected for processing (2)
  • src/__tests__/services/projectStorage.test.ts
  • src/services/projectStorage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tests/services/projectStorage.test.ts
  • src/services/projectStorage.ts

📝 Walkthrough

Walkthrough

Analysis records and links now include createdAt and updatedAt. Reducer operations create and update these values. Project and draft reads backfill missing timestamps. Tests use deterministic fixtures and cover timestamp behavior.

Changes

Analysis timestamp support

Layer / File(s) Summary
Timestamp contracts and legacy backfill
src/types/interlinearizer.d.ts, src/utils/analysis-timestamps.ts, src/utils/analysis-identity.ts, src/__tests__/utils/*
Analysis records and links define timestamps. Missing timestamps receive fallback values. Timestamp fields remain excluded from analysis identity.
Reducer timestamp propagation
src/store/analysisSlice.ts
Prepared actions generate timestamps for token, phrase, segment, morpheme, approval, fork, and merge operations.
Persistence read compatibility
src/services/projectStorage.ts, src/__tests__/services/projectStorage.test.ts
Project and draft reads backfill missing timestamps. Repaired drafts are persisted without hiding read results when persistence fails.
Timestamp regression coverage
src/__tests__/store/analysisSlice.test.ts
Tests cover creation, edits, sharing, forks, approvals, phrase updates, segment translations, and morpheme changes.
Timestamped test fixtures
src/__tests__/components/*, src/__tests__/hooks/useDraftProject.test.ts, src/__tests__/utils/*, src/__tests__/test-helpers.ts
Existing analysis and link fixtures now include shared deterministic timestamp fields.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant analysisSlice
  participant projectStorage
  participant AnalysisData
  Editor->>analysisSlice: dispatch prepared analysis action
  analysisSlice->>AnalysisData: create or update record and link timestamps
  projectStorage->>AnalysisData: read persisted project or draft
  projectStorage->>AnalysisData: backfill missing timestamps
Loading

Possibly related PRs

Suggested reviewers: imnasnainaec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding creation and modification timestamps to analyses.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 185-analysis-timestamps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alex-rawlings-yyc alex-rawlings-yyc linked an issue Aug 7, 2026 that may be closed by this pull request
Analysis payloads record when the content entered the project; links
record when each token, segment, or phrase took it on — the two diverge
whenever a payload is shared. Legacy records are backfilled on load.
@alex-rawlings-yyc
alex-rawlings-yyc force-pushed the 185-analysis-timestamps branch from 8bbc39e to dbfc9ae Compare August 7, 2026 21:10
@alex-rawlings-yyc
alex-rawlings-yyc marked this pull request as ready for review August 7, 2026 21:10
coderabbitai[bot]

This comment was marked as resolved.

Restore real timers from afterEach so a failing assertion can no longer
freeze
the clock for later tests, and pin the two invariants left unasserted:
link
updatedAt survives backfill, and differing timestamps still dedupe.

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alex-rawlings-yyc resolved 1 discussion.
Reviewable status: 0 of 20 files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

A project stored before it carried `updatedAt` passed `undefined` as the
backfill fallback, so the oldest analysis records stayed unstamped and
the
picker showed an invalid Modified date; it falls back to `createdAt`
instead.
Also retunes the analysis timestamp docs to the record-lifecycle
semantics
every write path already implements.

@imnasnainaec imnasnainaec 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.

Review pass over the analysis-timestamp work, against 2407b86. Nothing blocking: one behavior regression in getProject, one stability improvement in getDraft, and three documentation notes. Verified locally — 1663 tests pass at 100% coverage.

— Claude Opus 5 (inspired by Devin)

Comment thread src/services/projectStorage.ts Outdated
Comment thread src/services/projectStorage.ts Outdated
Comment thread src/types/interlinearizer.d.ts
Comment thread src/store/analysisSlice.ts
Comment thread src/types/type-guards.ts
A stored project whose analysis is missing no longer faults the read,
and a
draft that needed stamping is written back so the stand-in stops
drifting
between reads. Also corrects the timestamp docs on shared payloads and
on
what the analysis-record guard accepts.

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alex-rawlings-yyc made 5 comments.
Reviewable status: 0 of 21 files reviewed, 5 unresolved discussions (waiting on alex-rawlings-yyc and imnasnainaec).

Comment thread src/services/projectStorage.ts Outdated
Comment thread src/services/projectStorage.ts Outdated
Comment thread src/store/analysisSlice.ts
Comment thread src/types/interlinearizer.d.ts
Comment thread src/types/type-guards.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/services/projectStorage.ts`:
- Around line 633-637: Update the draft backfill flow around getDraft and
backfillAnalysisTimestamps so the read, timestamp mutation, and conditional
direct storage write execute within a single enqueueSerialized(draftQueues,
sourceProjectId, ...) operation. Replace the nested saveDraft call with the
appropriate direct persistence step inside that serialized callback, preserving
the existing error logging and avoiding a second queue submission.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4aa45d78-ac4a-4f97-b33e-d1a47bd39a75

📥 Commits

Reviewing files that changed from the base of the PR and between dbfc9ae and 382a02c.

📒 Files selected for processing (9)
  • src/__tests__/services/projectStorage.test.ts
  • src/__tests__/utils/analysis-identity.test.ts
  • src/__tests__/utils/analysis-timestamps.test.ts
  • src/__tests__/utils/suggestion-engine.test.ts
  • src/services/projectStorage.ts
  • src/store/analysisSlice.ts
  • src/types/interlinearizer.d.ts
  • src/types/type-guards.ts
  • src/utils/analysis-timestamps.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/tests/utils/analysis-identity.test.ts
  • src/types/interlinearizer.d.ts
  • src/tests/utils/analysis-timestamps.test.ts
  • src/tests/utils/suggestion-engine.test.ts
  • src/store/analysisSlice.ts

Comment thread src/services/projectStorage.ts Outdated
The write-back was a second queue submission, so an auto-save landing
between the two was clobbered by the stale copy the backfill stamped.
A record damaged outside the extension can carry neither time, which
left the analysis backfill stamping undefined onto every record.
Comment thread src/services/projectStorage.ts

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alex-rawlings-yyc made 1 comment.
Reviewable status: 0 of 21 files reviewed, 6 unresolved discussions (waiting on alex-rawlings-yyc and imnasnainaec).

Comment thread src/services/projectStorage.ts

@imnasnainaec imnasnainaec 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.

@imnasnainaec partially reviewed 15 files, made 1 comment, and resolved 5 discussions.
Reviewable status: 14 of 21 files reviewed, 2 unresolved discussions (waiting on alex-rawlings-yyc).


src/utils/analysis-timestamps.ts at r5 (raw file):
❓ I'm pondering if we even need to handle legacy analyses. We haven't even done a fully public release. It'd be simpler if we can just enforce fully stamped now.

@alex-rawlings-yyc

Copy link
Copy Markdown
Contributor Author

src/utils/analysis-timestamps.ts at r5 (raw file):

Previously, imnasnainaec (D. Ror.) wrote…

❓ I'm pondering if we even need to handle legacy analyses. We haven't even done a fully public release. It'd be simpler if we can just enforce fully stamped now.

That's what my initial thought was, but I figured it would be better to be safer to handle them by default and strip away legacy handling later if we decided it wasn't necessary. Since it exists already I'm fine with it, but I think I would really prefer if we didn't have code that handled legacy analyses

@imnasnainaec imnasnainaec 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.

@imnasnainaec reviewed 7 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

@alex-rawlings-yyc
alex-rawlings-yyc enabled auto-merge (squash) August 11, 2026 17:57
@alex-rawlings-yyc
alex-rawlings-yyc merged commit 73c1ebc into main Aug 11, 2026
10 checks passed
@alex-rawlings-yyc
alex-rawlings-yyc deleted the 185-analysis-timestamps branch August 11, 2026 17:59
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.

Add created/modified timestamps to analyses

2 participants