Skip to content

fix(macos): wire system notification Show click to focus target pane - #29

Merged
arrrrny merged 1 commit into
masterfrom
446-gi-27-macos-system-notification-show-4717
Aug 24, 2026
Merged

arrrrny merged 1 commit into
masterfrom
446-gi-27-macos-system-notification-show-4717

Conversation

@arrrrny

@arrrrny arrrrny commented Aug 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #27

Problem

On macOS with ui.toast.delivery = "system", clicking the system notification's "Show" action does nothing. terminal-notifier is invoked with only -title, -message, and -activate <bundle_id> — the -activate flag focuses the hosting terminal app on click, but Herdr never receives the click and has no way to know which workspace/pane to switch to. The ToastTarget built by agent_notification_delivery is discarded on the System path.

The in-app "Herdr" toast already supports click-to-focus via clickable_toast_at + focus_toast_target in src/app/input/mouse.rs, which ultimately calls focus_pane_in_workspace. The system-notification path had no equivalent click-back channel.

Fix

Plumb the public pane id through the System notification path and wire terminal-notifier's -execute flag to launch the herdr binary on click. The launched binary detects the click-handler mode (no args + no TTY on stdin + fresh marker file), reads the marker, and sends a pane.focus API request to the running TUI. The running TUI's existing handle_pane_focus then calls focus_pane_in_workspace — the same primitive the in-app toast uses.

Changes

  • src/platform/macos.rs: extend show_desktop_notification with click_target: Option<&str>. When Some, write a marker file at <config_dir>/notification_click_target.json containing the public pane id + a timestamp, and add -execute file://<current_exe> to the terminal-notifier command. Adds helpers notification_click_target_path, write_notification_click_target, format_notification_click_target_json, file_url_for_path, percent_encode_path_segment.
  • src/platform/{linux,windows,fallback}.rs: update signature to match (click_target ignored on non-macOS — no click-back channel is wired there).
  • src/app/api.rs: in emit_terminal_or_system_agent_notifications and emit_delayed_client_local_agent_notifications, compute the public pane id via self.public_pane_id(ws_idx, pane_id) and pass it as the click_target for System delivery. Terminal delivery keeps the OSC path with no click target. Update-available and notification.show API paths pass None (no pane context).
  • src/client/mod.rs: update handle_notify_with_notifiers signature so the system notifier closure takes an Option<&str> click_target. Client-side notifications pass None (no pane target). Updated 3 existing tests to use 3-arg closures for the system notifier position.
  • src/cli.rs: add mod notification_click; and call notification_click::handle_if_click_launch() at the start of maybe_run before normal CLI dispatch.
  • src/cli/notification_click.rs (new): hidden click-handler entry point. Heuristic: args.len() == 1 && !stdin.is_terminal() && fresh marker file (within 5 min). On a positive match, reads the marker, deletes it (one-shot), parses the pane id, and sends Method::PaneFocus(PaneTarget { pane_id }) via the existing cli::send_request path.

Drive-by

