Skip to content
Merged
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: 8 additions & 0 deletions packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RouteProvider, useRoute } from "@tui/context/route"
import { Switch, Match, createEffect, untrack, ErrorBoundary, createSignal, onMount, batch, Show, on } from "solid-js"
import { win32DisableProcessedInput, win32FlushInputBuffer, win32InstallCtrlCGuard } from "./win32"
import { Installation } from "@/installation"
import { UPGRADE_KV_KEY } from "./component/upgrade-indicator-utils"
import { Flag } from "@/flag/flag"
import { Log } from "@/util/log"
import { DialogProvider, useDialog } from "@tui/ui/dialog"
Expand Down Expand Up @@ -842,13 +843,20 @@ function App() {

// altimate_change start — branding: altimate upgrade
sdk.event.on(Installation.Event.UpdateAvailable.type, (evt) => {
kv.set(UPGRADE_KV_KEY, evt.properties.version)
toast.show({
variant: "info",
title: "Update Available",
message: `Altimate Code v${evt.properties.version} is available. Run 'altimate upgrade' to update manually.`,
duration: 10000,
})
})

sdk.event.on(Installation.Event.Updated.type, () => {
if (kv.get(UPGRADE_KV_KEY) !== Installation.VERSION) {
kv.set(UPGRADE_KV_KEY, Installation.VERSION)
}
})
// altimate_change end

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import semver from "semver"
import { Installation } from "@/installation"

export const UPGRADE_KV_KEY = "update_available_version"

function isNewer(candidate: string, current: string): boolean {
// Dev mode: show indicator for any valid semver candidate
if (current === "local") {
return semver.valid(candidate) !== null
}
if (!semver.valid(candidate) || !semver.valid(current)) {
return false
}
return semver.gt(candidate, current)
}

export function getAvailableVersion(kvValue: unknown): string | undefined {
if (typeof kvValue !== "string" || !kvValue) return undefined
if (kvValue === Installation.VERSION) return undefined
if (!isNewer(kvValue, Installation.VERSION)) return undefined
return kvValue
}
29 changes: 29 additions & 0 deletions packages/opencode/src/cli/cmd/tui/component/upgrade-indicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createMemo, Show, type JSX } from "solid-js"
import { useTerminalDimensions } from "@opentui/solid"
import { useTheme } from "@tui/context/theme"
import { useKV } from "../context/kv"
import { UPGRADE_KV_KEY, getAvailableVersion } from "./upgrade-indicator-utils"

export function UpgradeIndicator(props: { fallback?: JSX.Element }) {
const { theme } = useTheme()
const kv = useKV()
const dimensions = useTerminalDimensions()

const latestVersion = createMemo(() => getAvailableVersion(kv.get(UPGRADE_KV_KEY)))
const isCompact = createMemo(() => dimensions().width < 100)

return (
<Show when={latestVersion()} fallback={props.fallback}>
{(version) => (
<box flexDirection="row" gap={1} flexShrink={0}>
<text fg={theme.success}>↑</text>
<text fg={theme.accent}>{version()}</text>
<Show when={!isCompact()}>
<text fg={theme.textMuted}>update available ·</text>
</Show>
<text fg={theme.textMuted}>altimate upgrade</text>
</box>
)}
</Show>
)
}
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/tui/routes/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Installation } from "@/installation"
import { useKV } from "../context/kv"
import { useCommandDialog } from "../component/dialog-command"
import { useLocal } from "../context/local"
import { UpgradeIndicator } from "../component/upgrade-indicator"

// TODO: what is the best way to do this?
let once = false
Expand Down Expand Up @@ -152,7 +153,7 @@ export function Home() {
</box>
<box flexGrow={1} />
<box flexShrink={0}>
<text fg={theme.textMuted}>{Installation.VERSION}</text>
<UpgradeIndicator fallback={<text fg={theme.textMuted}>{Installation.VERSION}</text>} />
</box>
</box>
</>
Expand Down
2 changes: 2 additions & 0 deletions packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useRoute } from "../../context/route"
// altimate_change start - yolo mode visual indicator
import { Flag } from "@/flag/flag"
// altimate_change end
import { UpgradeIndicator } from "../../component/upgrade-indicator"

export function Footer() {
const { theme } = useTheme()
Expand Down Expand Up @@ -95,6 +96,7 @@ export function Footer() {
<text fg={theme.textMuted}>/status</text>
</Match>
</Switch>
<UpgradeIndicator />
</box>
</box>
)
Expand Down
Loading
Loading