mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
feat(tui): make notification and sound alerts independent toggles
Remove the attention.enabled master switch. Notifications and sounds are now enabled independently and both default to off. Existing enabled keys are ignored; there is no migration.
This commit is contained in:
@@ -128,7 +128,7 @@ export function createTuiAttention(input: {
|
||||
return {
|
||||
async notify(request) {
|
||||
try {
|
||||
if (!input.config.attention.enabled) return skipped("attention_disabled")
|
||||
if (!input.config.attention.notifications && !input.config.attention.sound) return skipped("attention_disabled")
|
||||
if (disposed || input.renderer.isDestroyed) return skipped("renderer_destroyed")
|
||||
|
||||
const message = normalizeText(request.message, "", MESSAGE_LIMIT)
|
||||
|
||||
@@ -253,20 +253,11 @@ export const settings: Setting[] = [
|
||||
format: (value) => `${value} ms`,
|
||||
keywords: ["leader key", "shortcut timeout"],
|
||||
},
|
||||
{
|
||||
title: "Attention",
|
||||
category: "Alerts",
|
||||
path: ["attention", "enabled"],
|
||||
default: false,
|
||||
values: [false, true],
|
||||
labels: ["off", "on"],
|
||||
keywords: ["alerts"],
|
||||
},
|
||||
{
|
||||
title: "Notifications",
|
||||
category: "Alerts",
|
||||
path: ["attention", "notifications"],
|
||||
default: true,
|
||||
default: false,
|
||||
values: [false, true],
|
||||
labels: ["off", "on"],
|
||||
keywords: ["system notifications", "desktop notifications", "alerts"],
|
||||
@@ -275,10 +266,10 @@ export const settings: Setting[] = [
|
||||
title: "Sounds",
|
||||
category: "Alerts",
|
||||
path: ["attention", "sound"],
|
||||
default: true,
|
||||
default: false,
|
||||
values: [false, true],
|
||||
labels: ["off", "on"],
|
||||
keywords: ["audio", "sound effects"],
|
||||
keywords: ["audio", "sound effects", "alerts"],
|
||||
},
|
||||
{
|
||||
title: "Volume",
|
||||
|
||||
@@ -95,7 +95,6 @@ export const Info = Schema.Struct({
|
||||
).annotate({ description: "Scrolling behavior" }),
|
||||
attention: Schema.optional(
|
||||
Schema.Struct({
|
||||
enabled: Schema.optional(Schema.Boolean).annotate({ description: "Enable attention alerts" }),
|
||||
notifications: Schema.optional(Schema.Boolean).annotate({ description: "Show system notifications" }),
|
||||
sound: Schema.optional(Schema.Boolean).annotate({ description: "Play attention sounds" }),
|
||||
volume: Schema.optional(
|
||||
@@ -242,7 +241,6 @@ export type Info = Schema.Schema.Type<typeof Info>
|
||||
|
||||
export type Resolved = Omit<Info, "attention" | "cursor" | "keybinds" | "leader" | "mouse" | "session" | "tabs"> & {
|
||||
attention: {
|
||||
enabled: boolean
|
||||
notifications: boolean
|
||||
sound: boolean
|
||||
volume: number
|
||||
@@ -285,9 +283,8 @@ export function resolve(input: Info, options: { terminalSuspend: boolean }): Res
|
||||
return {
|
||||
...input,
|
||||
attention: {
|
||||
enabled: input.attention?.enabled ?? false,
|
||||
notifications: input.attention?.notifications ?? true,
|
||||
sound: input.attention?.sound ?? true,
|
||||
notifications: input.attention?.notifications ?? false,
|
||||
sound: input.attention?.sound ?? false,
|
||||
volume: input.attention?.volume ?? 0.4,
|
||||
sound_pack: input.attention?.sound_pack ?? "opencode.default",
|
||||
sounds: input.attention?.sounds ?? {},
|
||||
|
||||
@@ -108,12 +108,11 @@ Set scroll speed and acceleration:
|
||||
|
||||
## Attention
|
||||
|
||||
Configure notifications and sounds:
|
||||
Configure notifications and sounds. Both are off by default and can be enabled independently:
|
||||
|
||||
```json title="cli.json"
|
||||
{
|
||||
"attention": {
|
||||
"enabled": true,
|
||||
"notifications": true,
|
||||
"sound": true,
|
||||
"volume": 0.4,
|
||||
@@ -127,8 +126,7 @@ Configure notifications and sounds:
|
||||
|
||||
| Field | Values | Description |
|
||||
| --------------- | ---------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `enabled` | boolean | Enables attention alerts. |
|
||||
| `notifications` | boolean | Shows system notifications. |
|
||||
| `notifications` | boolean | Shows system notifications when the terminal is not focused. |
|
||||
| `sound` | boolean | Plays attention sounds. |
|
||||
| `volume` | number from `0` to `1` | Sets sound volume. |
|
||||
| `sound_pack` | string | Selects the active sound pack. |
|
||||
|
||||
Reference in New Issue
Block a user