Skip to content

Commit 2e7fe6f

Browse files
authored
Merge pull request #28 from d3cker/devel
Release v0.6.7: sidebar compatibility and OpenCode 2.0.15 verification
2 parents a60e05c + b4eb59c commit 2e7fe6f

8 files changed

Lines changed: 159 additions & 37 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ include the full version, for example `## 0.7.0-beta.1`.
88

99
## Unreleased
1010

11+
### Documentation
12+
13+
- Record OpenCode 2.0.15 as the last tested version in README, with the verified
14+
compatibility scope and the distinction between devel and stable v0.6.6.
15+
16+
### Fixed
17+
18+
- Prevent the runtime sidebar from crashing on OpenCode 2.0.10 after semantic
19+
theme tokens changed, including in folders without initialized automation.
20+
Retain 2.0.6 theme support and test both SDK themes in the native renderer.
21+
1122
## 0.6.6
1223

1324
### Documentation
@@ -160,4 +171,4 @@ include the full version, for example `## 0.7.0-beta.1`.
160171
- Add detailed bot workflow diagrams and a documentation map in `AGENTS.md`.
161172
- Expand bundled bot instructions for planning, delegation, verification, and
162173
handing publication back to the dispatcher.
163-
- Add the README banner showing an OpenCode2 agent executing a task.
174+
- Add the README banner showing an OpenCode2 agent executing a task.

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ titles, and can merge after an authorized approval. The TUI is optional.
1111

1212
## Requirements
1313

14-
- OpenCode **2.0.6** with a working model; client/plugin SDK pinned to `2.0.6`.
14+
- OpenCode **2**, last tested with **2.0.15**; a working model is required.
15+
Client/plugin SDK dependencies remain pinned to `2.0.6`.
1516
- Node.js 22+, npm, and Git on macOS/Linux.
1617
- GitHub authentication (`gh auth login` and `gh auth setup-git`, or a token in
1718
the service environment) and permission to comment, push, and create PRs.
1819
- When configuring a project: a primary Git checkout with a GitHub `origin`,
1920
a pushed commit, and issues enabled.
2021

22+
Compatibility checks for the current `devel` build covered SDK type checking,
23+
native sidebar rendering with the 2.0.15 theme, and live session/status RPCs and
24+
GitHub polling. They did not include a new issue-to-PR execution. The sidebar fix
25+
required by newer themes is on `devel` and is not included in stable `v0.6.6`.
26+
2127
Choose **one** installation method below. No target repository is needed yet.
2228
Nothing needs to be published to npm. `$HOME` expands to your home directory.
2329

‎docs/installation.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ No package is published to npm; `private: true` blocks accidental publication.
9999
## TUI rendering and source validation
100100

