Skip to content

chore(#454): re-verify callback-external guard + fix stale null-bundled comment - #455

Merged
apotema merged 1 commit into
mainfrom
chore/454-extraction-cleanup
Jul 1, 2026
Merged

apotema merged 1 commit into
mainfrom
chore/454-extraction-cleanup

Conversation

@apotema

@apotema apotema commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Two low-risk cleanups from #454 (extraction tech-debt, follow-up to the completed epic #386).

1. Callback-external guard — investigated, kept (correct as-is) + regression test

src/codegen/lifecycle/render.zig ExternalCallbackBackendUnsupported is not dead code. It was already narrowed in #416: the guard fires only when use_callback_lifecycle and isExternal() and !callback_dispatch_handled, where callback_dispatch_handled = is_bgfx_android or cfg.backend == .sokol. External sokol-desktop (today's production state) keeps cfg.backend == .sokol via the enum-as-shorthand, so it's handled and the guard does NOT fire.

The guard still protects two genuinely-unsupported live paths: (1) a 3rd-party external callback backend sitting at the .raylib enum default, and (2) any external non-sokol backend on wasm. Added a regression test asserting external sokol-desktop generates the sokol callback main rather than erroring — fails loudly if anyone drops cfg.backend == .sokol from callback_dispatch_handled.

2. Stale comment (src/cache_cmd.zig)

"no-op when null is still bundled" was wrong post-extraction (null → labelle-null, no builtinProvider arm returns null). Rewrote to state the real no-op is the isPluginCached guard. Comment-only; logic unchanged.

zig build test + zig build both exit 0.

Ref #454, #386.

https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling for external desktop backends using a callback run loop, so valid setups are no longer incorrectly rejected.
    • Refined cache-related behavior to better match the current backend flow and avoid unnecessary fetches when the plugin is already cached.
  • Tests

    • Added a regression test covering an external sokol desktop backend with callback-based execution.

…x stale null comment

Follow-up to epic #386 (all 6 backends extracted to external packages).

Task 1 — callback-external guard (render.zig ~L181): re-checked, KEPT as-is.
The guard was already correctly narrowed in #416: `callback_dispatch_handled`
includes `cfg.backend == .sokol`, so external sokol-desktop (which resolves via
builtinProvider + declares loop_style = .callback) is NOT rejected — the enum-
as-shorthand preserves the `.sokol` tag and the callback dispatch has a real
branch. The guard still protects two genuinely-unsupported live paths: (a) a
third-party external callback backend whose `cfg.backend` sits at the `.raylib`
default (would fall through to the raylib-wasm fallback), and (b) any external
non-sokol backend on wasm (platform forces callback lifecycle, no dispatch
branch). Added a regression-lock test asserting external sokol-desktop generates
the sokol callback main instead of erroring.

Task 2 — stale comment (cache_cmd.zig ~L545): fixed. `null` is no longer bundled
(extracted to labelle-null); `builtinProvider(.null)` always returns a package
and no arm returns null, so `effectiveBackendPackage()` for the tests-target null
config always resolves. The real no-op is the `isPluginCached` guard (project
already IS null → fetched above), not a null effective package.

Claude-Session: https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1752e26f-623c-40d7-a4f3-65b5edb44bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 2eb7fbd and 5687433.

📒 Files selected for processing (2)
  • src/cache_cmd.zig
  • test/main_zig_tests.zig

📝 Walkthrough

Walkthrough

This PR clarifies a comment in ensureCache regarding .null backend handling in src/cache_cmd.zig, explaining that caching idempotency now relies on isPluginCached rather than a null-return check. It also adds a regression test verifying an external sokol desktop backend with callback run-loop is not rejected by the external-callback guard.

Changes

Null-backend caching comment and callback guard test

Layer / File(s) Summary
Cache guard comment update
src/cache_cmd.zig
Replaces the outdated comment describing null-return no-op behavior with an explanation that effectiveBackendPackage() resolves the external backend and idempotency comes from the isPluginCached guard.
External sokol callback regression test
test/main_zig_tests.zig
Adds a test generating main.zig for an external sokol desktop backend and asserts the callback export frame is present, confirming the external-callback guard does not falsely reject this case.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

Possibly related PRs

Poem

A comment tidied, a test set free,
Sokol callbacks now run happily.
No guard shall block the frame() call,
This little rabbit approves it all. 🐰
Hop along, cache clean and bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects both the callback-guard regression recheck and the stale cache comment fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/454-extraction-cleanup

Comment @coderabbitai help to get the list of available commands.

@apotema
apotema merged commit 0990d09 into main Jul 1, 2026
4 checks passed
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