feat: Tauri desktop GUI app with call engine
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m27s
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m27s
- New desktop/ directory with Tauri v2 + Vite + TypeScript - Rust backend: CallEngine wrapping wzp-client audio + transport - Web frontend: connect screen, in-call screen with participants, mic/speaker mute, keyboard shortcuts (m/s/q) - Dark theme UI, settings persistence via localStorage - Platform-aware --os-aec: warns on Windows/Linux (not yet implemented) - Workspace updated to include desktop/src-tauri Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
177
desktop/src/main.ts
Normal file
177
desktop/src/main.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
|
||||
// Elements
|
||||
const connectScreen = document.getElementById("connect-screen")!;
|
||||
const callScreen = document.getElementById("call-screen")!;
|
||||
const relayInput = document.getElementById("relay") as HTMLInputElement;
|
||||
const roomInput = document.getElementById("room") as HTMLInputElement;
|
||||
const aliasInput = document.getElementById("alias") as HTMLInputElement;
|
||||
const osAecCheckbox = document.getElementById("os-aec") as HTMLInputElement;
|
||||
const connectBtn = document.getElementById("connect-btn") as HTMLButtonElement;
|
||||
const connectError = document.getElementById("connect-error")!;
|
||||
const roomName = document.getElementById("room-name")!;
|
||||
const participantsDiv = document.getElementById("participants")!;
|
||||
const micBtn = document.getElementById("mic-btn")!;
|
||||
const spkBtn = document.getElementById("spk-btn")!;
|
||||
const hangupBtn = document.getElementById("hangup-btn")!;
|
||||
const statsDiv = document.getElementById("stats")!;
|
||||
|
||||
let statusInterval: number | null = null;
|
||||
|
||||
// Load saved settings
|
||||
const saved = localStorage.getItem("wzp-settings");
|
||||
if (saved) {
|
||||
try {
|
||||
const s = JSON.parse(saved);
|
||||
if (s.relay) relayInput.value = s.relay;
|
||||
if (s.room) roomInput.value = s.room;
|
||||
if (s.alias) aliasInput.value = s.alias;
|
||||
if (s.osAec !== undefined) osAecCheckbox.checked = s.osAec;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
localStorage.setItem(
|
||||
"wzp-settings",
|
||||
JSON.stringify({
|
||||
relay: relayInput.value,
|
||||
room: roomInput.value,
|
||||
alias: aliasInput.value,
|
||||
osAec: osAecCheckbox.checked,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Connect
|
||||
connectBtn.addEventListener("click", async () => {
|
||||
connectError.textContent = "";
|
||||
connectBtn.disabled = true;
|
||||
connectBtn.textContent = "Connecting...";
|
||||
saveSettings();
|
||||
|
||||
try {
|
||||
await invoke("connect", {
|
||||
relay: relayInput.value,
|
||||
room: roomInput.value,
|
||||
alias: aliasInput.value,
|
||||
osAec: osAecCheckbox.checked,
|
||||
});
|
||||
showCallScreen();
|
||||
} catch (e: any) {
|
||||
connectError.textContent = String(e);
|
||||
connectBtn.disabled = false;
|
||||
connectBtn.textContent = "Connect";
|
||||
}
|
||||
});
|
||||
|
||||
function showCallScreen() {
|
||||
connectScreen.classList.add("hidden");
|
||||
callScreen.classList.remove("hidden");
|
||||
roomName.textContent = roomInput.value;
|
||||
|
||||
// Poll status
|
||||
statusInterval = window.setInterval(pollStatus, 500);
|
||||
}
|
||||
|
||||
function showConnectScreen() {
|
||||
callScreen.classList.add("hidden");
|
||||
connectScreen.classList.remove("hidden");
|
||||
connectBtn.disabled = false;
|
||||
connectBtn.textContent = "Connect";
|
||||
if (statusInterval) {
|
||||
clearInterval(statusInterval);
|
||||
statusInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Mute buttons
|
||||
micBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const muted: boolean = await invoke("toggle_mic");
|
||||
micBtn.classList.toggle("muted", muted);
|
||||
} catch {}
|
||||
});
|
||||
|
||||
spkBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const muted: boolean = await invoke("toggle_speaker");
|
||||
spkBtn.classList.toggle("muted", muted);
|
||||
} catch {}
|
||||
});
|
||||
|
||||
// Hangup
|
||||
hangupBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
await invoke("disconnect");
|
||||
} catch {}
|
||||
showConnectScreen();
|
||||
});
|
||||
|
||||
// Keyboard shortcuts
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (callScreen.classList.contains("hidden")) return;
|
||||
if (e.key === "m") micBtn.click();
|
||||
if (e.key === "s") spkBtn.click();
|
||||
if (e.key === "q") hangupBtn.click();
|
||||
});
|
||||
|
||||
// Status polling
|
||||
interface CallStatus {
|
||||
active: boolean;
|
||||
mic_muted: boolean;
|
||||
spk_muted: boolean;
|
||||
participants: { fingerprint: string; alias: string | null }[];
|
||||
encode_fps: number;
|
||||
recv_fps: number;
|
||||
}
|
||||
|
||||
async function pollStatus() {
|
||||
try {
|
||||
const status: CallStatus = await invoke("get_status");
|
||||
if (!status.active) {
|
||||
showConnectScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
// Update mute state
|
||||
micBtn.classList.toggle("muted", status.mic_muted);
|
||||
spkBtn.classList.toggle("muted", status.spk_muted);
|
||||
|
||||
// Update participants
|
||||
participantsDiv.innerHTML = status.participants
|
||||
.map((p) => {
|
||||
const name = p.alias || "Anonymous";
|
||||
const initial = name.charAt(0).toUpperCase();
|
||||
const fp = p.fingerprint
|
||||
? p.fingerprint.substring(0, 8) + "..."
|
||||
: "";
|
||||
return `
|
||||
<div class="participant">
|
||||
<div class="avatar">${initial}</div>
|
||||
<div class="info">
|
||||
<div class="name">${escapeHtml(name)}</div>
|
||||
<div class="fp">${escapeHtml(fp)}</div>
|
||||
</div>
|
||||
</div>`;
|
||||
})
|
||||
.join("");
|
||||
|
||||
// Stats
|
||||
statsDiv.textContent = `TX: ${status.encode_fps} frames | RX: ${status.recv_fps} frames`;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function escapeHtml(s: string): string {
|
||||
const d = document.createElement("div");
|
||||
d.textContent = s;
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
// Listen for events from backend
|
||||
listen("call-event", (event: any) => {
|
||||
const { kind, message } = event.payload;
|
||||
if (kind === "room-update") {
|
||||
pollStatus();
|
||||
}
|
||||
});
|
||||
258
desktop/src/style.css
Normal file
258
desktop/src/style.css
Normal file
@@ -0,0 +1,258 @@
|
||||
:root {
|
||||
--bg: #1a1a2e;
|
||||
--surface: #16213e;
|
||||
--primary: #0f3460;
|
||||
--accent: #e94560;
|
||||
--text: #eee;
|
||||
--text-dim: #888;
|
||||
--green: #4ade80;
|
||||
--red: #ef4444;
|
||||
--radius: 12px;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
#app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Connect screen */
|
||||
#connect-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
#connect-screen h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.form input[type="text"] {
|
||||
background: var(--surface);
|
||||
border: 1px solid #333;
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
color: var(--text);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.form input[type="text"]:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
flex-direction: row !important;
|
||||
align-items: center;
|
||||
gap: 8px !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkbox input {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
button.primary {
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
button.primary:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: var(--red);
|
||||
font-size: 13px;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
/* Call screen */
|
||||
#call-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.call-header {
|
||||
text-align: center;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.room-name {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 13px;
|
||||
color: var(--green);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Participants */
|
||||
.participants {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius);
|
||||
padding: 16px;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.participant {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #ffffff10;
|
||||
}
|
||||
|
||||
.participant:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.participant .avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--primary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.participant .info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.participant .name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.participant .fp {
|
||||
font-size: 11px;
|
||||
color: var(--text-dim);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
.controls {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 20px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: var(--surface);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.control-btn .icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.control-btn .label {
|
||||
font-size: 10px;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
background: var(--primary);
|
||||
}
|
||||
|
||||
.control-btn.muted {
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.control-btn.muted .label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.control-btn.hangup {
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.control-btn.hangup:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.stats {
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: var(--text-dim);
|
||||
font-family: monospace;
|
||||
padding: 8px;
|
||||
}
|
||||
Reference in New Issue
Block a user