agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Fix default notifier onboarding

Open whoisasx opened this issue 6 months ago • 3 comments

Summary

  • Remove implicit Composio/manual notifier defaults from fresh global config and notifier registry loading.
  • Add startup notifier onboarding defaults: dashboard for all priorities and desktop only for urgent, with macOS AO Notifier.app setup best-effort.
  • Update dashboard/desktop setup defaults and tests for fresh config/startup routing.

Fixes #1958

Tests

  • pnpm build && pnpm typecheck && pnpm lint && pnpm test

whoisasx avatar May 20 '26 15:05 whoisasx

Test Coverage Report

Metric Value
Lines covered 2401/3195
Lines not covered 794/3195
Overall coverage 75.1%
Per-file breakdown
File Coverage
packages/cli/src/commands/start.ts 1127/1561 (72.2%)
packages/cli/src/lib/dashboard-setup.ts 128/214 (59.8%)
packages/cli/src/lib/desktop-setup.ts 449/612 (73.4%)
packages/cli/src/lib/startup-notifier-defaults.ts 197/221 (89.1%)
packages/core/src/global-config.ts 338/397 (85.1%)
packages/core/src/plugin-registry.ts 162/190 (85.3%)

Uncovered lines

  • packages/cli/src/commands/start.ts: L140-L142, L145, L160-L172, L187-L188, L199-L201, L204-L206, L208, L210-L214, L217-L218, L220, L222-L226, L228-L235, L237-L239, L279-L280, L285-L303, L305-L312, L314-L315, L321-L327, L329, L360-L361, L375-L377, L386-L387, L390-L414, L459-L473, L475-L478, L480-L494, L522, L533, L557-L558, L561-L562, L570-L571, L578-L583, L628-L631, L657-L658, L665-L675, L678-L679, L703-L704, L707-L711, L719-L726, L733-L734, L771-L774, L789-L794, L811-L813, L815-L822, L824-L826, L828-L833, L835-L836, L949-L952, L999, L1032-L1051, L1121-L1122, L1132-L1134, L1206-L1207, L1213-L1214, L1216-L1217, L1220-L1227, L1229, L1277-L1282, L1315-L1316, L1322-L1323, L1347-L1351, L1356-L1361, L1364-L1369, L1376-L1382, L1384-L1391, L1393-L1399, L1448, L1468-L1469, L1574-L1575, L1627-L1644, L1708, L1742-L1744, L1767-L1774, L1801-L1809, L1830-L1831, L1865-L1866, L1874-L1885, L1888, L1920, L1926-L1927, L1930-L1938, L1948-L1949, L1958-L1959, L2004-L2006, L2035-L2037, L2115-L2120, L2150-L2161, L2194-L2195
  • packages/cli/src/lib/dashboard-setup.ts: L47-L54, L67-L70, L90, L93, L95-L96, L106-L107, L146-L149, L158-L162, L164-L168, L170-L172, L174-L175, L177-L184, L186, L188-L200, L202-L204, L206-L211, L213-L218, L227-L229, L275, L277-L278, L280-L285
  • packages/cli/src/lib/desktop-setup.ts: L83-L86, L88-L95, L101-L104, L106-L108, L147-L148, L157-L158, L161-L164, L177-L182, L231-L232, L236-L239, L253-L254, L275-L277, L284-L285, L310-L317, L338-L339, L365-L366, L372-L373, L381-L390, L402-L403, L414-L417, L419-L420, L430, L443-L447, L450-L453, L455-L461, L466-L467, L470-L477, L502-L510, L532-L533, L551-L552, L570-L580, L595-L598, L601-L614, L624-L626, L636-L639, L729-L732, L735-L739
  • packages/cli/src/lib/startup-notifier-defaults.ts: L124, L147-L148, L169-L189
  • packages/core/src/global-config.ts: L28, L40, L125, L421-L422, L444, L487-L489, L492, L576, L583, L597, L610-L612, L625-L627, L629-L631, L633-L634, L636-L638, L688, L705, L713-L719, L722, L749, L759, L808-L809, L821, L830, L1101, L1112, L1114, L1118, L1120, L1122, L1124, L1128, L1234, L1267, L1279-L1280, L1336-L1338, L1347
  • packages/core/src/plugin-registry.ts: L170, L241, L329-L330, L332-L337, L340-L341, L343-L344, L346, L356, L374-L375, L379-L380, L392-L394, L397, L401-L403, L421

github-actions[bot] avatar May 20 '26 15:05 github-actions[bot]

Greptile Summary

This PR overhauls the notifier onboarding flow: it removes the old implicit Composio/manual-notifier defaults and replaces them with an explicit startup routine that wires dashboard to all priorities and desktop (AO Notifier.app) to urgent-only, with best-effort macOS install on ao start.

  • startup-notifier-defaults.ts (new): YAML-preserving, idempotent function that sanitises legacy Composio references, ensures dashboard + desktop notifier entries, and rebuilds per-priority routing. Correctly distinguishes default vs. custom desktop configs on the disable-default path.
  • start.ts: Calls ensureDefaultStartupNotifiers after maybePromptForUpdateChannel; attempts installAoNotifierAppForStartup on macOS, falls back to dashboard-only if it fails. On Linux/Windows the isMac() guard is never entered so desktopMode stays \"enable\", which causes ensureDesktopNotifier to write backend: \"ao-app\" — a macOS-only backend — into the config on those platforms.
  • plugin-registry.ts: canImplicitlyRegisterNotifier now prevents manual opt-in notifiers (composio, slack, etc.) from being auto-instantiated via routing references alone, while keeping dashboard/desktop implicitly registerable.

