Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/wicked-teams-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@fluidframework/tree": minor
"fluid-framework": minor
"__section": tree
---
Add the `minimize` transaction post-processor

When calling `runTransaction` or `runTransactionAsync` on a [`TreeContextAlpha`](https://fluidframework.com/docs/api/fluid-framework/treecontextalpha-interface),
with `RunTransactionParamsAlpha.postProcessor` set to [`minimize`](https://fluidframework.com/docs/api/fluid-framework/#minimize-variable),
edits to any newly created nodes which are removed by the transaction will be discarded.
Edits to removed nodes will also be discarded.
This is intended to remove information from changes (which, for example, may have been made by an AI system)
which cannot be easily inspected by a user looking at the effect of that change on the document.

```typescript
tree.runTransaction(() => { ... }, { postProcessor: minimize });
```
2 changes: 1 addition & 1 deletion packages/dds/tree/api-report/tree.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ export const MapNodeSchema: {
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is MapNodeSchema;
};

// @alpha @deprecated
// @alpha
export const minimize: TransactionPostProcessor;

// @alpha
Expand Down
7 changes: 2 additions & 5 deletions packages/dds/tree/src/shared-tree/transactionMinimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function minimizeSharedTreeChange(
* out to nothing. Minimizing the change reduces the size of the edit that is
* submitted to (and stored by) the service without altering the observable
* effect of the transaction.
* Minimization may discard edits to nodes which are removed by the transaction,
* which would cause an observable difference if those nodes are reattached by a concurrent edit.
*
* The current implementation is limited and is unable to guarantee that the
* resulting change is fully minimized if multiple distinct edit groups are
Expand All @@ -74,11 +76,6 @@ function minimizeSharedTreeChange(
* the implementation will throw a usage error:
* "At most one edit group can be minimized..."
*
* @deprecated Note: minimization is not yet implemented. For now this is a
* no-op that leaves the squashed change unchanged, so supplying it currently
* has no observable effect beyond reserving the behavior. A real
* implementation will be provided in a future change.
*
* @alpha
*/
export const minimize: TransactionPostProcessor = createTransactionPostProcessor({
Expand Down
Loading