Skip to content

SF-3959 Fix incorrect draft history displayed - #4191

Merged
Nateowami merged 5 commits into
masterfrom
fix/sf-3959-incorrect-history
Nov 5, 2026
Merged

Nateowami merged 5 commits into
masterfrom
fix/sf-3959-incorrect-history

Conversation

@RaymondLuong3

@RaymondLuong3 RaymondLuong3 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

The build history on the generation draft page can display incorrect information. The Project Notification Service listens for notifications and sends messages using signal R. This means that a project may be listening to the notification and that notification does not necessarily apply to the current project.

UPDATE:
This PR updates how consumers use the project notification service. Consumers now subscribe to observables that directly expose SignalR events. These subscriptions are automatically unsubscribed and the connection is closed when all subscriptions have been unsubscribed.


This change is Reviewable

@RaymondLuong3 RaymondLuong3 added the will require testing PR should not be merged until testers confirm testing is complete label Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.80645% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.30%. Comparing base (67cffac) to head (81f2b2c).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ate/draft-generation/draft-notification.service.ts 0.00% 4 Missing ⚠️
...lientApp/src/app/core/notification-service-base.ts 89.28% 3 Missing ⚠️
...ntApp/src/app/core/project-notification.service.ts 0.00% 3 Missing ⚠️
.../app/sync/sync-progress/sync-progress.component.ts 71.42% 2 Missing ⚠️
...aft-import-wizard/draft-import-wizard.component.ts 60.00% 2 Missing ⚠️
...late/editor/editor-draft/editor-draft.component.ts 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4191      +/-   ##
==========================================
+ Coverage   81.24%   81.30%   +0.05%     
==========================================
  Files         671      671              
  Lines       43040    43021      -19     
  Branches     7133     7138       +5     
==========================================
+ Hits        34967    34977      +10     
+ Misses       6906     6877      -29     
  Partials     1167     1167              

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

@RaymondLuong3 RaymondLuong3 added the ai-review-author-sign-off PR author has looked at AI review of change and determined no findings warrant further changes label Oct 16, 2026

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

@Nateowami made 1 comment.
Reviewable status: 0 of 11 files reviewed, 1 unresolved discussion (waiting on RaymondLuong3).


src/SIL.XForge.Scripture/ClientApp/src/app/core/notification-service-base.ts line 61 at r1 (raw file):

   * @param owner The same object that was passed to start().
   */
  stop(owner: object): Promise<void> {

Thanks for tracking down the cause and fixing this. My first thought in reading this start/stop code with owner objects is that this feels exactly like an observable that needs to be unsubscribed when it's no longer needed, and that manually implementing start/stop which the consumer has to remember to call means there's more work in every class that uses it.

I asked Claude to look into implementing this with observables, and it appears while it's not trivial, the consumers get a better experience. I haven't reviewed it, but I pushed it to refactor/sf-3959-notification-observables. To me it looks like the consumers would be a lot simpler and less error-prone.

What do you think?

@RaymondLuong3
RaymondLuong3 force-pushed the fix/sf-3959-incorrect-history branch from 4ea7acc to 4e91f81 Compare October 20, 2026 23:35
@RaymondLuong3 RaymondLuong3 removed the ai-review-author-sign-off PR author has looked at AI review of change and determined no findings warrant further changes label Oct 20, 2026

@RaymondLuong3 RaymondLuong3 left a comment

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.

@RaymondLuong3 made 1 comment.
Reviewable status: 0 of 19 files reviewed, 1 unresolved discussion (waiting on Nateowami).


src/SIL.XForge.Scripture/ClientApp/src/app/core/notification-service-base.ts line 61 at r1 (raw file):

Previously, Nateowami wrote…

Thanks for tracking down the cause and fixing this. My first thought in reading this start/stop code with owner objects is that this feels exactly like an observable that needs to be unsubscribed when it's no longer needed, and that manually implementing start/stop which the consumer has to remember to call means there's more work in every class that uses it.

I asked Claude to look into implementing this with observables, and it appears while it's not trivial, the consumers get a better experience. I haven't reviewed it, but I pushed it to refactor/sf-3959-notification-observables. To me it looks like the consumers would be a lot simpler and less error-prone.

What do you think?

Ok, I looked through the code and I can see the simplification for the consumer components. The project-notification service handles the closing of the connection when a component unsubscribes for the SignalR observable. I think this is an improvement on the current behaviour. I tested this for draft generation and draft applying and everything is behaving as I would expect.

@RaymondLuong3 RaymondLuong3 added the ai-review-author-sign-off PR author has looked at AI review of change and determined no findings warrant further changes label Oct 21, 2026
@Nateowami Nateowami removed the ai-review-author-sign-off PR author has looked at AI review of change and determined no findings warrant further changes label Oct 21, 2026
@pmachapman pmachapman self-assigned this Nov 3, 2026
@pmachapman
pmachapman self-requested a review November 3, 2026 22:07
@pmachapman pmachapman added the ai-review-reviewer-sign-off PR reviewer has looked at AI review of change and determined no findings warrant further changes label Nov 3, 2026

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

@pmachapman reviewed 19 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on RaymondLuong3).


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-notification.service.ts line 34 at r2 (raw file):