Confidence Score: 3/5

Needs cross-platform fix before merging: on Linux and Windows every ao start writes a desktop notifier config with backend: "ao-app" — a backend that only exists on macOS — into the global config and wires it into urgent routing, meaning urgent notifications on those platforms will silently attempt an unavailable backend.

The core onboarding logic is well-structured and idempotent, and the Composio cleanup is correct. However, the isMac() guard in ensureDefaultStartupNotifiers only prevents the AO Notifier.app install attempt on non-Mac hosts — it does not prevent the function from writing backend: "ao-app" as the desktop notifier default. ensureDesktopNotifier defaults the backend to "ao-app" unconditionally, and createDefaultNotifierConfigs in global-config.ts does the same for freshly parsed configs. Every Linux/Windows user who runs ao start after this update will have an unusable desktop notifier entry written into their global config and wired into urgent routing.

packages/cli/src/commands/start.ts (ensureDefaultStartupNotifiers — desktopMode should be "disable-default" on non-Mac) and packages/core/src/global-config.ts (createDefaultNotifierConfigs — backend: "ao-app" should be platform-conditional).

Important Files Changed

Filename Overview
packages/cli/src/lib/startup-notifier-defaults.ts New module implementing idempotent YAML-preserving notifier defaults. Correctly guards custom desktop configs. Exports createStartupNotifierConfig which is unused elsewhere in the PR.
packages/cli/src/commands/start.ts Adds ensureDefaultStartupNotifiers which gates AO Notifier.app install inside if (isMac()) but leaves desktopMode = "enable" on Linux/Windows, causing ensureDesktopNotifier to write backend: "ao-app" into the config on every platform.
packages/core/src/global-config.ts Replaces old Composio defaults with createDefaultNotifierConfigs() (desktop + dashboard). The factory hardcodes backend: "ao-app" which is macOS-only; applied on all platforms when notifiers is absent from a user's YAML.
packages/core/src/plugin-registry.ts Adds canImplicitlyRegisterNotifier guard that prevents manual opt-in notifiers (composio, slack, etc.) from being auto-instantiated when referenced only by routing; dashboard and desktop remain implicitly registerable.
packages/plugins/notifier-desktop/src/index.ts Extracts usesAoNotifierNativeActions helper and adds isMac() guard, fixing action-label hiding on Linux/Windows when backend is ao-app. Also retains the ENOENT-aware error handling in detectTerminalNotifier.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ao start invoked] --> B[runStartup]
    B --> C[ensureDefaultStartupNotifiers]
    C --> D{config.configPath exists?}
    D -- No --> E[return config unchanged]
    D -- Yes --> F[resolveStartupNotifierConfigPath]
    F --> G{isMac?}
    G -- Yes --> H[installAoNotifierAppForStartup]
    H -- success --> I[desktopMode = enable]
    H -- throws --> J[desktopMode = disable-default]
    G -- No --> I
    I --> K[ensureStartupNotifierDefaults]
    J --> K
    K --> L{changed?}
    L -- Yes --> M[writeFileSync YAML]
    M --> N[loadConfig targetConfigPath]
    L -- No --> O[return original config]
    N --> O
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/cli/src/lib/startup-notifier-defaults.ts:168-189
`createStartupNotifierConfig` is exported but never imported anywhere in the codebase — only `ensureStartupNotifierDefaults` is used. If this is intended as a future public API, a brief comment would clarify; otherwise it can be removed to avoid confusion with the similarly-structured internal logic in `ensureStartupNotifierDefaults`.

```suggestion
/** Returns the canonical startup notifier configuration for a given port.
 * Used when programmatically building a fresh config; for in-place YAML
 * updates prefer `ensureStartupNotifierDefaults`.
 */
export function createStartupNotifierConfig(port = 3000): StartupNotifierConfig {
  const dashboardUrl = `http://localhost:${port}`;
  return {
    notifiers: {
      desktop: {
        plugin: "desktop",
        backend: "ao-app",
        dashboardUrl,
      },
      dashboard: {
        plugin: "dashboard",
        limit: DEFAULT_DASHBOARD_NOTIFICATION_LIMIT,
      },
    },
    notificationRouting: {
      urgent: ["desktop", "dashboard"],
      action: ["dashboard"],
      warning: ["dashboard"],
      info: ["dashboard"],
    },
  };
}
```


Reviews (5): Last reviewed commit: "fix: preserve notifier routing fallbacks..." | Re-trigger Greptile

greptile-apps avatar May 20 '26 16:05 greptile-apps

Superseded by #2059. The original PR head branch is in ComposioHQ/agent-orchestrator and this session no longer has push permission there; the validated update was pushed to the fork branch instead.

whoisasx avatar May 25 '26 14:05 whoisasx