Compare commits

..

3 Commits

Author SHA1 Message Date
Kit Langton 2f0eef5c2a fix(tui): stop disabled tab pulse rendering 2026-08-13 11:32:00 -04:00
Kit Langton c253d4d311 fix(tui): highlight queued prompts on hover (#42219) 2026-08-12 22:32:30 -04:00
opencode-agent[bot] 33a1bd2e90 docs(desktop): add Solid best practices guidance (#42211)
Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
2026-08-13 11:56:55 +10:00
8 changed files with 38 additions and 75 deletions
+1
View File
@@ -1036,6 +1036,7 @@
"minimatch": "10.2.5",
"npm-package-arg": "13.0.2",
"resolve.exports": "catalog:",
"xdg-basedir": "5.1.0",
},
"devDependencies": {
"@tsconfig/bun": "catalog:",
+1
View File
@@ -1,5 +1,6 @@
# Desktop package notes
- Follow Solid best practices, leave a comment when violating this: https://www.brenelz.com/posts/solid-js-best-practices/
- Renderer process should only call `window.api` from `src/preload`.
- Main process should register IPC handlers in `src/main/ipc.ts`.
- NEVER hardcode user-visible English strings in production code. ALWAYS use an i18n key for native menus, picker titles, dialogs, buttons, accessible labels, and displayed errors.
+1 -1
View File
@@ -190,7 +190,7 @@ class PulseState {
}
get live() {
return this.active || this.breathing || this.envelopes.some(envelopeActive)
return this.enabled && (this.active || this.breathing || this.envelopes.some(envelopeActive))
}
get running() {
+4 -1
View File
@@ -2089,6 +2089,7 @@ function UserMessage(props: { message: SessionMessageUser }) {
function QueuedPromptDock(props: { prompts: { id: string; text: string }[]; onOpen: () => void }) {
const theme = useTheme("elevated")
const [hover, setHover] = createSignal(false)
const next = createMemo(() => props.prompts[0]?.text.replaceAll("\n", " "))
return (
@@ -2096,6 +2097,8 @@ function QueuedPromptDock(props: { prompts: { id: string; text: string }[]; onOp
border={["left"]}
borderColor={theme.border.default}
customBorderChars={SplitBorder.customBorderChars}
onMouseOver={() => setHover(true)}
onMouseOut={() => setHover(false)}
onMouseUp={props.onOpen}
>
<box
@@ -2104,7 +2107,7 @@ function QueuedPromptDock(props: { prompts: { id: string; text: string }[]; onOp
paddingBottom={1}
paddingLeft={2}
paddingRight={1}
backgroundColor={theme.background.default}
backgroundColor={hover() ? theme.raise(theme.background.default) : theme.background.default}
flexDirection="row"
>
<text fg={theme.text.subdued} wrapMode="none" truncate flexGrow={1} flexShrink={1} minWidth={0}>
@@ -1,6 +1,10 @@
import { expect, test } from "bun:test"
/** @jsxImportSource @opentui/solid */
import { RGBA } from "@opentui/core"
import { testRender } from "@opentui/solid"
import { createSignal } from "solid-js"
import {
TabPulse,
blendTabPulseColor,
completionPulseOpacity,
glowIgnitionLevel,
@@ -9,6 +13,26 @@ import {
} from "../../src/component/tab-pulse"
import { tint } from "../../src/theme/color"
test("a disabled pulse stays idle when it becomes active", async () => {
const background = RGBA.fromHex("#101010")
const [active, setActive] = createSignal(false)
const app = await testRender(
() => <TabPulse enabled={false} active={active()} color={background} backgroundColor={background} />,
{ width: 8, height: 1 },
)
try {
await app.renderOnce()
expect(app.renderer.root.liveCount).toBe(0)
setActive(true)
await app.renderOnce()
expect(app.renderer.root.liveCount).toBe(0)
} finally {
app.renderer.destroy()
}
})
test("completion pulse rises quickly and fades over the remaining duration", () => {
expect(completionPulseOpacity(0)).toBe(0)
expect(completionPulseOpacity(0.06)).toBeCloseTo(0.5)
+2 -1
View File
@@ -52,7 +52,8 @@
"mime-types": "3.0.2",
"minimatch": "10.2.5",
"npm-package-arg": "13.0.2",
"resolve.exports": "catalog:"
"resolve.exports": "catalog:",
"xdg-basedir": "5.1.0"
},
"devDependencies": {
"@tsconfig/bun": "catalog:",
+5 -10
View File
@@ -1,19 +1,14 @@
import os from "os"
import path from "path"
const home = os.homedir()
const data = process.env.XDG_DATA_HOME || (home ? path.join(home, ".local", "share") : undefined)
const cache = process.env.XDG_CACHE_HOME || (home ? path.join(home, ".cache") : undefined)
const config = process.env.XDG_CONFIG_HOME || (home ? path.join(home, ".config") : undefined)
const state = process.env.XDG_STATE_HOME || (home ? path.join(home, ".local", "state") : undefined)
import { xdgCache, xdgConfig, xdgData, xdgState } from "xdg-basedir"
/** The XDG base directories that root opencode's global paths. */
export function roots(app: string) {
return {
data: path.join(data!, app),
cache: path.join(cache!, app),
config: path.join(config!, app),
state: path.join(state!, app),
data: path.join(xdgData!, app),
cache: path.join(xdgCache!, app),
config: path.join(xdgConfig!, app),
state: path.join(xdgState!, app),
tmp: path.join(os.tmpdir(), app),
}
}
-62
View File
@@ -1,62 +0,0 @@
import { describe, expect, test } from "bun:test"
import os from "os"
import path from "path"
import { pathToFileURL } from "url"
const module = pathToFileURL(path.join(import.meta.dir, "../src/global-roots.ts")).href
describe("global roots", () => {
test("uses XDG overrides", () => {
const root = path.join(os.tmpdir(), "opencode-xdg-overrides")
const env = {
XDG_DATA_HOME: path.join(root, "data"),
XDG_CACHE_HOME: path.join(root, "cache"),
XDG_CONFIG_HOME: path.join(root, "config"),
XDG_STATE_HOME: path.join(root, "state"),
}
expect(run(env)).toEqual({
data: path.join(env.XDG_DATA_HOME, "opencode"),
cache: path.join(env.XDG_CACHE_HOME, "opencode"),
config: path.join(env.XDG_CONFIG_HOME, "opencode"),
state: path.join(env.XDG_STATE_HOME, "opencode"),
tmp: path.join(os.tmpdir(), "opencode"),
})
})
test("empty XDG overrides use home directory defaults", () => {
const home = path.join(os.tmpdir(), "opencode-xdg-home")
expect(
run({
XDG_DATA_HOME: "",
XDG_CACHE_HOME: "",
XDG_CONFIG_HOME: "",
XDG_STATE_HOME: "",
...(process.platform === "win32" ? { USERPROFILE: home } : { HOME: home }),
}),
).toEqual({
data: path.join(home, ".local", "share", "opencode"),
cache: path.join(home, ".cache", "opencode"),
config: path.join(home, ".config", "opencode"),
state: path.join(home, ".local", "state", "opencode"),
tmp: path.join(os.tmpdir(), "opencode"),
})
})
})
function run(env: Record<string, string>) {
const result = Bun.spawnSync({
cmd: [
process.execPath,
"-e",
`const { roots } = await import(${JSON.stringify(module)}); console.log(JSON.stringify(roots("opencode")))`,
],
env: { ...process.env, ...env },
stdout: "pipe",
stderr: "pipe",
})
expect(result.exitCode, result.stderr.toString()).toBe(0)
return JSON.parse(result.stdout.toString())
}