Skip to content

Conversation

@daesunp
Copy link
Contributor

@daesunp daesunp commented Nov 27, 2025

Description

This PR exposes a user provided "label" object that can be accessed through SchematizingSimpleTreeView.currentTransactionLabel, which can be accessed from the event callback in commitApplied.

@daesunp daesunp requested a review from a team as a code owner November 27, 2025 22:08
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct public api change Changes to a public API base: main PRs targeted against main branch labels Nov 27, 2025
@github-actions
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  243138 links
    1776 destination URLs
    2013 URLs ignored
       0 warnings
       0 errors


Copy link
Contributor

@noencke noencke left a comment

Choose a reason for hiding this comment

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

This is the first half of the feature - adding and setting the property. The second half is to pass the property to the changed and commitApplied event. I think that both halves are small enough changes that you should do them in the same PR. So next:

  1. Create a CommitMetadataAlpha that extends CommitMetadata and has a label: unknown property.
  2. Update both TreeBranch.commitApplied and TreeBranch.changed to use CommitMetadataAlpha.
  3. Update the tests to consume the label from the event commit metadata rather than directly from the static.

* This value is intended to be read within event handlers like `commitApplied`.
* This value is cleared after each transaction to prevent providing stale/incorrect labels.
*/
private static _currentTransactionLabel: unknown | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, there is no benefit to having a private property here and then making a getter and setter, because the getter and setter do no validation or transformation of the value.

I do think we would benefit from constraining the way that this field can be set. How about this:

private static transactionLabel?: unknown;

public static runWithTransactionLabel<T>(label: T, fn: (label: T) => void): void {
  this.transactionLabel = label;
  try {
    fn(label);
  } finally {
    this.transactionLabel = undefined;
  }
}

Then it's impossible for any code to ever accidentally set the label and forget to clear it, or forget to properly handle errors.

The passing of label to the fn and the resulting generic parameter is not strictly necessary but just a nice to have, IMO.

* This value is intended to be read within event handlers like `commitApplied`.
* This value is cleared after each transaction to prevent providing stale/incorrect labels.
*/
private static _currentTransactionLabel: unknown | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this property might work out even better if you put it on TreeCheckout - and it could be a member rather than be static. I know we discussed using a static because it's correct and it's easy - but if a non-static member is just as easy, then non-static is probably better style/convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds: tree area: dds Issues related to distributed data structures area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch public api change Changes to a public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants