Skip to content

Attribute template-import commits to a System author#2393

Merged
myieye merged 8 commits into
developfrom
dev/system-author-template-commits
Jul 2, 2026
Merged

Attribute template-import commits to a System author#2393
myieye merged 8 commits into
developfrom
dev/system-author-template-commits

Conversation

@myieye

@myieye myieye commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Builds on #2281 (template-based project creation, already merged). A scoped CommitMetadataInterceptor stamps only the template-import commits as a well-known System author (and flags them Template); later user edits keep their real author. The activity view shows "System" and stops pinning special authors.

Drive-by fixes found while polishing #2281:

  • Fold the runtime-composed New Project + (Local only) label into one translatable msgid (re-extracted catalogs).
  • Drop the stray assignment to the derived code in CreateProjectDialog.openDialog.

Test plan

  • LcmCrdt.Tests OpenProjectTests — 17 pass, incl. System-author stamping, interceptor scope/restore, and template identity.
  • pnpm --filter viewer run check — 0 errors.
image

myieye and others added 2 commits June 30, 2026 16:23
A scoped CommitMetadataInterceptor stamps only the template-import commits as
the System author (and flags them Template); later user edits keep their real
author. The activity view shows System and stops pinning special authors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Folds the runtime-composed "New Project" + "(Local only)" label (HomeView)
into one translatable msgid across all locales.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds CommitMetadataInterceptor to stamp template-imported commits with a fixed SystemAuthorId and TemplateProp marker. Wires the interceptor into CrdtMiniLcmApi and CrdtProjectsService, registers it in DI. On the frontend, adds SYSTEM_AUTHOR_KEY with a cog-icon UI in activity filtering and consolidates the "New Project (Local only)" i18n string across all locale catalogs.

Changes

Backend: Template commit metadata stamping

Layer / File(s) Summary
CommitHelpers constants and StampAsTemplate
backend/FwLite/LcmCrdt/Utils/CommitHelpers.cs
Adds SystemAuthorId, TemplateProp constants and StampAsTemplate method that sets AuthorId, clears AuthorName, and writes "true" into the template metadata entry.
CommitMetadataInterceptor
backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs
New class with scoped Intercept(Action<CommitMetadata>) returning an IDisposable that restores the previous interceptor, and Apply(CommitMetadata) that invokes the current interceptor.
DI registration and CrdtMiniLcmApi integration
backend/FwLite/LcmCrdt/LcmCrdtKernel.cs, backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Registers CommitMetadataInterceptor as scoped; injects it into CrdtMiniLcmApi and calls Apply in NewMetadata().
Template import wrapped in interceptor scope
backend/FwLite/LcmCrdt/CrdtProjectsService.cs
Wraps projectImporter.ImportProject(...) inside a CommitMetadataInterceptor scope using CommitHelpers.StampAsTemplate.
OpenProjectTests refactor and assertions
backend/FwLite/LcmCrdt.Tests/OpenProjectTests.cs
Extracts WithProjectFromTemplate helper and adds assertions for SystemAuthorId stamping, TemplateProp presence, interceptor scope restoration, and ClientId authorship on template vs. post-template commits.

Frontend: System author UI and locale updates

Layer / File(s) Summary
SYSTEM_AUTHOR_KEY and wellKnownAuthorKeyToLabel
frontend/viewer/src/lib/activity/utils.ts
Adds SYSTEM_AUTHOR_KEY constant and exported wellKnownAuthorKeyToLabel mapping; updates compareActivityAuthors to sort by translated label and simplifies authorSortRank.
ActivityFilter cog icon and label delegation
frontend/viewer/src/lib/activity/ActivityFilter.svelte
Imports SYSTEM_AUTHOR_KEY/wellKnownAuthorKeyToLabel, delegates label lookup, and renders a cog icon for system author entries.
"New Project (Local only)" i18n consolidation
frontend/viewer/src/home/HomeView.svelte, frontend/viewer/src/home/CreateProjectDialog.svelte
Collapses two composed i18n strings into one combined string; removes explicit code = '' reset.
Locale catalog updates
frontend/viewer/src/locales/*.po
Adds "New Project (Local only)" msgid and updates System/Unknown source-reference metadata across all locale files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • hahn-kev

🐇 A template was born, stamped with a gear,
Its commits now wear a system veneer.
The cog spins in the filter with pride,
"Local only" at last unified!
Hop hop, all the locales aligned — 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The changes are related to #1920, but the provided diff doesn't show the full template.sql creation and seeding workflow. Provide the earlier #2281 diff or the template.sql generation changes so the full linked-issue scope can be verified.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: attributing template-import commits to a System author.
Out of Scope Changes check ✅ Passed The locale, activity, and dialog tweaks are all described in the PR and support the template-import feature set.
Description check ✅ Passed The description accurately summarizes the template commit stamping, activity-view behavior, and the small UI/i18n fixes in this changeset.
✨ 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 dev/system-author-template-commits

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.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jun 30, 2026
@argos-ci

argos-ci Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 1, 2026, 2:23 PM

@myieye myieye marked this pull request as ready for review June 30, 2026 18:00

@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 `@backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs`:
- Around line 12-21: The current CommitMetadataInterceptor stores the override
in the scoped _interceptor field, so concurrent commits can leak one operation’s
metadata into another. Update CommitMetadataInterceptor.Intercept and Apply to
bind the override to the async execution context instead of the shared instance
state, using a per-flow storage mechanism so each commit only sees its own
CommitMetadata interceptor. Keep the IDisposable restore behavior tied to that
same flow-specific override rather than the singleton field.
🪄 Autofix (Beta)

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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d1ca1a31-9156-4393-aae3-3f585bf91cf7

📥 Commits

Reviewing files that changed from the base of the PR and between 0324051 and 92b444f.

📒 Files selected for processing (18)
  • backend/FwLite/LcmCrdt.Tests/OpenProjectTests.cs
  • backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs
  • backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
  • backend/FwLite/LcmCrdt/CrdtProjectsService.cs
  • backend/FwLite/LcmCrdt/LcmCrdtKernel.cs
  • backend/FwLite/LcmCrdt/Utils/CommitHelpers.cs
  • frontend/viewer/src/home/CreateProjectDialog.svelte
  • frontend/viewer/src/home/HomeView.svelte
  • frontend/viewer/src/lib/activity/ActivityFilter.svelte
  • frontend/viewer/src/lib/activity/utils.ts
  • frontend/viewer/src/locales/en.po
  • frontend/viewer/src/locales/es.po
  • frontend/viewer/src/locales/fr.po
  • frontend/viewer/src/locales/id.po
  • frontend/viewer/src/locales/ko.po
  • frontend/viewer/src/locales/ms.po
  • frontend/viewer/src/locales/sw.po
  • frontend/viewer/src/locales/vi.po
💤 Files with no reviewable changes (1)
  • frontend/viewer/src/home/CreateProjectDialog.svelte

Comment thread backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs Outdated
Comment thread backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs Outdated
Comment thread backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs Outdated
Comment thread backend/FwLite/LcmCrdt/CommitMetadataInterceptor.cs Outdated

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd like to use an AsyncLocal in the interceptor

Store the interceptor in an AsyncLocal instead of a shared field so a
template-import override can't leak into a concurrent commit made through the
same DI-scoped CrdtMiniLcmApi.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@myieye myieye requested a review from hahn-kev July 1, 2026 12:56
myieye and others added 5 commits July 1, 2026 15:03
The Select.Item label prop fell back to "Unknown" for the System author
(authorName is null by design), so typeahead couldn't jump to it. Use
authorKeyToLabel(key), which resolves the System/Unknown display names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ActivityView and ActivityItem rendered author from the raw authorName, which
is null for template (System) commits, so they showed "Unknown". Resolve the
well-known label from authorId (as the filter already does) before falling back
to authorName, then "Unknown".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the author name + well-known icon (FieldWorks logo, System cog) into a
single AuthorLabel component and use it in the filter dropdown/trigger and the
activity list and detail views, so the icons show everywhere a well-known
author is displayed — not just in the filter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Default the icon to size-4 (matches the text-sm activity list and detail views)
and have the author filter opt into size-5 explicitly, restoring the filter's
original icon size.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The FieldWorks logo reads best at size-5 and the System cog at size-4 in every
context, so hardcode each and drop the iconClass prop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@myieye myieye merged commit 83e3220 into develop Jul 2, 2026
32 checks passed
@myieye myieye deleted the dev/system-author-template-commits branch July 2, 2026 07:35
@coderabbitai coderabbitai Bot mentioned this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants