From c4c464b0da111dec567ace3a58569e9e25262676 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Mon, 19 Oct 2026 18:55:50 +0000 Subject: [PATCH] fix(config): keep watchBase when the config is read (0.45.4) readConfig whitelists its fields, so a watchBase written to config.json was dropped and the guide linked live rooms at the server's own :4321 address, not live.streaming. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- src/library.ts | 1 + test/guide-rooms.test.ts | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 13dd2a3..13c7b2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nixamp", - "version": "0.45.3", + "version": "0.45.4", "description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.", "license": "MIT", "type": "module", diff --git a/src/library.ts b/src/library.ts index 572985d..42b6a08 100644 --- a/src/library.ts +++ b/src/library.ts @@ -59,6 +59,7 @@ export function readConfig(): Config { ...(Array.isArray(record["guideHosts"]) ? { guideHosts: (record["guideHosts"] as unknown[]).filter((one): one is string => typeof one === "string") } : {}), ...(typeof record["guideAds"] === "object" && record["guideAds"] !== null ? { guideAds: record["guideAds"] as Config["guideAds"] } : {}), ...(Array.isArray(record["guidePeers"]) ? { guidePeers: (record["guidePeers"] as unknown[]).filter((one): one is string => typeof one === "string") } : {}), + ...(typeof record["watchBase"] === "string" ? { watchBase: record["watchBase"] } : {}), }; } catch { return {}; diff --git a/test/guide-rooms.test.ts b/test/guide-rooms.test.ts index f80eff5..76b39c5 100644 --- a/test/guide-rooms.test.ts +++ b/test/guide-rooms.test.ts @@ -5,7 +5,8 @@ import type { AddressInfo } from "node:net"; import { mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleRooms, RoomProbe, roomAddress, roomEntries, RoomStore, ROOMS_PER_MEMBER, watchPage } from "../src/guide-rooms.ts"; +import { handleRooms, RoomProbe, roomAddress, roomEntries, RoomStore, ROOMS_PER_MEMBER, watchBase, watchPage } from "../src/guide-rooms.ts"; +import { readConfig, writeConfig } from "../src/library.ts"; import { renderGuide } from "../src/station-guide.ts"; const PLAY = "https://server1.chovy.nixamp.com:4321/api/channels/folder-b19b85542264?k=JV5m_XbnQFD0K9_JEnGEXw"; @@ -25,6 +26,20 @@ test("a room address is a channel or the live stream, with a key and nothing els ]) assert.equal(roomAddress(bad), null, bad); }); +test("watchBase survives a config read, so the guide links rooms where it was told", () => { + const dir = mkdtempSync(join(tmpdir(), "rooms-config-")); + const saved = process.env["XDG_STATE_HOME"]; + process.env["XDG_STATE_HOME"] = dir; + try { + writeConfig({ watchBase: "https://live.streaming.pit.world" }); + assert.equal(readConfig().watchBase, "https://live.streaming.pit.world"); + assert.equal(watchBase("https://fallback.example", {}), "https://live.streaming.pit.world"); + } finally { + if (saved === undefined) delete process.env["XDG_STATE_HOME"]; else process.env["XDG_STATE_HOME"] = saved; + rmSync(dir, { recursive: true, force: true }); + } +}); + test("the room page carries the stream address", () => { assert.equal(watchPage("https://live.streaming.pit.world", PLAY), `https://live.streaming.pit.world/watch?play=${encodeURIComponent(PLAY)}`); });