Skip to content

Conversation

@egordidenko
Copy link
Contributor

@egordidenko egordidenko commented Dec 24, 2025

Description

Checklist

Summary by CodeRabbit

  • New Features

    • Added a public method to access the uploader API directly.
  • Bug Fixes

    • Strengthened validation for cloud image editor activity parameters — missing identifiers now trigger an explicit error.
  • Tests

    • Added end-to-end test covering the cloud image editing flow, including event-driven setting of the activity and UI visibility assertions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds validation to CloudImageEditorActivity to require internalId, refactors setCurrentActivity parameter handling in the public API, and exposes getAPI() on UploadCtxProvider with an end-to-end test that sets the cloud-image-edit activity via a file-upload-success event.

Changes

Cohort / File(s) Summary
Parameter Validation
src/blocks/CloudImageEditorActivity/CloudImageEditorActivity.ts
activityParams getter now validates that params contains internalId; throws an error if missing.
API Method Signature Refactoring
src/abstract/UploaderPublicApi.ts
setCurrentActivity signature changed from variadic ...params to a single conditional-rest binding ...[params], making the fallback param type unknown instead of any.
API Enhancement & Testing
tests/api.e2e.test.tsx, src/.../UploadCtxProvider*
Added getAPI() on UploadCtxProvider; new E2E test registers file-upload-success listener, calls setCurrentActivity('cloud-image-edit', { internalId }), and asserts cloud-image-editor UI visibility.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Uploader as Uploader (upload flow)
  participant Provider as UploadCtxProvider
  participant API as UploaderPublicApi
  participant Activity as CloudImageEditorActivity
  participant UI as UI / Modal

  Uploader->>Provider: emit file-upload-success(event with internalId)
  Note right of Provider: getAPI() used by test to obtain API
  Provider->>API: invoke setCurrentActivity('cloud-image-edit', {internalId})
  API->>Activity: set current activity params
  Activity->>Activity: validate params (requires internalId)
  alt params valid
    Activity->>UI: open cloud-image-editor modal
    UI-->>Provider: modal visible
  else invalid params
    Activity-->>API: throw validation error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template structure with no actual content—no linked issue, change explanation, code snippets, or details about what was modified and why. Fill in the Description section with the actual changes made, link any related issues, and complete the checklist items to indicate what was tested and documented.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(cloud-image-editor): adjusted activityParams' directly corresponds to the main changes: enforcing internalId validation in CloudImageEditorActivity and updating the setCurrentActivity type signature for parameter handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cloud-image-edit-activity-params

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba03d4e and 4e08d5a.

📒 Files selected for processing (1)
  • src/abstract/UploaderPublicApi.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/abstract/UploaderPublicApi.ts (2)

358-358: Good improvement: unknown is more type-safe than any.

Changing the fallback type from any to unknown for unregistered activity types improves type safety by requiring explicit type assertion or narrowing before using the params value.


354-355: Design is intentional; no breaking change present.

The asymmetric signature is a deliberate type-enforcing design. Activities in ActivityParamsMap ('cloud-image-edit' and 'external') require parameters, while unregistered activities like 'camera' and custom activities allow optional parameters. All existing call sites comply with this contract, and the type test file explicitly documents that omitting params for parameterized activities should produce TypeScript errors—confirming this is the intended behavior.

Likely an incorrect or invalid review comment.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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

Copy link
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: 1

Caution

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

⚠️ Outside diff range comments (1)
src/blocks/CloudImageEditorActivity/CloudImageEditorActivity.ts (1)

18-30: The array handling is necessary due to a bug in UploaderPublicApi.setCurrentActivity, and ExternalSource has the same unhandled vulnerability.

Line 362 of src/abstract/UploaderPublicApi.ts stores the rest parameter array directly in '*currentActivityParams' rather than unwrapping it with params?.[0]. This causes ActivityBlock.activityParams to return an array instead of the expected object. CloudImageEditorActivity correctly handles this with array unwrapping, but ExternalSource does not—it will throw "External Source activity params not found" when called via the public API.

Either fix setCurrentActivity to unwrap the parameter, or add identical array handling to ExternalSource. Additionally, add tests for both activities covering the public API path since none currently exist.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f3dbfe2 and bcaed7c.

📒 Files selected for processing (1)
  • src/blocks/CloudImageEditorActivity/CloudImageEditorActivity.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Copy link

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 PR fixes a bug in the Cloud Image Editor activity where activityParams could be received in array format instead of as a direct object. This occurs when activity parameters are passed through the setCurrentActivity API, which uses rest parameters internally.

Key Changes:

  • Added array format handling to extract the first parameter object from the array
  • Added validation to throw an error if the array is empty
  • Maintained backward compatibility with the existing object format

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

Copy link
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: 1

Caution

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

⚠️ Outside diff range comments (1)
src/blocks/CloudImageEditorActivity/CloudImageEditorActivity.ts (1)

18-25: Add null/undefined guard before using the in operator.

The in operator at line 21 will throw a TypeError if params is null or undefined. This can occur if super.activityParams returns a nullish value.

Additionally, based on the type signature in UploaderPublicApi.setCurrentActivity (lines 354-358 of UploaderPublicApi.ts), params may be passed as a tuple/array. If params is [{ internalId: '123' }], the check 'internalId' in params will be false because arrays don't have an internalId property directly—only their elements do. This inconsistency between the two files needs to be resolved (see my comment on UploaderPublicApi.ts).

