import React, { useState } from 'react'; import type { Origin } from '@plannotator/shared/agents'; import { useUpdateCheck } from '../hooks/useUpdateCheck'; import { isWindows } from '../utils/platform'; const PI_INSTALL_COMMAND = 'pi install npm:@plannotator/pi-extension'; function getInstallCommand(isWSL: boolean): string { return isWindows && !isWSL ? 'powershell -c "irm https://plannotator.ai/install.ps1 | iex"' : 'curl -fsSL https://plannotator.ai/install.sh | bash'; } interface UpdateBannerProps { origin?: Origin | null; isWSL?: boolean; } export const UpdateBanner: React.FC = ({ origin, isWSL = false }) => { const updateInfo = useUpdateCheck(); const [copied, setCopied] = useState(false); const [dismissed, setDismissed] = useState(false); // Debug: ?preview-origin=opencode to test OpenCode-specific UI const urlParams = new URLSearchParams(window.location.search); const previewOrigin = urlParams.get('preview-origin'); const effectiveOrigin = previewOrigin || origin; const isPi = effectiveOrigin === 'pi'; const isOpenCode = effectiveOrigin === 'opencode'; const installCommand = isPi ? PI_INSTALL_COMMAND : getInstallCommand(isWSL); if (!updateInfo?.updateAvailable || dismissed) return null; const handleCopy = async () => { try { await navigator.clipboard.writeText(installCommand); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (e) { console.error('Failed to copy:', e); } }; const hasFeature = !!updateInfo.featureHighlight; // Expanded banner for milestone releases with feature highlights if (hasFeature) { return (
{/* Feature highlight header */}

{updateInfo.featureHighlight!.title}

New in {updateInfo.latestVersion}

{/* Feature description */}

{updateInfo.featureHighlight!.description}

You have {updateInfo.currentVersion}

{/* Agent-specific extra instructions */} {isOpenCode && (

Run the install script, then restart OpenCode.

)} {isPi && (

Run the install command, then restart Pi.

)}
Release notes
); } // Standard update banner return (

Update available

{updateInfo.latestVersion} is available (you have {updateInfo.currentVersion})

Notes
); };