Fix Ghostty shell integration and surface background ordering#31
Fix Ghostty shell integration and surface background ordering#31
Conversation
Source ghostty-integration from the zshrc shim so shell-integration features (title, CWD, marks) work inside Shellraiser-managed surfaces. Move surface background styling after Ghostty surface registration to ensure correct render ordering. Update tests accordingly.
📝 WalkthroughWalkthroughThe PR adds Ghostty resource sync steps to builds, updates zsh RC shims to conditionally source Ghostty integration, removes shell-wrapper wrapping from Ghostty launch commands, and adjusts Metal layer/background styling initialization in the Ghostty surface view. Tests updated/added accordingly. Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Sources/Shellraiser/Infrastructure/Ghostty/LibghosttySurfaceView.swift (1)
453-454:⚠️ Potential issue | 🟡 MinorKeep background-style ordering consistent with initializer path.
Line 453 applies style before resizing, but Lines 68-69 do the reverse. This inconsistency can cause background styling to be overwritten during updates.
💡 Proposed fix
- applyGhosttyBackgroundStyle() - updateScaleAndSize() + updateScaleAndSize() + applyGhosttyBackgroundStyle()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Sources/Shellraiser/Infrastructure/Ghostty/LibghosttySurfaceView.swift` around lines 453 - 454, The background style is applied before resizing in the update path (applyGhosttyBackgroundStyle() then updateScaleAndSize()), which is inconsistent with the initializer where updateScaleAndSize() runs before applyGhosttyBackgroundStyle(); swap the calls in the update path so updateScaleAndSize() is invoked prior to applyGhosttyBackgroundStyle() (reference functions updateScaleAndSize and applyGhosttyBackgroundStyle) to keep ordering consistent and avoid the style being overwritten by size/scale adjustments.
🧹 Nitpick comments (1)
Makefile (1)
19-21: Add a pre-copy resource existence check with an actionable error.If
ghostty/zig-out/share/*is missing,cpfails with a generic error. A small guard makes failures clearer for contributors.💡 Proposed fix
build-app: xcodebuild $(BUILD_FLAGS) -derivedDataPath $(DERIVED_DATA) build + test -d ghostty/zig-out/share/ghostty -a -d ghostty/zig-out/share/terminfo || (echo "Missing Ghostty resources. Build/update ghostty submodule first."; exit 1) rm -rf $(APP_PATH)/Contents/Resources/ghostty $(APP_PATH)/Contents/Resources/terminfo cp -R ghostty/zig-out/share/ghostty $(APP_PATH)/Contents/Resources/ghostty cp -R ghostty/zig-out/share/terminfo $(APP_PATH)/Contents/Resources/terminfo build-isolated: xcodebuild $(ISOLATED_BUILD_FLAGS) -derivedDataPath $(ISOLATED_DERIVED_DATA) build + test -d ghostty/zig-out/share/ghostty -a -d ghostty/zig-out/share/terminfo || (echo "Missing Ghostty resources. Build/update ghostty submodule first."; exit 1) rm -rf $(ISOLATED_APP_PATH)/Contents/Resources/ghostty $(ISOLATED_APP_PATH)/Contents/Resources/terminfo cp -R ghostty/zig-out/share/ghostty $(ISOLATED_APP_PATH)/Contents/Resources/ghostty cp -R ghostty/zig-out/share/terminfo $(ISOLATED_APP_PATH)/Contents/Resources/terminfoAlso applies to: 25-27
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Makefile` around lines 19 - 21, Add an existence check before copying the built resources: in the Makefile rule that runs the cp commands for ghostty/zig-out/share/ghostty and ghostty/zig-out/share/terminfo, test that each source directory exists (e.g., with a shell test like [ -d ... ]) and if missing print a clear actionable error (mentioning which source is missing and suggesting to run the build for ghostty) and exit non‑zero; apply the same pre-copy guard to the other cp invocations referenced in the same Makefile section so failures are explicit and actionable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Sources/Shellraiser/Infrastructure/Agents/AgentRuntimeBridge.swift`:
- Around line 569-571: Guard the ghostty sourcing by checking the target file is
present and readable before calling source: instead of only testing [[ -n
"$GHOSTTY_RESOURCES_DIR" ]], add a read-check for
"$GHOSTTY_RESOURCES_DIR/shell-integration/zsh/ghostty-integration" (e.g., test
-r or [[ -r ... ]]) and only run source when that check passes; update the
snippet that references GHOSTTY_RESOURCES_DIR and the path
"shell-integration/zsh/ghostty-integration" accordingly so startup won’t fail if
the integration file is missing or unreadable.
---
Outside diff comments:
In `@Sources/Shellraiser/Infrastructure/Ghostty/LibghosttySurfaceView.swift`:
- Around line 453-454: The background style is applied before resizing in the
update path (applyGhosttyBackgroundStyle() then updateScaleAndSize()), which is
inconsistent with the initializer where updateScaleAndSize() runs before
applyGhosttyBackgroundStyle(); swap the calls in the update path so
updateScaleAndSize() is invoked prior to applyGhosttyBackgroundStyle()
(reference functions updateScaleAndSize and applyGhosttyBackgroundStyle) to keep
ordering consistent and avoid the style being overwritten by size/scale
adjustments.
---
Nitpick comments:
In `@Makefile`:
- Around line 19-21: Add an existence check before copying the built resources:
in the Makefile rule that runs the cp commands for ghostty/zig-out/share/ghostty
and ghostty/zig-out/share/terminfo, test that each source directory exists
(e.g., with a shell test like [ -d ... ]) and if missing print a clear
actionable error (mentioning which source is missing and suggesting to run the
build for ghostty) and exit non‑zero; apply the same pre-copy guard to the other
cp invocations referenced in the same Makefile section so failures are explicit
and actionable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d7d14f61-21e3-42b8-aecd-c5cdff053d07
📒 Files selected for processing (6)
MakefileSources/Shellraiser/Infrastructure/Agents/AgentRuntimeBridge.swiftSources/Shellraiser/Infrastructure/Ghostty/GhosttyRuntime.swiftSources/Shellraiser/Infrastructure/Ghostty/LibghosttySurfaceView.swiftTests/ShellraiserTests/AgentRuntimeBridgeTests.swiftTests/ShellraiserTests/GhosttyRuntimeCommandTests.swift
Sources/Shellraiser/Infrastructure/Agents/AgentRuntimeBridge.swift
Outdated
Show resolved
Hide resolved
- Guard ghostty integration source with -r readability check on the file - Fix background style ordering in registerSurfaceCallbacks to match initializer order - Add existence checks in Makefile before copying ghostty/terminfo resources
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Makefile (1)
25-31: Consider extracting the resource sync logic into a reusable target.The ghostty/terminfo resource copy block is duplicated between
build-appandbuild-isolated. This increases maintenance burden if paths or logic change.♻️ Optional refactor to reduce duplication
+define sync_ghostty_resources + `@test` -d ghostty/zig-out/share/ghostty || (echo "Error: ghostty/zig-out/share/ghostty not found. Run 'zig build' in the ghostty directory first." && exit 1) + `@test` -d ghostty/zig-out/share/terminfo || (echo "Error: ghostty/zig-out/share/terminfo not found. Run 'zig build' in the ghostty directory first." && exit 1) + rm -rf $(1)/Contents/Resources/ghostty $(1)/Contents/Resources/terminfo + cp -R ghostty/zig-out/share/ghostty $(1)/Contents/Resources/ghostty + cp -R ghostty/zig-out/share/terminfo $(1)/Contents/Resources/terminfo +endef + build-app: xcodebuild $(BUILD_FLAGS) -derivedDataPath $(DERIVED_DATA) build - `@test` -d ghostty/zig-out/share/ghostty || ... - ... + $(call sync_ghostty_resources,$(APP_PATH)) build-isolated: xcodebuild $(ISOLATED_BUILD_FLAGS) -derivedDataPath $(ISOLATED_DERIVED_DATA) build - `@test` -d ghostty/zig-out/share/ghostty || ... - ... + $(call sync_ghostty_resources,$(ISOLATED_APP_PATH))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Makefile` around lines 25 - 31, The Makefile duplicates the resource-copy logic between the build-isolated and build-app targets; extract that into a reusable target (e.g., a new target named sync-ghostty-resources) and have both build-isolated and build-app depend on or invoke it. Move the `@test` existence checks for ghostty/zig-out/share/ghostty and ghostty/zig-out/share/terminfo, the rm -rf of $(ISOLATED_APP_PATH)/Contents/Resources/{ghostty,terminfo}, and the cp -R commands into that new target, and reference variables like ISOLATED_APP_PATH so path logic for ghostty/zig-out/share/ghostty and ghostty/zig-out/share/terminfo is centralized and not duplicated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@Makefile`:
- Around line 25-31: The Makefile duplicates the resource-copy logic between the
build-isolated and build-app targets; extract that into a reusable target (e.g.,
a new target named sync-ghostty-resources) and have both build-isolated and
build-app depend on or invoke it. Move the `@test` existence checks for
ghostty/zig-out/share/ghostty and ghostty/zig-out/share/terminfo, the rm -rf of
$(ISOLATED_APP_PATH)/Contents/Resources/{ghostty,terminfo}, and the cp -R
commands into that new target, and reference variables like ISOLATED_APP_PATH so
path logic for ghostty/zig-out/share/ghostty and ghostty/zig-out/share/terminfo
is centralized and not duplicated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f5e51a4e-9d96-44c3-bc65-851add641a0e
📒 Files selected for processing (3)
MakefileSources/Shellraiser/Infrastructure/Agents/AgentRuntimeBridge.swiftSources/Shellraiser/Infrastructure/Ghostty/LibghosttySurfaceView.swift
Source ghostty-integration from the zshrc shim so shell-integration features (title, CWD, marks) work inside Shellraiser-managed surfaces. Move surface background styling after Ghostty surface registration to ensure correct render ordering. Update tests accordingly.
Summary by CodeRabbit
New Features
Bug Fixes
Tests