Open
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefines how collaboration version IDs are validated and tightens the conditions under which a version change is detected to prevent spurious "version changed" behavior, likely addressing a flickering modal issue. Sequence diagram for versionChanged detection logicsequenceDiagram
participant Caller
participant SyncContext
participant CollabMessage
participant versionChanged
participant isCollabVersionId
Caller->>versionChanged: versionChanged(SyncContext, CollabMessage)
activate versionChanged
versionChanged->>CollabMessage: check update
versionChanged->>CollabMessage: check syncRequest
alt no update and no syncRequest
versionChanged-->>Caller: false
else has update or syncRequest
versionChanged->>CollabMessage: read version (update.version or syncRequest.version)
versionChanged->>SyncContext: read doc.version
versionChanged->>isCollabVersionId: isCollabVersionId(incomingVersion)
activate isCollabVersionId
isCollabVersionId->>isCollabVersionId: UUID_REGEX.test(value)
isCollabVersionId-->>versionChanged: incomingKnown
deactivate isCollabVersionId
versionChanged->>isCollabVersionId: isCollabVersionId(localVersion)
activate isCollabVersionId
isCollabVersionId->>isCollabVersionId: UUID_REGEX.test(value)
isCollabVersionId-->>versionChanged: localKnown
deactivate isCollabVersionId
versionChanged->>versionChanged: compare versions based on known flags
versionChanged-->>Caller: boolean
deactivate versionChanged
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The custom UUID_REGEX is fairly complex and encodes some special cases (all zeros/all fs); consider centralizing this as a shared UUID utility or adding inline comments breaking down the pattern to make future maintenance and updates easier.
- The early return in versionChanged for messages without update or syncRequest changes its behavior scope; consider explicitly narrowing the collab.ICollabMessage type (e.g., via a union or type guard) so that the function’s intended input domain is enforced at the type level rather than via a runtime check.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The custom UUID_REGEX is fairly complex and encodes some special cases (all zeros/all fs); consider centralizing this as a shared UUID utility or adding inline comments breaking down the pattern to make future maintenance and updates easier.
- The early return in versionChanged for messages without update or syncRequest changes its behavior scope; consider explicitly narrowing the collab.ICollabMessage type (e.g., via a union or type guard) so that the function’s intended input domain is enforced at the type level rather than via a runtime check.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Horusiath
commented
Mar 6, 2026
| }; | ||
|
|
||
| export const isCollabVersionId = (value: string | null | undefined): value is string => { | ||
| return typeof value === 'string' && uuidValidate(value); |
Contributor
Author
There was a problem hiding this comment.
You really don't need an entire dependency for a single regex test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Improve version change detection in collaborative sync to avoid reacting to invalid or irrelevant messages.
Bug Fixes: