(fix): remove unused dependencies
Some checks failed
/ build-desktop (linux) (push) Failing after 52s
/ build-web (push) Failing after 1m3s
/ build-mobile (push) Failing after 1m6s
/ release (push) Has been skipped

(fix): remove dead code
(fix): remove unused exports
This commit is contained in:
Alois 2026-06-03 14:53:18 +02:00
commit be56080ba1
29 changed files with 168 additions and 338 deletions

View file

@ -16,15 +16,11 @@
},
"dependencies": {
"@livekit/components-react": "^2.9.20",
"@tanstack/react-query": "^5.100.7",
"@tanstack/react-router": "^1.169.1",
"@tanstack/react-virtual": "^3.13.24",
"@tauri-apps/api": "^2",
"@tensamin/crypto": "workspace:*",
"@tensamin/markdown": "workspace:*",
"@tensamin/shared": "workspace:*",
"@tensamin/storage": "workspace:*",
"@tensamin/tauri": "workspace:*",
"@tensamin/ttp": "workspace:*",
"@tensamin/ui": "*",
"@tensamin/user": "workspace:*",
@ -34,7 +30,6 @@
"react": "^19.2.0",
"react-dom": "^19.2.0",
"recharts": "^3.8.1",
"sonner": "^2.0.7",
"zod": "^4.3.6",
"zustand": "^5.0.8"
}

View file

