Skip to content

fix: Don't display preview annotations from previous media on the next one#6068

Merged
dwesolow merged 4 commits intodevelopfrom
dwesolow/fix-sam
Apr 14, 2026
Merged

fix: Don't display preview annotations from previous media on the next one#6068
dwesolow merged 4 commits intodevelopfrom
dwesolow/fix-sam

Conversation

@dwesolow
Copy link
Copy Markdown
Contributor

@dwesolow dwesolow commented Apr 9, 2026

Summary

The issue was caused by incorrect AbortController instance inside the main function (race conditions/closures).
This PR fixes that and adds unit tests.

How to test

Checklist

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

@dwesolow dwesolow self-assigned this Apr 9, 2026
Copilot AI review requested due to automatic review settings April 9, 2026 14:40
@github-actions github-actions bot added the Geti UI Issues related to Geti application frontend label Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🐳 Docker image sizes

Device Size
cpu 3584.4 MB (3.50 GB)
cuda 11715.6 MB (11.44 GB)
xpu 10553.0 MB (10.31 GB)

Copy link
Copy Markdown
Contributor

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

Fixes a race condition in the Segment Anything tool where preview annotations from a previous media item could be applied to the next one by ensuring cancellation is tied to the correct AbortController instance, and adds unit tests to validate cancellation behavior.

Changes:

  • Update useWithCancel to capture the per-invocation AbortController and use it for abort checks.
  • Add Vitest coverage for useWithCancel (cancel, superseded calls, unmount cleanup).
  • Refactor mocks to introduce getMockedShape and adjust preview update promise handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
application/ui/src/features/annotator/tools/segment-anything-tool/use-with-cancel.ts Fixes abort-controller closure/race by checking the correct controller instance; adjusts hook dependencies.
application/ui/src/features/annotator/tools/segment-anything-tool/use-with-cancel.test.ts Adds unit tests covering cancellation and superseded-call behavior.
application/ui/src/features/annotator/tools/segment-anything-tool/segment-anything-tool.component.tsx Adds a .catch to prevent rejected promises from bubbling during preview updates.
application/ui/mocks/mock-annotation.ts Adds getMockedShape helper and reuses it in getMockedAnnotation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread application/ui/mocks/mock-annotation.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

📊 Test coverage report

Metric Coverage
Lines 56.2%
Functions 78.1%
Branches 87.3%
Statements 56.2%

setPreviewShapes(shapes.map((shape) => removeOffLimitPoints(shape, roi)));
})
.catch(() => {
return [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it clear the current setPreviewShapes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it shouldn't. It would cause flickering previews (like a disco mode).

@dwesolow dwesolow requested a review from a team as a code owner April 13, 2026 06:43
@dwesolow dwesolow added this pull request to the merge queue Apr 14, 2026
Merged via the queue into develop with commit e2a3461 Apr 14, 2026
33 checks passed
@dwesolow dwesolow deleted the dwesolow/fix-sam branch April 14, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Geti UI Issues related to Geti application frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants