Skip to content

Notification plugin from docs doesn't work #4846

Closed

Description

@oabdellatif

Description

I want to configure notifications on my machine using the example snippet from the docs: https://opencode.ai/docs/plugins/#send-notifications. This seems to work for other people, but I don't get any notifications after the session completes as expected. I've confirmed the syntax is correct and I see the plugin being loaded in the logs: INFO 2025-11-27T22:42:08 +5ms service=plugin path=file:///home/oabdellatif/.config/opencode/plugin/notification.js loading plugin.

After some debugging, what seems to be happening is that the event subscription isn't being created. I added console.log() lines as follows:

export const NotificationPlugin = async ({ project, client, $, directory, worktree }) => {
  console.log("Plugin loaded")
  return {
    event: async ({ event }) => {
      console.log("Event received: " + event.type)
      // Send notification on session completion
      if (event.type === "session.idle") {
        await $`wsl-notify-send.exe "Session completed!"`
      }
    },
  }
}

I never see the second log line, which leads me to the above conclusion. After some more back and forth with Big Pickle and adding debug logs, it seems like Plugin.init() is either not being called or there's some caching issue.

OpenCode version

1.0.119

Steps to reproduce

  1. Copy the plugin to ~/.config/opencode/plugin/notification.js
  2. Run opencode and start a new session
  3. Wait for the session to complete

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04 LTS on WSL2

Terminal

VS Code Terminal

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 28, 2025
  2. github-actions commented on Nov 28, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. JunarisAlf commented on Nov 28, 2025

    @JunarisAlf
    • sudo apt install libnotify-bin
    • Change the push command to notify-send "OpenCode" "Task complete"
  4. JunarisAlf commented on Nov 28, 2025

    @JunarisAlf

    Ah, you are on wsl windows, first you need figured it out the cli command for the push notifications, try manually first, then apply it to plugin

  5. self-assigned this
    on Dec 2, 2025
  6. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  7. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    I use this plugin and the session idle definitely fires for me:

    import type { Plugin } from "@opencode-ai/plugin";
    
    export const Notify: Plugin = async ({ client, $ }) => {
      return {
        async event({ event }) {
          switch (event.type) {
            case "session.idle":
              await client.tui.showToast({
                body: {
                  title: "[debug] event",
                  message: event.type,
                  variant: "info",
                },
              });
              break;
          }
        },
      };
    };
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions