Skip to content

Commit 96f6138

Browse files
committed
wip: v1.17.9 reconciliation — §4 app.tsx + UpgradeIndicator port (checkpoint 7)
app.tsx re-home into packages/tui/src/app.tsx + UpgradeIndicator component port. packages/tui + packages/core both typecheck GREEN. app.tsx (5 applied): - terminal-detection: created fork-original packages/tui/src/terminal-detection.ts (detectModeFromCOLORFGBG, AltimateAI#704) + eager COLORFGBG light-mode short-circuit in the theme-detection path (avoids the 1s waitForThemeMode delay). - branding: docs URL opencode.ai/docs -> docs.altimate.sh; DialogAlert update message "OpenCode v…" -> "Altimate Code v…". app.tsx MOOT (2): variant_list keybind (upstream v1.17.9 shipped PR #21185 natively); disableStdoutInterception (opentui API removed; renderer externalOutputMode handles it). app.tsx DEFERRED (7): trace-viewer feature — depends on opencode-side altimate/observability (Trace/renderTraceViewer/DialogTraceList), unreachable from packages/tui. Same architectural blocker as the dialogs/enhance (task: expose opencode deps to tui). UpgradeIndicator port (fork-original, was deferred — now unblocked since it only needed Installation.VERSION = InstallationVersion in core): - packages/tui/src/component/upgrade-indicator{,-utils}.tsx — repointed imports to the tui layout, Installation.VERSION -> InstallationVersion. Added semver + @types/semver to packages/tui (were opencode-only deps). - routes/session/footer.tsx — wired <UpgradeIndicator /> back into the session footer. (home-screen UpgradeIndicator still deferred — lives in the new feature-plugins/home/footer plugin, a different surface.) OLD cli/cmd/tui/** files untouched (deleted in §3.4 after remaining re-homing/decisions).
1 parent 34c1f36 commit 96f6138

8 files changed

Lines changed: 127 additions & 37 deletions

File tree

‎.github/meta/commit.txt‎

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
1-
wip: v1.17.9 reconciliation — §4 re-home TUI batch 2 + line-streaming flags (checkpoint 6)
1+
wip: v1.17.9 reconciliation — §4 app.tsx + UpgradeIndicator port (checkpoint 7)
22

3-
Second re-homing wave into packages/tui (live TUI). packages/tui + packages/core both
4-
typecheck GREEN.
3+
app.tsx re-home into packages/tui/src/app.tsx + UpgradeIndicator component port.
4+
packages/tui + packages/core both typecheck GREEN.
55

6-
Re-homed (functional):
7-
- context/sync.tsx — full streaming feature set: yolo auto-approve (adapted to the new
8-
permission.reply API: workspace arg + reply:"once"), smooth-streaming direct-path delta
9-
update, and the complete line-streaming buffer feature (lineBuffer + flushLineBuffer +
10-
flushAllBuffersForMessage + the 5 event-handler hooks). event.type/.properties is correct
11-
here (useEvent unwraps GlobalEvent.payload, unlike sdk.tsx).
12-
- routes/session/index.tsx — `builder` agent name on plan_exit, smooth-streaming scroll
13-
(toBottom 0ms), calm-mode content width cap (maxWidth via ALTIMATE_CONTENT_MAX_WIDTH).
14-
- theme/index.ts — light-mode fg fallback (#704), code-block + inline-code backgrounds for
15-
light-theme contrast. NOTE: inline-code uses theme.backgroundElement vs upstream's new
16-
theme.background — flagged inline for the next merge's human review.
17-
- feature-plugins/home/tips-view.tsx — fork DE-specific tips (/discover, /cost-report,
18-
/dbt-docs, /sql-review, /migrate-sql, lineage, anti-patterns) folded into the new Tip pool.
6+
app.tsx (5 applied):
7+
- terminal-detection: created fork-original packages/tui/src/terminal-detection.ts
8+
(detectModeFromCOLORFGBG, #704) + eager COLORFGBG light-mode short-circuit in the
9+
theme-detection path (avoids the 1s waitForThemeMode delay).
10+
- branding: docs URL opencode.ai/docs -> docs.altimate.sh; DialogAlert update message
11+
"OpenCode v…" -> "Altimate Code v…".
12+
app.tsx MOOT (2): variant_list keybind (upstream v1.17.9 shipped PR #21185 natively);
13+
disableStdoutInterception (opentui API removed; renderer externalOutputMode handles it).
14+
app.tsx DEFERRED (7): trace-viewer feature — depends on opencode-side altimate/observability
15+
(Trace/renderTraceViewer/DialogTraceList), unreachable from packages/tui. Same architectural
16+
blocker as the dialogs/enhance (task: expose opencode deps to tui).
1917

20-
Flags re-homed into packages/core/src/flag/flag.ts (tui depends on core, not opencode):
21-
ALTIMATE_LINE_STREAMING, ALTIMATE_CONTENT_MAX_WIDTH (+ numberEnv helper), joining the
22-
ALTIMATE_CALM_MODE/SMOOTH_STREAMING/CLI_YOLO added in checkpoint 5.
18+
UpgradeIndicator port (fork-original, was deferred — now unblocked since it only needed
19+
Installation.VERSION = InstallationVersion in core):
20+
- packages/tui/src/component/upgrade-indicator{,-utils}.tsx — repointed imports to the tui
21+
layout, Installation.VERSION -> InstallationVersion. Added semver + @types/semver to
22+
packages/tui (were opencode-only deps).
23+
- routes/session/footer.tsx — wired <UpgradeIndicator /> back into the session footer.
24+
(home-screen UpgradeIndicator still deferred — lives in the new feature-plugins/home/footer
25+
plugin, a different surface.)
2326

24-
MOOT (upstream v1.17.9 shipped equivalents — dropped per upstream_fix rule):
25-
- prompt skills-dialog keybind → upstream `prompt_skills` keybind.
26-
- session workspace-gate, smooth-streaming memoize, light-theme md fg (upstream ships
27-
fg=markdownText + bg=background).
28-
29-
DEFERRED — architectural (tracked): enhance feature (enhance-prompt.ts), dialog-provider
30-
(AltimateApi), dialog-skill (skill-helpers + keymap port). All three depend on opencode-package
31-
code unreachable from packages/tui — need the shared code moved into @opencode-ai/core, routed
32-
via SDK/server, or implemented as tui plugins. Real features; not dropped.
33-
34-
DEFERRED — render-rewritten: session/index TextPart code-during-streaming, tips first-time-only
35-
behavior, sidebar trace section (sidebar_content slot), footer/home UpgradeIndicator (component
36-
not yet ported into packages/tui).
37-
38-
OLD cli/cmd/tui/** files untouched (deleted in §3.4 after all re-homing verified).
27+
OLD cli/cmd/tui/** files untouched (deleted in §3.4 after remaining re-homing/decisions).

‎bun.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/tui/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@
6161
"opentui-spinner": "catalog:",
6262
"remeda": "catalog:",
6363
"strip-ansi": "7.1.2",
64+
"semver": "^7.6.3",
6465
"solid-js": "catalog:"
6566
},
6667
"devDependencies": {
6768
"@tsconfig/bun": "catalog:",
6869
"@types/bun": "catalog:",
70+
"@types/semver": "^7.5.8",
6971
"@typescript/native-preview": "catalog:"
7072
}
7173
}

‎packages/tui/src/app.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ import * as TuiAudio from "./audio"
8282
import { win32DisableProcessedInput, win32FlushInputBuffer } from "./terminal-win32"
8383
import { destroyRenderer } from "./util/renderer"
8484
import { cliErrorMessage, errorFormat } from "./util/error"
85+
// altimate_change start — fix: pure helper extracted to terminal-detection for test coverage (#704)
86+
import { detectModeFromCOLORFGBG } from "./terminal-detection"
87+
// altimate_change end
8588

8689
const appGlobalBindingCommands = [
8790
"session.list",
@@ -229,7 +232,10 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
229232
yield* Effect.tryPromise(async () => {
230233
// Prewarm palette before ThemeProvider mounts so `system` theme avoids a first-paint fallback flash.
231234
void renderer.getPalette({ size: 16 }).catch(() => undefined)
232-
const mode = (await renderer.waitForThemeMode(1000)) ?? "dark"
235+
// altimate_change start — fix: check COLORFGBG eagerly to avoid 1s startup delay on terminals without OSC 11 (#704)
236+
const envMode = detectModeFromCOLORFGBG(process.env.COLORFGBG)
237+
const mode = envMode === "light" ? "light" : ((await renderer.waitForThemeMode(1000)) ?? "dark")
238+
// altimate_change end
233239
if (renderer.isDestroyed) return
234240

235241
await render(() => {
@@ -796,7 +802,9 @@ function App(props: { onSnapshot?: () => Promise<string[]>; pluginHost: TuiPlugi
796802
name: "docs.open",
797803
title: "Open docs",
798804
run: () => {
799-
open("https://opencode.ai/docs").catch(() => {})
805+
// altimate_change start — altimate docs URL
806+
open("https://docs.altimate.sh").catch(() => {})
807+
// altimate_change end
800808
dialog.clear()
801809
},
802810
category: "System",
@@ -1037,7 +1045,9 @@ function App(props: { onSnapshot?: () => Promise<string[]>; pluginHost: TuiPlugi
10371045
await DialogAlert.show(
10381046
dialog,
10391047
"Update Complete",
1040-
`Successfully updated to OpenCode v${result.data.version}. Please restart the application.`,
1048+
// altimate_change start — branding: altimate update-complete message
1049+
`Successfully updated to Altimate Code v${result.data.version}. Please restart the application.`,
1050+
// altimate_change end
10411051
)
10421052

10431053
void exit()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// altimate_change start — fork-original component re-homed from packages/opencode/src/cli/cmd/tui
2+
// during the v1.17.9 TUI extraction. Installation.VERSION -> InstallationVersion (core).
3+
import semver from "semver"
4+
import { InstallationVersion } from "@opencode-ai/core/installation/version"
5+
6+
export const UPGRADE_KV_KEY = "update_available_version"
7+
8+
function isNewer(candidate: string, current: string): boolean {
9+
// Dev mode: show indicator for any valid semver candidate
10+
if (current === "local") {
11+
return semver.valid(candidate) !== null
12+
}
13+
if (!semver.valid(candidate) || !semver.valid(current)) {
14+
return false
15+
}
16+
return semver.gt(candidate, current)
17+
}
18+
19+
export function getAvailableVersion(kvValue: unknown): string | undefined {
20+
if (typeof kvValue !== "string" || !kvValue) return undefined
21+
if (kvValue === InstallationVersion) return undefined
22+
if (!isNewer(kvValue, InstallationVersion)) return undefined
23+
return kvValue
24+
}
25+
// altimate_change end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// altimate_change start — fork-original component re-homed from packages/opencode/src/cli/cmd/tui
2+
// during the v1.17.9 TUI extraction. Imports repointed to the packages/tui layout.
3+
import { createMemo, Show, type JSX } from "solid-js"
4+
import { useTerminalDimensions } from "@opentui/solid"
5+
import { useTheme } from "../context/theme"
6+
import { useKV } from "../context/kv"
7+
import { UPGRADE_KV_KEY, getAvailableVersion } from "./upgrade-indicator-utils"
8+
9+
export function UpgradeIndicator(props: { fallback?: JSX.Element }) {
10+
const { theme } = useTheme()
11+
const kv = useKV()
12+
const dimensions = useTerminalDimensions()
13+
14+
const latestVersion = createMemo(() => getAvailableVersion(kv.get(UPGRADE_KV_KEY)))
15+
const isCompact = createMemo(() => dimensions().width < 100)
16+
17+
return (
18+
<Show when={latestVersion()} fallback={props.fallback}>
19+
{(version) => (
20+
<box flexDirection="row" gap={1} flexShrink={0}>
21+
<text fg={theme.success}>↑</text>
22+
<text fg={theme.accent}>{version()}</text>
23+
<Show when={!isCompact()}>
24+
<text fg={theme.textMuted}>update available ·</text>
25+
</Show>
26+
{/* upgrade hint shows the altimate-code CLI command */}
27+
<text fg={theme.textMuted}>altimate upgrade</text>
28+
</box>
29+
)}
30+
</Show>
31+
)
32+
}
33+
// altimate_change end

