Skip to content

bug: non-macOS notification fires even when terminal is focused #68

@terisuke

Description

@terisuke

発見元

Codex CLI セカンドオピニオンレビュー(2026-04-05)→ コード検証済み

問題

packages/opencode/src/notification/index.ts:48terminalIsFocused() が macOS 以外で常に false を返す。

export async function terminalIsFocused(): Promise<boolean> {
  if (platform() !== "darwin") return false  // ← Linux/Windows は常に false
  // ... macOS only: osascript でフォーカス検出
}

結果: Linux/Windows ではターミナルがフォーカスされていても session-complete 通知が発火する。

影響箇所

  • packages/opencode/src/notification/index.ts:48
  • packages/opencode/src/cli/cmd/tui/app.tsx:820,840

対策案

  • Linux: /proc/[pid]/fd/0 のターミナル比較
  • Windows: Win32 GetForegroundWindow API
  • または non-macOS ではデフォルトで通知を抑制

重要度: MEDIUM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions