Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/cli/doctor/checks/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { CHECK_IDS, CHECK_NAMES } from "../constants"

async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> {
try {
const proc = Bun.spawn(["which", binary], { stdout: "pipe", stderr: "pipe" })
const output = await new Response(proc.stdout).text()
await proc.exited
if (proc.exitCode === 0) {
return { exists: true, path: output.trim() }
const path = Bun.which(binary)
if (path) {
return { exists: true, path }
}
} catch {
// intentionally empty - binary not found
Expand Down
13 changes: 3 additions & 10 deletions src/cli/doctor/checks/opencode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@ export function buildVersionCommand(
export async function findOpenCodeBinary(): Promise<{ binary: string; path: string } | null> {
for (const binary of OPENCODE_BINARIES) {
try {
const lookupCommand = getBinaryLookupCommand(process.platform)
const proc = Bun.spawn([lookupCommand, binary], { stdout: "pipe", stderr: "pipe" })
const output = await new Response(proc.stdout).text()
await proc.exited
if (proc.exitCode === 0) {
const paths = parseBinaryPaths(output)
const selectedPath = selectBinaryPath(paths, process.platform)
if (selectedPath) {
return { binary, path: selectedPath }
}
const path = Bun.which(binary)
if (path) {
return { binary, path }
}
} catch {
continue
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/comment-checker/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function runCommentChecker(input: HookInput, cliPath?: string, cust
debugLog("running comment-checker with input:", jsonInput.substring(0, 200))

try {
const args = [binaryPath]
const args = [binaryPath, "check"]
if (customPrompt) {
args.push("--prompt", customPrompt)
}
Expand Down
22 changes: 1 addition & 21 deletions src/hooks/session-notification-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,8 @@ let aplayPath: string | null = null
let aplayPromise: Promise<string | null> | null = null

async function findCommand(commandName: string): Promise<string | null> {
const isWindows = process.platform === "win32"
const cmd = isWindows ? "where" : "which"

try {
const proc = spawn([cmd, commandName], {
stdout: "pipe",
stderr: "pipe",
})

const exitCode = await proc.exited
if (exitCode !== 0) {
return null
}

const stdout = await new Response(proc.stdout).text()
const path = stdout.trim().split("\n")[0]

if (!path) {
return null
}

return path
return Bun.which(commandName)
} catch {
return null
}
Comment on lines 24 to 28
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spawn import from "bun" is no longer used after the refactoring to use Bun.which() directly. This unused import should be removed.

Copilot uses AI. Check for mistakes.
Expand Down
13 changes: 10 additions & 3 deletions src/hooks/session-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ export function createSessionNotification(

function markSessionActivity(sessionID: string) {
cancelPendingNotification(sessionID)
notifiedSessions.delete(sessionID)
if (!executingNotifications.has(sessionID)) {
notifiedSessions.delete(sessionID)
}
}

async function executeNotification(sessionID: string, version: number) {
Expand Down Expand Up @@ -254,6 +256,11 @@ export function createSessionNotification(
} finally {
executingNotifications.delete(sessionID)
pendingTimers.delete(sessionID)
// Clear notified state if there was activity during notification
if (sessionActivitySinceIdle.has(sessionID)) {
notifiedSessions.delete(sessionID)
sessionActivitySinceIdle.delete(sessionID)
}
}
}

Expand All @@ -262,7 +269,7 @@ export function createSessionNotification(

const props = event.properties as Record<string, unknown> | undefined

if (event.type === "session.updated" || event.type === "session.created") {
if (event.type === "session.created") {
const info = props?.info as Record<string, unknown> | undefined
const sessionID = info?.id as string | undefined
if (sessionID) {
Expand Down Expand Up @@ -299,7 +306,7 @@ export function createSessionNotification(
return
}

if (event.type === "message.updated" || event.type === "message.created") {
if (event.type === "message.updated") {
const info = props?.info as Record<string, unknown> | undefined
const sessionID = info?.sessionID as string | undefined
if (sessionID) {
Expand Down
Loading