feat: settings panel with Cmd+, shortcut (macOS standard)
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m48s
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m48s
- Full settings page as modal overlay (blur backdrop) - Opens via gear icon on connect/call screens or Cmd+, (Ctrl+, on Win/Linux) - Escape or click outside to close - Settings: relay, room, alias, OS AEC toggle, AGC toggle - Identity section showing fingerprint and identity file path - Recent rooms management (remove individual, clear all) - Save syncs back to connect form - Gear icon on both connect and in-call screens Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
<input id="os-aec" type="checkbox" checked />
|
||||
OS Echo Cancel
|
||||
</label>
|
||||
<button id="settings-btn-home" class="icon-btn" title="Settings (Cmd+,)">⚙</button>
|
||||
</div>
|
||||
<button id="connect-btn" class="primary">Connect</button>
|
||||
<p id="connect-error" class="error"></p>
|
||||
@@ -40,7 +41,10 @@
|
||||
<!-- In-call screen -->
|
||||
<div id="call-screen" class="hidden">
|
||||
<div class="call-header">
|
||||
<div class="call-header-row">
|
||||
<div id="room-name" class="room-name"></div>
|
||||
<button id="settings-btn-call" class="icon-btn small" title="Settings (Cmd+,)">⚙</button>
|
||||
</div>
|
||||
<div class="call-meta">
|
||||
<span id="call-status" class="status-dot"></span>
|
||||
<span id="call-timer" class="call-timer">0:00</span>
|
||||
@@ -68,6 +72,61 @@
|
||||
|
||||
<div id="stats" class="stats"></div>
|
||||
</div>
|
||||
|
||||
<!-- Settings panel (overlay) -->
|
||||
<div id="settings-panel" class="hidden">
|
||||
<div class="settings-card">
|
||||
<div class="settings-header">
|
||||
<h2>Settings</h2>
|
||||
<button id="settings-close" class="icon-btn">×</button>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Connection</h3>
|
||||
<label>Default Relay
|
||||
<input id="s-relay" type="text" />
|
||||
</label>
|
||||
<label>Default Room
|
||||
<input id="s-room" type="text" />
|
||||
</label>
|
||||
<label>Alias
|
||||
<input id="s-alias" type="text" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Audio</h3>
|
||||
<label class="checkbox">
|
||||
<input id="s-os-aec" type="checkbox" />
|
||||
OS Echo Cancellation (macOS VoiceProcessingIO)
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input id="s-agc" type="checkbox" checked />
|
||||
Automatic Gain Control
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Identity</h3>
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">Fingerprint</span>
|
||||
<span id="s-fingerprint" class="fp-display-large"></span>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">Identity file</span>
|
||||
<span class="fp-display">~/.wzp/identity</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Recent Rooms</h3>
|
||||
<div id="s-recent-rooms" class="recent-rooms-list"></div>
|
||||
<button id="s-clear-recent" class="secondary-btn">Clear History</button>
|
||||
</div>
|
||||
|
||||
<button id="settings-save" class="primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
|
||||
@@ -23,6 +23,20 @@ const statsDiv = document.getElementById("stats")!;
|
||||
const myFingerprintEl = document.getElementById("my-fingerprint")!;
|
||||
const recentRoomsDiv = document.getElementById("recent-rooms")!;
|
||||
|
||||
const settingsPanel = document.getElementById("settings-panel")!;
|
||||
const settingsClose = document.getElementById("settings-close")!;
|
||||
const settingsSave = document.getElementById("settings-save")!;
|
||||
const settingsBtnHome = document.getElementById("settings-btn-home")!;
|
||||
const settingsBtnCall = document.getElementById("settings-btn-call")!;
|
||||
const sRelay = document.getElementById("s-relay") as HTMLInputElement;
|
||||
const sRoom = document.getElementById("s-room") as HTMLInputElement;
|
||||
const sAlias = document.getElementById("s-alias") as HTMLInputElement;
|
||||
const sOsAec = document.getElementById("s-os-aec") as HTMLInputElement;
|
||||
const sAgc = document.getElementById("s-agc") as HTMLInputElement;
|
||||
const sFingerprint = document.getElementById("s-fingerprint")!;
|
||||
const sRecentRooms = document.getElementById("s-recent-rooms")!;
|
||||
const sClearRecent = document.getElementById("s-clear-recent")!;
|
||||
|
||||
let statusInterval: number | null = null;
|
||||
let myFingerprint = "";
|
||||
|
||||
@@ -32,6 +46,7 @@ interface Settings {
|
||||
room: string;
|
||||
alias: string;
|
||||
osAec: boolean;
|
||||
agc: boolean;
|
||||
recentRooms: string[];
|
||||
}
|
||||
|
||||
@@ -41,6 +56,7 @@ function loadSettings(): Settings {
|
||||
room: "android",
|
||||
alias: "",
|
||||
osAec: true,
|
||||
agc: true,
|
||||
recentRooms: [],
|
||||
};
|
||||
try {
|
||||
@@ -259,3 +275,92 @@ listen("call-event", (event: any) => {
|
||||
const { kind } = event.payload;
|
||||
if (kind === "room-update") pollStatus();
|
||||
});
|
||||
|
||||
// ── Settings panel ──
|
||||
function openSettings() {
|
||||
const s = loadSettings();
|
||||
sRelay.value = s.relay;
|
||||
sRoom.value = s.room;
|
||||
sAlias.value = s.alias;
|
||||
sOsAec.checked = s.osAec;
|
||||
sFingerprint.textContent = myFingerprint || "(connect to see)";
|
||||
renderSettingsRecentRooms(s.recentRooms);
|
||||
settingsPanel.classList.remove("hidden");
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
settingsPanel.classList.add("hidden");
|
||||
}
|
||||
|
||||
function renderSettingsRecentRooms(rooms: string[]) {
|
||||
if (rooms.length === 0) {
|
||||
sRecentRooms.innerHTML = '<span style="color:var(--text-dim);font-size:12px">No recent rooms</span>';
|
||||
return;
|
||||
}
|
||||
sRecentRooms.innerHTML = rooms
|
||||
.map(
|
||||
(r, i) => `
|
||||
<div class="recent-room-item">
|
||||
<span>${escapeHtml(r)}</span>
|
||||
<button class="remove" data-idx="${i}">×</button>
|
||||
</div>`
|
||||
)
|
||||
.join("");
|
||||
sRecentRooms.querySelectorAll(".remove").forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const idx = parseInt((btn as HTMLElement).dataset.idx || "0");
|
||||
const s = loadSettings();
|
||||
s.recentRooms.splice(idx, 1);
|
||||
localStorage.setItem("wzp-settings", JSON.stringify(s));
|
||||
renderSettingsRecentRooms(s.recentRooms);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
settingsBtnHome.addEventListener("click", openSettings);
|
||||
settingsBtnCall.addEventListener("click", openSettings);
|
||||
settingsClose.addEventListener("click", closeSettings);
|
||||
|
||||
settingsPanel.addEventListener("click", (e) => {
|
||||
if (e.target === settingsPanel) closeSettings();
|
||||
});
|
||||
|
||||
settingsSave.addEventListener("click", () => {
|
||||
const s = loadSettings();
|
||||
s.relay = sRelay.value;
|
||||
s.room = sRoom.value;
|
||||
s.alias = sAlias.value;
|
||||
s.osAec = sOsAec.checked;
|
||||
localStorage.setItem("wzp-settings", JSON.stringify(s));
|
||||
// Sync back to main form
|
||||
relayInput.value = s.relay;
|
||||
roomInput.value = s.room;
|
||||
aliasInput.value = s.alias;
|
||||
osAecCheckbox.checked = s.osAec;
|
||||
renderRecentRooms(s.recentRooms);
|
||||
closeSettings();
|
||||
});
|
||||
|
||||
sClearRecent.addEventListener("click", () => {
|
||||
const s = loadSettings();
|
||||
s.recentRooms = [];
|
||||
localStorage.setItem("wzp-settings", JSON.stringify(s));
|
||||
renderSettingsRecentRooms([]);
|
||||
renderRecentRooms([]);
|
||||
});
|
||||
|
||||
// Cmd+, (macOS) or Ctrl+, (Windows/Linux) opens settings
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === ",") {
|
||||
e.preventDefault();
|
||||
if (settingsPanel.classList.contains("hidden")) {
|
||||
openSettings();
|
||||
} else {
|
||||
closeSettings();
|
||||
}
|
||||
}
|
||||
// Escape closes settings
|
||||
if (e.key === "Escape" && !settingsPanel.classList.contains("hidden")) {
|
||||
closeSettings();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -342,3 +342,164 @@ button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
font-family: monospace;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
/* ── Icon button ── */
|
||||
.icon-btn {
|
||||
background: none;
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px;
|
||||
color: var(--text-dim);
|
||||
font-size: 18px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
|
||||
.icon-btn.small { width: 28px; height: 28px; font-size: 14px; }
|
||||
|
||||
.call-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ── Settings panel ── */
|
||||
#settings-panel {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
background: var(--bg);
|
||||
border: 1px solid #333;
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
width: 100%;
|
||||
max-width: 380px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.settings-header h2 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.settings-section h3 {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
color: var(--text-dim);
|
||||
border-bottom: 1px solid #333;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.settings-section label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 11px;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.settings-section input[type="text"] {
|
||||
background: var(--surface);
|
||||
border: 1px solid #333;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
color: var(--text);
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.settings-section input[type="text"]:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.setting-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.fp-display-large {
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.recent-rooms-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.recent-room-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: var(--surface);
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.recent-room-item .remove {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.recent-room-item .remove:hover { color: var(--red); }
|
||||
|
||||
.secondary-btn {
|
||||
background: var(--surface);
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
color: var(--text-dim);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.secondary-btn:hover { border-color: var(--accent); color: var(--text); }
|
||||
|
||||
Reference in New Issue
Block a user