feat(auto-update-checker): add local development mode toast notification

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-19 15:02:29 +09:00
parent a47571722a
commit f5e65b8c5c

View File

@@ -23,7 +23,7 @@ export function createAutoUpdateCheckerHook(ctx: PluginInput, options: AutoUpdat
let hasChecked = false
return {
event: async ({ event }: { event: { type: string; properties?: unknown } }) => {
event: ({ event }: { event: { type: string; properties?: unknown } }) => {
if (event.type !== "session.created") return
if (hasChecked) return
@@ -32,23 +32,29 @@ export function createAutoUpdateCheckerHook(ctx: PluginInput, options: AutoUpdat
hasChecked = true
const cachedVersion = getCachedVersion()
const localDevVersion = getLocalDevVersion(ctx.directory)
const displayVersion = localDevVersion ?? cachedVersion
setTimeout(() => {
const cachedVersion = getCachedVersion()
const localDevVersion = getLocalDevVersion(ctx.directory)
const displayVersion = localDevVersion ?? cachedVersion
if (showStartupToast) {
showVersionToast(ctx, displayVersion, getToastMessage(false)).catch(() => {})
}
showConfigErrorsIfAny(ctx).catch(() => {})
showConfigErrorsIfAny(ctx).catch(() => {})
if (localDevVersion) {
log("[auto-update-checker] Skipped: local development mode")
return
}
if (localDevVersion) {
if (showStartupToast) {
showLocalDevToast(ctx, displayVersion, isSisyphusEnabled).catch(() => {})
}
log("[auto-update-checker] Local development mode")
return
}
runBackgroundUpdateCheck(ctx, autoUpdate, getToastMessage).catch(err => {
log("[auto-update-checker] Background update check failed:", err)
})
if (showStartupToast) {
showVersionToast(ctx, displayVersion, getToastMessage(false)).catch(() => {})
}
runBackgroundUpdateCheck(ctx, autoUpdate, getToastMessage).catch(err => {
log("[auto-update-checker] Background update check failed:", err)
})
}, 0)
},
}
}
@@ -172,6 +178,24 @@ async function showAutoUpdatedToast(ctx: PluginInput, oldVersion: string, newVer
log(`[auto-update-checker] Auto-updated toast shown: v${oldVersion} → v${newVersion}`)
}
async function showLocalDevToast(ctx: PluginInput, version: string | null, isSisyphusEnabled: boolean): Promise<void> {
const displayVersion = version ?? "dev"
const message = isSisyphusEnabled
? "Sisyphus running in local development mode."
: "Running in local development mode. oMoMoMo..."
await ctx.client.tui
.showToast({
body: {
title: `OhMyOpenCode ${displayVersion} (dev)`,
message,
variant: "warning" as const,
duration: 5000,
},
})
.catch(() => {})
log(`[auto-update-checker] Local dev toast shown: v${displayVersion}`)
}
export type { UpdateCheckResult, AutoUpdateCheckerOptions } from "./types"
export { checkForUpdate } from "./checker"
export { invalidatePackage, invalidateCache } from "./cache"