Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Nov 3, 2025

Expands the Opaque type to accept any kind of BrandedCell wrapping T, not just OpaqueRef. This allows more flexible type handling across the codebase by accepting Cell, OpaqueCell, Stream, ComparableCell, ReadonlyCell, and WriteonlyCell as valid Opaque values.

Also refines RenderNode type to explicitly accept BrandedCell rather than the overly permissive Opaque, improving type safety in view rendering.

Updates tests to reflect the new type capabilities, particularly in schema-to-ts.test.ts where nested cell types are now properly handled.

Progress on recipe construction rollout plan:

  • Completed: Opaque accepts T or any CellLike at any nesting level
  • Completed: Accept any T where any sub part of T can be wrapped in one or more BrandedCell (for inputs to node factories)

Summary by cubic

Extends Opaque to accept all BrandedCell variants and narrows RenderNode to BrandedCell for safer view typing. This improves type safety and makes recipe and schema types more flexible.

  • New Features

    • Opaque now accepts AnyCell, BrandedCell, OpaqueCell, Cell, Stream, ComparableCell, ReadonlyCell, and WriteonlyCell wrapping T (including nested cases).
    • Better inference for nested cells in schema-to-ts and node factory inputs; marks two rollout plan items as complete.
  • Refactors

    • RenderNode is now InnerRenderNode | BrandedCell | RenderNode[], removing Opaque.
    • Exported AnyCellWrapping and updated tests and docs accordingly.

Written for commit 25706b4. Summary will update automatically on new commits.

@seefeldb seefeldb requested a review from mathpirate November 3, 2025 20:21
Expands the Opaque<T> type to accept any kind of BrandedCell wrapping T,
not just OpaqueRef<T>. This allows more flexible type handling across the
codebase by accepting Cell<T>, OpaqueCell<T>, Stream<T>, ComparableCell<T>,
ReadonlyCell<T>, and WriteonlyCell<T> as valid Opaque values.

Also refines RenderNode type to explicitly accept BrandedCell<InnerRenderNode>
rather than the overly permissive Opaque<any>, improving type safety in view
rendering.

Updates tests to reflect the new type capabilities, particularly in
schema-to-ts.test.ts where nested cell types are now properly handled.

Progress on recipe construction rollout plan:
- Completed: Opaque<T> accepts T or any CellLike<T> at any nesting level
- Completed: Accept any T where any sub part of T can be wrapped in one or
  more BrandedCell (for inputs to node factories)
@seefeldb seefeldb force-pushed the berni/extend-opaque-to-accept-all-kinds-of-cells branch from cc9cc33 to edc5a3d Compare November 3, 2025 20:24
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/runner/test/schema-to-ts.test.ts">

<violation number="1" location="packages/runner/test/schema-to-ts.test.ts:809">
The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like `name`) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.


// Verify that the recipe function parameter matches our expected input type
expectType<ExpectedInput, InferredInput>();
expectType<InferredInput, ExpectedInput>();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 3, 2025

Choose a reason for hiding this comment

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

The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like name) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.

Prompt for AI agents
Address the following comment on packages/runner/test/schema-to-ts.test.ts at line 809:

<comment>The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like `name`) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.</comment>

<file context>
@@ -801,11 +802,11 @@ describe(&quot;Schema-to-TS Type Conversion&quot;, () =&gt; {
 
     // Verify that the recipe function parameter matches our expected input type
-    expectType&lt;ExpectedInput, InferredInput&gt;();
+    expectType&lt;InferredInput, ExpectedInput&gt;();
 
     // The expected output is the output schema wrapped in a single OpaqueRef.
</file context>
Suggested change
expectType<InferredInput, ExpectedInput>();
expectType<ExpectedInput, InferredInput>();
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is actually the correct order

@seefeldb seefeldb merged commit a5ad113 into main Nov 3, 2025
9 checks passed
@seefeldb seefeldb deleted the berni/extend-opaque-to-accept-all-kinds-of-cells branch November 3, 2025 20:37
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