fix(bridge): prefer bonjour TXT displayName

This commit is contained in:
Peter Steinberger
2025-12-13 18:31:06 +00:00
parent 537c515dde
commit 3b853b329f
4 changed files with 47 additions and 25 deletions

View File

@@ -24,6 +24,11 @@ function safeServiceName(name: string) {
return trimmed.length > 0 ? trimmed : "Clawdis";
}
function prettifyInstanceName(name: string) {
const normalized = name.trim().replace(/\s+/g, " ");
return normalized.replace(/\s+\(Clawdis\)\s*$/i, "").trim() || normalized;
}
type BonjourService = {
advertise: () => Promise<void>;
destroy: () => Promise<void>;
@@ -52,11 +57,13 @@ export async function startGatewayBonjourAdvertiser(
typeof opts.instanceName === "string" && opts.instanceName.trim()
? opts.instanceName.trim()
: `${hostname} (Clawdis)`;
const displayName = prettifyInstanceName(instanceName);
const txtBase: Record<string, string> = {
role: "master",
gatewayPort: String(opts.gatewayPort),
lanHost: `${hostname}.local`,
displayName,
};
if (typeof opts.bridgePort === "number" && opts.bridgePort > 0) {
txtBase.bridgePort = String(opts.bridgePort);