‎packages/tui/src/routes/session/footer.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { useRoute } from "../../context/route"
88
// altimate_change start - yolo mode visual indicator
99
import { Flag } from "@opencode-ai/core/flag/flag"
1010
// altimate_change end
11+
// altimate_change start - upgrade indicator in session footer
12+
import { UpgradeIndicator } from "../../component/upgrade-indicator"
13+
// altimate_change end
1114

1215
export function Footer() {
1316
const { theme } = useTheme()
@@ -95,6 +98,9 @@ export function Footer() {
9598
<text fg={theme.textMuted}>/status</text>
9699
</Match>
97100
</Switch>
101+
{/* altimate_change start - upgrade indicator in session footer */}
102+
<UpgradeIndicator />
103+
{/* altimate_change end */}
98104
</box>
99105
</box>
100106
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// altimate_change start — fix: pure-TS helper extracted from app.tsx for direct test coverage (#704)
2+
/**
3+
* Detect terminal background mode from the COLORFGBG env var.
4+
*
5+
* Format is `fg;bg` or `fg;default;bg` (rxvt/urxvt). The last semicolon-
6+
* separated component is the background palette index. Only indices that
7+
* are canonically light (7 = light-gray, 15 = bright-white) classify as
8+
* "light" — other bright indices (9 red, 12 blue, 13 magenta) are dark
9+
* by luminance and must not be treated as light.
10+
*
11+
* Returns `null` when the value is missing, malformed (e.g. "default"),
12+
* or outside the 0-15 ANSI range.
13+
*/
14+
export function detectModeFromCOLORFGBG(value: string | undefined): "dark" | "light" | null {
15+
if (!value) return null
16+
const parts = value.split(";")
17+
const last = parts[parts.length - 1]?.trim()
18+
if (!last) return null
19+
const bg = parseInt(last, 10)
20+
if (!Number.isInteger(bg) || bg < 0 || bg > 15) return null
21+
return bg === 7 || bg === 15 ? "light" : "dark"
22+
}
23+
// altimate_change end

0 commit comments

Comments
 (0)