Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ jobs:
- name: Swift Test
run: swift test --no-parallel

- name: Compile for x86_64
run: |
set -euo pipefail
# KeyboardShortcuts 2.x added #Preview blocks in Recorder.swift that use
# PreviewsMacros — a plugin unavailable in command-line swift build.
# Strip them before building (same patch applied in package_app.sh).
recorder=".build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Recorder.swift"
if [[ -f "$recorder" ]] && grep -q '#Preview' "$recorder"; then
chmod +w "$recorder"
perl -0777 -i -pe 's/\n#Preview \{[^}]*\}//g' "$recorder"
fi
swift build -c release --arch x86_64 --product CodexBar
swift build -c release --arch x86_64 --product CodexBarCLI
swift build -c release --arch x86_64 --product CodexBarClaudeWatchdog

- name: Build + package universal binary (ad-hoc signed)
run: |
set -euo pipefail
ARCHES="arm64 x86_64" CODEXBAR_SIGNING=adhoc ./Scripts/package_app.sh release
lipo -archs CodexBar.app/Contents/MacOS/CodexBar

build-linux-cli:
strategy:
fail-fast: false
Expand Down
26 changes: 26 additions & 0 deletions Scripts/package_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ if [[ ${#ARCH_LIST[@]} -eq 0 ]]; then
esac
fi

patch_keyboard_shortcuts_recorder() {
local recorder_path="$ROOT/.build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Recorder.swift"
if [[ ! -f "$recorder_path" ]]; then
return 0
fi
if ! grep -q '#Preview' "$recorder_path"; then
return 0
fi

chmod +w "$recorder_path" || true
python3 - "$recorder_path" <<'PY'
import sys, re
from pathlib import Path

path = Path(sys.argv[1])
text = path.read_text()

# Remove #Preview { ... } blocks — they use PreviewsMacros which is unavailable
# when cross-compiling and are not needed for release builds.
patched = re.sub(r'\n#Preview \{[^}]*\}', '', text, flags=re.DOTALL)
if patched != text:
path.write_text(patched)
PY
}

patch_keyboard_shortcuts() {
local util_path="$ROOT/.build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Utilities.swift"
if [[ ! -f "$util_path" ]]; then
Expand Down Expand Up @@ -103,6 +128,7 @@ if [[ ! -f "$KEYBOARD_SHORTCUTS_UTIL" ]]; then
swift build -c "$CONF" --arch "${ARCH_LIST[0]}"
fi
patch_keyboard_shortcuts
patch_keyboard_shortcuts_recorder

for ARCH in "${ARCH_LIST[@]}"; do
swift build -c "$CONF" --arch "$ARCH"
Expand Down
9 changes: 8 additions & 1 deletion Sources/CodexBar/MenuHighlightStyle.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import SwiftUI

private struct MenuItemHighlightedKey: EnvironmentKey {
static let defaultValue: Bool = false
}

extension EnvironmentValues {
@Entry var menuItemHighlighted: Bool = false
var menuItemHighlighted: Bool {
get { self[MenuItemHighlightedKey.self] }
set { self[MenuItemHighlightedKey.self] = newValue }
}
}

enum MenuHighlightStyle {
Expand Down