Files
hikari-desktop/src/lib/notifications/terminalNotifier.ts
T
naomi a8f98406e1
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 54s
CI / Lint & Test (push) Successful in 14m2s
CI / Build Linux (push) Successful in 16m38s
CI / Build Windows (cross-compile) (push) Successful in 26m27s
feat: add notification sounds (#44)
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #44
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-19 16:18:25 -08:00

51 lines
1.2 KiB
TypeScript

import { claudeStore } from "$lib/stores/claude";
import { NOTIFICATION_SOUNDS, type NotificationType } from "./types";
export function sendTerminalNotification(type: NotificationType, message?: string): void {
const sound = NOTIFICATION_SOUNDS[type];
const title = sound.phrase;
// Create a formatted notification message
const separator = "═".repeat(50);
const timestamp = new Date().toLocaleTimeString();
let emoji = "";
let color = "";
switch (type) {
case "success":
emoji = "✨";
color = "\x1b[32m"; // Green
break;
case "error":
emoji = "❌";
color = "\x1b[31m"; // Red
break;
case "permission":
emoji = "🔐";
color = "\x1b[33m"; // Yellow
break;
case "connection":
emoji = "🔗";
color = "\x1b[36m"; // Cyan
break;
case "task_start":
emoji = "🚀";
color = "\x1b[34m"; // Blue
break;
}
const reset = "\x1b[0m";
// Format the notification
const notification = `
${color}${separator}${reset}
${emoji} ${color}NOTIFICATION${reset} - ${timestamp}
${color}${title}${reset}
${message || ""}
${color}${separator}${reset}`;
// Add to terminal as a special system message
claudeStore.addLine("system", notification);
}