Options -> Meldungen: multiple-choice text position (Server/Channel/Client), 'only important sounds' when muted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-23 20:38:13 +00:00
1 parent b808e2ec99
commit 14aa44c1c9
8 files changed
+114 -37

No files matched your search

+21
View File
@@ -4851,3 +4851,24 @@
.ts-notify-tree select {
font-size: 1em;
}
.ts-notify-text {
position: relative;
}
.ts-notify-text > summary {
cursor: pointer;
list-style: none;
}
.ts-notify-text > summary::after {
content: " ▾";
opacity: 0.6;
}
.ts-notify-text-menu {
position: absolute;
right: 0;
z-index: 2;
display: flex;
flex-direction: column;
padding: 4px 8px;
background: var(--bg-toolbar-1);
border: 1px solid var(--border);
}
+54 -19
View File
@@ -150,17 +150,18 @@ import {
importSoundPack,
isSpecialKey,
loadSoundPacks,
notificationTextPosition,
notificationTextPositions,
notify,
packScript,
runSoundScript,
saveNotificationSettings,
setNotificationPlaybackMuted,
setSessionSoundPack,
textPositionChoices,
type NotificationNode,
type NotificationOverride,
type NotificationSettings,
type SoundPack,
type TextPosition,
} from "./notifications";
import {
iconPackCss,
@@ -1982,6 +1983,8 @@ interface PmMessage {
fromSelf: boolean;
message: string;
fromLog?: boolean;
/** Notification text (Options -> Meldungen -> Text Position "Client"). */
isLog?: boolean;
}
interface PmThread {
@@ -6735,14 +6738,14 @@ function MeldungenPanel({
setSettings(next);
};
const defaultScript = (key: string) => packScript(pack, settings.pack, key);
const override = (keys: string[], patch: { off?: boolean; script?: string; text?: TextPosition }) => {
const override = (keys: string[], patch: NotificationOverride) => {
const overrides = { ...settings.overrides };
for (const key of keys) {
const merged = { ...overrides[key], ...patch };
// Values equal to the default aren't overrides (that's what makes a row bold).
if (!merged.off) delete merged.off;
if (merged.script === defaultScript(key)) delete merged.script;
if (merged.text === "server") delete merged.text;
if (merged.text?.join() === "server") delete merged.text;
if (Object.keys(merged).length) overrides[key] = merged;
else delete overrides[key];
}
@@ -6766,6 +6769,7 @@ function MeldungenPanel({
const key = node.key;
const o = settings.overrides[key];
const script = o?.script ?? defaultScript(key);
const text = Array.isArray(o?.text) ? o.text : ["server"];
return (
<tr key={id} className={o ? "ts-notify-custom" : undefined}>
<td style={indent}>
@@ -6792,14 +6796,25 @@ function MeldungenPanel({
</td>
<td>
{!special && (
<select
value={o?.text ?? "server"}
onChange={(e) => override([key], { text: e.target.value as TextPosition })}
>
<option value="none">{t("notify.text.none")}</option>
<option value="server">{t("notify.text.server")}</option>
<option value="channel">{t("notify.text.channel")}</option>
</select>
<details className="ts-notify-text">
<summary>{text.map((p) => t(`notify.text.${p}`)).join(", ") || "—"}</summary>
<div className="ts-notify-text-menu">
{textPositionChoices(key).map((p) => (
<label key={p} className="ts-options-checkbox">
<input
type="checkbox"
checked={text.includes(p)}
onChange={(e) =>
override([key], {
text: textPositionChoices(key).filter((c) => (c === p ? e.target.checked : text.includes(c))),
})
}
/>
{t(`notify.text.${p}`)}
</label>
))}
</div>
</details>
)}
</td>
</tr>
@@ -6892,6 +6907,7 @@ function MeldungenPanel({
onChange={(e) => save({ ...settings, whenMuted: e.target.value as NotificationSettings["whenMuted"] })}
>
<option value="all">{t("notify.whenMuted.all")}</option>
<option value="important">{t("notify.whenMuted.important")}</option>
<option value="none">{t("notify.whenMuted.none")}</option>
</select>
</div>
@@ -9658,11 +9674,22 @@ function AppInner() {
const key = SERVER_LOG_NOTIFICATIONS[data.kind as keyof typeof SERVER_LOG_NOTIFICATIONS];
// Join/leave/switch sounds come from the channel diff above; these only place the text.
if (!["clientJoin", "clientLeave", "clientChannelSwitch"].includes(data.kind)) void notify(key);
const position = notificationTextPosition(key);
if (position !== "none")
(position === "channel" ? setChat : setServerChat)((prev) =>
capLines([...prev, { from: "", message, isLog: true }], chatSettingsRef.current.maxLines)
);
const maxLines = chatSettingsRef.current.maxLines;
for (const position of notificationTextPositions(key)) {
if (position === "client") {
// Into an open private chat with that client, if there is one.
const client = "client" in data ? data.client : undefined;
setPmThreads((prev) => {
const thread = Object.values(prev).find((th) => th.partnerName === client);
if (!thread) return prev;
const messages = capLines([...thread.messages, { fromSelf: false, message, isLog: true }], maxLines);
return { ...prev, [thread.partnerId]: { ...thread, messages } };
});
} else
(position === "channel" ? setChat : setServerChat)((prev) =>
capLines([...prev, { from: "", message, isLog: true }], maxLines)
);
}
break;
}
case "disconnected": {
@@ -13957,7 +13984,11 @@ function AppInner() {
}}
>
{activeTab === "channel"
? chat.map((entry, i) => (
? chat.map((entry, i) => entry.isLog ? (
<div key={i} className="ts-chat-line ts-chat-line-log">
<span>{entry.message}</span>
</div>
) : (
<div
key={i}
className={`ts-chat-line${entry.from === ownClient?.name ? " ts-chat-line-self" : ""}${
@@ -13984,7 +14015,11 @@ function AppInner() {
</div>
)
)
: pmThreads[activeTab]?.messages.map((entry, i) => (
: pmThreads[activeTab]?.messages.map((entry, i) => entry.isLog ? (
<div key={i} className="ts-chat-line ts-chat-line-log">
<span>{entry.message}</span>
</div>
) : (
<div
key={i}
className={`ts-chat-line${entry.fromSelf ? " ts-chat-line-self" : ""}${
+3 -2
View File
@@ -899,10 +899,11 @@
"notify.col.action": "Akce",
"notify.col.script": "Zvukový skript",
"notify.col.text": "Pozice textu",
"notify.text.none": "Žádná",
"notify.text.server": "Server",
"notify.text.channel": "Kanál",
"notify.resetAll": "Obnovit všechny změny",
"notify.applyToFavorites": "Použít tento zvukový balíček pro všechny oblíbené",
"notify.applyToFavoritesConfirm": "Nastavit všem oblíbeným tento zvukový balíček? Vlastní balíčky jednotlivých oblíbených budou zrušeny."
"notify.applyToFavoritesConfirm": "Nastavit všem oblíbeným tento zvukový balíček? Vlastní balíčky jednotlivých oblíbených budou zrušeny.",
"notify.whenMuted.important": "Přehrávat jen důležité zvuky",
"notify.text.client": "Klient"
}
+3 -2
View File
@@ -899,10 +899,11 @@
"notify.col.action": "Aktion",
"notify.col.script": "Sound Skript",
"notify.col.text": "Text Position",
"notify.text.none": "Keine",
"notify.text.server": "Server",
"notify.text.channel": "Channel",
"notify.resetAll": "Alle Anpassungen zurücksetzen",
"notify.applyToFavorites": "Dieses Sound Pack für alle Favoriten verwenden",
"notify.applyToFavoritesConfirm": "Alle Favoriten auf dieses Sound Pack setzen? Eigene Sound Packs einzelner Favoriten werden dabei zurückgesetzt."
"notify.applyToFavoritesConfirm": "Alle Favoriten auf dieses Sound Pack setzen? Eigene Sound Packs einzelner Favoriten werden dabei zurückgesetzt.",
"notify.whenMuted.important": "Nur wichtige Sounds spielen",
"notify.text.client": "Client"
}
+3 -2
View File
@@ -899,10 +899,11 @@
"notify.col.action": "Action",
"notify.col.script": "Sound script",
"notify.col.text": "Text position",
"notify.text.none": "None",
"notify.text.server": "Server",
"notify.text.channel": "Channel",
"notify.resetAll": "Reset all changes",
"notify.applyToFavorites": "Use this sound pack for all favorites",
"notify.applyToFavoritesConfirm": "Set all favorites to this sound pack? Sound packs set on individual favorites will be reset."
"notify.applyToFavoritesConfirm": "Set all favorites to this sound pack? Sound packs set on individual favorites will be reset.",
"notify.whenMuted.important": "Play only important sounds",
"notify.text.client": "Client"
}
+3 -2
View File
@@ -898,10 +898,11 @@
"notify.col.action": "رویداد",
"notify.col.script": "اسکریپت صدا",
"notify.col.text": "محل متن",
"notify.text.none": "هیچ",
"notify.text.server": "سرور",
"notify.text.channel": "کانال",
"notify.resetAll": "بازنشانی همه تغییرات",
"notify.applyToFavorites": "استفاده از این بسته صدا برای همه موارد علاقه",
"notify.applyToFavoritesConfirm": "همه موارد علاقه روی این بسته صدا تنظیم شوند؟ بسته‌های صدای جداگانه بازنشانی می‌شوند."
"notify.applyToFavoritesConfirm": "همه موارد علاقه روی این بسته صدا تنظیم شوند؟ بسته‌های صدای جداگانه بازنشانی می‌شوند.",
"notify.whenMuted.important": "فقط صداهای مهم پخش شوند",
"notify.text.client": "کلاینت"
}
+3 -2
View File
@@ -898,10 +898,11 @@
"notify.col.action": "动作",
"notify.col.script": "声音脚本",
"notify.col.text": "文本位置",
"notify.text.none": "无",
"notify.text.server": "服务器",
"notify.text.channel": "频道",
"notify.resetAll": "重置所有更改",
"notify.applyToFavorites": "将此声音包用于所有收藏",
"notify.applyToFavoritesConfirm": "将所有收藏设为此声音包?单个收藏的声音包设置将被重置。"
"notify.applyToFavoritesConfirm": "将所有收藏设为此声音包?单个收藏的声音包设置将被重置。",
"notify.whenMuted.important": "仅播放重要声音",
"notify.text.client": "客户端"
}
+24 -8
View File
@@ -151,17 +151,20 @@ export interface SoundPack {
files: Record<string, Blob>;
}
export type TextPosition = "none" | "server" | "channel";
/** Where an event's text line goes; several at once, like native's multiple choice.
* "client" = the private chat with the client it's about. */
export type TextPosition = "server" | "channel" | "client";
export interface NotificationOverride {
off?: boolean;
script?: string;
text?: TextPosition;
text?: TextPosition[];
}
export interface NotificationSettings {
pack: string;
whenMuted: "all" | "none";
/** "important": only IMPORTANT_KEYS while the output is muted. */
whenMuted: "all" | "important" | "none";
overrides: Record<string, NotificationOverride>;
}
@@ -269,12 +272,24 @@ export function packScript(pack: SoundPack | undefined, packId: string, key: str
return pack?.scripts[key] ?? "";
}
/** Text positions native offers for a key: everything gets Server, events about
* channels/yourself also Channel, events about another client also Client. */
export function textPositionChoices(key: string): TextPosition[] {
if (key.startsWith("CLIENT_") || key === "OTHER_RECEIVED_POKE") return ["server", "channel", "client"];
if (/^(CHANNEL|YOU|CHAT)_/.test(key)) return ["server", "channel"];
return ["server"];
}
// ponytail: guessed set, native doesn't document which sounds count as "wichtig".
const IMPORTANT_KEYS = /^(CONNECTION_|YOU_WERE_|SOUND_|OTHER_RECEIVED_POKE$|SERVER_ERROR$)/;
export const isNotificationEnabled = (key: string) => isSpecialKey(key) || !settings.overrides[key]?.off;
/** Where the event's text goes; "none" also when the row is unticked. */
export function notificationTextPosition(key: string): TextPosition {
if (!isNotificationEnabled(key)) return "none";
return settings.overrides[key]?.text ?? "server";
/** Where the event's text goes; nowhere when the row is unticked. */
export function notificationTextPositions(key: string): TextPosition[] {
if (!isNotificationEnabled(key)) return [];
const text = settings.overrides[key]?.text;
return Array.isArray(text) ? text : ["server"];
}
export type NotificationVars = Record<string, string>;
@@ -298,7 +313,8 @@ export async function runSoundScript(script: string, packId: string, vars: Notif
/** Plays the sound for a TS3 notification key, honouring the Meldungen settings. */
export async function notify(key: string, vars?: NotificationVars): Promise<void> {
if (!isNotificationEnabled(key)) return;
if (playbackMuted && settings.whenMuted === "none") return;
if (playbackMuted && (settings.whenMuted === "none" || (settings.whenMuted === "important" && !IMPORTANT_KEYS.test(key))))
return;
const packId = sessionPack ?? settings.pack;
const override = settings.overrides[key]?.script;
const pack = packId.startsWith("pack:") ? (await loadSoundPacks()).find((p) => p.id === packId) : undefined;