Skip to content

Conversation

@subtleGradient
Copy link
Member

Summary

  • add effect as a workspace dev dependency so BiDi resolves its optional peer outside the nix shell
  • simplify the BiDi service typing so command results are tracked as unknown without unsafe assertions
  • collapse event handler generics to a single shape for easier registration while keeping spec links intact

Testing

  • pnpm test --run
  • pnpm lint-fix
  • pnpm check
  • pnpm circular
  • pnpm codegen
  • pnpm test-types --target current
  • pnpm docgen
  • pnpm codemod
  • pnpm build
  • node scripts/verify-subpaths.mjs

https://chatgpt.com/codex/tasks/task_e_68d6f9e082f8832f82a4ce3673d79f64

Copilot AI review requested due to automatic review settings September 28, 2025 18:25
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 introduces a new WebDriver BiDi package (@effect-native/bidi) that provides runtime primitives for the WebDriver BiDi protocol within the Effect ecosystem. The implementation relaxes typing constraints to use unknown for command results, adds effect as a workspace dev dependency, and establishes the foundational infrastructure for BiDi command/response correlation and event handling.

Key changes:

  • Creates a complete BiDi package with command routing, event subscription, and transport abstraction
  • Simplifies service typing by using unknown for command results to avoid unsafe type assertions
  • Adds workspace-level effect dev dependency to resolve peer dependency issues outside nix shell

Reviewed Changes

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

Show a summary per file
File Description
packages-native/bidi/src/internal/BiDi.ts Core BiDi implementation with transport abstraction, command correlation, and event dispatching
packages-native/bidi/src/BiDi.ts Public API surface re-exporting internal types and services with WebDriver BiDi spec documentation
packages-native/bidi/test/BiDi.test.ts Test suite validating command/response correlation and error handling scenarios
packages-native/bidi/package.json Package configuration with optional effect peer dependency and workspace dev dependency
package.json Adds workspace-level effect dev dependency for BiDi peer resolution
.specs/bidi/progress.md Implementation roadmap tracking BiDi specification coverage and milestone progress
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines +84 to +91
export type EventHandler = (event: Event) => Effect.Effect<void>

/** @internal */
export interface BiDiService {
readonly send: <Params>(
command: Command<Params>
) => Effect.Effect<unknown, CommandFailed | TransportSendError | TransportClosed>
readonly onEvent: (method: string, handler: EventHandler) => Effect.Effect<void, never, Scope.Scope>
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The EventHandler type lacks error handling capability. Consider allowing handlers to fail with specific error types: (event: Event) => Effect.Effect<void, E> to enable proper error propagation from event processing.

Suggested change
export type EventHandler = (event: Event) => Effect.Effect<void>
/** @internal */
export interface BiDiService {
readonly send: <Params>(
command: Command<Params>
) => Effect.Effect<unknown, CommandFailed | TransportSendError | TransportClosed>
readonly onEvent: (method: string, handler: EventHandler) => Effect.Effect<void, never, Scope.Scope>
export type EventHandler<E = never> = (event: Event) => Effect.Effect<void, E>
/** @internal */
export interface BiDiService {
readonly send: <Params>(
command: Command<Params>
) => Effect.Effect<unknown, CommandFailed | TransportSendError | TransportClosed>
readonly onEvent: <E = never>(method: string, handler: EventHandler<E>) => Effect.Effect<void, E, Scope.Scope>

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +74
if ((failure as { readonly _tag?: string })._tag !== "CommandFailed") {
throw new Error(`unexpected failure: ${JSON.stringify(failure)}`)
}
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

Using type assertion with manual tag checking is fragile. Consider using Effect's pattern matching utilities or a proper type guard function to check the failure type more safely.

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +111
Object.prototype.hasOwnProperty.call(message, "id") &&
Object.prototype.hasOwnProperty.call(message, "result")

const isCommandError = (message: IncomingMessage): message is CommandError =>
Object.prototype.hasOwnProperty.call(message, "id") &&
Object.prototype.hasOwnProperty.call(message, "error")
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

Using Object.prototype.hasOwnProperty.call() is verbose and can be replaced with the more modern Object.hasOwn() method for better readability and performance.

Suggested change
Object.prototype.hasOwnProperty.call(message, "id") &&
Object.prototype.hasOwnProperty.call(message, "result")
const isCommandError = (message: IncomingMessage): message is CommandError =>
Object.prototype.hasOwnProperty.call(message, "id") &&
Object.prototype.hasOwnProperty.call(message, "error")
Object.hasOwn(message, "id") &&
Object.hasOwn(message, "result")
const isCommandError = (message: IncomingMessage): message is CommandError =>
Object.hasOwn(message, "id") &&
Object.hasOwn(message, "error")

Copilot uses AI. Check for mistakes.
@subtleGradient subtleGradient changed the base branch from effect-native/main to codex/create-@effect-native/bidi-package-with-tdd September 28, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant