# gitlab-tracker-notify
Optional desktop notification plugin for [gitlab-tracker](../README.md).
Powered by [`notify-rust`](https://crates.io/crates/notify-rust), it surfaces MR state changes as native OS notifications. Build without the `desktop` feature for a zero-dependency stub suitable for headless or CI environments.
---
## Events
Four events trigger a desktop notification:
| 🌿 **New branch detected** | An MR's commit SHA was found on a branch not present in the last persisted state |
| 🕐 **MR updated** | `updated_at` from GitLab differs from the previously stored value |
| 🔀 **Mergeability changed** | The mergeability status transitioned (e.g. `Mergeable → Conflict`) |
| 🏁 **Milestone changed** | The milestone attached to the MR changed (e.g. `v2.4.0 → v2.5.0`) |
---
## Clickable notifications
Each notification includes an **"Open MR"** action button. Clicking it opens the MR directly in your default web browser — no need to switch to the terminal first. The URL is resolved from the `web_url` field returned by the GitLab API.
> **Platform support:** the click-to-open behaviour relies on D-Bus actions on Linux (GNOME, KDE, etc.) and the system `open` command on macOS. On environments without a notification daemon the click action is silently ignored.
---
## Anti-spam on startup
Change notifications (`updated_at`, mergeability, milestone) are **suppressed during the initial sync** — the first fetch cycle after launch. This prevents a flood of toasts when the app starts and reconciles its in-memory state with the GitLab API. Only genuine changes detected during subsequent background refreshes (or a manual `R` refresh) will produce notifications.
* ✅ **No duplicate alerts** when restarting the app with an unchanged state.
* ✅ **No spam** during the initial sync or redundant refresh cycles.
* ✅ **Reliable detection** of real changes across refreshes and restarts.
* ✅ **One click to open** the MR in your browser directly from the notification.
The last-known branch state per MR is persisted in `tracker_state.json` under the `last_known_branches` key.
---
## Feature flags
| `desktop` | ✅ enabled | Enables `notify-rust` and `open` dependencies — produces real OS notifications |
Build without desktop notifications (headless / CI environments):
```bash
cargo build --release --no-default-features
```