Skip to content

feat: customizable notifications and extension APIs#3

Open
vekexasia wants to merge 3 commits intoferologics:masterfrom
vekexasia:feat/customizable-notifications
Open

feat: customizable notifications and extension APIs#3
vekexasia wants to merge 3 commits intoferologics:masterfrom
vekexasia:feat/customizable-notifications

Conversation

@vekexasia
Copy link
Copy Markdown

@vekexasia vekexasia commented Mar 9, 2026

Summary

This PR combines the two commits currently in the branch:

  1. feat: customizable notifications, focus tracking, and extension API
  2. feat: add pause API and remove focus tracking

Net result: pi-notify gains customizable notification content plus extension-facing APIs for sending and pausing notifications. The earlier focus-tracking implementation introduced in the first commit is removed by the second commit, so it is not part of the final behavior of this PR.

Included in the final PR

1. Customizable title & body

Notifications can now be customized via environment variables:

  • PI_NOTIFY_TITLE
  • PI_NOTIFY_BODY

Both support template placeholders resolved at send time:

  • {cwd}
  • {folder}

Example:

export PI_NOTIFY_TITLE="Pi ({folder})"
export PI_NOTIFY_BODY="Done in {folder}"

2. pi-notify:customize event

Other extensions can dynamically modify outgoing notifications before delivery:

pi.events.on("pi-notify:customize", (notification) => {
    notification.body = "{folder} on {branch} — done!";
    notification.vars.branch = getCurrentGitBranch();
});

3. pi-notify:send event

Other extensions can trigger notifications programmatically:

pi.events.emit("pi-notify:send", {
    title: "Build",
    body: "Finished in {duration}s",
    vars: { duration: "42" },
    silent: true,
});

4. Pause / unpause API

Other extensions can now suppress notifications temporarily:

pi.events.emit("pi-notify:pause");
pi.events.emit("pi-notify:unpause");

And can observe pause state changes:

pi.events.on("pi-notify:paused", ({ paused }) => {
    console.log(paused ? "Notifications paused" : "Notifications resumed");
});

While paused, both the default agent_end notification and notifications emitted via pi-notify:send are suppressed.

Final behavior change vs. first commit

The first commit added terminal focus tracking and a force option. The second commit removes that design. So the final PR:

  • does not use CSI ?1004h focus reporting
  • does not emit pi-notify:focus
  • does not expose force on pi-notify:send

Notifications are sent normally unless they are explicitly paused.

Docs / release

  • README updated to reflect the final API surface
  • package version bumped to 1.5.0

- Template placeholders ({folder}, {cwd}) in title and body
- PI_NOTIFY_TITLE / PI_NOTIFY_BODY env vars for static defaults
- pi-notify:customize event for dynamic customization from other extensions
- pi-notify:send event so other extensions can trigger notifications
- Terminal focus tracking (CSI ?1004h) — suppress notifications when focused
- pi-notify:focus event for other extensions to track focus state
- force option to bypass focus suppression
- silent option to skip the sound hook
- Updated README with full documentation
@vekexasia vekexasia changed the title feat: customizable notifications, focus tracking, and extension API feat: add pause API and remove focus tracking Mar 9, 2026
@vekexasia vekexasia changed the title feat: add pause API and remove focus tracking feat: customizable notifications and extension APIs Mar 9, 2026
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