MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / UpdateBanner

Function UpdateBanner

ui/src/components/UpdateBanner.tsx:23–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 * eventually handle that path natively).
22 */
23export function UpdateBanner() {
24 const [info, setInfo] = useState<VersionInfo | null>(null)
25 const [sessionDismissed, setSessionDismissed] = useState(false)
26
27 useEffect(() => {
28 api.version.get().then(setInfo).catch(() => {})
29 }, [])
30
31 if (!info || !info.hasUpdate || !info.latest) return null
32 if (sessionDismissed) return null
33
34 const skippedVersion = (() => {
35 try { return localStorage.getItem(SKIP_STORAGE_KEY) } catch { return null }
36 })()
37 if (skippedVersion === info.latest) return null
38
39 const handleSkip = () => {
40 try { localStorage.setItem(SKIP_STORAGE_KEY, info.latest!) } catch { /* ignore */ }
41 setSessionDismissed(true)
42 }
43 const handleDismiss = () => {
44 setSessionDismissed(true)
45 }
46
47 return (
48 <div className="flex items-center gap-3 px-4 py-2 bg-accent-dim/30 border-b border-accent/40 text-[12px] text-text">
49 <span className="shrink-0">
50 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="text-accent">
51 <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
52 <polyline points="7 10 12 15 17 10" />
53 <line x1="12" y1="15" x2="12" y2="3" />
54 </svg>
55 </span>
56 <span className="flex-1 min-w-0 truncate">
57 <span className="font-semibold">v{info.latest}</span> is available
58 {' '}<span className="text-text-muted">(you have v{info.current})</span>
59 {info.publishedAt && (
60 <span className="text-text-muted"> · released {info.publishedAt.slice(0, 10)}</span>
61 )}
62 </span>
63 <span className="text-text-muted shrink-0 hidden md:inline">
64 Run <code className="text-accent bg-bg-tertiary px-1 rounded">git pull &amp;&amp; pnpm build</code> to update
65 </span>
66 {info.releaseUrl && (
67 <a
68 href={info.releaseUrl}
69 target="_blank"
70 rel="noopener noreferrer"
71 className="text-accent hover:underline shrink-0"
72 >
73 Release notes →
74 </a>
75 )}
76 <button
77 onClick={handleSkip}
78 className="text-text-muted hover:text-text shrink-0 text-[11px]"
79 title="Don't show this update again"
80 >

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected