Share embedded Ghostty runtime state - #141
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR changes
Confidence Score: 4/5The change is small and mechanically straightforward — one comptime selection between two well-understood modules — and the only runtime field access ( The comptime branch logic is correct, the field access is compatible across both possible state types, and the test correctly documents the invariant. The only concern is the missing Files Needing Attention: src/renderer/scene/CApi.zig — specifically the test guard condition at the new test block. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["build_config.scene_renderer_only (comptime bool)"]
A -->|true| B["@import scene_runtime.zig\n→ scene_runtime.State\n{alloc, resources_dir}"]
A -->|false| C["@import global.zig\n→ GlobalState\n{gpa, alloc, action, logging, …}"]
B --> D["const state = &runtime.state"]
C --> D
D --> E["newImpl() → state.alloc\n(only field accessed)"]
Reviews (1): Last reviewed commit: "fix(renderer): share embedded Ghostty ru..." | Re-trigger Greptile |
| if (!build_config.scene_renderer_only) { | ||
| const global_state = &@import("../../global.zig").state; |
There was a problem hiding this comment.
The
if guard here lacks the comptime keyword. In Zig, a function-scope if without comptime still causes both branches to be analyzed for type correctness, even when the condition is a comptime-known constant. When building in scene_renderer_only = true mode, the dead branch's @import("../../global.zig") may be analyzed, potentially pulling in global.zig's transitive dependencies (xev, fontconfig, glslang, etc.) that are not available in that build configuration. Adding comptime prevents any analysis of the dead branch and makes the conditional-compilation intent explicit.
| if (!build_config.scene_renderer_only) { | |
| const global_state = &@import("../../global.zig").state; | |
| if (comptime !build_config.scene_renderer_only) { | |
| const global_state = &@import("../../global.zig").state; |
Summary
Verification
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Shares the embedded Ghostty runtime state with the renderer so both iOS scene rendering and macOS scene capture run on the same initialized runtime.
build_config.scene_renderer_only: useglobal.zigfor embedded,scene_runtime.zigfor renderer-only builds.statepointer.Written for commit 647849e. Summary will update on new commits.