@ -1,18 +1,14 @@
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui";
import { Button } from "@tensamin/ui";
import { toggleDeaf, useCall } from "../../store";
import { HeadphoneOff, Headphones } from "lucide-react";
import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton";
export default function DeafButton({
className,
iconSize,
tooltip,
portalContainer,
}: {
className?: string;
iconSize?: number;
tooltip?: string;
portalContainer?: HTMLElement;
}) {
}: CallButtonProps) {
const deaf = useCall((state) => state.deaf);
const button = (
@ -22,27 +18,12 @@ export default function DeafButton({
className={className}
>
{deaf ? (
<HeadphoneOff
style={{ scale: (iconSize ? iconSize + 100 : 100) + "%" }}
/>
<HeadphoneOff style={iconScale(iconSize)} />
) : (
<Headphones
style={{ scale: (iconSize ? iconSize + 100 : 100) + "%" }}
/>
<Headphones style={iconScale(iconSize)} />
)}
</Button>
);
if (!tooltip) {
return button;
}
return (
<Tooltip>
<TooltipTrigger render={button} />
<TooltipContent portalProps={{ container: portalContainer }}>
{tooltip}
</TooltipContent>
</Tooltip>
);
return withTooltip(button, tooltip, portalContainer);
}

View file

@ -1,18 +1,14 @@
import { LeaveIcon } from "@livekit/components-react";
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui";
import { Button } from "@tensamin/ui";
import { disconnect, useCall } from "../../store";
import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton";
export default function LeaveButton({
className,
iconSize,
tooltip,
portalContainer,
}: {
className?: string;
iconSize?: number;
tooltip?: string;
portalContainer?: HTMLElement;
}) {
}: CallButtonProps) {
const state = useCall((store) => store.state);
const button = (
@ -22,20 +18,9 @@ export default function LeaveButton({
disabled={state === "closing" || state === "closed"}
variant="destructive"
>
<LeaveIcon style={{ scale: (iconSize ? iconSize + 100 : 100) + "%" }} />
<LeaveIcon style={iconScale(iconSize)} />
</Button>
);
if (!tooltip) {
return button;
}
return (
<Tooltip>
<TooltipTrigger render={button} />
<TooltipContent portalProps={{ container: portalContainer }}>
{tooltip}
</TooltipContent>
</Tooltip>
);
return withTooltip(button, tooltip, portalContainer);
}

View file

@ -1,18 +1,14 @@
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui";
import { Button } from "@tensamin/ui";
import { toggleMute, useCall } from "../../store";
import { Mic, MicOff } from "lucide-react";
import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton";
export default function MuteButton({
className,
iconSize,
tooltip,
portalContainer,
}: {
className?: string;
iconSize?: number;
tooltip?: string;
portalContainer?: HTMLElement;
}) {
}: CallButtonProps) {
const micEnabled = useCall((state) => state.micEnabled);
const button = (
@ -22,23 +18,12 @@ export default function MuteButton({
onClick={() => void toggleMute()}
>
{micEnabled ? (
<Mic style={{ scale: (iconSize ? iconSize + 100 : 100) + "%" }} />
<Mic style={iconScale(iconSize)} />
) : (
<MicOff style={{ scale: (iconSize ? iconSize + 100 : 100) + "%" }} />
<MicOff style={iconScale(iconSize)} />
)}
</Button>
);
if (!tooltip) {
return button;
}
return (
<Tooltip>
<TooltipTrigger render={button} />
<TooltipContent portalProps={{ container: portalContainer }}>
{tooltip}
</TooltipContent>
</Tooltip>
);
return withTooltip(button, tooltip, portalContainer);
}

View file

@ -0,0 +1,32 @@
import { type ReactElement } from "react";
import { Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui";
export type CallButtonProps = {
className?: string;
iconSize?: number;
tooltip?: string;
portalContainer?: HTMLElement;
};
export function iconScale(iconSize?: number) {
return { scale: (iconSize ? iconSize + 100 : 100) + "%" };
}
export function withTooltip(
button: ReactElement,
tooltip?: string,
portalContainer?: HTMLElement,
) {
if (!tooltip) {
return button;
}
return (
<Tooltip>
<TooltipTrigger render={button} />
<TooltipContent portalProps={{ container: portalContainer }}>
{tooltip}
</TooltipContent>
</Tooltip>
);
}

View file

@ -18,7 +18,7 @@ import {
import { Track, type Participant } from "livekit-client";
import { useEffect, useRef, useState } from "react";
import { useUser, type User } from "@tensamin/user/context";
import { useIsSpeaking } from "../../speakingIndicator";
import { useIsSpeaking } from "../../speakingState";
import VideoViewer from "../videoViewer";
import { HeadphoneOff, MicOff, Monitor, Plus, Shield } from "lucide-react";

View file

@ -1,5 +1,10 @@
import { log } from "@tensamin/shared/log";
import { useCall } from "./store";
import {
clearSpeakingParticipants,
removeSpeakingParticipant,
setMicGated,
updateSpeakingParticipants,
} from "./speakingState";
const SPEAKING_THRESHOLD = 0.01;
const SPEAKING_HANGTIME_MS = 500;
@ -85,12 +90,7 @@ class SpeakingDetector {
}
this.entries.delete(participantId);
useCall.setState((state) => {
if (!state.speakingParticipantIds.has(participantId)) return state;
const next = new Set(state.speakingParticipantIds);
next.delete(participantId);
return { speakingParticipantIds: next };
});
removeSpeakingParticipant(participantId);
if (participantId === this.localParticipantId && this.localMicGateClosed) {
this.muteLocalTrack(false);
@ -104,7 +104,7 @@ class SpeakingDetector {
entry.isSpeaking = false;
entry.lastSpeakingTime = 0;
}
useCall.setState({ speakingParticipantIds: new Set() });
clearSpeakingParticipants();
}
}
@ -131,7 +131,7 @@ class SpeakingDetector {
}
this.localMicGateClosed = muted;
useCall.setState({ micGated: muted });
setMicGated(muted);
}
private applyNoiseGate(rms: number) {
@ -197,24 +197,7 @@ class SpeakingDetector {
}
if (changed.size > 0) {
useCall.setState((state) => {
let hasDiff = false;
const next = new Set(state.speakingParticipantIds);
for (const [id, speaking] of changed) {
if (speaking) {
if (!next.has(id)) {
next.add(id);
hasDiff = true;
}
} else {
if (next.has(id)) {
next.delete(id);
hasDiff = true;
}
}
}
return hasDiff ? { speakingParticipantIds: next } : state;
});
updateSpeakingParticipants(changed);
}
}
@ -246,7 +229,3 @@ export function disposeSpeakingDetector(): void {
detectorInstance = null;
}
}
export function useIsSpeaking(participantId: number): boolean {
return useCall((state) => state.speakingParticipantIds.has(participantId));
}

View file

@ -0,0 +1,55 @@
import { create } from "zustand";
type SpeakingState = {
speakingParticipantIds: Set<number>;
micGated: boolean;
};
const useSpeakingState = create<SpeakingState>(() => ({
speakingParticipantIds: new Set(),
micGated: false,
}));
export function setMicGated(micGated: boolean) {
useSpeakingState.setState({ micGated });
}
export function clearSpeakingParticipants() {
useSpeakingState.setState({ speakingParticipantIds: new Set() });
}
export function removeSpeakingParticipant(participantId: number) {
useSpeakingState.setState((state) => {
if (!state.speakingParticipantIds.has(participantId)) return state;
const next = new Set(state.speakingParticipantIds);
next.delete(participantId);
return { speakingParticipantIds: next };
});
}
export function updateSpeakingParticipants(changed: Map<number, boolean>) {
useSpeakingState.setState((state) => {
let hasDiff = false;
const next = new Set(state.speakingParticipantIds);
for (const [id, speaking] of changed) {
if (speaking) {
if (!next.has(id)) {
next.add(id);
hasDiff = true;
}
} else if (next.has(id)) {
next.delete(id);
hasDiff = true;
}
}
return hasDiff ? { speakingParticipantIds: next } : state;
});
}
export function useIsSpeaking(participantId: number): boolean {
return useSpeakingState((state) =>
state.speakingParticipantIds.has(participantId),
);
}

View file

@ -109,8 +109,6 @@ type CallStore = {
layoutVersion: number;
screenRef: React.RefObject<HTMLDivElement | null> | null;
runtime: Runtime | null;
speakingParticipantIds: Set<number>;
micGated: boolean;
};
let _keyProvider: ExternalE2EEKeyProvider | null = null;
@ -857,7 +855,6 @@ export async function disconnect() {
watchedStreamParticipantIds: [],
pendingWatchedParticipantIds: [],
activeScreenShareParticipantIds: [],
micGated: false,
});
getRoom().remoteParticipants.forEach((participant) => {
@ -1079,8 +1076,6 @@ export const useCall = create<CallStore>(() => ({
layoutVersion: 0,
screenRef: null,
runtime: null,
speakingParticipantIds: new Set(),
micGated: false,
}));
// Register app-level call listeners and wire React dependencies into the store.

View file

@ -1,11 +0,0 @@
import { z } from "zod";
import { ttp } from "@tensamin/shared/data";
export type RawMessages = z.infer<typeof ttp.messages_get.response>["messages"];
export type RawMessage = RawMessages[number];
export type LiveMessage = RawMessage & {
failed?: boolean;
localId: string;
};

View file

@ -395,49 +395,12 @@ export async function getSharedSecret(
return out;
};
/**
* Returns WebCrypto subtle API when available.
* @returns SubtleCrypto instance or undefined.
*/
const getSubtle = () => globalThis.crypto?.subtle;
{
/*
const hkdfAesGcmFromShared = async (
sharedSecret: BufferSource,
infoStr: string
): Promise<CryptoKey> => {
const subtle = getSubtle();
if (!subtle) throw new Error("WebCrypto subtle not available");
const info = textEncoder.encode(infoStr);
const baseKey = await subtle.importKey(
"raw",
sharedSecret,
"HKDF",
false,
["deriveKey"]
);
return await subtle.deriveKey(
{
name: "HKDF",
hash: "SHA-256",
salt: new Uint8Array(0),
info,
},
baseKey,
{ name: "AES-GCM", length: 256 },
false,
["encrypt", "decrypt"]
);
};
*/
}
const myJwk: JWK = normalizeOkpX448Jwk(ownJwk, "own_jwk");
const peerJwk: JWK = normalizeOkpX448Jwk(otherJwk, "other_jwk");
const subtle = getSubtle();
//const infoStr = `ECDH-X448-AES-GCM-v1|my=${myJwk.x}|peer=${peerJwk.x}`;
if (subtle) {
const algorithms = [{ name: "ECDH", namedCurve: "X448" }, { name: "X448" }];

View file

@ -17,7 +17,6 @@
"@codemirror/lang-markdown": "^6.5.0",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.41.1",
"@tensamin/ui": "*",
"react": "^19.2.0",
"react-dom": "^19.2.0"
}

View file

@ -80,7 +80,7 @@ const INLINE_TOKEN_REGEX =
* @param input Parameter input.
* @returns InlineNode[].
*/
export function parseInlineNodes(input: string): InlineNode[] {
function parseInlineNodes(input: string): InlineNode[] {
const nodes: InlineNode[] = [];
let cursor = 0;
@ -369,7 +369,7 @@ export function parseMarkdownBlocks(markdown: string): MarkdownBlock[] {
* @param nodes Parameter nodes.
* @returns React.ReactNode[].
*/
export function renderInline(nodes: InlineNode[]): React.ReactNode[] {
function renderInline(nodes: InlineNode[]): React.ReactNode[] {
return nodes.map((node, index) => {
if (node.type === "text") {
return node.value;
@ -636,7 +636,7 @@ function readTable(
};
}
export const markdownStyles = `
const markdownStyles = `
.tm-md-root { color: hsl(var(--foreground)); line-height: 1.55; font-size: 0.95rem; }
.tm-md-heading { margin: 0.2rem 0 0.35rem; font-weight: 700; line-height: 1.25; }
.tm-md-h1 { font-size: 1.65rem; }

View file

@ -19,9 +19,11 @@
"@tensamin/chat": "workspace:*",
"@tensamin/storage": "workspace:*",
"@tensamin/ttp": "workspace:*",
"@tensamin/ui": "*",
"@tensamin/user": "workspace:*",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"sonner": "^2.0.7",
"zod": "^4.3.6"
}
}

View file

@ -21,7 +21,6 @@
"lucide-react": "^1.14.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"sonner": "^2.0.7",
"zod": "^4.3.6"
}
}

View file

@ -25,9 +25,15 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
const { load, save } = useStorage();
const [contacts, setContacts] = useState<Contacts>([]);
const [communities, setCommunities] = useState<Communities>([]);
const [calls, setCalls] = useState<Calls>([]);
const [localCalls, setLocalCalls] = useState<Calls>([]);
const calls = [
...freshCalls,
...localCalls.filter(
(call) => !freshCalls.some((fresh) => fresh.call_id === call.call_id),
),
];
// Get cached data and merge fresh data
// Cached session data fills in items the server did not return freshly.
useEffect(() => {
load("cached_contacts").then((cachedData) => {
setContacts([
@ -53,16 +59,6 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
});
}, [load, freshContacts, freshCommunities]);
useEffect(() => {
setCalls((prevCalls) => [
...freshCalls,
...prevCalls.filter(
(call) => !freshCalls.some((fresh) => fresh.call_id === call.call_id),
),
]);
}, [freshCalls]);
// Save data
useEffect(() => {
save("cached_contacts", contacts);
}, [contacts, save]);
@ -98,7 +94,7 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
};
const insertCall = (call: Calls[number]) => {
setCalls((prevCalls) => {
setLocalCalls((prevCalls) => {
if (prevCalls.some((prevCall) => prevCall.call_id === call.call_id)) {
return prevCalls;
}

View file

@ -17,14 +17,11 @@
"@tensamin/crypto": "workspace:*",
"@tensamin/shared": "workspace:*",
"@tensamin/storage": "workspace:*",
"@tensamin/tauri": "workspace:*",
"@tensamin/ttp": "workspace:*",
"@tensamin/ui": "*",
"@tensamin/user": "workspace:*",
"lucide-react": "^1.8.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"sonner": "^2.0.7",
"zod": "^4.3.6"
"react-dom": "^19.2.0"
}
}

View file

@ -21,8 +21,7 @@
"@tauri-apps/api": "^2",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"tauri-plugin-app-events-api": "^0.2.0",
"zod": "^4.3.6"
"tauri-plugin-app-events-api": "^0.2.0"
},
"devDependencies": {
"eslint": "^10.0.3"