Skip to content

fix(hooks): the Hot Reload hook works with BSD sed on macOS - #195

Merged
kazo0 merged 1 commit into
mainfrom
fix/hook-bsd-sed
Oct 17, 2026
Merged

kazo0 merged 1 commit into
mainfrom
fix/hook-bsd-sed

Conversation

@kazo0

@kazo0 kazo0 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): n/a (internal, found by the AX evaluation of the plugin)

PR Type

  • Bugfix
  • Build or CI related changes

What is the current behavior?

On macOS, hooks/hot-reload-edit.sh never says anything. It uses two GNU-only sed constructs that BSD sed accepts without an error but handles differently:

  1. Path extraction uses \| alternation in a basic regex (\.\(xaml\|cs\)). BSD sed has no alternation there, so the edited file's path never matches and the hook exits 0 with no output after every .xaml/.cs edit.
  2. json_escape joins lines with :a;N;$!ba. On the last line, BSD sed's N drops the pattern space instead of printing it, so any one-line string comes out empty. The Hot Reload verdict is always one line (head -1), so even with (1) fixed, every status message would read "Hot Reload The running app…" with the verdict missing. (1) hid this bug.

In the AX evaluation (Claude Code on macOS, plugin 471ef25), every hook event in all 10 full-stack runs returned "output": "". CI runs only on ubuntu-latest, where GNU sed handles both constructs, so it never caught either one.

What is the new behavior?

  • Path extraction: sed -En 's/.*"file_path" *: *"([^"]*\.(xaml|cs))".*/\1/p'.
  • json_escape: $!N instead of N, the portable idiom.
  • New .github/scripts/Test-Hooks.ps1 runs the hook against canned hook input and a stand-in DevServer CLI. It covers six cases: no CLI (reminder), XAML file, applied, compile failure (decision: block with the diagnostics), rude edit, and other file types (no output). It also checks that the output is valid JSON.
  • validate-plugin.yml gets a hooks job that runs it on ubuntu-latest and macos-latest.

Verified on macOS (Darwin 27, BSD sed):

Script Test-Hooks.ps1
main (471ef25) 5 errors (no output in any case)
fix (1) only 2 errors (applied, rude edit: empty verdict)
this PR passes

End to end against a running app (Uno.Sdk 7.0.0-dev.81, uno-devserver 7.0.0-dev.2354, desktop):

  • XAML edit → Hot Reload edit to 'Smoke/Presentation/MainPage.xaml': applied (server op #1 Success in 1.7s, … 1 element(s) replaced), and uno_app_find_elements saw the new text.
  • C# syntax error → {"decision":"block", … error CS1525: Invalid expression term ';'}.

In a rerun of the evaluation's repair scenario (5 runs), the hook now returns output after every edit (5/5, was 0/5).

PR Checklist

  • Documentation has been added/updated (no doc change: the README already describes this behavior)
  • Associated with an issue (GitHub or internal)

Additional Information

Not in this PR, for follow-up:

  • The verdict branches need a uno-devserver CLI with the app command. Only 7.0 dev builds have it: 6.7.24 and 6.7.135 (latest stable) answer Unknown command 'app', so the hook falls back to the reminder, with no warning. The plugin doesn't name a minimum version.
  • The Edit|Write|MultiEdit matcher misses files the agent writes with Bash heredocs, which happened in 4 of 5 full-stack runs of the feature scenario.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4tF6WULD6Bus9fnPC6hXx

hot-reload-edit.sh used two GNU-only sed constructs that BSD sed (macOS)
accepts without an error but handles differently:

- `\|` alternation in a basic regex: the edited file's path never matched,
  so the hook exited 0 with no output after every edit. Now `sed -E` with
  `(xaml|cs)`.
- `N` on the last line in json_escape: BSD sed drops the pattern space, so
  a one-line verdict ("edit to '...': applied") came out empty. Now `$!N`.

Found by the AX evaluation of the plugin (round 1, 2026-10-16): in all 10
full-stack runs on macOS every hook event returned empty output.

Test-Hooks.ps1 runs the hook against canned input and a stand-in DevServer
CLI (no CLI, applied, compile failure, rude edit, other file types), and
CI runs it on ubuntu-latest and macos-latest; the old script fails it on
macOS and passes it on Linux.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B4tF6WULD6Bus9fnPC6hXx
@kazo0
kazo0 merged commit b1f290c into main Oct 17, 2026
6 checks passed
@kazo0
kazo0 deleted the fix/hook-bsd-sed branch October 17, 2026 14:12
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