101101
The runtime sidebar uses the host's OpenTUI/Solid APIs and semantic theme tokens.
102+
It accepts both the 2.0.6 text tokens and the renamed 2.0.10 tokens, where
103+
`base`/`muted` replace `default`/`subdued` and `text.status` is absent.
102104
The package declares OpenTUI and Solid peer dependencies; server entrypoint imports
103105
stay independent of renderer initialization. A sidebar update requires both the
104106
owner plugin's monitor RPC and an updated/reopened TUI. An older or unavailable
@@ -107,9 +109,10 @@ the [OpenCode CLI plugin API](https://opencode.ai/v2/docs/build/plugins/cli/).
107109

108110
For development, `npm ci` installs pinned renderer, theme and Bun test dependencies.
109111
`npm run check` includes `npm run test:tui`, which renders the actual sidebar using
110-
Bun's native OpenTUI support and checks live updates, stale readings, tab selection
111-
and a narrow layout. Bun is needed for this native renderer test, not for the
112-
Node-based management CLI. Package validation still imports the server and TUI
112+
Bun's native OpenTUI support with resolved themes from both OpenCode 2.0.6 and
113+
2.0.10. It checks startup without a configured owner, unavailable status, live
114+
updates, stale readings, tab selection and a narrow layout. Bun is needed for this
115+
native renderer test, not for the Node-based management CLI. Package validation still imports the server and TUI
113116
entrypoints in an isolated Node installation without initializing a renderer.
114117

115118
## Testing and migration

‎docs/runtime.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,10 @@ scheduler jobs and truncates long labels/errors. `/bot` manages task sessions;
430430

431431
The TUI and owner plugin must both contain the monitor API. With an older server,
432432
an unloaded/unconfigured owner, a direct worktree-only launch, or a failed RPC,
433-
the panel reports unavailable status. Load the configured owner and update both
434-
sides as needed; reopen TUI clients after installation. Monitoring uses the
433+
the panel reports unavailable status. Opening an unconfigured folder does not
434+
initialize automation. The panel supports both OpenCode 2.0.6 and 2.0.10 theme
435+
structures, including while connecting or displaying unavailable status. Load the
436+
configured owner and update both sides as needed; reopen TUI clients after installation. Monitoring uses the
435437
connected OpenCode client, so it also works with a remote service when the correct
436438
owner location and updated plugin are available there. Live worker/scan diagnostics
437439
reset when the owner is recreated; task checkpoints and scheduler history remain

‎package-lock.json‎

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

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"devDependencies": {
4848
"@eslint/js": "^10.0.1",
4949
"@opencode/theme": "2.0.6",
50+
"@opencode/theme-current": "npm:@opencode/theme@2.0.10",
5051
"@opentui/core": "0.5.10",
5152
"@opentui/solid": "0.5.10",
5253
"@types/node": "^22.0.0",

‎src/sidebar.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
import type { RGBA } from "@opentui/core";
12
import type { Plugin } from "@opencode/plugin/tui";
23
import { jsx } from "@opentui/solid/jsx-runtime";
34
import { createSignal } from "solid-js";
45
import { GithubRpc, SchedulerRpc } from "./rpc.js";
56
import { RuntimePoller, runtimeLines, selectedTask, type RuntimeSnapshot } from "./runtime-panel.js";
67

8+
// OpenCode 2.0.10 renamed semantic text tokens and removed text.status.
9+
// Keep the adapter structural so the pinned 2.0.6 SDK remains supported.
10+
type SidebarTheme = { text: {
11+
base?: RGBA; default?: RGBA; muted?: RGBA; subdued?: RGBA;
12+
status?: { running?: RGBA };
13+
action?: { primary?: { base?: RGBA; default?: RGBA } };
14+
feedback?: { error?: { base?: RGBA; default?: RGBA }; warning?: { base?: RGBA; default?: RGBA } };
15+
} };
16+
17+
function sidebarColor(theme: SidebarTheme, tone: string | undefined) {
18+
const text = theme.text;
19+
const base = text.base ?? text.default;
20+
if (tone === "error" || tone === "warning") return text.feedback?.[tone]?.base ?? text.feedback?.[tone]?.default ?? base;
21+
if (tone === "heading") return text.action?.primary?.base ?? text.status?.running ?? base;
22+
if (tone === "muted") return text.muted ?? text.subdued ?? base;
23+
return base;
24+
}
25+
726
export function RuntimeSidebar(props: { context: Plugin.Context; snapshot: () => RuntimeSnapshot; now: () => number; sessionID: string }) {
8-
const theme = props.context.theme;
927
return jsx("box", { flexDirection: "column", marginTop: 1, flexShrink: 0,
1028
get children() {
1129
const snapshot = props.snapshot();
@@ -14,7 +32,7 @@ export function RuntimeSidebar(props: { context: Plugin.Context; snapshot: () =>
1432
? props.context.data.session.status(task.sessionID) : undefined;
1533
return runtimeLines(snapshot, props.now(), props.sessionID, sessionStatus).map(line => jsx("text", {
1634
content: line.text, wrapMode: "word", marginTop: line.tone === "heading" ? 1 : 0,
17-
fg: line.tone === "error" ? theme.text.feedback.error.default : line.tone === "warning" ? theme.text.feedback.warning.default : line.tone === "heading" ? theme.text.status.running : line.tone === "muted" ? theme.text.subdued : theme.text.default,
35+
fg: sidebarColor(props.context.theme, line.tone),
1836
}));
1937
},
2038
});

‎test/fixtures/sidebar-render.ts‎

Lines changed: 96 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,101 @@ import { writeFile } from "node:fs/promises";
33
import type { Plugin } from "@opencode/plugin/tui";
44
import { testRender } from "@opentui/solid";
55
import { createSignal } from "solid-js";
6-
import { RGBA } from "@opentui/core";
6+
import { DEFAULT_THEME, resolveThemeDocument } from "@opencode/theme/tui";
7+
import { migrateV1, resolveThemeDocument as resolveCurrentTheme } from "@opencode/theme-current/tui";
78
import { RuntimeSidebar } from "../../src/sidebar.js";
89
import type { RuntimeSnapshot } from "../../src/runtime-panel.js";
9-
const color = (hex: string) => RGBA.fromHex(hex);
10-
const theme = { text: { default: color("#eeeeee"), subdued: color("#999999"), status: { running: color("#00d7af") }, feedback: { warning: { default: color("#ffaf00") }, error: { default: color("#ff5f5f") } } } };
11-
const snapshot: RuntimeSnapshot = { dispatcherAt: 10000, schedulerAt: 10000,
12-
dispatcher: { ownerDirectory: "/repo", worker: "executing", activeTask: "owner/repo#18", scanning: true,
13-
tasks: [{ key: "owner/repo#18", repo: "owner/repo", issueNumber: 18, round: 4, phase: "running", status: "ready", sessionReady: true, sessionID: "s", branch: "thirst-for-levels", baseBranch: "main", model: "deepseek/deepseek-v4", prNumber: 19, prState: "open", pendingFeedback: 1 }] },
14-
scheduler: [{ id: "github-issues", running: true, paused: false, nextAt: 12000, failures: 0 }],
15-
};
16-
const context = { theme, data: { session: { get: () => ({}), status: () => "running" } } } as unknown as Plugin.Context;
17-
const [state, setState] = createSignal(snapshot);
18-
const [sessionID, setSession] = createSignal("s");
19-
const view = await testRender(() => RuntimeSidebar({ context, snapshot: state, now: () => 10000, get sessionID() { return sessionID(); } }), { width: 36, height: 38 });
20-
try {
21-
await view.renderOnce();
22-
const frame = view.captureCharFrame();
23-
assert.match(frame, /BOT RUNTIME/); assert.match(frame, /Session execution/);
24-
assert.match(frame, /Scheduler: Running/); assert.match(frame, /PR #19/); assert.match(frame, /\/botstatus/);
25-
await writeFile(process.env.PANEL_FRAME ?? "/tmp/opencode-sidebar-frame.txt", frame);
26-
setState({ ...snapshot, dispatcherError: "Disconnected", schedulerError: "Disconnected" });
27-
await view.renderOnce();
28-
assert.match(view.captureCharFrame(), /STALE \/ partial data/);
29-
setState({ ...snapshot, dispatcher: { ...snapshot.dispatcher!, tasks: [...snapshot.dispatcher!.tasks, { key: "owner/repo#22", repo: "owner/repo", issueNumber: 22, round: 1, status: "waiting", phase: "running", sessionID: "other", sessionReady: true, question: "permission" }] } });
30-
setSession("other"); await view.renderOnce();
31-
assert.match(view.captureCharFrame(), /Waiting for permission/);
32-
view.resize(28, 45); await view.renderOnce();
33-
assert.match(view.captureCharFrame(), /\/botstatus/);
34-
console.log("Native sidebar render: running, stale, session switch and narrow layout passed");
35-
} finally { view.renderer.destroy(); }
10+
const legacyTheme = resolveThemeDocument(DEFAULT_THEME, "dark");
11+
// Resolve through each real SDK instead of mocking its output token structure.
12+
const currentTheme = resolveCurrentTheme(migrateV1({ theme: {
13+
primary: "#aabbcc",
14+
secondary: "#aabbcc",
15+
accent: "#aabbcc",
16+
error: "#aabbcc",
17+
warning: "#aabbcc",
18+
success: "#aabbcc",
19+
info: "#aabbcc",
20+
text: "#aabbcc",
21+
textMuted: "#aabbcc",
22+
background: "#aabbcc",
23+
backgroundPanel: "#aabbcc",
24+
backgroundElement: "#aabbcc",
25+
border: "#aabbcc",
26+
borderActive: "#aabbcc",
27+
borderSubtle: "#aabbcc",
28+
diffAdded: "#aabbcc",
29+
diffRemoved: "#aabbcc",
30+
diffContext: "#aabbcc",
31+
diffHunkHeader: "#aabbcc",
32+
diffHighlightAdded: "#aabbcc",
33+
diffHighlightRemoved: "#aabbcc",
34+
diffAddedBg: "#aabbcc",
35+
diffRemovedBg: "#aabbcc",
36+
diffContextBg: "#aabbcc",
37+
diffLineNumber: "#aabbcc",
38+
diffAddedLineNumberBg: "#aabbcc",
39+
diffRemovedLineNumberBg: "#aabbcc",
40+
markdownText: "#aabbcc",
41+
markdownHeading: "#aabbcc",
42+
markdownLink: "#aabbcc",
43+
markdownLinkText: "#aabbcc",
44+
markdownCode: "#aabbcc",
45+
markdownBlockQuote: "#aabbcc",
46+
markdownEmph: "#aabbcc",
47+
markdownStrong: "#aabbcc",
48+
markdownHorizontalRule: "#aabbcc",
49+
markdownListItem: "#aabbcc",
50+
markdownListEnumeration: "#aabbcc",
51+
markdownImage: "#aabbcc",
52+
markdownImageText: "#aabbcc",
53+
markdownCodeBlock: "#aabbcc",
54+
syntaxComment: "#aabbcc",
55+
syntaxKeyword: "#aabbcc",
56+
syntaxFunction: "#aabbcc",
57+
syntaxVariable: "#aabbcc",
58+
syntaxString: "#aabbcc",
59+
syntaxNumber: "#aabbcc",
60+
syntaxType: "#aabbcc",
61+
syntaxOperator: "#aabbcc",
62+
syntaxPunctuation: "#aabbcc",
63+
} }), "dark");
64+
// OpenTUI may shut down the process after a render error. Never report success
65+
// unless both complete render scenarios reached their final assertions.
66+
let completed = 0;
67+
process.on("exit", () => { if (completed !== 2) process.exitCode = 1; });
68+
for (const theme of [legacyTheme, currentTheme]) {
69+
const snapshot: RuntimeSnapshot = { dispatcherAt: 10000, schedulerAt: 10000,
70+
dispatcher: { ownerDirectory: "/repo", worker: "executing", activeTask: "owner/repo#18", scanning: true,
71+
tasks: [{ key: "owner/repo#18", repo: "owner/repo", issueNumber: 18, round: 4, phase: "running", status: "ready", sessionReady: true, sessionID: "s", branch: "thirst-for-levels", baseBranch: "main", model: "deepseek/deepseek-v4", prNumber: 19, prState: "open", pendingFeedback: 1 }] },
72+
scheduler: [{ id: "github-issues", running: true, paused: false, nextAt: 12000, failures: 0 }],
73+
};
74+
const context = { theme, data: { session: { get: () => ({}), status: () => "running" } } } as unknown as Plugin.Context;
75+
const [state, setState] = createSignal<RuntimeSnapshot>({});
76+
const [sessionID, setSession] = createSignal("s");
77+
const view = await testRender(() => RuntimeSidebar({ context, snapshot: state, now: () => 10000, get sessionID() { return sessionID(); } }), { width: 36, height: 38 });
78+
try {
79+
await view.renderOnce();
80+
assert.match(view.captureCharFrame(), /Connecting to owner/);
81+
setState({ dispatcherError: "Unconfigured owner", schedulerError: "Unconfigured owner" });
82+
await view.renderOnce();
83+
assert.match(view.captureCharFrame(), /Dispatcher unavailable/);
84+
assert.match(view.captureCharFrame(), /Scheduler unavailable/);
85+
setState(snapshot);
86+
await view.renderOnce();
87+
const frame = view.captureCharFrame();
88+
assert.match(frame, /BOT RUNTIME/); assert.match(frame, /Session execution/);
89+
assert.match(frame, /Scheduler: Running/); assert.match(frame, /PR #19/); assert.match(frame, /\/botstatus/);
90+
await writeFile(process.env.PANEL_FRAME ?? "/tmp/opencode-sidebar-frame.txt", frame);
91+
setState({ ...snapshot, dispatcherError: "Disconnected", schedulerError: "Disconnected" });
92+
await view.renderOnce();
93+
assert.match(view.captureCharFrame(), /STALE \/ partial data/);
94+
setState({ ...snapshot, dispatcher: { ...snapshot.dispatcher!, tasks: [...snapshot.dispatcher!.tasks, { key: "owner/repo#22", repo: "owner/repo", issueNumber: 22, round: 1, status: "waiting", phase: "running", sessionID: "other", sessionReady: true, question: "permission" }] } });
95+
setSession("other"); await view.renderOnce();
96+
assert.match(view.captureCharFrame(), /Waiting for permission/);
97+
view.resize(28, 45); await view.renderOnce();
98+
assert.match(view.captureCharFrame(), /\/botstatus/);
99+
completed++;
100+
console.log("Native sidebar render: unconfigured, running, stale, session switch and narrow layout passed");
101+
} finally { view.renderer.destroy(); }
102+
103+
}

0 commit comments

Comments
 (0)