Add TUI notifications and attention sounds (disabled by default) (#26980)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { afterEach, beforeEach, expect, test } from "bun:test"
|
||||
import path from "path"
|
||||
import fs from "fs/promises"
|
||||
import { pathToFileURL } from "url"
|
||||
import { provideTestInstance, tmpdir } from "../fixture/fixture"
|
||||
import { InstanceRuntime } from "@/project/instance-runtime"
|
||||
import { TuiConfig } from "../../src/cli/cmd/tui/config/tui"
|
||||
@@ -142,6 +143,59 @@ test("loads tui config with the same precedence order as server config paths", a
|
||||
expect(config.diff_style).toBe("stacked")
|
||||
})
|
||||
|
||||
test("resolves attention config defaults and overrides", async () => {
|
||||
await using defaults = await tmpdir()
|
||||
expect((await getTuiConfig(defaults.path)).attention).toEqual({
|
||||
enabled: false,
|
||||
notifications: true,
|
||||
sound: true,
|
||||
volume: 0.4,
|
||||
sound_pack: "opencode.default",
|
||||
sounds: {},
|
||||
})
|
||||
|
||||
await using overridden = await tmpdir({
|
||||
init: async (dir) => {
|
||||
await Bun.write(
|
||||
path.join(dir, "tui.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
attention: {
|
||||
enabled: false,
|
||||
notifications: false,
|
||||
sound: false,
|
||||
volume: 0.7,
|
||||
sound_pack: "acme.soft",
|
||||
sounds: {
|
||||
default: path.join(dir, "default.mp3"),
|
||||
question: pathToFileURL(path.join(dir, "question.mp3")).href,
|
||||
error: "./error.mp3",
|
||||
subagent_done: "./subagent-done.mp3",
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
expect((await getTuiConfig(overridden.path)).attention).toEqual({
|
||||
enabled: false,
|
||||
notifications: false,
|
||||
sound: false,
|
||||
volume: 0.7,
|
||||
sound_pack: "acme.soft",
|
||||
sounds: {
|
||||
default: path.join(overridden.path, "default.mp3"),
|
||||
question: path.join(overridden.path, "question.mp3"),
|
||||
error: path.join(overridden.path, "error.mp3"),
|
||||
subagent_done: path.join(overridden.path, "subagent-done.mp3"),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("migrates tui-specific keys from opencode.json when tui.json does not exist", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
|
||||
Reference in New Issue
Block a user