🔎 Proposed fix: Add defensive checks
 override get activityParams(): ActivityParams {
   const params = super.activityParams;
+  
+  if (!params || typeof params !== 'object') {
+    throw new Error(`Cloud Image Editor activity params not found`);
+  }
+  
+  // Handle array format if needed (based on UploaderPublicApi signature)
+  const paramsObj = Array.isArray(params) ? params[0] : params;
+  
+  if (!paramsObj || !('internalId' in paramsObj)) {
+    throw new Error(`Cloud Image Editor activity params not found`);
+  }
   
-  if ('internalId' in params) {
-    return params;
-  }
-  throw new Error(`Cloud Image Editor activity params not found`);
+  return paramsObj;
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 570a8ee and 3662a80.

📒 Files selected for processing (2)
  • src/abstract/UploaderPublicApi.ts
  • src/blocks/CloudImageEditorActivity/CloudImageEditorActivity.ts

Copy link

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

Comment on lines 354 to 358
params: T extends keyof ActivityParamsMap
? [ActivityParamsMap[T]]
: T extends RegisteredActivityType
? [undefined?]
: [any?]
: [any?],
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Removing the spread operator from the parameter changes the method signature in a way that breaks existing usage. The original ...params with type [ActivityParamsMap[T]] allowed calling the method with optional parameters like setCurrentActivity('camera') or setCurrentActivity('cloud-image-edit', { internalId: 'id' }). With the spread operator removed, the type signature now requires passing a tuple array, which would require calls like setCurrentActivity('cloud-image-edit', [{ internalId: 'id' }]). This breaks the existing API. Either restore the spread operator or change the parameter type to not be a tuple array.

Copilot uses AI. Check for mistakes.
Copy link
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: 1

♻️ Duplicate comments (1)
src/abstract/UploaderPublicApi.ts (1)

354-358: Tuple wrapping issue resolved.

The previous review flagged that params was incorrectly wrapped in tuple format ([ActivityParamsMap[T]]). This has been correctly fixed - the type now directly uses ActivityParamsMap[T] without the array wrapper.

🧹 Nitpick comments (2)
tests/api.e2e.test.tsx (2)

103-103: Inconsistent API access pattern.

Other tests in this file use uploadCtxProvider.api (lines 30, 57, 83), but this test uses uploadCtxProvider.getAPI(). Consider using a consistent approach unless there's a specific reason for the difference.

Suggested change for consistency
-    const api = uploadCtxProvider.getAPI();
+    const api = uploadCtxProvider.api;

109-110: Redundant type assertion.

The detail type is already inferred from CustomEvent<EventPayload['file-upload-success']> on line 109, making the assertion on line 110 unnecessary.

Suggested simplification
   const eventHandler = (event: CustomEvent<EventPayload['file-upload-success']>) => {
-     const detail = event.detail as EventPayload['file-upload-success'];
+     const detail = event.detail;
     api.setCurrentActivity('cloud-image-edit', { internalId: detail.internalId });
     api.setModalState(true);
   };
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3662a80 and b5381f2.

📒 Files selected for processing (2)
  • src/abstract/UploaderPublicApi.ts
  • tests/api.e2e.test.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
tests/api.e2e.test.tsx (1)
src/blocks/UploadCtxProvider/EventEmitter.ts (1)
  • EventPayload (43-67)

@egordidenko egordidenko force-pushed the fix/cloud-image-edit-activity-params branch from b5381f2 to e95f1d7 Compare December 24, 2025 18:33
@egordidenko egordidenko force-pushed the fix/cloud-image-edit-activity-params branch 2 times, most recently from 1764b34 to 7723f2c Compare December 24, 2025 19:59
Copy link
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: 2

Caution

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

⚠️ Outside diff range comments (1)
types/test/public-upload-api.test-d.tsx (1)

11-11: Pipeline failure caused by breaking signature change.

The signature change in UploaderPublicApi.setCurrentActivity now requires a second parameter, causing this line to fail type checking. Activities like 'camera' that don't require parameters must now explicitly pass undefined.

This should be addressed by making the params parameter optional in the implementation (see review comment on src/abstract/UploaderPublicApi.ts).

🔎 Temporary workaround
-api.setCurrentActivity('camera');
+api.setCurrentActivity('camera', undefined);

However, the proper fix is to make the parameter optional in the method signature.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1764b34 and 7723f2c.

📒 Files selected for processing (2)
  • src/abstract/UploaderPublicApi.ts
  • types/test/public-upload-api.test-d.tsx
🧰 Additional context used
🪛 GitHub Actions: checks
types/test/public-upload-api.test-d.tsx

[error] 11-11: tsd type check failed: Expected 2 arguments, but got 1. (Step: tsd -t ./dist/index.d.ts -f ./types/test/)

🪛 GitHub Check: CodeQL
types/test/public-upload-api.test-d.tsx

[notice] 3-3: Unused variable, import, function or class
Unused import createRunnableDevEnvironment.

🔇 Additional comments (2)
types/test/public-upload-api.test-d.tsx (2)

18-18: Test correctly verifies required params.

This test appropriately validates that cloud-image-edit activity cannot be called with undefined params since it requires internalId.


36-36: Test correctly validates custom activity flexibility.

This appropriately verifies that custom activities can be called with undefined params, demonstrating the type system's flexibility for unregistered activities.

@egordidenko egordidenko force-pushed the fix/cloud-image-edit-activity-params branch from 7723f2c to ba03d4e Compare December 24, 2025 20:04
@egordidenko egordidenko force-pushed the fix/cloud-image-edit-activity-params branch from ba03d4e to 4e08d5a Compare December 25, 2025 15:59
@egordidenko egordidenko merged commit 7e808bd into main Dec 25, 2025
6 of 7 checks passed
@egordidenko egordidenko deleted the fix/cloud-image-edit-activity-params branch December 25, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants