Skip to content

id(roc): finish the example migration — tic-tac-toe -> RocJson, roc-counter -> Screen, adopt RocText (#565) - #2970

Merged
dezren39 merged 3 commits into
mainfrom
queue/2637-565-roc-example-migration
Oct 31, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/2637-565-roc-example-migration

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Finishes the example migration pinned by triage task 2164 for #565 (queue task 2637).

Changes

  • tic-tac-toe (pkgs/id/examples/tic-tac-toe/main.roc): records is built with pf.RocJson (RocJson.Object + the encode_or_crash idiom copied from roc-chat/lounge) instead of a hand-built JSON string. Output is byte-identical: {"board":"...","plays":N,"winner":"..."}.
  • roc-counter (pkgs/id/examples/roc-counter/main.roc): view/layout render through pf.Screen (boxed 20x3 "counter" screen, wider box on wide viewports — the roc-screen pattern), and update matches its event after pf.RocText.trim, so roc-counter is also the first example importing RocText.
  • Checked-in artifacts rebuilt with each example's build.sh: tic-tac-toe.wasm (69,319 B) and counter.wasm (59,951 B), both validated and under the 400 KB cap.
  • Fixture test updates (the counter wasm/source is a suite-wide fixture and its view is now a Screen frame): exact count=N view assertions in src/sandbox.rs, src/world_session/tests.rs, and src/world_compile.rs now assert the Screen frame contains count=N; the source-compile test grants the counter's new platform imports (Screen, RocText). No assertion intent changed — each still proves the count after the same inputs.

Verification (laptop, this branch)

  • roc check on both examples: no errors.
  • Both build.sh runs: built + wasm-tools validate passed.
  • cargo test --lib -- counter tic_tac_toe: 10 passed, 0 failed (includes the full tic-tac-toe game test, counter records/snapshot/restore tests, and both counter source-compile tests).

Note on #541

The pinned-compiler rebuild criterion completes with #541 (still open), per the task packet: these artifacts were rebuilt with the laptop's current roc via the existing sibling build.sh pattern, and the PR flags that dependency rather than blocking on it.

🤖 Agent note · pr opened


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 06:32
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 44b1678e-9ab2-4c79-b640-d070ee130755
Commits

Reviewing files that changed from the base of the PR and between ed59bc6 and bfd5804.

Files ignored due to path filters: 2
  • pkgs/id/examples/roc-counter/counter.wasm is excluded by !**/*.wasm
  • pkgs/id/examples/tic-tac-toe/tic-tac-toe.wasm is excluded by !**/*.wasm
Files selected for processing: 7
  • pkgs/id/examples/roc-counter/main.roc
  • pkgs/id/examples/tic-tac-toe/main.roc
  • pkgs/id/src/sandbox.rs
  • pkgs/id/src/world_compile.rs
  • pkgs/id/src/world_net.rs
  • pkgs/id/src/world_session/tests.rs
  • pkgs/id/src/world_store.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T08:16:25.955328Z bfd5804 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 720eb57701

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/examples/roc-counter/main.roc Resolved
Comment thread pkgs/id/examples/roc-counter/main.roc Resolved
@dezren39
dezren39 merged commit c1b9052 into main Oct 31, 2026
1 check passed
@dezren39
dezren39 deleted the queue/2637-565-roc-example-migration branch October 31, 2026 08:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfd580419b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3 to +4
import pf.Screen
import pf.RocText

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Grant the new imports in source-compilation integration tests

When Roc and the platform assets are available, test_worlds_compile_roc_sources_on_the_fly and test_worlds_compile_native_workers_on_the_fly in tests/cli_integration.rs now fail before compilation. Both load this source but start fresh servers without capability grants; WorldCore::new initializes an empty grant set, and WorldService::compile_and_install passes its effective grants to check_imports, which rejects Screen. Grant Screen and RocText in these fixtures before compiling; updating the direct compilation unit tests does not cover these service-level consumers.

Useful? React with 👍 / 👎.

Comment on lines +33 to +34
base = Screen.boxed(Screen.new(w, h), 0, 0, w, h, "counter")
Screen.render_json(Screen.put_text(base, 2, 1, "count=${model.count.to_str()}", { fg: 0, bg: 0, bold: Bool.False }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Rebaseline the counter's rendering fuel budgets

The sandbox-enabled suite still enforces 100,000-fuel budgets for both counter View and Layout in src/sandbox.rs::FUEL_BUDGETS, despite replacing the inexpensive text output with Screen construction and JSON rendering. The equivalent existing roc-screen renderer has recorded baselines of 123,675 fuel for its 20×3 view and 378,384 for its wide layout, already above those counter limits. Consequently checked_in_examples_stay_within_fuel_budgets retains obsolete thresholds for the rebuilt artifact. Measure the new counter and deliberately update its rendering budgets alongside this change.

Useful? React with 👍 / 👎.

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.

1 participant