Skip to content

Commit 2a22e6b

Browse files
committed
wip: v1.17.9 reconciliation — §4 re-home TUI customizations into packages/tui (checkpoint 5)
The TUI was extracted upstream to packages/tui (live) from cli/cmd/tui/** (dead — no @tui alias resolves it). Re-apply the fork customizations into the live package, preserving altimate_change markers. packages/tui + packages/core both typecheck GREEN. Re-homed (functional + branding): - context/sdk.tsx — smooth-streaming delta pre-merge (ALTIMATE_SMOOTH_STREAMING). Adapted to v2 GlobalEvent (discriminant nested under `.payload`, not top-level). - routes/session/footer.tsx — YOLO-mode badge (ALTIMATE_CLI_YOLO). - routes/session/sidebar.tsx — "Altimate Code" branding (uses InstallationVersion). - component/logo.tsx — restore brand colors (primary/accent vs textMuted/text) in the rewritten 8-arg renderLine call-site. - component/dialog-status.tsx — `altimate mcp auth` branding fix. - component/error-component.tsx — `altimate-code: fatal:` title + AltimateAI/altimate-code issue URL (was anomalyco/opencode brand leak). - context/route.tsx — restore dropped navigate debug log (console.debug; tui has no structured logger). Flag re-home (packages/core/src/flag/flag.ts): added ALTIMATE_CALM_MODE, ALTIMATE_SMOOTH_STREAMING, ALTIMATE_CLI_YOLO getters + altTruthy helper, since packages/tui depends on @opencode-ai/core (not opencode) and could not otherwise see the fork flags. MOOT (not re-applied — upstream issue gone): dialog-mcp / dialog-workspace-list logger fixes (tui uses console.* throughout, has no structured logger, the old console.log/debug prints don't exist in the rewritten files). DEFERRED (tracked, code re-architected into other owner files — next pass): - theme AltimateAI#704 light-fg + code-block/inline-code bg → packages/tui/src/theme/index.ts (generateSystem/getSyntaxRules). One human decision: inline-code backgroundElement vs upstream's new background. - beginner/first-time tips + onboarding hint → feature-plugins/home/{tips,tips-view}.tsx (home is now a plugin-slot shell). - UpgradeIndicator: component + utils exist only in the old tree, not ported → blocks the footer + home upgrade-indicator blocks until ported into packages/tui/src/component. - sidebar trace section → sidebar_content plugin slot. OLD cli/cmd/tui/** files untouched (deleted later in §3.4 after all re-homing verified).
1 parent 4294cc9 commit 2a22e6b

9 files changed

Lines changed: 142 additions & 22 deletions

File tree

‎.github/meta/commit.txt‎

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
1-
wip: v1.17.9 reconciliation — altimate/ Tool-API surface green (checkpoint 4)
1+
wip: v1.17.9 reconciliation — §4 re-home TUI customizations into packages/tui (checkpoint 5)
22

3-
Closes the last 3 typecheck errors in the fork's own src/altimate/** tree via the
4-
tool-zod-compat adapter (§2.12):
3+
The TUI was extracted upstream to packages/tui (live) from cli/cmd/tui/** (dead — no
4+
@tui alias resolves it). Re-apply the fork customizations into the live package,
5+
preserving altimate_change markers. packages/tui + packages/core both typecheck GREEN.
56

6-
- altimate-core-rewrite.ts: annotate execute return as the shim's `LegacyResult` so
7-
the legacy `Tool.define` overload's metadata type (M) infers cleanly. This tool's
8-
execute omits the `ctx` param, so M was being inferred from a complex multi-branch
9-
return union and failing overload resolution. `args` still types from `parameters`.
10-
- tool-lookup.ts: upstream's Tool rewrite made `info.init()` an Effect (was a Promise)
11-
and `parameters` an Effect Schema (was zod). Run the init Effect via
12-
`Effect.runPromise` and describe parameters from `Def.jsonSchema` (JSON Schema,
13-
populated for both native tools and our legacy zod tools) instead of the removed
14-
zod introspection. New `describeJsonSchema`/`inferJsonType` replace the zod walkers.
7+
Re-homed (functional + branding):
8+
- context/sdk.tsx — smooth-streaming delta pre-merge (ALTIMATE_SMOOTH_STREAMING).
9+
Adapted to v2 GlobalEvent (discriminant nested under `.payload`, not top-level).
10+
- routes/session/footer.tsx — YOLO-mode badge (ALTIMATE_CLI_YOLO).
11+
- routes/session/sidebar.tsx — "Altimate Code" branding (uses InstallationVersion).
12+
- component/logo.tsx — restore brand colors (primary/accent vs textMuted/text) in the
13+
rewritten 8-arg renderLine call-site.
14+
- component/dialog-status.tsx — `altimate mcp auth` branding fix.
15+
- component/error-component.tsx — `altimate-code: fatal:` title + AltimateAI/altimate-code
16+
issue URL (was anomalyco/opencode brand leak).
17+
- context/route.tsx — restore dropped navigate debug log (console.debug; tui has no
18+
structured logger).
1519

16-
src/altimate/** now typechecks with 0 errors (was 37 at the start of this resume).
17-
Package total 3040 -> 3037; the remainder is upstream-shared restructure: stale-file
18-
deletion (§3.4) + TUI/server re-home (§4) + Effect migration of survivor files.
20+
Flag re-home (packages/core/src/flag/flag.ts): added ALTIMATE_CALM_MODE,
21+
ALTIMATE_SMOOTH_STREAMING, ALTIMATE_CLI_YOLO getters + altTruthy helper, since packages/tui
22+
depends on @opencode-ai/core (not opencode) and could not otherwise see the fork flags.
23+
24+
MOOT (not re-applied — upstream issue gone): dialog-mcp / dialog-workspace-list logger
25+
fixes (tui uses console.* throughout, has no structured logger, the old console.log/debug
26+
prints don't exist in the rewritten files).
27+
28+
DEFERRED (tracked, code re-architected into other owner files — next pass):
29+
- theme #704 light-fg + code-block/inline-code bg → packages/tui/src/theme/index.ts
30+
(generateSystem/getSyntaxRules). One human decision: inline-code backgroundElement vs
31+
upstream's new background.
32+
- beginner/first-time tips + onboarding hint → feature-plugins/home/{tips,tips-view}.tsx
33+
(home is now a plugin-slot shell).
34+
- UpgradeIndicator: component + utils exist only in the old tree, not ported → blocks the
35+
footer + home upgrade-indicator blocks until ported into packages/tui/src/component.
36+
- sidebar trace section → sidebar_content plugin slot.
37+
38+
OLD cli/cmd/tui/** files untouched (deleted later in §3.4 after all re-homing verified).

‎packages/core/src/flag/flag.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ export function truthy(key: string) {
55
return value === "true" || value === "1"
66
}
77

8+
// altimate_change start — dual env var support: ALTIMATE_CLI_* (primary) + OPENCODE_* (fallback).
9+
// Re-homed from packages/opencode/src/flag/flag.ts so the extracted TUI (packages/tui, which
10+
// depends on core not opencode) can read the fork flags it uses.
11+
function altTruthy(altKey: string, openKey: string) {
12+
return truthy(altKey) || truthy(openKey)
13+
}
14+
// altimate_change end
15+
816
const copy = process.env["OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT"]
917
const fff = process.env["OPENCODE_DISABLE_FFF"]
1018

@@ -75,4 +83,22 @@ export const Flag = {
7583
get OPENCODE_CLIENT() {
7684
return process.env["OPENCODE_CLIENT"] ?? "cli"
7785
},
86+
// altimate_change start — fork flags used by the extracted TUI (packages/tui). Getters so the
87+
// runtime-set yolo flag (set by --yolo middleware after module load) evaluates at access time.
88+
get ALTIMATE_CALM_MODE() {
89+
return altTruthy("ALTIMATE_CALM_MODE", "OPENCODE_CALM_MODE")
90+
},
91+
get ALTIMATE_SMOOTH_STREAMING() {
92+
return this.ALTIMATE_CALM_MODE || altTruthy("ALTIMATE_SMOOTH_STREAMING", "OPENCODE_SMOOTH_STREAMING")
93+
},
94+
get ALTIMATE_CLI_YOLO() {
95+
const alt = process.env["ALTIMATE_CLI_YOLO"]
96+
if (alt !== undefined) {
97+
const v = alt.toLowerCase()
98+
return v === "true" || v === "1"
99+
}
100+
const oc = process.env["OPENCODE_YOLO"]?.toLowerCase()
101+
return oc === "true" || oc === "1"
102+
},
103+
// altimate_change end
78104
}

‎packages/tui/src/component/dialog-status.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export function DialogStatus() {
8080
<Match when={item.status === "failed" && item}>{(val) => val().error}</Match>
8181
<Match when={item.status === "disabled"}>Disabled in configuration</Match>
8282
<Match when={(item.status as string) === "needs_auth"}>
83-
Needs authentication (run: opencode mcp auth {key})
83+
{/* altimate_change start — upstream_fix: branding regression */}
84+
Needs authentication (run: altimate mcp auth {key})
85+
{/* altimate_change end */}
8486
</Match>
8587
<Match when={(item.status as string) === "needs_client_registration" && item}>
8688
{(val) => (val() as { error: string }).error}

