Skip to content

Conversation

jpsantosbh
Copy link
Collaborator

@jpsantosbh jpsantosbh commented Aug 18, 2025

Description

Make dial() async again to support listen parameters similar to the realtime-sdk API. This is an old request from the DevEx team, and we need this before the first public release of @signalwire/client SDK.

The old way still allowed developers to choose between the "dial(), add listeners, start()" or "dial(listen:{...})" approach.

Type of change

  • Internal refactoring
  • Bug fix (bugfix - non-breaking)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Code snippets

import { SignalWire } from '@signalwire/client'

// 1. Create client
const client = await SignalWire({
  host: 'your-space.signalwire.com',
  token: 'your-access-token'
})

// 2. Dial with event listeners - call starts automatically!
const call = await client.dial({
  to: '/public/conference-room',
  audio: true,
  video: true,
  listen: {
    'call.joined': (params) => {
      console.log('Call joined!', params)
    },
    'member.joined': (params) => {
      console.log('Member joined:', params.member.name)
    }
  }
})

// Call is already started and ready to use
console.log('Call ID:', call.id)

In case of new feature or breaking changes, please include code snippets.

jpsantosbh and others added 30 commits July 21, 2025 15:43
Fabric references renamed too Call
# Conflicts:
#	internal/e2e-client/playwright.config.ts
#	package-lock.json
#	packages/js/CHANGELOG.md
#	packages/js/package.json
#	packages/realtime-api/CHANGELOG.md
#	packages/realtime-api/package.json
#	packages/web-api/CHANGELOG.md
#	packages/web-api/package.json
- Remove browser-js workflows (production and staging)
- Remove realtime-api workflows (production and staging)
- Update unit-tests.yml to only run browser-client workflows
- Remove stack tests that reference deleted realtime-api package
- Add --passWithNoTests flag to test scripts to handle empty test suites

This focuses the CI/CD pipeline on the @signalwire/client package only.
- Fix test file path: buildVideoWithCallSDK.spec.ts -> buildVideoWithFabricSDK.spec.ts
- Add correct path prefixes for callfabric tests (callfabric/*.spec.ts)
- Fix renegotiation test paths to include callfabric/ prefix
- Disable relayApp.spec.ts test that depends on removed @signalwire/realtime-api

These configuration mismatches were causing e2e workflow failures.
Merging the type renames for @signalwire/client back to the original repository
# Conflicts:
#	internal/e2e-js/fixtures.ts
#	internal/e2e-js/package.json
#	internal/e2e-js/playwright.config.ts
#	internal/e2e-js/tests/buildVideoWithVideoSDK.spec.ts
#	internal/e2e-js/tests/callfabric/agentCustomer.spec.ts
#	internal/e2e-js/tests/roomSession.spec.ts
#	internal/e2e-js/tests/roomSessionAudienceCount.spec.ts
#	internal/e2e-js/tests/roomSessionAutomaticStream.spec.ts
#	internal/e2e-js/tests/roomSessionBadNetwork.spec.ts
#	internal/e2e-js/tests/roomSessionCleanup.spec.ts
#	internal/e2e-js/tests/roomSessionDemote.spec.ts
#	internal/e2e-js/tests/roomSessionDemoteAudience.spec.ts
#	internal/e2e-js/tests/roomSessionDemotePromote.spec.ts
#	internal/e2e-js/tests/roomSessionDemoteReattachPromote.spec.ts
#	internal/e2e-js/tests/roomSessionDevices.spec.ts
#	internal/e2e-js/tests/roomSessionFollowLeader.spec.ts
#	internal/e2e-js/tests/roomSessionJoinFrom.spec.ts
#	internal/e2e-js/tests/roomSessionJoinUntil.spec.ts
#	internal/e2e-js/tests/roomSessionLocalStream.spec.ts
#	internal/e2e-js/tests/roomSessionLockUnlock.spec.ts
#	internal/e2e-js/tests/roomSessionMaxMembers.spec.ts
#	internal/e2e-js/tests/roomSessionMethodsOnNonExistingMembers.spec.ts
#	internal/e2e-js/tests/roomSessionMultipleStreams.spec.ts
#	internal/e2e-js/tests/roomSessionPromoteDemote.spec.ts
#	internal/e2e-js/tests/roomSessionPromoteMeta.spec.ts
#	internal/e2e-js/tests/roomSessionPromoteParticipant.spec.ts
#	internal/e2e-js/tests/roomSessionPromoteReattachDemote.spec.ts
#	internal/e2e-js/tests/roomSessionRaiseHand.spec.ts
#	internal/e2e-js/tests/roomSessionReattach.spec.ts
#	internal/e2e-js/tests/roomSessionReattachBadAuth.spec.ts
#	internal/e2e-js/tests/roomSessionReattachMultiple.spec.ts
#	internal/e2e-js/tests/roomSessionReattachScreenshare.spec.ts
#	internal/e2e-js/tests/roomSessionReattachWrongCallId.spec.ts
#	internal/e2e-js/tests/roomSessionReattachWrongProtocol.spec.ts
#	internal/e2e-js/tests/roomSessionRemoveAllMembers.spec.ts
#	internal/e2e-js/tests/roomSessionStreaming.spec.ts
#	internal/e2e-js/tests/roomSessionStreamingAPI.spec.ts
#	internal/e2e-js/tests/roomSessionTalkingEventsParticipant.spec.ts
#	internal/e2e-js/tests/roomSessionTalkingEventsToAudience.spec.ts
#	internal/e2e-js/tests/roomSessionUnauthorized.spec.ts
#	internal/e2e-js/tests/roomSessionUpdateMedia.spec.ts
#	internal/e2e-js/tests/roomSettings.spec.ts
#	internal/e2e-js/utils.ts
#	packages/js/src/fabric/FabricRoomSession.ts
#	packages/js/src/fabric/utils/validationProxy.ts
#	packages/js/src/fabric/utils/validators.ts
- Copy playground-js to playground-client
- Remove non-fabric samples (chat, pubSub, video, videoManager)
- Update imports to use @signalwire/client instead of @signalwire/js
- Add Vite configuration for proper module resolution
- Update e2e-client to use playground-client

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Apply Vite configuration fixes to properly resolve @signalwire/client modules
- Update blank template to explicitly import and expose SignalWire exports
- Add module aliases, optimization, and process definitions for browser compatibility
- This ensures window._SWJS is properly populated during e2e tests

The combination of playground-client and these fixes resolves the module loading issue.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Remove direct dependency on @signalwire/realtime-api in test file
- Create relayAppWorker.js to execute realtime-api operations in Node.js context
- Add relayAppClient fixture to manage Node.js child processes
- Install @signalwire/realtime-api as dev dependency from npm registry
- Update all three test cases to use the new fixture pattern
- Maintain same test assertions and behavior

This change isolates the realtime-api package execution to a separate Node.js process,
allowing the tests to work without importing the Node.js-only package directly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@jpsantosbh jpsantosbh force-pushed the joao/dial-with-events branch from 8e14e95 to acaa0be Compare August 20, 2025 10:41
@jpsantosbh jpsantosbh changed the title WIP: Add event listeners to dial() Add optional listen param to dial() to support starting calls using a single method. Aug 20, 2025
@jpsantosbh jpsantosbh marked this pull request as ready for review August 20, 2025 11:59
@@ -436,23 +447,131 @@ const createCFClientWithToken = async (
return swClient
}

export const createCallStateUtility = (page: Page) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an attempt to simplify the e2e tests.
This allows for both waiting for a specific event and waiting for a particular change of state.

Comment on lines +47 to +51
// Trigger mute action
await page.evaluate(async () => {
const callObj = window._callObj
await callObj!.audioMute()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be helpful for debugging purposes if page.evalulate() call that awaits or resolves a promise should also have a timeout otherwise we could still potentially have "hanging" promises

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is a valid point, especially when the promise resolution depends on external events.
But for method calls, the SDK has its internal timeout, and page.evaluate has a default timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious and trying to understand if I am missing something - If the page.evaluate has the default timeout. Why did we even create the new utilities?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMO, we don't need the utilities; they are a nice-to-have.

What we need is a test to execute a single action each time it runs in the page scope.
If inside the page.evaluate, we have only await callObj!.audioMute() like here when this page.evaluate fail we now exactly why.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could take advantage of test.step to improve readibility of the test

@@ -436,23 +447,131 @@ const createCFClientWithToken = async (
return swClient
}

export const createCallStateUtility = (page: Page) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

we might want some unit tests for the _callState

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now you really made me think... I always thought test code is self-testable 🤔

You can still write a faulty test, but that means the code being tested has a "pairing" fault... And if that is the case, the problem most likely is a misunderstanding of the requirements, meaning that all attempts to test will embed the same fault.

I never thought to test a test, but maybe I'm wrong...

But in this case, what do you mean by " unit tests for the _callState"? What function/implementation do you think I should cover?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just that the __callState instance has state and some methods that might be worthwhile to write unit tests so that:

  1. That the state and methods work as intended
  2. There are no unintended regressions or bugs introduced in the future should this test utility change

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I was thinking that if these utilities have some level of complexity and are critical to the e2e tests then they might be worthwhile having their own set of basic tests to minimize the chances that the e2e tests don't face errors due to the test code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, let me try that

LittorWired
LittorWired previously approved these changes Aug 27, 2025
iAmmar7
iAmmar7 previously approved these changes Aug 28, 2025
Copy link
Collaborator

@iAmmar7 iAmmar7 left a comment

Choose a reason for hiding this comment

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

Just highlighting:

Based on the above points, I am not sure if that's what the DevExp need. But I will leave this decision up to you.

Comment on lines 27 to 33
_callState?: {
history: any[]
update(event: string, payload: any): void
getState(): any
getSelfState(): any
logHistory(): void
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid any, if possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, I want any, this is to handle ANY object passed to it.

@@ -58,22 +68,24 @@ export const createTestServer = async (
logLevel: 'silent',
resolve: {
alias: {
'@signalwire/client': path.resolve(__dirname, '../../packages/client/src'),
'@signalwire/client': path.resolve(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pretty weird, I am not sure why we even need these aliases?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@claude, can you check why we are using the aliases while creating the Playwright test server using Vite? The e2e-client package is a part of the monorepo, which has the @signalwire/client package already. Do we even need these aliases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@iAmmar7 I discovered why... This PR was made on top of the SDK version with type export issues. #1299

At some point, CC added this as a workaround for the issue, but it can now be removed.
#1301

return this.buildOutboundCall(params)

const callSession = this.buildOutboundCall(params)
return this.initializeCallSession(callSession, params, 'dial')
Copy link
Collaborator

Choose a reason for hiding this comment

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

dial is now going to start the call as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only if the user opted to pass the listeners.
But yes, dial now can be used to dial the address, not just build a session then later start the call.

this.logger.debug(`adding listener for event '${eventName}'`)
const wrappedHandler = async (params: any) => {
try {
await handler(params)
Copy link
Collaborator

Choose a reason for hiding this comment

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

await' has no effect on the type of this expression.ts(80007)

You probably don't need the await here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What if the developer using the SDK passes an async function to listen to the event?

Status_and_Add_optional_listen_param_to_dial___to_support_starting_calls_using_a_single_method__by_jpsantosbh_·_Pull_Request__1289_·_signalwire_signalwire-js

@@ -316,15 +318,55 @@ export class WSClient extends BaseClient<{}> implements WSClientContract {
})
}

public dial(params: DialParams) {
// TODO: Do we need this remove item here?
private async initializeCallSession(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might be able to move this to the CallSession class so that you don't need to pass the callSession as a parameter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, we can do that later

}) => {
return new Promise<any>(async (resolve, _reject) => {
// @ts-expect-error
const client: SignalWireContract = window._client
const listenHandlers: any = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can avoid any here:

Considering the listen type in Dial and Reattach is Partial<CallSessionEvents>, you may need to export the CallSessionEvents type from the SDK.

Suggested change
const listenHandlers: any = {}
const listenHandlers: Partial<CallSessionEvents> = {}

@@ -4,6 +4,7 @@ import {
IncomingCallHandlers,
} from './incomingCallManager'
import { CallSession } from '../CallSession'
import { CallSessionEvents } from 'packages/client/src/utils/interfaces'
Copy link
Collaborator

Choose a reason for hiding this comment

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

The import should be relative to avoid build issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch

@jpsantosbh jpsantosbh dismissed stale reviews from iAmmar7 and LittorWired via 6a6e1f9 August 28, 2025 18:53
Copy link

claude bot commented Aug 28, 2025

Claude finished @jpsantosbh's task —— View job


Pull Request Review

Reviewing PR #1289: Add optional listen param to dial() to support starting calls using a single method.

Review Tasks:

  • Read and analyze core implementation files
  • Review WSClient.ts changes and dial() method modifications
  • Examine interface changes and type definitions
  • Analyze test coverage and quality
  • Review e2e utilities and test implementations
  • Check for security and performance concerns
  • Evaluate existing review comments and concerns
  • Provide comprehensive feedback and recommendations

Summary

This PR successfully implements the optional listen parameter for the dial() method, allowing developers to start calls with event listeners attached in a single method call. The implementation follows good patterns and includes comprehensive test coverage.

Code Quality Assessment

✅ Strengths

  1. Clean API Design: The listen parameter integration is well-designed and maintains backward compatibility
  2. Comprehensive Testing: Excellent test coverage with 962 lines of well-structured unit tests covering both success and error scenarios
  3. Error Handling: Robust error handling with proper cleanup on failures
  4. Type Safety: Good TypeScript integration with proper type definitions

⚠️ Areas for Improvement

Critical Issues

  1. Missing Changeset - The changeset-bot correctly identified that this PR needs a changeset since it adds new functionality

  2. Import Path Issue (packages/client/src/unified/interfaces/wsClient.ts:30):

    import { CallSessionEvents } from 'packages/client/src/utils/interfaces'  // ❌ Absolute path

    Should be:

    import { CallSessionEvents } from '../../utils/interfaces/fabric'  // ✅ Relative path

Minor Issues

  1. Unnecessary await (WSClient.ts:469):

    await handler(params)  // The await may not be necessary for sync handlers

    Consider checking if handler is async before awaiting.

  2. Type Usage: Several places use any type that could be more specific:

    • CallStateManager.ts: Multiple any types could be replaced with specific interfaces
    • E2E utilities: Some handler parameters could be better typed

Questionable Design Decisions

  1. E2E Test Aliases: The Vite aliases in e2e tests seem unnecessary since the packages are in the same monorepo. This adds complexity without clear benefit.

  2. CallStateManager Complexity: The CallStateManager utility in e2e tests has significant logic that might warrant its own unit tests (as suggested in review comments).

Security & Performance

  • Security: No security concerns identified. Proper error isolation in event handlers prevents failures from affecting other handlers
  • Performance: Event listener wrapping is efficient and errors are properly contained
  • Memory Management: Proper cleanup on failures with callSession.destroy()

Test Coverage

Excellent - The test suite is comprehensive:

  • Unit tests for both dial() and reattach() methods
  • Error handling scenarios including cleanup failures
  • Event listener functionality and error isolation
  • Integration scenarios with complete flow testing
  • Edge cases like storage unavailability

Addressing Review Comments

Most existing review comments have valid concerns:

  1. Import path issue: Confirmed - should use relative imports
  2. await unnecessarily: Confirmed - conditional await would be better
  3. Type improvements: any types could be more specific
  4. Missing changeset: Required for version tracking

Recommendations

High Priority

  1. Add changeset for version bump tracking
  2. Fix import path to use relative imports
  3. Consider conditional await for sync vs async handlers

Medium Priority

  1. Improve type safety by replacing any with specific types
  2. Consider simplifying e2e test setup by removing unnecessary aliases

Low Priority

  1. Add unit tests for CallStateManager utility if it's intended to be reusable

Overall Assessment

This is a well-implemented feature with excellent test coverage and clean API design. The core functionality is solid, but there are a few technical debt items that should be addressed, particularly the missing changeset and import path issue.

Recommendation: Approve after addressing the critical issues (changeset, import paths).

Copy link

claude bot commented Aug 28, 2025

Claude finished @jpsantosbh's task —— View job


Pull Request Review

Reviewing PR #1289: Add optional listen param to dial() to support starting calls using a single method.

Review Tasks:

  • Read and analyze core implementation files
  • Review WSClient.ts changes and dial() method modifications
  • Examine interface changes and type definitions
  • Analyze test coverage and quality
  • Review e2e utilities and test implementations
  • Check for security and performance concerns
  • Evaluate existing review comments and concerns
  • Provide comprehensive feedback and recommendations

Summary

This PR successfully implements the optional listen parameter for the dial() method, allowing developers to start calls with event listeners attached in a single method call. The implementation follows good patterns and includes comprehensive test coverage.

Code Quality Assessment

✅ Strengths

  1. Clean API Design: The listen parameter integration is well-designed and maintains backward compatibility
  2. Comprehensive Testing: Excellent test coverage with 962 lines of well-structured unit tests covering both success and error scenarios
  3. Error Handling: Robust error handling with proper cleanup on failures
  4. Type Safety: Good TypeScript integration with proper type definitions

⚠️ Areas for Improvement

Critical Issues

  1. Missing Changeset - The changeset-bot correctly identified that this PR needs a changeset since it adds new functionality

  2. Import Path Issue (packages/client/src/unified/interfaces/wsClient.ts:30):

    import { CallSessionEvents } from 'packages/client/src/utils/interfaces'  // ❌ Absolute path

    Should be:

    import { CallSessionEvents } from '../../utils/interfaces/fabric'  // ✅ Relative path

Minor Issues

  1. Unnecessary await (WSClient.ts:469):

    await handler(params)  // The await may not be necessary for sync handlers

    Consider checking if handler is async before awaiting.

  2. Type Usage: Several places use any type that could be more specific:

    • CallStateManager.ts: Multiple any types could be replaced with specific interfaces
    • E2E utilities: Some handler parameters could be better typed

Questionable Design Decisions

  1. E2E Test Aliases: The Vite aliases in e2e tests seem unnecessary since the packages are in the same monorepo. This adds complexity without clear benefit.

  2. CallStateManager Complexity: The CallStateManager utility in e2e tests has significant logic that might warrant its own unit tests (as suggested in review comments).

Security & Performance

  • Security: No security concerns identified. Proper error isolation in event handlers prevents failures from affecting other handlers
  • Performance: Event listener wrapping is efficient and errors are properly contained
  • Memory Management: Proper cleanup on failures with callSession.destroy()

Test Coverage

Excellent - The test suite is comprehensive:

  • Unit tests for both dial() and reattach() methods
  • Error handling scenarios including cleanup failures
  • Event listener functionality and error isolation
  • Integration scenarios with complete flow testing
  • Edge cases like storage unavailability

Addressing Review Comments

Most existing review comments have valid concerns:

  1. Import path issue: Confirmed - should use relative imports
  2. await unnecessarily: Confirmed - conditional await would be better
  3. Type improvements: any types could be more specific
  4. Missing changeset: Required for version tracking

Recommendations

High Priority

  1. Add changeset for version bump tracking
  2. Fix import path to use relative imports
  3. Consider conditional await for sync vs async handlers

Medium Priority

  1. Improve type safety by replacing any with specific types
  2. Consider simplifying e2e test setup by removing unnecessary aliases

Low Priority

  1. Add unit tests for CallStateManager utility if it's intended to be reusable

Overall Assessment

This is a well-implemented feature with excellent test coverage and clean API design. The core functionality is solid, but there are a few technical debt items that should be addressed, particularly the missing changeset and import path issue.

Recommendation: Approve after addressing the critical issues (changeset, import paths).

Copy link

claude bot commented Sep 4, 2025

Claude finished @jpsantosbh's task —— View job


Pull Request Review

Reviewing PR #1289: Add optional listen param to dial() to support starting calls using a single method.

Review Tasks:

  • Read repository guidelines and setup instructions
  • Analyze core implementation changes in WSClient.ts
  • Review new CallStateManager utility and its tests
  • Examine test coverage and quality improvements
  • Check security and performance considerations
  • Evaluate how previous review feedback has been addressed
  • Provide comprehensive feedback and recommendations

Summary

This PR successfully implements the optional listen parameter for the dial() method, allowing developers to start calls with event listeners attached in a single method call. The implementation has been significantly improved since the last review with the addition of comprehensive test coverage and addressing most previous feedback.

Code Quality Assessment

✅ Strengths

  1. Clean API Design: The listen parameter integration is well-designed and maintains backward compatibility
  2. Comprehensive Testing: Excellent test coverage with 962 lines of well-structured unit tests covering both success and error scenarios
  3. Error Handling: Robust error handling with proper cleanup on failures and event listener error isolation
  4. Type Safety: Good TypeScript integration with proper type definitions
  5. New CallStateManager: Well-tested utility with 286 lines of comprehensive unit tests
  6. Changeset Added: Proper changeset has been added for version tracking

⚠️ Issues Identified

Critical Issues

  1. Import Path Issue (packages/client/src/unified/WSClient.ts:30):
    import { CallSessionEvents } from 'packages/client/src/utils/interfaces'  // ❌ Absolute path
    Should be:
    import { CallSessionEvents } from '../../utils/interfaces/fabric'  // ✅ Relative path
    This has been flagged by previous reviewers and remains unaddressed.

Minor Issues

  1. Conditional await (WSClient.ts:469):

    await handler(params)  // May not be necessary for sync handlers

    While the PR author correctly pointed out that user handlers might be async, a conditional check could improve performance for sync handlers.

  2. Type Usage in CallStateManager (CallStateManager.ts):

    • Uses any types throughout which could be more specific
    • While the author mentioned wanting any for flexibility, using union types or generics would be safer
  3. Typo in Changeset: "envent listeners" should be "event listeners"

Security & Performance

  • Security: No security concerns identified. Error isolation in event handlers prevents failures from affecting other handlers
  • Performance: Event listener wrapping is efficient with proper error containment
  • Memory Management: Proper cleanup on failures with callSession.destroy()

Test Coverage Analysis

Excellent - The test suite now includes:

  • ✅ Unit tests for both dial() and reattach() methods (962 lines)
  • ✅ Error handling scenarios including cleanup failures
  • ✅ Event listener functionality and error isolation
  • ✅ CallStateManager utility tests (286 lines covering all edge cases)
  • ✅ Integration scenarios with complete flow testing
  • ✅ Edge cases like storage unavailability

Addressing Previous Review Feedback

Progress Made:

  1. Changeset added: Now includes proper changeset for version tracking
  2. CallStateManager tests added: Comprehensive unit tests addressing reviewer concerns
  3. Test utility improvements: Better structured e2e test utilities

Still Outstanding:

  1. Import path: Critical relative import issue remains unaddressed
  2. Conditional await: Performance optimization suggestion not implemented
  3. Type safety: any types could be more specific in places

Recommendations

High Priority (Should be addressed before merge)

  1. Fix import path in WSClient.ts line 30 to use relative imports
  2. Fix typo in changeset: "envent" → "event"

Medium Priority

  1. Consider conditional await for better performance with sync handlers
  2. Improve type safety in CallStateManager by using more specific types

Low Priority

  1. Code organization: Consider moving attachEventListeners to CallSession class as suggested by reviewer

Overall Assessment

This is a well-implemented feature with substantial improvements since the last review. The addition of comprehensive test coverage (both unit and e2e) significantly strengthens the implementation. The core functionality is solid and the API design is clean.

The main blocker is the import path issue which could cause build problems. Once that's resolved, this PR should be ready for merge.

Recommendation: Address the import path issue and typo, then approve.


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.

3 participants