Skip to content

E2E Segmentation Tests#7725

Open
mcdoh wants to merge 24 commits into
developfrom
e2e/segmentation
Open

E2E Segmentation Tests#7725
mcdoh wants to merge 24 commits into
developfrom
e2e/segmentation

Conversation

@mcdoh
Copy link
Copy Markdown
Contributor

@mcdoh mcdoh commented Jun 4, 2026

🔗 Related Issues

📋 What changes are proposed in this pull request?

tests

🧪 How is this patch tested? If it is not, please explain why.

📝 Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • AI-assisted segmentation and manual segmentation tools (Pen, Brush, Merge) with segmentation-mode UI controls and tool switching.
  • Bug Fixes

    • More reliable mask serialization and persistence so saved annotations better reflect mask adds/edits/removals.
  • Tests

    • Extensive unit and end-to-end coverage including deterministic SAM2 worker for stable AI-assisted segmentation tests and many hook/overlay command tests.
  • Chores

    • CLI Python runner now fails on non-zero exit codes for stricter CI behavior.

Enterprise sync PR: https://github.com/voxel51/fiftyone-teams/pull/2824

@mcdoh mcdoh requested a review from a team as a code owner June 4, 2026 14:34
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR extracts resolvePointVariant and buildAnnotationLabel into dedicated modules, refactors usePointSelection to avoid stale-closure cleanup and re-exports variant APIs, adds a BrowserAnnotationProvider test seam for deterministic SAM2 workers, updates PythonRunner.exec to reject on non-zero exits, and adds extensive unit and Playwright e2e tests plus POM/SDK helpers for segmentation and persistence workflows.

Sequence Diagram(s)

sequenceDiagram
  participant UI
  participant usePointSelection
  participant resolvePointVariant
  participant DetectionOverlay
  participant BrowserAnnotationProvider
  participant SAM2Worker
  UI->>usePointSelection: click(relativePoint, modifiers, label)
  usePointSelection->>resolvePointVariant: relativePoint, modifiers, label
  resolvePointVariant->>DetectionOverlay: containsMaskPixel(relativePoint) [if overlay present]
  resolvePointVariant-->>usePointSelection: POSITIVE / NEGATIVE (shift may invert)
  usePointSelection-->>UI: apply point with variant
  UI->>BrowserAnnotationProvider: request SAM2 inference
  BrowserAnnotationProvider->>SAM2Worker: postMessage(embedAndDecode)
  SAM2Worker-->>BrowserAnnotationProvider: postMessage(inference result)
  BrowserAnnotationProvider-->>UI: inference result (mask,bbox)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • lanzhenw
  • kaixi-wang
  • tom-vx51
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete; only 'tests' appears in the proposed changes section, and testing methodology, related issues, and affected areas are not filled in. Expand the 'What changes are proposed' section to summarize the e2e tests and refactoring (SAM2 mock worker, point variant resolution, persistence logic). Document how tests were run. Populate or confirm 'Related Issues' and select affected areas (likely App and Build).
Title check ❓ Inconclusive The title 'E2E Segmentation Tests' is vague and generic, failing to convey meaningful detail about the specific changes or primary focus. Replace with a specific title that captures the main addition, e.g., 'Add SAM2 segmentation and pen-tool e2e tests' or 'Add segmentation tool e2e tests with mock worker support'.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e/segmentation

Comment @coderabbitai help to get the list of available commands and usage tips.

@voxel51-bot
Copy link
Copy Markdown
Collaborator

Enterprise sync conflict

This branch has a merge conflict with Enterprise develop. Resolve the conflicts on oss-sync/e2e/segmentation and push — CI will re-run automatically.

Enterprise sync run: https://github.com/voxel51/fiftyone-teams/actions/runs/26958577003

See Integrating OSS work into Enterprise for instructions.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/packages/annotation/src/agents/hooks/resolvePointVariant.ts`:
- Around line 37-45: The function resolvePointVariant currently types its third
parameter label as non-null but guards against null at runtime; change the
signature of resolvePointVariant to accept label: AnnotationLabel | null
(nullable) and update any related type annotations/imports if necessary so
callers (e.g., usePointSelection) can pass selectedLabel without casting; keep
the existing runtime guards (label && label.overlay ...) intact.

In `@e2e-pw/src/oss/specs/MISSING-annotate-segmentation-pen-roundtrip.spec.ts`:
- Around line 46-67: The beforeAll hook sets process.env.VFF_AI_SEGMENTATION =
"true" but the suite never restores the original value; update the teardown in
test.afterAll to capture the original value before mutating (in test.beforeAll)
and restore it in test.afterAll (or delete the key if it was undefined),
referencing the existing test.beforeAll/test.afterAll blocks and the
VFF_AI_SEGMENTATION environment variable so test isolation is preserved.

In `@e2e-pw/src/oss/specs/MISSING-pcd-only-dataset.spec.ts`:
- Around line 66-72: The current broad except around
fou3d.compute_orthographic_projection_images swallows all errors and can mask
real regressions; replace the blanket "except Exception" with either no
try/except (let failures propagate and fail the spec) or catch only the specific
expected exception type (e.g., ValueError or a custom NaN-related exception from
fiftyone.utils.utils3d) and handle it explicitly (log a clear message and
re-raise or mark the test as skipped/failing). Locate the call to
fou3d.compute_orthographic_projection_images and update the error handling so
only known, documented exceptions are caught and all other exceptions propagate.

In `@e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts`:
- Around line 70-78: The suite sets process.env.VFF_AI_SEGMENTATION = "true" in
test.beforeAll which can leak to other specs; update test.afterAll to restore or
delete that env var (e.g., delete process.env.VFF_AI_SEGMENTATION or reset to
its previous value captured before setting) and ensure this cleanup runs after
foWebServer.stopWebServer() (or immediately after) so VFF_AI_SEGMENTATION does
not persist across worker processes; locate the env set in the beforeAll block
and the teardown in test.afterAll to implement the restore/delete.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 88aeaf62-47f0-4618-831e-99f355404243

📥 Commits

Reviewing files that changed from the base of the PR and between 4b8ad38 and eaa558b.

⛔ Files ignored due to path filters (10)
  • app/package.json is excluded by !**/*.json
  • app/yarn.lock is excluded by !**/yarn.lock, !**/*.lock, !**/*.lock
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-ai-mask-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-ai-mask-chromium-linux.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-brush-stroke-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-brush-stroke-chromium-linux.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-merge-union-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-merge-union-chromium-linux.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-pen-rectangle-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts-snapshots/seg-pen-rectangle-chromium-linux.png is excluded by !**/*.png, !**/*.png
📒 Files selected for processing (35)
  • app/packages/annotation/src/agents/hooks/resolvePointVariant.test.ts
  • app/packages/annotation/src/agents/hooks/resolvePointVariant.ts
  • app/packages/annotation/src/agents/hooks/useActiveTask.test.ts
  • app/packages/annotation/src/agents/hooks/useApplyInferenceResult.test.ts
  • app/packages/annotation/src/agents/hooks/useInferenceStatus.test.ts
  • app/packages/annotation/src/agents/hooks/usePointSelection.test.ts
  • app/packages/annotation/src/agents/hooks/usePointSelection.ts
  • app/packages/annotation/src/agents/hooks/useRegisterPointSelectionEventHandlers.test.ts
  • app/packages/annotation/src/persistence/buildAnnotationLabel.test.ts
  • app/packages/annotation/src/persistence/buildAnnotationLabel.ts
  • app/packages/annotation/src/persistence/useLighterDeltaSupplier.test.ts
  • app/packages/annotation/src/persistence/useLighterDeltaSupplier.ts
  • app/packages/annotation/src/persistence/usePersistAnnotationDeltas.test.ts
  • app/packages/annotation/src/persistence/usePersistenceRetryController.test.ts
  • app/packages/annotation/src/providers/BrowserAnnotationProvider.test.ts
  • app/packages/annotation/src/providers/BrowserAnnotationProvider.ts
  • app/packages/core/src/components/Modal/Sidebar/Annotate/Edit/useAIAnnotationMode.test.ts
  • app/packages/core/src/components/Modal/Sidebar/Annotate/Edit/useManualSegmentationTools.test.ts
  • app/packages/core/src/components/Modal/Sidebar/Annotate/Edit/usePenTool.test.ts
  • app/packages/lighter/src/commands/AddMaskKeypointCommand.test.ts
  • app/packages/lighter/src/commands/PaintStrokeCommand.test.ts
  • app/packages/lighter/src/interaction/InteractivePenHandler.test.ts
  • app/packages/lighter/src/interaction/buildBrushCursor.test.ts
  • app/packages/lighter/src/overlay/MaskKeypoints.test.ts
  • app/packages/lighter/src/overlay/rippleRing.test.ts
  • e2e-pw/src/oss/fixtures/annotate-sdk.ts
  • e2e-pw/src/oss/poms/modal/annotate-sidebar.ts
  • e2e-pw/src/oss/poms/modal/sample-canvas/index.ts
  • e2e-pw/src/oss/specs/MISSING-annotate-segmentation-ai-sam2.spec.ts
  • e2e-pw/src/oss/specs/MISSING-annotate-segmentation-pen-roundtrip.spec.ts
  • e2e-pw/src/oss/specs/MISSING-pcd-only-dataset.spec.ts
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts
  • e2e-pw/src/shared/python-runner/python-runner.test.ts
  • e2e-pw/src/shared/python-runner/python-runner.ts
  • e2e-pw/src/shared/sam2-mock-worker.ts

Comment thread app/packages/annotation/src/agents/hooks/resolvePointVariant.ts
Comment thread e2e-pw/src/oss/specs/MISSING-pcd-only-dataset.spec.ts Outdated
Comment thread e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts
@voxel51-bot
Copy link
Copy Markdown
Collaborator

Enterprise sync conflict

This branch has a merge conflict with Enterprise develop. Resolve the conflicts on oss-sync/e2e/segmentation and push — CI will re-run automatically.

Enterprise sync run: https://github.com/voxel51/fiftyone-teams/actions/runs/27037321714

See Integrating OSS work into Enterprise for instructions.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/packages/annotation/src/agents/hooks/usePointSelection.ts (1)

45-66: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

PointSelection interface is missing the reset method.

The hook returns reset at line 222 and useSyncPointSelectionWithScene destructures it at line 238, but the interface doesn't declare it. TypeScript will error when callers try to access .reset through the typed return.

🔧 Proposed fix
 export interface PointSelection {
   /**
    * Activates point selection.
    */
   activate(): void;

   /**
    * Deactivates point selection. Disables interactivity with the point
    * selection business logic.
    */
   deactivate(): void;

   /**
    * Clears all placed points while keeping point selection active. The
    * overlay and interactive handler remain in place — the user can continue
    * placing new points on an empty canvas.
    */
   clearPoints(): void;

+  /**
+   * Resets the state atoms without interacting with the scene. Use this when
+   * the underlying scene has already been destroyed (e.g. sample navigation)
+   * and the overlay/handler references are now stale.
+   */
+  reset(): void;
+
   /** The current activation status of the point selection tool. */
   isActive: boolean;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/packages/annotation/src/agents/hooks/usePointSelection.ts` around lines
45 - 66, The PointSelection interface is missing a declaration for the reset
method that is being returned by the hook and used by callers. Add a new method
declaration to the PointSelection interface after the clearPoints method with
appropriate JSDoc documentation explaining what the reset method does (you can
reference how the method is used in the hook at line 222 to understand its
purpose).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@app/packages/annotation/src/agents/hooks/usePointSelection.ts`:
- Around line 45-66: The PointSelection interface is missing a declaration for
the reset method that is being returned by the hook and used by callers. Add a
new method declaration to the PointSelection interface after the clearPoints
method with appropriate JSDoc documentation explaining what the reset method
does (you can reference how the method is used in the hook at line 222 to
understand its purpose).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a3c8f315-ad80-4a94-b33f-675af1b54767

📥 Commits

Reviewing files that changed from the base of the PR and between eaa558b and 36422f9.

⛔ Files ignored due to path filters (2)
  • app/package.json is excluded by !**/*.json
  • app/yarn.lock is excluded by !**/yarn.lock, !**/*.lock, !**/*.lock
📒 Files selected for processing (2)
  • app/packages/annotation/src/agents/hooks/usePointSelection.ts
  • app/packages/annotation/src/persistence/buildAnnotationLabel.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts (1)

204-204: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove misleading comment.

The comment claims annotateSDK is "unused", but line 221 calls annotateSDK.getDetectionsState(). Remove this comment or update it to reflect the actual usage.

Proposed fix
-    // Annotate the freshly-saved sample.
-    void annotateSDK; // unused — kept so per-test fixture creation still runs
+    // Annotate the freshly-saved sample.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts` at line
204, The inline comment claiming "annotateSDK" is unused is incorrect; update or
remove it so it no longer misleads future readers — locate the
declaration/reference to annotateSDK (the variable used later via
annotateSDK.getDetectionsState()) and either delete the comment or change it to
accurately state that the variable is used by per-test fixtures and later by
getDetectionsState().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts`:
- Line 204: The inline comment claiming "annotateSDK" is unused is incorrect;
update or remove it so it no longer misleads future readers — locate the
declaration/reference to annotateSDK (the variable used later via
annotateSDK.getDetectionsState()) and either delete the comment or change it to
accurately state that the variable is used by per-test fixtures and later by
getDetectionsState().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d604e672-b6ad-4b80-b6c0-f68b826439af

📥 Commits

Reviewing files that changed from the base of the PR and between 36422f9 and 51bf8bf.

📒 Files selected for processing (4)
  • app/packages/annotation/src/agents/hooks/resolvePointVariant.ts
  • e2e-pw/src/oss/specs/MISSING-annotate-segmentation-pen-roundtrip.spec.ts
  • e2e-pw/src/oss/specs/MISSING-pcd-only-dataset.spec.ts
  • e2e-pw/src/oss/specs/MISSING-segmentation-tool-snapshots.spec.ts

@voxel51-bot
Copy link
Copy Markdown
Collaborator

Enterprise sync conflict

This branch has a merge conflict with Enterprise develop. Resolve the conflicts on oss-sync/e2e/segmentation and push — CI will re-run automatically.

Enterprise sync run: https://github.com/voxel51/fiftyone-teams/actions/runs/27142943724

See Integrating OSS work into Enterprise for instructions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants