Skip to content

Activity redesign 1/8: resolve change subjects server-side and generate the change-type list#2435

Open
myieye wants to merge 1 commit into
developfrom
claude/activity-1-backend-change-info
Open

Activity redesign 1/8: resolve change subjects server-side and generate the change-type list#2435
myieye wants to merge 1 commit into
developfrom
claude/activity-1-backend-change-info

Conversation

@myieye

@myieye myieye commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Part 1 of 8 of the activity redesign (readable summaries + before/after diffs, #2170). The full assembled result of parts 1–6 — reviewed end-to-end by CodeRabbit and verified green — lived in #2434 (now closed); it was too large to merge in one piece, so it's split into a stacked sequence where each part is independently green and reviewable. This PR is the only one open; each next part gets its PR when its predecessor merges.

The sequence (each branch builds on the previous; part 6's tree is byte-identical to the reviewed #2434 head):

  1. claude/activity-1-backend-change-info (this PR) — backend enrichment + change-type codegen. No user-visible change.
  2. claude/activity-2-ws-code-chips — writing-system codes render as monospace chips app-wide (editor field labels, dictionary preview) for parity with the upcoming read-only diffs.
  3. claude/activity-3-diff-components — the read-only diff-view component library (field-level before/after, inline text diff via @sanity/diff-match-patch, audio diffs) + storybook gallery + field-coverage guard tests. No consumer yet.
  4. claude/activity-4-list-summaries — the activity list rows become readable summaries ("Apfel › apple · Set Definition (en) to …") grouped by entry, with per-author colours, badges, and bulk-create collapsing; exhaustiveness tests fail if a new change type lacks a summary.
  5. claude/activity-5-detail-previews — the detail panel renders real before/after diffs through the diff components; single-entry create commits collapse to an assembled read-only view; per-card failure containment.
  6. claude/activity-6-list-detail-layout — extracts Browse's responsive list↔detail shell into a shared ListDetailLayout and adopts it in Activity: resizable split panes on desktop, full-width list on mobile with full-screen detail + back-button support.
  7. claude/activity-7-change-type-filter — replaces the flat ~65-row activity-type multi-select with a grouped, searchable, tri-state filter (sections by what a change touches, collapsed by default, hover "Only" shortcuts, empty selection = unfiltered, debounced instant apply).
  8. claude/activity-8-author-filter — unifies the author facet onto the same shell and semantics (shared FacetFilter component, empty = unfiltered, ×-clear, "Only"), deleting the old 'all'-sentinel machinery and the "No authors → empty feed" state.

UI previews for the filter parts (7 and 8) — open in a browser:

This part

Adds ActivityChangeInfoResolver: one batched pass per activity page that labels each change with the entity it's about (entry headword with homograph subscript, "headword › gloss" for senses, vocab object names), any item the change references only by id (the part of speech set, the semantic domain removed, the component linked), and the change's root entry so the frontend can group a commit's changes. Deleted objects are recovered from their latest snapshot (one Take(1) query per missing id) so a delete can still name its subject. ProjectActivity returns a materialized page (Task<ProjectActivity[]>) of enriched record copies (ChangeInfo is init-only) since the resolver batch-loads across the page — every consumer already materialized.

ChangeContext gains PreviousSnapshot (the entity's state just before the commit), the data needed for true before/after diffs (#2170).

A Reinforced.Typings generator emits a ChangeType string-literal union + knownChangeTypes array from the registered CRDT change types, using the same discriminator helper the runtime uses — parts 4 and 7's coverage tests are built on it, so a new change type can't silently ship without a summary or a filter group.

Tests: HistoryServiceActivityTests covers subject/target naming (homograph only-when-assigned, morph-type markers, sense numbering, deleted-object recovery, component endpoints, reorders) — 36 tests, all passing. Frontend impact is limited to regenerated types (additive) and a one-line HistoryView fix for the new required changeInfo property.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vm9mEUzcfgX4oUPAbhcfsj

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f3fa9ce1-8eff-4b63-8257-62a32b3381ee

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Project activity now returns materialized pages enriched with resolved subjects and targets. Backend context handling, generated TypeScript contracts, invokable callers, viewer data construction, and extensive naming tests were updated accordingly.

Project Activity Enrichment

Layer / File(s) Summary
Activity contract and batch resolution
backend/FwLite/LcmCrdt/HistoryService.cs
ProjectActivity returns enriched arrays, ChangeContext tracks previous snapshots, and change-type key lookup is public.
Change-info label resolution
backend/FwLite/LcmCrdt/ActivityChangeInfoResolver.cs
Loads current or recovered entities and resolves subjects, targets, headwords, sense labels, reorder metadata, and component endpoints.
Generated frontend contracts
backend/FwLite/FwLiteShared/TypeGen/*, frontend/viewer/src/lib/dotnet-types/generated-types/LcmCrdt/*
Generates activity metadata interfaces and a complete ChangeType union with its known-value array.
Callers and validation
backend/FwLite/FwLiteShared/Services/HistoryServiceJsInvokable.cs, backend/FwLite/LcmCrdt.Tests/*, frontend/viewer/src/lib/history/HistoryView.svelte
Updates callers and tests for materialized results and adds coverage for change-info naming across change scenarios.

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

Possibly related PRs

Suggested reviewers: rmunn, hahn-kev

Poem

I hop through changes, neat and bright,
With labels blooming into sight.
Old snapshots found, new types agree,
A tidy trail for history.
The rabbit stamps: “Enriched—whee!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.28% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main backend change and generated change-type list.
Description check ✅ Passed The description directly matches the PR's backend enrichment and change-type generation work.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/activity-1-backend-change-info

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.

@argos-ci

argos-ci Bot commented Jul 12, 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 15, 2026, 4:33 AM
e2e (Inspect) ⚠️ Changes detected (Review) 5 changed Jul 15, 2026, 4:41 AM

@myieye

myieye commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Note for the Argos review: this part is backend-only and intends zero visual change — the deterministic default build agrees (✅ no changes detected). The 5 diffs on the e2e build should therefore be environment noise (the e2e suite screenshots live pages with relative timestamps/seeded data, and it has flagged diffs on every recent build regardless of branch). If any of the 5 shows a real content difference rather than timestamp/data churn, please flag it here — that would mean the enriched activity payload is affecting the current UI, which would be a bug in this part.


Generated by Claude Code

@myieye myieye changed the title Activity redesign 1/6: resolve change subjects server-side and generate the change-type list Activity redesign 1/7: resolve change subjects server-side and generate the change-type list Jul 12, 2026
@myieye myieye changed the title Activity redesign 1/7: resolve change subjects server-side and generate the change-type list Activity redesign 1/8: resolve change subjects server-side and generate the change-type list Jul 12, 2026
@myieye

myieye commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

@myieye: Got it, I'll review the changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

looks good, I glossed over the change info resolver.

string[]? changeTypeKeys = null,
ActivitySort sort = ActivitySort.NewestFirst)
{
return await historyService.ProjectActivity(skip, take,

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 want to keep this awaiting as it preserves the stack trace, we should only do this where we don't await a task as an optimization on a hot path

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in cba8373 — restored async/await here.


Generated by Claude Code

var array = string.Concat(typeNames.Select(name => $"\n '{name}',"));

Context.Location.CurrentNamespace.CompilationUnits.Add(new RtRaw(
$"export type ChangeType ={union};\n\nexport const knownChangeTypes = [{array}\n] as const satisfies readonly ChangeType[];\n"));

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.

are these new lines going to add noise when git rewrites them on windows checkout?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No — the root .gitattributes normalizes every text file to LF on both commit and checkout (* text=auto eol=lf), Windows included. So these \n literals match the rest of this generated file and every other checked-in file; a Windows checkout gets LF too, so there's no CRLF churn and the stale-types check stays stable.


Generated by Claude Code

}

[Fact]
public async Task ProjectActivity_ChangeInfo_AddsHomographSubscriptToSubject_OnlyWhenAssigned()

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.

let's split these subject specific tests out into their own test class as they're much lower importance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in cba8373 — moved the ChangeInfo subject/target-naming tests into a new HistoryServiceActivitySubjectTests, with the fixture + helpers factored into a shared HistoryServiceActivityTestsBase. The core paging/filter/sort tests stay in HistoryServiceActivityTests.


Generated by Claude Code

.ToListAsyncLinqToDB();
var index = affectingCommitIds.IndexOf(commitId);
if (index < 0 || index + 1 >= affectingCommitIds.Count) return null;
return await dataModel.GetAtCommit<object>(affectingCommitIds[index + 1], entityId) as IObjectWithId;

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.

this seems overly complicated, can't we just dataModel.GetAtTime(commitTime - one tick, entityId)? I guess that would throw if there's no commits before. We should probably add an API in harmony for this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've left this as-is for now. GetAtTime(commitTime - 1 tick) goes through linq2db, which truncates every SQLite timestamp comparison to millisecond precision (strftime('…%f')) — see the landmine note in backend/FwLite/AGENTS.md and SnapshotAtCommitService. A sub-millisecond - 1 tick can't reliably exclude the current commit when two commits land in the same millisecond, so this walks commits by their deterministic order rather than by timestamp. I agree a dedicated Harmony API (previous-snapshot-before-a-commit, ordered by commit order not time) is the clean fix — happy to file that upstream and switch to it as a follow-up.


Generated by Claude Code

}

private static string Subscript(int number) =>
new(number.ToString().Select(digit => (char)('₀' + (digit - '0'))).ToArray());

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.

use this instead for less allocations and handling negative (not likely):

private static string Subscript(int number)
{
    // A standard int32 will never exceed 11 characters (e.g., "-2147483648")
    Span<char> buffer = stackalloc char[11];
    number.TryFormat(buffer, out int charsWritten);
    for (int i = 0; i < charsWritten; i++)
    {
        // Handle negative signs cleanly with the subscript minus character (U+208B)
        buffer[i] = buffer[i] == '-' ? '₋' : (char)(buffer[i] - '0' + '₀');
    }

    return buffer[..charsWritten].ToString();
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in cba8373 — switched to the stackalloc + TryFormat version, keeping the subscript-minus handling for negatives.


Generated by Claude Code

…type list

Adds ActivityChangeInfoResolver: one batched pass per activity page that labels each
change with the entity it's about (entry headword with homograph subscript, 'headword › gloss'
for senses, vocab object names), the referenced item it names only by id (part of speech set,
semantic domain removed, component linked), and the root entry so the frontend can group a
commit's changes. Deleted objects are recovered from their latest snapshot so a delete can
still name its subject. ProjectActivity returns a materialized page (Task<ProjectActivity[]>)
of enriched record copies since the resolver batch-loads across it.

ChangeContext gains PreviousSnapshot (the entity's state just before the commit) so the
frontend can render true before/after diffs (#2170).

A Reinforced.Typings generator emits a ChangeType union + knownChangeTypes array from the
registered CRDT change types via the same discriminator helper the runtime uses, giving the
frontend a generated, exhaustive list to guard summary coverage with.

Part 1/6 of the activity redesign (#2434 shows the assembled result).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vm9mEUzcfgX4oUPAbhcfsj
@myieye
myieye force-pushed the claude/activity-1-backend-change-info branch from b532dcf to cba8373 Compare July 15, 2026 04:30
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.

3 participants