cargo fmt was run to keep CI lint green. The pre-existing formatting drift in src/api/wait.rs, src/pty/actor/unix.rs, and src/session.rs (introduced by rustfmt 1.96.1's stricter line-wrapping rules) is included as drive-by fixes.

Test plan

  • cargo check ✓ (no errors; only pre-existing unused import: super::* warning in src/cli/agent.rs:953).
  • cargo check --tests ✓ (test code type-checks cleanly).
  • cargo fmt --check ✓.
  • New unit tests for: marker-file JSON shape (stable + escaped), marker-file path resolution, -execute URL emission with a real file:// URL pointing at the running binary, no -execute when click_target is None, file URL percent encoding (ASCII + UTF-8), click-launch heuristic path resolution, click-handler marker JSON parsing (canonical + missing pane_id + invalid JSON).
  • The local Daytona sandbox uses a fake-zig stub at /tmp/fake-zig/zig that no-ops the zig build step, so the vendored libghostty-vt.a static library is never produced and the binary link step fails with rust-lld: error: unable to find library -lghostty-vt. This is an environmental limitation of the sandbox, not a regression introduced by this PR. CI installs real Zig 0.15.2 per .github/workflows/ci.yml and runs the full cargo nextest suite.

Summary by CodeRabbit

  • New Features

    • macOS desktop notifications can now include an actionable link that focuses the originating pane when clicked.
    • Notification launches are handled automatically, including background launches without additional command-line arguments.
    • Pane targeting is supported for relevant agent-state and delayed client notifications.
  • Bug Fixes

    • Improved notification behavior so untargeted messages do not trigger pane focus.
    • Preserved consistent notification behavior across Linux, Windows, and unsupported platforms.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8158e5ef-8a1d-4dd2-af77-f1346ee0a8a8

📥 Commits

Reviewing files that changed from the base of the PR and between 0efb47f and 988f7f1.

📒 Files selected for processing (11)
  • src/api/wait.rs
  • src/app/api.rs
  • src/cli.rs
  • src/cli/notification_click.rs
  • src/client/mod.rs
  • src/platform/fallback.rs
  • src/platform/linux.rs
  • src/platform/macos.rs
  • src/platform/windows.rs
  • src/pty/actor/unix.rs
  • src/session.rs

📝 Walkthrough

Walkthrough

System notifications now carry optional pane targets. macOS writes target markers and launches a click handler. The handler sends pane-focus requests through the existing CLI path. Other platforms accept and ignore the target.

Changes

Notification click-to-focus

Layer / File(s) Summary
Notification target routing
src/app/api.rs, src/client/mod.rs
Notification delivery explicitly selects terminal or system backends. System notifications receive the originating public pane ID. Untargeted notifications pass None.
Platform notification target support
src/platform/macos.rs, src/platform/linux.rs, src/platform/windows.rs, src/platform/fallback.rs
Desktop notification APIs accept optional click targets. macOS writes JSON marker files and adds terminal-notifier launch arguments. Other platforms ignore the target. Tests cover marker data, paths, command construction, and URL encoding.
Notification click launch handling
src/cli.rs, src/cli/notification_click.rs
CLI dispatch detects fresh marker-based launches, sends PaneFocus requests, removes markers, and returns handled exit codes.
Unchanged formatting cleanup
src/api/wait.rs, src/platform/linux.rs, src/platform/macos.rs, src/pty/actor/unix.rs, src/session.rs
Test helpers and expressions are reformatted without behavior changes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: ogulcancelik

Sequence Diagram(s)

sequenceDiagram
  participant AppApi
  participant MacOSNotifications
  participant TerminalNotifier
  participant HerdrCLI
  participant RunningTUI
  AppApi->>MacOSNotifications: send notification with public pane ID
  MacOSNotifications->>MacOSNotifications: write marker file
  MacOSNotifications->>TerminalNotifier: launch current executable on click
  TerminalNotifier->>HerdrCLI: start without CLI arguments
  HerdrCLI->>HerdrCLI: read and remove marker
  HerdrCLI->>RunningTUI: send PaneFocus request
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

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

@arrrrny
arrrrny merged commit c731fef into master Aug 24, 2026
3 of 6 checks passed
@arrrrny
arrrrny deleted the 446-gi-27-macos-system-notification-show-4717 branch August 24, 2026 14:27
arrrrny added a commit that referenced this pull request Sep 9, 2026
* docs: publish preview documentation

* fix: consume failed selection copies without interrupting agents (herdrdev#3681)

* fix: keep manual selections active during terminal output (herdrdev#3684)

* fix: resolve queued submissions when pty actor exits

refs herdrdev#3685

* feat: add conditional styles for sidebar tokens (herdrdev#3693)

* fix: match claude bash permission prompts at every cursor position (herdrdev#3615)

Claude marks the selected option with "❯", but bash_permission_prompt did not allow that prefix on numbered branches and did not cover the three-option "don't ask again" layout. Match both two- and three-option Bash approval prompts regardless of the selected option.

refs herdrdev#2650

* feat: make ui.pane_borders a three-state auto/always/off mode (herdrdev#3234)

* feat: make ui.pane_borders a three-state auto/always/off mode

Legacy booleans keep parsing (true = auto, false = off); "always" frames
a lone pane while pane_outer_borders is enabled.

* fix: align pane border reload test and documentation

---------

Co-authored-by: Rudolf Schmidt <[email protected]>
Co-authored-by: Jonathan Liebig <[email protected]>

* fix: preserve sessions after interrupted pane exits (herdrdev#3418)

* fix: preserve sessions when pane shells are signaled

refs herdrdev#3415

* fix: preserve shutdown checkpoints across platforms

refs herdrdev#3415

---------

Co-authored-by: Jonathan Liebig <[email protected]>

* fix: require explicit consent for remote server replacement

* docs: prepare 0.9.0 release documentation

* release: v0.9.0

* docs: publish release distribution for v0.9.0

* fix: reduce idle ssh cpu without dropping final output (herdrdev#3728)

* fix: stop polling idle ssh uploads on unix

* fix: preserve ssh output during idle bridge cancellation

* test: exercise active ssh upload cancellation

* docs: publish preview documentation

* fix: show ssh errors during machine setup (herdrdev#3733)

refs herdrdev#3731

Co-authored-by: akbash-bot <[email protected]>

* chore: move marketplace worker to website repository

* fix: collapse worktree groups with saved machines (herdrdev#3781)

* fix: collapse worktree groups with saved machines

refs herdrdev#3778

* fix: scope worktree collapse by machine

refs herdrdev#3778

* fix: collapse machines without switching focus

refs herdrdev#3778

---------

Co-authored-by: akbash-bot <[email protected]>
Co-authored-by: Ogulcan Celik <[email protected]>

* fix: support preinstalled windows remote hosts (herdrdev#3661)

* fix: support windows hosts in saved ssh machines

refs herdrdev#3651

* fix: keep windows ssh bridge writes blocking

refs herdrdev#3651

* fix: close saved windows ssh bootstrap input

refs herdrdev#3651

* refactor: simplify remote bridge helpers

refs herdrdev#3651

* refactor: isolate remote bridge platform behavior

refs herdrdev#3651

* fix: close captured ssh input under windows consoles

refs herdrdev#3651

* test: remove redundant remote command assertions

refs herdrdev#3651

refs herdrdev#3701

* test: handle framed ssh commands in machine setup

refs herdrdev#3651

---------

Co-authored-by: Ogulcan Celik <[email protected]>

* fix: restore autofocus when creating worktrees (herdrdev#3787)

* fix: restore autofocus when creating worktrees

refs herdrdev#3766

* fix: let the client focus newly created worktrees

refs herdrdev#3766

* feat: navigate and highlight workspaces across machines (herdrdev#3755)

* fix: highlight workspace navigation with saved machines

refs herdrdev#3754

* feat: navigate workspaces across connected machines

refs herdrdev#3754

* feat: navigate workspaces across machines

refs herdrdev#3754

---------

Co-authored-by: akbash-bot <[email protected]>
Co-authored-by: Ogulcan Celik <[email protected]>

* fix(macos): wire system notification Show click to focus target pane (#29)

Co-authored-by: arrrrny <[email protected]>

* fix(macos): pass bare binary path to terminal-notifier -execute (#33)

terminal-notifier runs -execute as a shell command (/bin/sh -c), so the
previous file:// URL form was never a valid command and the notification
click did nothing. Pass the bare current_exe() path so the launched herdr
binary self-detects the click and dispatches pane.focus.

refs #32

* fix: expose badge socket API as a herdr badge CLI verb (#31)

* fix: expose badge socket API as a herdr badge CLI verb

The badge system (badge.set/clear/list) was fully implemented in the
binary but had no CLI surface, so controllers could only reach it via
raw JSON-RPC. Add a top-level herdr badge command group with set,
clear, and list subcommands that dispatch to those socket methods.

refs #30

* fix(pr 31): apply CodeRabbit review fixes

* fix(api): regenerate protocol schema artifact for badge methods

The custom-badges PR (#16 / fork #2) added badge.set/badge.clear/badge.list
to the JSON-RPC Method/ResponseResult enums but did not regenerate the
committed schema artifact, so generated_protocol_schema_artifact_is_current
failed. Regenerate docs/next/api/herdr-api.schema.json.

refs #2

* feat: restore ziki agent detection and agent-state push support

Port the dropped old-lineage ziki work (#36, #37) onto current upstream:
Agent::Ziki detection with a bundled manifest ([ziki-state: <state>]
screen markers and ziki:<state> OSC titles), full lifecycle report
authority for herdr:ziki with the no-session-start-push anchor, the
loopback HTTP state-report push listener (POST /api/v1/pane/report/agent,
[server].agent_push_listen_addr, HERDR_API_LISTEN_ADDR override), and the
catalog entry at distribution/agent-detection/ziki.toml following the
upstream website/ -> distribution/ rename.

refs #43

* ci: add fork-upstream sync guardrail with FORK_OWNED_FILES verification

The daily upstream sync (sync-upstream.yml) now mirrors the robust pattern
from arrrrny/kimi-code: on merge conflict it aborts and opens a sync-labeled
issue; after a clean merge it verifies every file in FORK_OWNED_FILES still
contains its survival marker. If upstream silently dropped a fork-owned
feature the job fails and opens an issue.

FORK_OWNED_FILES covers: macOS notification click-to-focus, login-shell PATH
for custom commands, agent status indicators, badge CLI verb, and ziki
detection manifests.

Also adds a Fork Upstream Sync Policy section to AGENTS.md.

* chore: re-point FORK_OWNED_FILES to post-merge paths and cover restored features

Upstream deleted src/app/input/navigate.rs; its #12 login-shell PATH env
is superseded by the #17 login-shell spawn now guarded via
src/app/custom_commands.rs and the existing #4 entries. The website/
catalog path moved to distribution/. Adds guard entries for the badge
store + CLI verb, agent-wait hardening, PTY chunking, --current hard
error, events.subscribe no-replay, hermes resume, partial-shutdown
recovery, and the ziki push listener. Every path+marker verified.

refs #43

* style: apply cargo fmt to ported changes

refs #43

* fix(ci): use grep -e in the fork-owned marker guardrail

Markers starting with a dash (e.g. the --current hard-error marker)
were parsed as grep options and the guardrail silently mis-reported.

refs #43

* fix: port sidebar badges to the client-shell snapshot architecture

The badges feature (#16, #31) predates the client-shell refactor
(herdrdev#3487) and its sidebar.rs replacement no longer compiled against the
restructured code. Restore src/ui/sidebar.rs to upstream and re-port
badge rendering onto the new architecture:

- protocol: add ClientShellBadge and a badges field to
  ClientShellSnapshot (private same-install wire, roundtrip-tested)
- server: populate the snapshot by merging run/badge.json file badges
  with in-memory IPC-set badges (in-memory wins on key conflict)
- client: render [text] badges after the " spaces" header in
  src/client/shell/sidebar.rs
- badges: restore BadgeStore len/is_empty/clear_all helpers lost in
  the merge; adapt badge API tests to AppPolicy::TEST

refs #16
refs #31
refs #43

* fix: prepend login-shell PATH in custom_command_env

Wire the combined login-shell PATH (cached_login_shell_path +
combined_login_shell_path from the integration registry) into
custom_command_env(), the single choke point for shell/pane/popup
custom commands, as documented in the #4 commit message. The helper
landed without a production caller during the original work, leaving it
dead code; probe failure still leaves PATH untouched.

refs #4
refs #43

* test: align hermes asset test with tui resume reporting

The fork reports resumed Hermes sessions for every interactive
platform on pre_llm_call (#25), so the upstream test encoding the
cli-only gate no longer matches. Update it to assert the fork contract
(startup, resume, new, resume sequence with per platform:start_source
dedup) and guard the test file in FORK_OWNED_FILES alongside the new
badge port paths.

refs #25
refs #43

* fix: default badges snapshot field and refresh api schema artifact

The new ClientShellSnapshot.badges field broke the frozen
generation-1 fixture decode (missing field). Give it
#[serde(default)] per the stable endpoint contract instead of
touching the frozen fixture, and regenerate the schema artifact
(cargo test surfaced both).

refs #43

* docs: add badge cli section to ja and zh-cn cli reference

The fork's badge CLI verb docs only existed in the English
cli-reference, breaking the docs translation parity contract in CI.

refs #31
refs #43

* docs: restore preview snapshot to the recorded preview commit

The scheduled upstream sync merged newer docs/next content into
master without re-snapshotting docs/preview, so preview.mjs check
failed on master itself (pre-existing breakage). Restore
docs/preview/website to exactly match 9e9bc8a:docs/next/website as
recorded in distribution/preview.json.

refs #43

---------

Co-authored-by: kangal-bot <[email protected]>
Co-authored-by: JJ Liebig <[email protected]>
Co-authored-by: akbash-bot <[email protected]>
Co-authored-by: Can Celik <[email protected]>
Co-authored-by: caner-akca <[email protected]>
Co-authored-by: Rudolf S. <[email protected]>
Co-authored-by: Rudolf Schmidt <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: akbash <[email protected]>
Co-authored-by: arrrrny <[email protected]>
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.

macOS system notification "Show" does not focus the target window/pane

1 participant