‎packages/tui/src/component/error-component.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export function ErrorComponent(props: { error: Error; reset: () => void; mode?:
1818
})
1919
const [copied, setCopied] = createSignal(false)
2020

21-
const issueURL = new URL("https://github.com/anomalyco/opencode/issues/new?template=bug-report.yml")
21+
// altimate_change start — upstream_fix: bug-report URL pointed at anomalyco/opencode;
22+
// we file bugs against AltimateAI/altimate-code.
23+
const issueURL = new URL("https://github.com/AltimateAI/altimate-code/issues/new?template=bug-report.yml")
24+
// altimate_change end
2225

2326
// Choose safe fallback colors per mode since theme context may not be available
2427
const isLight = props.mode === "light"
@@ -30,7 +33,10 @@ export function ErrorComponent(props: { error: Error; reset: () => void; mode?:
3033
}
3134

3235
if (props.error.message) {
33-
issueURL.searchParams.set("title", `opentui: fatal: ${props.error.message}`)
36+
// altimate_change start — upstream_fix: prefix said "opentui: fatal:"; we file
37+
// bugs against AltimateAI/altimate-code, so use that prefix instead.
38+
issueURL.searchParams.set("title", `altimate-code: fatal: ${props.error.message}`)
39+
// altimate_change end
3440
}
3541

3642
if (props.error.stack) {

‎packages/tui/src/component/logo.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,21 +856,24 @@ export function Logo(props: { shape?: LogoShape; ink?: RGBA; idle?: boolean } =
856856
<For each={ctx.shape.left}>
857857
{(line, index) => (
858858
<box flexDirection="row" gap={1}>
859+
{/* altimate_change start — upstream merge replaced primary/accent with textMuted/text,
860+
killing the altimate-code brand colors. Restore main's colored rendering. */}
859861
<box flexDirection="row">
860-
{renderLine(line, index(), props.ink ?? theme.textMuted, !!props.ink, 0, frame(), dusk(), idleState())}
862+
{renderLine(line, index(), props.ink ?? theme.primary, !!props.ink, 0, frame(), dusk(), idleState())}
861863
</box>
862864
<box flexDirection="row">
863865
{renderLine(
864866
ctx.shape.right[index()],
865867
index(),
866-
props.ink ?? theme.text,
868+
props.ink ?? theme.accent,
867869
true,
868870
ctx.LEFT + GAP,
869871
frame(),
870872
dusk(),
871873
idleState(),
872874
)}
873875
</box>
876+
{/* altimate_change end */}
874877
</box>
875878
)}
876879
</For>

‎packages/tui/src/context/route.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export const { use: useRoute, provider: RouteProvider } = createSimpleContext({
3535
return store
3636
},
3737
navigate(route: Route) {
38+
// altimate_change start — upstream_fix: navigation debug log was dropped
39+
console.debug("navigate", { route })
40+
// altimate_change end
3841
setStore(reconcile(route))
3942
},
4043
}

‎packages/tui/src/context/sdk.tsx‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,54 @@ export const { use: useSDK, provider: SDKProvider } = createSimpleContext({
5757
queue = []
5858
timer = undefined
5959
last = Date.now()
60+
61+
// altimate_change start - smooth streaming: pre-merge delta events
62+
// When enabled, merge consecutive delta events for the same part+field
63+
// to reduce store updates from N-per-part to 1-per-part per flush cycle.
64+
if (Flag.ALTIMATE_SMOOTH_STREAMING) {
65+
const merged: GlobalEvent[] = []
66+
const deltaMap = new Map<string, number>()
67+
for (const event of events) {
68+
// v2 GlobalEvent nests the discriminated event under `.payload`.
69+
if (event.payload.type === "message.part.delta") {
70+
const props = event.payload.properties as {
71+
messageID: string
72+
partID: string
73+
field: string
74+
delta: string
75+
}
76+
const key = `${props.messageID}:${props.partID}:${props.field}`
77+
const existing = deltaMap.get(key)
78+
if (existing !== undefined) {
79+
const prev = merged[existing]
80+
const prevPayload = prev.payload as { id: string; type: "message.part.delta"; properties: typeof props }
81+
merged[existing] = {
82+
...prev,
83+
payload: {
84+
...prevPayload,
85+
properties: {
86+
...prevPayload.properties,
87+
delta: prevPayload.properties.delta + props.delta,
88+
},
89+
},
90+
} as GlobalEvent
91+
continue
92+
}
93+
deltaMap.set(key, merged.length)
94+
} else {
95+
deltaMap.clear()
96+
}
97+
merged.push(event)
98+
}
99+
batch(() => {
100+
for (const event of merged) {
101+
emitter.emit("event", event)
102+
}
103+
})
104+
return
105+
}
106+
// altimate_change end
107+
60108
// Batch all event emissions so all store updates result in a single render
61109
batch(() => {
62110
for (const event of events) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { useDirectory } from "../../context/directory"
55
import { useConnected } from "../../component/use-connected"
66
import { createStore } from "solid-js/store"
77
import { useRoute } from "../../context/route"
8+
// altimate_change start - yolo mode visual indicator
9+
import { Flag } from "@opencode-ai/core/flag/flag"
10+
// altimate_change end
811

912
export function Footer() {
1013
const { theme } = useTheme()
@@ -60,6 +63,13 @@ export function Footer() {
6063
</text>
6164
</Match>
6265
<Match when={connected()}>
66+
{/* altimate_change start - yolo mode visual indicator */}
67+
<Show when={Flag.ALTIMATE_CLI_YOLO}>
68+
<text fg={theme.warning}>
69+
<span style={{ fg: theme.warning }}>△</span> YOLO
70+
</text>
71+
</Show>
72+
{/* altimate_change end */}
6373
<Show when={permissions().length > 0}>
6474
<text fg={theme.warning}>
6575
<span style={{ fg: theme.warning }}>△</span> {permissions().length} Permission

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
8888

8989
<box flexShrink={0} gap={1} paddingTop={1}>
9090
<pluginRuntime.Slot name="sidebar_footer" mode="single_winner" session_id={props.sessionID}>
91+
{/* altimate_change start — sidebar branding */}
9192
<text fg={theme.textMuted}>
92-
<span style={{ fg: theme.success }}>•</span> <b>Open</b>
93+
<span style={{ fg: theme.success }}>•</span> <b>Altimate</b>
9394
<span style={{ fg: theme.text }}>
94-
<b>Code</b>
95+
<b> Code</b>
9596
</span>{" "}
9697
<span>{InstallationVersion}</span>
9798
</text>
99+
{/* altimate_change end */}
98100
</pluginRuntime.Slot>
99101
</box>
100102
</box>

0 commit comments

Comments
 (0)