Skip to content

improvement(container-runtime): Further simplifications for dirty/saved logic #24703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

markfields
Copy link
Member

@markfields markfields commented May 23, 2025

Description

Some follow-ups to #24646:

  • Don't bother calling updateDocumentDirtyState when processing a non-modern-runtime message, since we don't even check for its presence in PendingStateManager
  • Get rid of the special treatment of dirty state in replayPendingStates. See commit message on feef9a1 for details

TODO:

  • write one or two tests

@github-actions github-actions bot added base: main PRs targeted against main branch area: runtime Runtime related issues labels May 23, 2025
Justification:
Of all the calls to `updateDocumentDirtyState` that we were blocking emit for,
the only one that could be hit during synchronous `replayPendingStates` is under `submit`.  This can never result in transitioning from dirty -> saved, so doing one transition from "before state" to "after state" will not be distinguishable from letting the transition happen naturally as ops are resubmitted (or not)
@markfields markfields force-pushed the cr/is-dirty-followups branch from d9ca16c to 18685d5 Compare May 23, 2025 21:17
@markfields markfields marked this pull request as ready for review May 23, 2025 22:29
@Copilot Copilot AI review requested due to automatic review settings May 23, 2025 22:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request simplifies the dirty/saved state handling logic in the container runtime. Key changes include removing the temporary suppression of dirty document events during replay operations, eliminating the unused flag emitDirtyDocumentEvent, and adjusting the invocation of updateDocumentDirtyState in relevant code paths.

Comments suppressed due to low confidence (1)

packages/runtime/container-runtime/src/containerRuntime.ts:2528

  • Ensure that the removal of the temporary suppression block for dirty events does not inadvertently affect state consistency during op replay. Verify that updateDocumentDirtyState fully replicates the intended behavior of the removed logic.
// Replaying is an internal operation and we don't want to generate noise while doing it.

@@ -2832,6 +2819,9 @@ export class ContainerRuntime
localOpMetadata?: unknown;
}[] = this.pendingStateManager.processInboundMessages(inboundResult, local);

// This message could have been the last pending local (dirtyable) message, in which case we need to update dirty state to "saved"
Copy link
Preview

Copilot AI May 23, 2025

Choose a reason for hiding this comment

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

Review the revised placement and frequency of updateDocumentDirtyState calls to ensure that dirty state transitions remain consistent across all scenarios.

Copilot uses AI. Check for mistakes.

@markfields markfields marked this pull request as draft June 6, 2025 19:47
@markfields
Copy link
Member Author

Converting to a draft, not expecting to prioritize this before going on Leave. Will finish the tests and pick it up in August.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant