Merge pull request #12 from recurse-chat/bug-fixes

BUG Fix: Muting and deafen, and sidebar UI
This commit is contained in:
2026-08-29 11:53:56 -04:00
committed by GitHub
5 changed files with 85 additions and 66 deletions
+20 -6
View File
@@ -46,6 +46,7 @@ pub struct VoiceState {
#[derive(Default)] #[derive(Default)]
pub struct VoiceStateInner { pub struct VoiceStateInner {
pub session: Mutex<Option<VoiceSession>>, pub session: Mutex<Option<VoiceSession>>,
pub backend_config: Arc<Mutex<BackendConfig>>,
} }
pub struct VoiceSession { pub struct VoiceSession {
@@ -532,10 +533,7 @@ pub fn connect_to_vc(
producer_in: Arc::clone(&shared_producer_in), producer_in: Arc::clone(&shared_producer_in),
consumer_out: Arc::clone(&shared_consumer_out), consumer_out: Arc::clone(&shared_consumer_out),
backend_config: Arc::new(Mutex::new(BackendConfig { backend_config: Arc::clone(&voice_state.inner.backend_config),
is_muted: false,
is_deaf: false,
})),
}; };
session.setup_input(config.input_device_name.clone(), Arc::clone(&state_inner))?; session.setup_input(config.input_device_name.clone(), Arc::clone(&state_inner))?;
@@ -641,6 +639,7 @@ pub fn connect_to_vc(
let shutdown = shutdown.clone(); let shutdown = shutdown.clone();
let cipher = cipher.clone(); let cipher = cipher.clone();
let backend_config = session.backend_config.clone(); let backend_config = session.backend_config.clone();
let consumer_out = session.consumer_out.clone();
thread::spawn(move || { thread::spawn(move || {
let mut packets: BTreeMap<u32, Vec<f32>> = BTreeMap::new(); let mut packets: BTreeMap<u32, Vec<f32>> = BTreeMap::new();
@@ -651,13 +650,28 @@ pub fn connect_to_vc(
let mut next_frame_time = Instant::now(); let mut next_frame_time = Instant::now();
while !shutdown.load(Ordering::Relaxed) { while !shutdown.load(Ordering::Relaxed) {
let is_deaf = { backend_config.lock().unwrap().is_deaf }; let is_deaf = {
let cfg = backend_config.lock().unwrap();
cfg.is_deaf
};
if is_deaf { if is_deaf {
// Keep draining the UDP socket while deafened/muted so stale
// packets don't accumulate in the OS buffer and get replayed
// when we undeafen/unmute. Decrypting and discarding here
// fully consumes the socket backlog.
if let Ok(len) = socket.recv(&mut udp_buffer) {
let _ = cipher.lock().unwrap().decrypt(&udp_buffer[..len]);
}
// Drop any audio already buffered for playback so that on
// unmute/undeafen we don't replay audio from the past.
if let Ok(mut cons) = consumer_out.lock() {
cons.clear();
}
packets.clear(); packets.clear();
is_prebuffering = true; is_prebuffering = true;
std::thread::sleep(Duration::from_secs(1)); thread::sleep(Duration::from_millis(1));
continue; continue;
} }
+2 -4
View File
@@ -103,7 +103,7 @@ pub fn get_config(app: AppHandle, state: State<ConfigState>) -> Result<Config, S
Ok(config) Ok(config)
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct BackendConfig { pub struct BackendConfig {
pub is_muted: bool, pub is_muted: bool,
@@ -115,9 +115,7 @@ pub fn update_backend_config(
voice_state: State<'_, VoiceState>, voice_state: State<'_, VoiceState>,
config: BackendConfig, config: BackendConfig,
) -> Result<(), String> { ) -> Result<(), String> {
if let Some(v) = &mut *voice_state.inner.session.lock().unwrap() { *voice_state.inner.backend_config.lock().unwrap() = config;
*v.backend_config.lock().unwrap() = config
}
Ok(()) Ok(())
} }
+1 -1
View File
@@ -49,7 +49,7 @@ export default function App() {
minSize="4rem" minSize="4rem"
groupResizeBehavior="preserve-pixel-size" groupResizeBehavior="preserve-pixel-size"
> >
<div className="flex"> <div className="h-screen flex overflow-y-hidden">
<ServerList appRef={appRef} /> <ServerList appRef={appRef} />
<Sidebar appRef={appRef} /> <Sidebar appRef={appRef} />
</div> </div>
+57 -50
View File
@@ -5,6 +5,7 @@ import { openUrl } from "@tauri-apps/plugin-opener";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { RefreshCw, Rss } from "lucide-react"; import { RefreshCw, Rss } from "lucide-react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import StatusCard from "../view/StatusCard";
function formatTime(publishedAt: number): string { function formatTime(publishedAt: number): string {
if (!publishedAt) return ""; if (!publishedAt) return "";
@@ -73,7 +74,9 @@ function StaticFallback() {
); );
} }
export default function MainPageSidebar(_props: { export default function MainPageSidebar({
appRef,
}: {
appRef: React.RefObject<Enclave | null>; appRef: React.RefObject<Enclave | null>;
}) { }) {
const [items, setItems] = useState<NewsItem[] | null>(null); const [items, setItems] = useState<NewsItem[] | null>(null);
@@ -98,58 +101,62 @@ export default function MainPageSidebar(_props: {
}, [load]); }, [load]);
return ( return (
<div className="flex h-screen w-full flex-col"> <div className="h-full relative w-full @container">
<header className="flex items-center justify-between px-3 py-2.5 border-b border-b-border"> <div className="flex h-screen w-full flex-col">
<h1 className="text-lg font-semibold flex items-center gap-2"> <header className="flex items-center justify-between px-3 py-2.5 border-b border-b-border">
<Rss className="h-4 w-4 text-primary" /> <h1 className="text-lg font-semibold flex items-center gap-2">
Security News <Rss className="h-4 w-4 text-primary" />
</h1> Security News
<Button </h1>
variant="ghost" <Button
size="icon-sm" variant="ghost"
disabled={loading} size="icon-sm"
onClick={load} disabled={loading}
> onClick={load}
<RefreshCw className={cn("h-4 w-4", loading && "animate-spin")} /> >
</Button> <RefreshCw className={cn("h-4 w-4", loading && "animate-spin")} />
</header> </Button>
</header>
<section className="flex-1 overflow-y-scroll scrollbar-none [scrollbar-width:none] [&::-webkit-scrollbar]:hidden px-2 py-2"> <section className="flex-1 overflow-y-scroll scrollbar-none[&::-webkit-scrollbar]:hidden px-2 py-2 mb-28">
{loading && items === null && ( {loading && items === null && (
<p className="px-2 py-4 text-sm text-muted-foreground"> <p className="px-2 py-4 text-sm text-muted-foreground">
Loading news… Loading news…
</p> </p>
)} )}
{error && !loading && <StaticFallback />} {error && !loading && <StaticFallback />}
{items && ( {items && (
<div className="flex flex-col gap-0.5"> <div className="flex flex-col gap-0.5">
{items.map((item) => ( {items.map((item) => (
<button <button
key={item.link} key={item.link}
className="group flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left hover:bg-accent" className="group flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left hover:bg-accent"
onClick={() => openUrl(item.link)} onClick={() => openUrl(item.link)}
> >
<span className="text-sm text-foreground leading-tight"> <span className="text-sm text-foreground leading-tight">
{item.title} {item.title}
</span> </span>
<span className="flex items-center gap-1.5 text-xs text-muted-foreground"> <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span className="truncate">{item.source}</span> <span className="truncate">{item.source}</span>
{item.publishedAt > 0 && ( {item.publishedAt > 0 && (
<> <>
<span aria-hidden>·</span> <span aria-hidden>·</span>
<span className="shrink-0"> <span className="shrink-0">
{formatTime(item.publishedAt)} {formatTime(item.publishedAt)}
</span> </span>
</> </>
)} )}
</span> </span>
</button> </button>
))} ))}
</div> </div>
)} )}
</section> </section>
</div>
<StatusCard appRef={appRef} />
</div> </div>
); );
} }
+5 -5
View File
@@ -64,7 +64,7 @@ export function RenderFeatures({
return ( return (
users && ( users && (
<div className="flex flex-col gap-1.5 px-4 pt-0.5"> <div className="flex flex-col gap-2 px-4 pt-2">
{(isCurrentVc ? users : users.slice(0, 15)).map((pubkey) => { {(isCurrentVc ? users : users.slice(0, 15)).map((pubkey) => {
const user = appRef.current?.server?.users[pubkey]; const user = appRef.current?.server?.users[pubkey];
if (!user) return null; if (!user) return null;
@@ -156,20 +156,20 @@ export default function ServerSidebar({
appRef: React.RefObject<Enclave | null>; appRef: React.RefObject<Enclave | null>;
}) { }) {
return ( return (
<div className="h-screen relative w-full @container"> <div className="h-full relative w-full @container">
{appRef.current?.server?.meta && ( {appRef.current?.server?.meta && (
<> <div className="h-full">
<header className="px-3 pt-2.5 pb-2.5 text-lg font-semibold border-b border-b-border"> <header className="px-3 pt-2.5 pb-2.5 text-lg font-semibold border-b border-b-border">
<h1>{appRef.current.server.meta.name}</h1> <h1>{appRef.current.server.meta.name}</h1>
</header> </header>
<section className="px-1.5 pt-3.5 w-full h-full flex flex-col gap-1 overflow-y-scroll scrollbar-none [scrollbar-width:none] [&::-webkit-scrollbar]:hidden pb-55"> <section className="px-1.5 pt-3.5 w-full h-full flex flex-col gap-1 overflow-y-scroll scrollbar-none [&::-webkit-scrollbar]:hidden mb-28">
<RenderChannels <RenderChannels
appRef={appRef} appRef={appRef}
channels={appRef.current.server.meta.channels} channels={appRef.current.server.meta.channels}
/> />
</section> </section>
</> </div>
)} )}
<StatusCard appRef={appRef} /> <StatusCard appRef={appRef} />