/** Whether the state is the final notification sent after applying a draft, whether it succeeded or failed. */
export function isDraftApplyFinished(state: DraftApplyState): boolean {

This function does not need to be exported.

Code quote:

export function isDraftApplyFinished(state: DraftApplyState): boolean {

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

:lgtm: I think this is ready for testing. Just a minor non-blocking suggestion.

@pmachapman made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on RaymondLuong3).

@pmachapman pmachapman added ready to test and removed will require testing PR should not be merged until testers confirm testing is complete labels Nov 3, 2026
@RaymondLuong3
RaymondLuong3 force-pushed the fix/sf-3959-incorrect-history branch from 4e91f81 to 9227790 Compare November 4, 2026 00:20

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

@pmachapman reviewed 4 files and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on RaymondLuong3).

@Nateowami Nateowami added testing complete Testing of PR is complete and should no longer hold up merging of the PR and removed ready to test labels Nov 5, 2026
@RaymondLuong3
RaymondLuong3 force-pushed the fix/sf-3959-incorrect-history branch from 9227790 to 2fff528 Compare November 5, 2026 15:51
@Nateowami
Nateowami enabled auto-merge (squash) November 5, 2026 15:56
Nateowami and others added 2 commits November 5, 2026 12:42
Replace start/stop/subscribeToProject/set...Handler/remove...Handler with
methods such as buildProgress$(projectId) that return an observable of that
project's notifications. The connection is started for the first subscriber,
restarted when the app comes back online, and stopped a short while after the
last subscriber unsubscribes. Notifications are filtered by project in the
service, so components no longer need to check the project ID themselves.

Components now subscribe with quietTakeUntilDestroyed instead of registering
handlers and stopping the connection in onDestroy. Operations that wait for
progress notifications (applying a draft) call whenListening(projectId)
before starting, so that no notifications are missed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RaymondLuong3
RaymondLuong3 force-pushed the fix/sf-3959-incorrect-history branch from 2fff528 to 81f2b2c Compare November 5, 2026 18:42
@Nateowami
Nateowami merged commit 108f91e into master Nov 5, 2026
28 of 29 checks passed
@Nateowami
Nateowami deleted the fix/sf-3959-incorrect-history branch November 5, 2026 18:52

This branch was previously deployed

1 inactive deployment
screenshot_diff — 81f2b2cb Deployed Nov 5, 2026 by RaymondLuong3 via Compare Screenshots #1291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-reviewer-sign-off PR reviewer has looked at AI review of change and determined no findings warrant further changes testing complete Testing of PR is complete and should no longer hold up merging of the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants