fix: SeamEvent union type by removing generic event resource - #964
Merged
Conversation
Generate the SeamEvent union from the blueprint's top-level events collection only, excluding the generic event resource whose all-optional properties (including event_type) prevented TypeScript from narrowing the union on event_type and made event_id optional everywhere. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1miDUhtRigVPj3ZmPPU8y
razor-x
marked this pull request as ready for review
August 14, 2026 21:29
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1miDUhtRigVPj3ZmPPU8y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the
SeamEventdiscriminated union type by removing the generic event resource definition and updating the resource layout generation to exclude discriminated union resource types from the generic resources collection.Key Changes
SeamEventthat contained all-optional properties (created_at,event_description,event_id,event_type,occurred_at,workspace_id). This generic type was preventing proper type narrowing on the discriminant.getResourceLayoutContexts()incodegen/lib/layouts/resources.tsto filter out discriminated union resource types (events and action attempts) from the generic resources collection before building the union.Implementation Details
The fix ensures that
SeamEventis a proper discriminated union where each member has a specificevent_typevalue, allowing TypeScript to narrow the type correctly. By excluding the generic event resource from the resources collection during codegen, the union only includes the specific event type variants defined in the blueprint's events collection, preventing the all-optional generic type from interfering with type narrowing.https://claude.ai/code/session_01L1miDUhtRigVPj3ZmPPU8y