Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Oct 17, 2025

…sCell

When getting array elements as cells, plain objects (not marked with asCell or asStream) now receive immutable data URIs instead of array index paths. This provides stable references while preventing mutation loops when reassigning array elements.

Changes:

  • Array element objects get data URIs with empty paths
  • Nested documents (marked asCell) continue to use of: URIs as before
  • Only create array index references when element is already a link
  • Update tests to reflect new data URI behavior for plain objects
  • Change createDataCellURI return type from string to URI for consistency

Summary by cubic

Array elements that are plain objects (not marked as asCell/asStream) are now returned as immutable data: URIs with empty paths instead of array index links. This stabilizes references and prevents mutation loops when arrays are reordered or reassigned.

  • New Features

    • Plain object array elements are wrapped in data: URIs (empty path); nested documents keep of: URIs.
    • Array index references are only created when the element is already a link.
    • Updated transform logic and tests to reflect the new behavior.
  • Migration

    • createDataCellURI now returns a URI type (was string); update type annotations and callers.
    • Code relying on array index paths for plain objects should handle data: URIs with empty paths.

…sCell

When getting array elements as cells, plain objects (not marked with asCell
or asStream) now receive immutable data URIs instead of array index paths.
This provides stable references while preventing mutation loops when
reassigning array elements.

Changes:
- Array element objects get data URIs with empty paths
- Nested documents (marked asCell) continue to use of: URIs as before
- Only create array index references when element is already a link
- Update tests to reflect new data URI behavior for plain objects
- Change createDataCellURI return type from string to URI for consistency
@seefeldb seefeldb requested review from Copilot and ubik2 October 17, 2025 23:50
@seefeldb seefeldb changed the title feat(runner): create data URIs for array element objects not marked a… feat(runner): create data URIs for array element objects not marked asCell Oct 17, 2025
Copy link
Contributor

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 updates array element handling in the schema runner to assign immutable data URIs to plain object elements (not marked asCell/asStream), improving link stability and avoiding mutation loops.

  • Switch array element link detection to parse the in-memory element value and create data URIs for plain objects
  • Change createDataCellURI return type to URI for consistency
  • Update tests to expect data URIs for plain object elements and adopt setRaw in setup

Reviewed Changes

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

File Description
packages/runner/src/schema.ts Implements data URI creation for plain object array elements and adjusts link parsing logic.
packages/runner/src/link-utils.ts Changes createDataCellURI return type from string to URI.
packages/runner/test/schema.test.ts Updates tests to reflect data URI behavior and uses setRaw in test setup.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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 3 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.test.ts">

<violation number="1" location="packages/runner/test/schema.test.ts:1454">
setRaw serializes the input and cannot handle RegularCell instances; this call will throw and leave the VDOM fixture unset, so the test no longer exercises the intended linked-data path.</violation>
</file>

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

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.

No issues found across 1 file

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.

No issues found across 2 files

Changed from base64 encoding to URL encoding (encodeURIComponent) for
data URIs to handle UTF-8 characters properly. This matches the pattern
already used in runtime.ts and avoids the btoa() Latin1 limitation.

Changes:
- createDataCellURI() now uses encodeURIComponent instead of base64
- getJSONFromDataURI() already handles both formats (base64 and URL-encoded)
- Update tests to use getJSONFromDataURI() instead of manual atob() decoding
- Add comprehensive test for UTF-8 character support

This fixes integration test failures where recipes containing non-ASCII
characters (emojis, Chinese, Arabic, etc.) would cause data URI creation
to fail with "characters outside of the Latin1 range" error.

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

Co-Authored-By: Claude <noreply@anthropic.com>
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.

No issues found across 3 files

@seefeldb seefeldb merged commit e817c4c into main Oct 20, 2025
9 checks passed
@seefeldb seefeldb deleted the feat/array-element-get-as-data-uri branch October 20, 2025 18:08
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