From 9f94c5f1784f20cd3359762d3ccb37c50cfe3cd3 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 8 Mar 2026 02:16:03 +0900 Subject: [PATCH] fix(auto-update-checker): suppress background bun install output Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .../hook/background-update-check.test.ts | 28 ++++++++++--------- .../hook/background-update-check.ts | 9 ++++-- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/hooks/auto-update-checker/hook/background-update-check.test.ts b/src/hooks/auto-update-checker/hook/background-update-check.test.ts index 0c7cbbf4d..c427c3213 100644 --- a/src/hooks/auto-update-checker/hook/background-update-check.test.ts +++ b/src/hooks/auto-update-checker/hook/background-update-check.test.ts @@ -25,7 +25,7 @@ const mockGetCachedVersion = mock((): string | null => "3.4.0") const mockGetLatestVersion = mock(async (): Promise => "3.5.0") const mockExtractChannel = mock(() => "latest") const mockInvalidatePackage = mock(() => {}) -const mockRunBunInstall = mock(async () => true) +const mockRunBunInstallWithDetails = mock(async () => ({ success: true })) const mockShowUpdateAvailableToast = mock( async (_ctx: PluginInput, _latestVersion: string, _getToastMessage: ToastMessageGetter): Promise => {} ) @@ -41,7 +41,7 @@ mock.module("../checker", () => ({ })) mock.module("../version-channel", () => ({ extractChannel: mockExtractChannel })) mock.module("../cache", () => ({ invalidatePackage: mockInvalidatePackage })) -mock.module("../../../cli/config-manager", () => ({ runBunInstall: mockRunBunInstall })) +mock.module("../../../cli/config-manager", () => ({ runBunInstallWithDetails: mockRunBunInstallWithDetails })) mock.module("./update-toasts", () => ({ showUpdateAvailableToast: mockShowUpdateAvailableToast, showAutoUpdatedToast: mockShowAutoUpdatedToast, @@ -62,7 +62,7 @@ describe("runBackgroundUpdateCheck", () => { mockGetLatestVersion.mockReset() mockExtractChannel.mockReset() mockInvalidatePackage.mockReset() - mockRunBunInstall.mockReset() + mockRunBunInstallWithDetails.mockReset() mockShowUpdateAvailableToast.mockReset() mockShowAutoUpdatedToast.mockReset() @@ -70,7 +70,7 @@ describe("runBackgroundUpdateCheck", () => { mockGetCachedVersion.mockReturnValue("3.4.0") mockGetLatestVersion.mockResolvedValue("3.5.0") mockExtractChannel.mockReturnValue("latest") - mockRunBunInstall.mockResolvedValue(true) + mockRunBunInstallWithDetails.mockResolvedValue({ success: true }) }) describe("#given no plugin entry found", () => { @@ -83,7 +83,7 @@ describe("runBackgroundUpdateCheck", () => { expect(mockFindPluginEntry).toHaveBeenCalledTimes(1) expect(mockShowUpdateAvailableToast).not.toHaveBeenCalled() expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() - expect(mockRunBunInstall).not.toHaveBeenCalled() + expect(mockRunBunInstallWithDetails).not.toHaveBeenCalled() }) }) @@ -110,7 +110,7 @@ describe("runBackgroundUpdateCheck", () => { await runBackgroundUpdateCheck(mockCtx, true, getToastMessage) //#then expect(mockGetLatestVersion).toHaveBeenCalledWith("latest") - expect(mockRunBunInstall).not.toHaveBeenCalled() + expect(mockRunBunInstallWithDetails).not.toHaveBeenCalled() expect(mockShowUpdateAvailableToast).not.toHaveBeenCalled() expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() }) @@ -125,7 +125,7 @@ describe("runBackgroundUpdateCheck", () => { await runBackgroundUpdateCheck(mockCtx, true, getToastMessage) //#then expect(mockGetLatestVersion).toHaveBeenCalledTimes(1) - expect(mockRunBunInstall).not.toHaveBeenCalled() + expect(mockRunBunInstallWithDetails).not.toHaveBeenCalled() expect(mockShowUpdateAvailableToast).not.toHaveBeenCalled() expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() }) @@ -139,7 +139,7 @@ describe("runBackgroundUpdateCheck", () => { await runBackgroundUpdateCheck(mockCtx, autoUpdate, getToastMessage) //#then expect(mockShowUpdateAvailableToast).toHaveBeenCalledWith(mockCtx, "3.5.0", getToastMessage) - expect(mockRunBunInstall).not.toHaveBeenCalled() + expect(mockRunBunInstallWithDetails).not.toHaveBeenCalled() expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() }) }) @@ -152,7 +152,7 @@ describe("runBackgroundUpdateCheck", () => { await runBackgroundUpdateCheck(mockCtx, true, getToastMessage) //#then expect(mockShowUpdateAvailableToast).toHaveBeenCalledTimes(1) - expect(mockRunBunInstall).not.toHaveBeenCalled() + expect(mockRunBunInstallWithDetails).not.toHaveBeenCalled() expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() }) @@ -182,12 +182,13 @@ describe("runBackgroundUpdateCheck", () => { describe("#given unpinned with auto-update and install succeeds", () => { it("invalidates cache, installs, and shows auto-updated toast", async () => { //#given - mockRunBunInstall.mockResolvedValue(true) + mockRunBunInstallWithDetails.mockResolvedValue({ success: true }) //#when await runBackgroundUpdateCheck(mockCtx, true, getToastMessage) //#then expect(mockInvalidatePackage).toHaveBeenCalledTimes(1) - expect(mockRunBunInstall).toHaveBeenCalledTimes(1) + expect(mockRunBunInstallWithDetails).toHaveBeenCalledTimes(1) + expect(mockRunBunInstallWithDetails).toHaveBeenCalledWith({ outputMode: "pipe" }) expect(mockShowAutoUpdatedToast).toHaveBeenCalledWith(mockCtx, "3.4.0", "3.5.0") expect(mockShowUpdateAvailableToast).not.toHaveBeenCalled() }) @@ -196,11 +197,12 @@ describe("runBackgroundUpdateCheck", () => { describe("#given unpinned with auto-update and install fails", () => { it("falls back to notification-only toast", async () => { //#given - mockRunBunInstall.mockResolvedValue(false) + mockRunBunInstallWithDetails.mockResolvedValue({ success: false, error: "install failed" }) //#when await runBackgroundUpdateCheck(mockCtx, true, getToastMessage) //#then - expect(mockRunBunInstall).toHaveBeenCalledTimes(1) + expect(mockRunBunInstallWithDetails).toHaveBeenCalledTimes(1) + expect(mockRunBunInstallWithDetails).toHaveBeenCalledWith({ outputMode: "pipe" }) expect(mockShowUpdateAvailableToast).toHaveBeenCalledWith(mockCtx, "3.5.0", getToastMessage) expect(mockShowAutoUpdatedToast).not.toHaveBeenCalled() }) diff --git a/src/hooks/auto-update-checker/hook/background-update-check.ts b/src/hooks/auto-update-checker/hook/background-update-check.ts index 161031839..c81cb9096 100644 --- a/src/hooks/auto-update-checker/hook/background-update-check.ts +++ b/src/hooks/auto-update-checker/hook/background-update-check.ts @@ -1,5 +1,5 @@ import type { PluginInput } from "@opencode-ai/plugin" -import { runBunInstall } from "../../../cli/config-manager" +import { runBunInstallWithDetails } from "../../../cli/config-manager" import { log } from "../../../shared/logger" import { invalidatePackage } from "../cache" import { PACKAGE_NAME } from "../constants" @@ -13,7 +13,12 @@ function getPinnedVersionToastMessage(latestVersion: string): string { async function runBunInstallSafe(): Promise { try { - return await runBunInstall() + const result = await runBunInstallWithDetails({ outputMode: "pipe" }) + if (!result.success && result.error) { + log("[auto-update-checker] bun install failed:", result.error) + } + + return result.success } catch (err) { const errorMessage = err instanceof Error ? err.message : String(err) log("[auto-update-checker] bun install error:", errorMessage)