Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0e3e85467 | |||
| 9e3a6040e3 | |||
| ebd2a364a7 | |||
| 167036533c | |||
| fd18ee6079 | |||
| 6f5f88573a | |||
| 370c3746f7 | |||
| aa811f4277 | |||
| 112c9d58da |
20 changed files with 309 additions and 115 deletions
|
|
@ -147,7 +147,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
VERSION="$(node -p "require('./package.json').version")"
|
VERSION="$(node -p "require('./package.json').version")"
|
||||||
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
|
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
|
||||||
echo "tag=${VERSION}-prod" >> "$FORGEJO_OUTPUT"
|
echo "tag=$VERSION" >> "$FORGEJO_OUTPUT"
|
||||||
|
|
||||||
- name: Create release and upload files
|
- name: Create release and upload files
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
|
|
@ -2,7 +2,6 @@
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"tauri-apps.tauri-vscode",
|
"tauri-apps.tauri-vscode",
|
||||||
"rust-lang.rust-analyzer",
|
"rust-lang.rust-analyzer",
|
||||||
"bradlc.vscode-tailwindcss",
|
"bradlc.vscode-tailwindcss"
|
||||||
"antfu.vite"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
"dev:mobile:raw": "tauri android dev",
|
"dev:mobile:raw": "tauri android dev",
|
||||||
"build:mobile:raw": "tauri android build",
|
"build:mobile:raw": "tauri android build",
|
||||||
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:mobile:raw; else bun dev:mobile:raw; fi",
|
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:mobile:raw; else bun dev:mobile:raw; fi",
|
||||||
"build:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun build:mobile:raw; else bun build:mobile:raw; fi",
|
"build:mobile": "bun run render-version.ts && if command -v nix >/dev/null 2>&1; then nix develop --command bun build:mobile:raw; else bun build:mobile:raw; fi && bun run render-version.ts --unrender",
|
||||||
"dev:desktop:raw": "tauri dev",
|
"dev:desktop:raw": "tauri dev",
|
||||||
"build:desktop:raw": "tauri build",
|
"build:desktop:raw": "tauri build",
|
||||||
"dev:desktop": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:desktop:raw; else bun dev:desktop:raw; fi",
|
"dev:desktop": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:desktop:raw; else bun dev:desktop:raw; fi",
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
"react-dom": "^19.2.0"
|
"react-dom": "^19.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2"
|
"@tauri-apps/cli": "^2",
|
||||||
|
"@types/node": "^25.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
75
apps/tauri/render-version.ts
Normal file
75
apps/tauri/render-version.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
// Config
|
||||||
|
const PLACEHOLDER_VERSION = "0.0.0";
|
||||||
|
|
||||||
|
const rootPackageJsonPath = path.resolve(__dirname, "../../package.json");
|
||||||
|
const cargoTomlPath = path.resolve(__dirname, "./src-tauri/Cargo.toml");
|
||||||
|
const tauriConfigPath = path.resolve(__dirname, "./src-tauri/tauri.conf.json");
|
||||||
|
|
||||||
|
// Args
|
||||||
|
const isUnrender = process.argv.includes("--unrender");
|
||||||
|
|
||||||
|
// Version Source
|
||||||
|
const packageJson = JSON.parse(
|
||||||
|
fs.readFileSync(rootPackageJsonPath, "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
|
const packageVersion: string = packageJson.version;
|
||||||
|
|
||||||
|
if (!packageVersion && !isUnrender) {
|
||||||
|
throw new Error("No version found in package.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetVersion = isUnrender
|
||||||
|
? PLACEHOLDER_VERSION
|
||||||
|
: packageVersion;
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
function updateCargoToml(content: string): string {
|
||||||
|
const regex = /^version\s*=\s*".*"$/m;
|
||||||
|
|
||||||
|
if (!regex.test(content)) {
|
||||||
|
throw new Error("Could not find version field in Cargo.toml");
|
||||||
|
}
|
||||||
|
|
||||||
|
return content.replace(
|
||||||
|
regex,
|
||||||
|
`version = "${targetVersion}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTauriConfig(content: string): string {
|
||||||
|
const regex = /"version"\s*:\s*".*"/;
|
||||||
|
|
||||||
|
if (!regex.test(content)) {
|
||||||
|
throw new Error("Could not find version field in tauri.conf.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
return content.replace(
|
||||||
|
regex,
|
||||||
|
`"version": "${targetVersion}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Cargo.toml
|
||||||
|
const cargoToml = fs.readFileSync(cargoTomlPath, "utf8");
|
||||||
|
|
||||||
|
const updatedCargoToml = updateCargoToml(cargoToml);
|
||||||
|
|
||||||
|
fs.writeFileSync(cargoTomlPath, updatedCargoToml, "utf8");
|
||||||
|
|
||||||
|
// Update tauri.conf.json
|
||||||
|
const tauriConfig = fs.readFileSync(tauriConfigPath, "utf8");
|
||||||
|
|
||||||
|
const updatedTauriConfig = updateTauriConfig(tauriConfig);
|
||||||
|
|
||||||
|
fs.writeFileSync(tauriConfigPath, updatedTauriConfig, "utf8");
|
||||||
|
|
||||||
|
// Finished
|
||||||
|
if (isUnrender) {
|
||||||
|
console.log(`Unrendered versions back to ${PLACEHOLDER_VERSION}`);
|
||||||
|
} else {
|
||||||
|
console.log(`Rendered version ${targetVersion}`);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tensamin"
|
name = "Tensamin"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
description = "Privacy focused messanger"
|
description = "Privacy focused messanger"
|
||||||
authors = ["methanium"]
|
authors = ["methanium"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Tensamin",
|
"productName": "Tensamin",
|
||||||
"version": "0.1.0",
|
"version": "0.0.0",
|
||||||
"mainBinaryName": "tensamin",
|
"mainBinaryName": "tensamin",
|
||||||
"identifier": "net.tensamin.client",
|
"identifier": "net.tensamin.client",
|
||||||
"build": {
|
"build": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"types": ["node"],
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
|
|
@ -8,5 +9,5 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"noEmit": true
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src", "./render-version.ts"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,11 +190,9 @@ export default function Form() {
|
||||||
[save],
|
[save],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isTauriEnv = isTauri();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex md:flex-row flex-col gap-15">
|
<div className="flex md:flex-row flex-col gap-15">
|
||||||
{isTauriEnv ? (
|
{isTauri() ? (
|
||||||
<>
|
<>
|
||||||
<QrCodeScanner
|
<QrCodeScanner
|
||||||
onData={async (data) => {
|
onData={async (data) => {
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ function QrCodeLogin() {
|
||||||
const [qrCodeBase64, setQrCodeBase64] = useState<string | undefined>(
|
const [qrCodeBase64, setQrCodeBase64] = useState<string | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
const [connectionString, setConnectionString] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
load("private_key").then((value) => {
|
load("private_key").then((value) => {
|
||||||
|
|
@ -58,15 +59,25 @@ function QrCodeLogin() {
|
||||||
setUserId(value);
|
setUserId(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
load("ttp_url")
|
||||||
|
.then((value) => {
|
||||||
|
if (value) {
|
||||||
|
const url = new URL(value);
|
||||||
|
setConnectionString(`@${url.host}`);
|
||||||
|
} else {
|
||||||
|
setConnectionString("");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => setConnectionString(""));
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userId && privateKey) {
|
if (userId && privateKey && connectionString !== null) {
|
||||||
generateQR(`tensamin://tu::${userId}::${privateKey}`).then(
|
generateQR(
|
||||||
setQrCodeBase64,
|
`tensamin://tu::${userId}${connectionString}::${privateKey}`,
|
||||||
);
|
).then(setQrCodeBase64);
|
||||||
}
|
}
|
||||||
}, [userId, privateKey]);
|
}, [userId, privateKey, connectionString]);
|
||||||
|
|
||||||
const [qrCodeVisible, setQrCodeVisible] = useState(false);
|
const [qrCodeVisible, setQrCodeVisible] = useState(false);
|
||||||
|
|
||||||
|
|
|
||||||
5
bun.lock
5
bun.lock
|
|
@ -40,6 +40,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2",
|
"@tauri-apps/cli": "^2",
|
||||||
|
"@types/node": "^25.9.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"apps/web": {
|
"apps/web": {
|
||||||
|
|
@ -1661,6 +1662,8 @@
|
||||||
|
|
||||||
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||||
|
|
||||||
|
"@tensamin/tauri/@types/node": ["@types/node@25.9.1", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg=="],
|
||||||
|
|
||||||
"@tensamin/ui/recharts": ["recharts@3.8.0", "", { "dependencies": { "@reduxjs/toolkit": "^1.9.0 || 2.x.x", "clsx": "^2.1.1", "decimal.js-light": "^2.5.1", "es-toolkit": "^1.39.3", "eventemitter3": "^5.0.1", "immer": "^10.1.1", "react-redux": "8.x.x || 9.x.x", "reselect": "5.1.1", "tiny-invariant": "^1.3.3", "use-sync-external-store": "^1.2.2", "victory-vendor": "^37.0.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Z/m38DX3L73ExO4Tpc9/iZWHmHnlzWG4njQbxsF5aSjwqmHNDDIm0rdEBArkwsBvR8U6EirlEHiQNYWCVh9sGQ=="],
|
"@tensamin/ui/recharts": ["recharts@3.8.0", "", { "dependencies": { "@reduxjs/toolkit": "^1.9.0 || 2.x.x", "clsx": "^2.1.1", "decimal.js-light": "^2.5.1", "es-toolkit": "^1.39.3", "eventemitter3": "^5.0.1", "immer": "^10.1.1", "react-redux": "8.x.x || 9.x.x", "reselect": "5.1.1", "tiny-invariant": "^1.3.3", "use-sync-external-store": "^1.2.2", "victory-vendor": "^37.0.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Z/m38DX3L73ExO4Tpc9/iZWHmHnlzWG4njQbxsF5aSjwqmHNDDIm0rdEBArkwsBvR8U6EirlEHiQNYWCVh9sGQ=="],
|
||||||
|
|
||||||
"@tensamin/ui/shadcn": ["shadcn@3.8.5", "", { "dependencies": { "@antfu/ni": "^25.0.0", "@babel/core": "^7.28.0", "@babel/parser": "^7.28.0", "@babel/plugin-transform-typescript": "^7.28.0", "@babel/preset-typescript": "^7.27.1", "@dotenvx/dotenvx": "^1.48.4", "@modelcontextprotocol/sdk": "^1.26.0", "@types/validate-npm-package-name": "^4.0.2", "browserslist": "^4.26.2", "commander": "^14.0.0", "cosmiconfig": "^9.0.0", "dedent": "^1.6.0", "deepmerge": "^4.3.1", "diff": "^8.0.2", "execa": "^9.6.0", "fast-glob": "^3.3.3", "fs-extra": "^11.3.1", "fuzzysort": "^3.1.0", "https-proxy-agent": "^7.0.6", "kleur": "^4.1.5", "msw": "^2.10.4", "node-fetch": "^3.3.2", "open": "^11.0.0", "ora": "^8.2.0", "postcss": "^8.5.6", "postcss-selector-parser": "^7.1.0", "prompts": "^2.4.2", "recast": "^0.23.11", "stringify-object": "^5.0.0", "tailwind-merge": "^3.0.1", "ts-morph": "^26.0.0", "tsconfig-paths": "^4.2.0", "validate-npm-package-name": "^7.0.1", "zod": "^3.24.1", "zod-to-json-schema": "^3.24.6" }, "bin": { "shadcn": "dist/index.js" } }, "sha512-jPRx44e+eyeV7xwY3BLJXcfrks00+M0h5BGB9l6DdcBW4BpAj4x3lVmVy0TXPEs2iHEisxejr62sZAAw6B1EVA=="],
|
"@tensamin/ui/shadcn": ["shadcn@3.8.5", "", { "dependencies": { "@antfu/ni": "^25.0.0", "@babel/core": "^7.28.0", "@babel/parser": "^7.28.0", "@babel/plugin-transform-typescript": "^7.28.0", "@babel/preset-typescript": "^7.27.1", "@dotenvx/dotenvx": "^1.48.4", "@modelcontextprotocol/sdk": "^1.26.0", "@types/validate-npm-package-name": "^4.0.2", "browserslist": "^4.26.2", "commander": "^14.0.0", "cosmiconfig": "^9.0.0", "dedent": "^1.6.0", "deepmerge": "^4.3.1", "diff": "^8.0.2", "execa": "^9.6.0", "fast-glob": "^3.3.3", "fs-extra": "^11.3.1", "fuzzysort": "^3.1.0", "https-proxy-agent": "^7.0.6", "kleur": "^4.1.5", "msw": "^2.10.4", "node-fetch": "^3.3.2", "open": "^11.0.0", "ora": "^8.2.0", "postcss": "^8.5.6", "postcss-selector-parser": "^7.1.0", "prompts": "^2.4.2", "recast": "^0.23.11", "stringify-object": "^5.0.0", "tailwind-merge": "^3.0.1", "ts-morph": "^26.0.0", "tsconfig-paths": "^4.2.0", "validate-npm-package-name": "^7.0.1", "zod": "^3.24.1", "zod-to-json-schema": "^3.24.6" }, "bin": { "shadcn": "dist/index.js" } }, "sha512-jPRx44e+eyeV7xwY3BLJXcfrks00+M0h5BGB9l6DdcBW4BpAj4x3lVmVy0TXPEs2iHEisxejr62sZAAw6B1EVA=="],
|
||||||
|
|
@ -1721,6 +1724,8 @@
|
||||||
|
|
||||||
"@modelcontextprotocol/sdk/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
"@modelcontextprotocol/sdk/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||||
|
|
||||||
|
"@tensamin/tauri/@types/node/undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
|
||||||
|
|
||||||
"@tensamin/ui/shadcn/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
"@tensamin/ui/shadcn/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||||
|
|
||||||
"ajv-formats/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
"ajv-formats/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Lock, LockOpen } from "lucide-react";
|
import { Lock, LockOpen } from "lucide-react";
|
||||||
import { openCallPage, useCall } from "../store";
|
import { openCallPage, useCall, getRoom } from "../store";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
|
@ -78,7 +78,7 @@ function ConnectionBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TinyPingGraph() {
|
export function TinyPingGraph() {
|
||||||
const room = useCall((store) => store.room);
|
const room = getRoom();
|
||||||
|
|
||||||
const [mapData, setMapData] = useState<Map<number, number>>(() => new Map());
|
const [mapData, setMapData] = useState<Map<number, number>>(() => new Map());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useUser, type User } from "@tensamin/user/context";
|
import { useUser, type User } from "@tensamin/user/context";
|
||||||
import { useCall } from "../store";
|
import { useCall, getRoom } from "../store";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useStorage } from "@tensamin/storage/context";
|
import { useStorage } from "@tensamin/storage/context";
|
||||||
import {
|
import {
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
export default function TopBar() {
|
export default function TopBar() {
|
||||||
const { get } = useUser();
|
const { get } = useUser();
|
||||||
const { load } = useStorage();
|
const { load } = useStorage();
|
||||||
const room = useCall((state) => state.room);
|
const room = getRoom();
|
||||||
const screenRef = useCall((state) => state.screenRef);
|
const screenRef = useCall((state) => state.screenRef);
|
||||||
const [portalContainer, setPortalContainer] = useState<HTMLElement>();
|
const [portalContainer, setPortalContainer] = useState<HTMLElement>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { VideoTrack, useParticipantTracks } from "@livekit/components-react";
|
import { VideoTrack, useParticipantTracks } from "@livekit/components-react";
|
||||||
import { TrackPublication } from "livekit-client";
|
import { TrackPublication } from "livekit-client";
|
||||||
import { useCall } from "../store";
|
import { getRoom } from "../store";
|
||||||
import { cn } from "@tensamin/ui";
|
import { cn } from "@tensamin/ui";
|
||||||
import { Loader2 } from "lucide-react";
|
import { Loader2 } from "lucide-react";
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ export default function VideoViewer({
|
||||||
publication: TrackPublication;
|
publication: TrackPublication;
|
||||||
participantId: string;
|
participantId: string;
|
||||||
}) {
|
}) {
|
||||||
const room = useCall((state) => state.room);
|
const room = getRoom();
|
||||||
const tracks = useParticipantTracks([publication.source], {
|
const tracks = useParticipantTracks([publication.source], {
|
||||||
participantIdentity: participantId,
|
participantIdentity: participantId,
|
||||||
room,
|
room,
|
||||||
|
|
|
||||||
|
|
@ -101,27 +101,46 @@ type CallStore = {
|
||||||
callIsPopout: boolean;
|
callIsPopout: boolean;
|
||||||
layoutVersion: number;
|
layoutVersion: number;
|
||||||
screenRef: React.RefObject<HTMLDivElement | null> | null;
|
screenRef: React.RefObject<HTMLDivElement | null> | null;
|
||||||
room: Room;
|
|
||||||
keyProvider: ExternalE2EEKeyProvider;
|
|
||||||
e2eeWorker: Worker;
|
|
||||||
runtime: Runtime | null;
|
runtime: Runtime | null;
|
||||||
speakingParticipantIds: Set<number>;
|
speakingParticipantIds: Set<number>;
|
||||||
micGated: boolean;
|
micGated: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const keyProvider = new ExternalE2EEKeyProvider();
|
let _keyProvider: ExternalE2EEKeyProvider | null = null;
|
||||||
const e2eeWorker = new Worker(
|
let _e2eeWorker: Worker | null = null;
|
||||||
|
let _room: Room | null = null;
|
||||||
|
|
||||||
|
function getKeyProvider(): ExternalE2EEKeyProvider {
|
||||||
|
if (!_keyProvider) {
|
||||||
|
_keyProvider = new ExternalE2EEKeyProvider();
|
||||||
|
}
|
||||||
|
return _keyProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getE2EEWorker(): Worker {
|
||||||
|
if (!_e2eeWorker) {
|
||||||
|
_e2eeWorker = new Worker(
|
||||||
new URL("livekit-client/e2ee-worker", import.meta.url),
|
new URL("livekit-client/e2ee-worker", import.meta.url),
|
||||||
);
|
);
|
||||||
const room = new Room({
|
}
|
||||||
|
return _e2eeWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRoom(): Room {
|
||||||
|
if (!_room) {
|
||||||
|
_room = new Room({
|
||||||
dynacast: true,
|
dynacast: true,
|
||||||
adaptiveStream: true,
|
adaptiveStream: true,
|
||||||
loggerName: "tensamin",
|
loggerName: "tensamin",
|
||||||
encryption: {
|
encryption: {
|
||||||
keyProvider,
|
keyProvider: getKeyProvider(),
|
||||||
worker: e2eeWorker,
|
worker: getE2EEWorker(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
return _room;
|
||||||
|
}
|
||||||
|
|
||||||
const remoteAudioElements = new Map<string, HTMLMediaElement>();
|
const remoteAudioElements = new Map<string, HTMLMediaElement>();
|
||||||
|
|
||||||
const SCREEN_SHARE_PREVIEW_MAX_WIDTH = 320;
|
const SCREEN_SHARE_PREVIEW_MAX_WIDTH = 320;
|
||||||
|
|
@ -170,6 +189,7 @@ export function getParticipantId(identity: string | undefined): number | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllParticipants(): Participant[] {
|
function getAllParticipants(): Participant[] {
|
||||||
|
const room = getRoom();
|
||||||
return [...room.remoteParticipants.values(), room.localParticipant];
|
return [...room.remoteParticipants.values(), room.localParticipant];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,7 +207,7 @@ function getTrackPublicationBySource(
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRemoteParticipant(participantId: number) {
|
function getRemoteParticipant(participantId: number) {
|
||||||
return [...room.remoteParticipants.values()].find(
|
return [...getRoom().remoteParticipants.values()].find(
|
||||||
(participant) => getParticipantId(participant.identity) === participantId,
|
(participant) => getParticipantId(participant.identity) === participantId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +235,7 @@ function syncRemoteParticipantTrackSubscriptions(participantId: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncAllRemoteTrackSubscriptions() {
|
function syncAllRemoteTrackSubscriptions() {
|
||||||
for (const participant of room.remoteParticipants.values()) {
|
for (const participant of getRoom().remoteParticipants.values()) {
|
||||||
const participantId = getParticipantId(participant.identity);
|
const participantId = getParticipantId(participant.identity);
|
||||||
|
|
||||||
if (participantId != null) {
|
if (participantId != null) {
|
||||||
|
|
@ -256,7 +276,7 @@ function hasParticipant(participantId: number) {
|
||||||
|
|
||||||
function getLocalScreenShareTrack(): MediaStreamTrack | null {
|
function getLocalScreenShareTrack(): MediaStreamTrack | null {
|
||||||
const track = getTrackPublicationBySource(
|
const track = getTrackPublicationBySource(
|
||||||
room.localParticipant,
|
getRoom().localParticipant,
|
||||||
Track.Source.ScreenShare,
|
Track.Source.ScreenShare,
|
||||||
)?.track;
|
)?.track;
|
||||||
|
|
||||||
|
|
@ -275,7 +295,7 @@ async function updateLocalParticipantAttributes(
|
||||||
screenSharePreviewLength: attributes.screenSharePreview?.length ?? 0,
|
screenSharePreviewLength: attributes.screenSharePreview?.length ?? 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
await room.localParticipant.setAttributes(attributes).catch((error) => {
|
await getRoom().localParticipant.setAttributes(attributes).catch((error) => {
|
||||||
log(1, "call", "red", "Failed to update local participant attributes", {
|
log(1, "call", "red", "Failed to update local participant attributes", {
|
||||||
attributes: Object.keys(attributes),
|
attributes: Object.keys(attributes),
|
||||||
error,
|
error,
|
||||||
|
|
@ -487,7 +507,7 @@ function requireRuntime(runtime: Runtime | null): Runtime {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRoomMetadata() {
|
export function getRoomMetadata() {
|
||||||
const roomMetadata = room.metadata;
|
const roomMetadata = getRoom().metadata;
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(roomMetadata || '{"admins": []}');
|
const data = JSON.parse(roomMetadata || '{"admins": []}');
|
||||||
return data as { admins: number[] };
|
return data as { admins: number[] };
|
||||||
|
|
@ -498,7 +518,8 @@ export function getRoomMetadata() {
|
||||||
|
|
||||||
// Sync local participant flags and screen-share derived state for the active call UI.
|
// Sync local participant flags and screen-share derived state for the active call UI.
|
||||||
export function syncParticipantState() {
|
export function syncParticipantState() {
|
||||||
const { room, screenShareSession } = useCall.getState();
|
const { screenShareSession } = useCall.getState();
|
||||||
|
const room = getRoom();
|
||||||
|
|
||||||
useCall.setState({
|
useCall.setState({
|
||||||
micEnabled: room.localParticipant.isMicrophoneEnabled,
|
micEnabled: room.localParticipant.isMicrophoneEnabled,
|
||||||
|
|
@ -721,7 +742,7 @@ let screenShareController: ReturnType<
|
||||||
function getScreenShareController() {
|
function getScreenShareController() {
|
||||||
if (!screenShareController) {
|
if (!screenShareController) {
|
||||||
screenShareController = createScreenShareController({
|
screenShareController = createScreenShareController({
|
||||||
room,
|
room: getRoom(),
|
||||||
getState: () => ({
|
getState: () => ({
|
||||||
screenShareSession: useCall.getState().screenShareSession,
|
screenShareSession: useCall.getState().screenShareSession,
|
||||||
}),
|
}),
|
||||||
|
|
@ -733,7 +754,7 @@ function getScreenShareController() {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getLocalParticipantId: () =>
|
getLocalParticipantId: () =>
|
||||||
getParticipantId(room.localParticipant.identity),
|
getParticipantId(getRoom().localParticipant.identity),
|
||||||
startWatching: startWatchingStream,
|
startWatching: startWatchingStream,
|
||||||
stopWatching: stopWatchingStream,
|
stopWatching: stopWatchingStream,
|
||||||
syncParticipantState,
|
syncParticipantState,
|
||||||
|
|
@ -758,7 +779,7 @@ export async function connect(callId: string) {
|
||||||
callSecret: useCall.getState().callSecret,
|
callSecret: useCall.getState().callSecret,
|
||||||
});
|
});
|
||||||
|
|
||||||
await room
|
await getRoom()
|
||||||
.connect("wss://call.tensamin.net", token, {
|
.connect("wss://call.tensamin.net", token, {
|
||||||
autoSubscribe: false,
|
autoSubscribe: false,
|
||||||
})
|
})
|
||||||
|
|
@ -774,7 +795,7 @@ export async function connect(callId: string) {
|
||||||
|
|
||||||
syncAllRemoteTrackSubscriptions();
|
syncAllRemoteTrackSubscriptions();
|
||||||
|
|
||||||
await room.localParticipant.setMicrophoneEnabled(true).catch((error) => {
|
await getRoom().localParticipant.setMicrophoneEnabled(true).catch((error) => {
|
||||||
log(1, "call", "red", "Failed to enable microphone", error);
|
log(1, "call", "red", "Failed to enable microphone", error);
|
||||||
toast("error", "Failed to enable microphone.");
|
toast("error", "Failed to enable microphone.");
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -819,12 +840,12 @@ export async function disconnect() {
|
||||||
micGated: false,
|
micGated: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
room.remoteParticipants.forEach((participant) => {
|
getRoom().remoteParticipants.forEach((participant) => {
|
||||||
participant.setVolume(1);
|
participant.setVolume(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await room.disconnect();
|
await getRoom().disconnect();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(1, "call", "red", "Failed to disconnect from room", error);
|
log(1, "call", "red", "Failed to disconnect from room", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -867,8 +888,8 @@ export async function joinCall(
|
||||||
callSecret,
|
callSecret,
|
||||||
);
|
);
|
||||||
|
|
||||||
await keyProvider.setKey(decryptedSecret);
|
await getKeyProvider().setKey(decryptedSecret);
|
||||||
await room.setE2EEEnabled(true);
|
await getRoom().setE2EEEnabled(true);
|
||||||
useCall.setState({ callSecret: decryptedSecret });
|
useCall.setState({ callSecret: decryptedSecret });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log(1, "call", "red", "Failed getting call secret", err);
|
log(1, "call", "red", "Failed getting call secret", err);
|
||||||
|
|
@ -878,8 +899,8 @@ export async function joinCall(
|
||||||
} else {
|
} else {
|
||||||
const random = crypto.randomUUID();
|
const random = crypto.randomUUID();
|
||||||
|
|
||||||
await keyProvider.setKey(random);
|
await getKeyProvider().setKey(random);
|
||||||
await room.setE2EEEnabled(true);
|
await getRoom().setE2EEEnabled(true);
|
||||||
useCall.setState({ callSecret: random });
|
useCall.setState({ callSecret: random });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -898,11 +919,11 @@ export async function joinCall(
|
||||||
export async function toggleDeaf() {
|
export async function toggleDeaf() {
|
||||||
const nextDeaf = !useCall.getState().deaf;
|
const nextDeaf = !useCall.getState().deaf;
|
||||||
|
|
||||||
room.remoteParticipants.forEach((participant) => {
|
getRoom().remoteParticipants.forEach((participant) => {
|
||||||
participant.setVolume(nextDeaf ? 0 : 1);
|
participant.setVolume(nextDeaf ? 0 : 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (nextDeaf && room.localParticipant.isMicrophoneEnabled) {
|
if (nextDeaf && getRoom().localParticipant.isMicrophoneEnabled) {
|
||||||
await toggleMute();
|
await toggleMute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -922,7 +943,7 @@ export async function toggleMute() {
|
||||||
await toggleDeaf();
|
await toggleDeaf();
|
||||||
}
|
}
|
||||||
|
|
||||||
await room.localParticipant.setMicrophoneEnabled(!micEnabled);
|
await getRoom().localParticipant.setMicrophoneEnabled(!micEnabled);
|
||||||
syncParticipantState();
|
syncParticipantState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -986,7 +1007,7 @@ export function resetCallState() {
|
||||||
async function ensureNoiseFilter(
|
async function ensureNoiseFilter(
|
||||||
noiseFilter: DeepFilterNoiseFilterProcessor,
|
noiseFilter: DeepFilterNoiseFilterProcessor,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const microphoneTrack = room.localParticipant.getTrackPublication(
|
const microphoneTrack = getRoom().localParticipant.getTrackPublication(
|
||||||
Track.Source.Microphone,
|
Track.Source.Microphone,
|
||||||
)?.track;
|
)?.track;
|
||||||
|
|
||||||
|
|
@ -1001,7 +1022,7 @@ async function ensureNoiseFilter(
|
||||||
log(1, "call", "red", "Failed to enable noise filter", err);
|
log(1, "call", "red", "Failed to enable noise filter", err);
|
||||||
});
|
});
|
||||||
|
|
||||||
const participantId = getParticipantId(room.localParticipant.identity);
|
const participantId = getParticipantId(getRoom().localParticipant.identity);
|
||||||
if (participantId != null) {
|
if (participantId != null) {
|
||||||
const processedTrack = microphoneTrack.mediaStreamTrack;
|
const processedTrack = microphoneTrack.mediaStreamTrack;
|
||||||
getSpeakingDetector().addTrack(
|
getSpeakingDetector().addTrack(
|
||||||
|
|
@ -1021,8 +1042,8 @@ export const useCall = create<CallStore>(() => ({
|
||||||
livekitToken: null,
|
livekitToken: null,
|
||||||
currentCallData: null,
|
currentCallData: null,
|
||||||
deaf: false,
|
deaf: false,
|
||||||
micEnabled: room.localParticipant.isMicrophoneEnabled,
|
micEnabled: false,
|
||||||
screenShareEnabled: room.localParticipant.isScreenShareEnabled,
|
screenShareEnabled: false,
|
||||||
screenShareSession: null,
|
screenShareSession: null,
|
||||||
focusedParticipantId: null,
|
focusedParticipantId: null,
|
||||||
focusedParticipantType: null,
|
focusedParticipantType: null,
|
||||||
|
|
@ -1030,15 +1051,11 @@ export const useCall = create<CallStore>(() => ({
|
||||||
watchedStreamParticipantIds: [],
|
watchedStreamParticipantIds: [],
|
||||||
pendingWatchedParticipantIds: [],
|
pendingWatchedParticipantIds: [],
|
||||||
activeScreenShareParticipantIds: [],
|
activeScreenShareParticipantIds: [],
|
||||||
isEncrypted:
|
isEncrypted: false,
|
||||||
room.localParticipant.isE2EEEnabled && room.localParticipant.isEncrypted,
|
|
||||||
callIsFullscreen: false,
|
callIsFullscreen: false,
|
||||||
callIsPopout: false,
|
callIsPopout: false,
|
||||||
layoutVersion: 0,
|
layoutVersion: 0,
|
||||||
screenRef: null,
|
screenRef: null,
|
||||||
room,
|
|
||||||
keyProvider,
|
|
||||||
e2eeWorker,
|
|
||||||
runtime: null,
|
runtime: null,
|
||||||
speakingParticipantIds: new Set(),
|
speakingParticipantIds: new Set(),
|
||||||
micGated: false,
|
micGated: false,
|
||||||
|
|
@ -1384,6 +1401,7 @@ export function useInitializeCall() {
|
||||||
syncParticipantState();
|
syncParticipantState();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const room = getRoom();
|
||||||
room.on(RoomEvent.Connected, onConnected);
|
room.on(RoomEvent.Connected, onConnected);
|
||||||
room.on(RoomEvent.Reconnected, onConnected);
|
room.on(RoomEvent.Reconnected, onConnected);
|
||||||
room.on(RoomEvent.Disconnected, onDisconnected);
|
room.on(RoomEvent.Disconnected, onDisconnected);
|
||||||
|
|
@ -1424,7 +1442,7 @@ export function useInitializeCall() {
|
||||||
clearRemoteAudio();
|
clearRemoteAudio();
|
||||||
listenersRegistered.current = false;
|
listenersRegistered.current = false;
|
||||||
room.disconnect();
|
room.disconnect();
|
||||||
e2eeWorker.terminate();
|
if (_e2eeWorker) _e2eeWorker.terminate();
|
||||||
};
|
};
|
||||||
}, [noiseFilter, load]);
|
}, [noiseFilter, load]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { RoomEvent } from "livekit-client";
|
import { RoomEvent } from "livekit-client";
|
||||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useCall } from "../../store";
|
import { useCall, getRoom } from "../../store";
|
||||||
import Base from "../../components/modals/base";
|
import Base from "../../components/modals/base";
|
||||||
|
|
||||||
const SECONDARY_ROW_HEIGHT_PX = 180;
|
const SECONDARY_ROW_HEIGHT_PX = 180;
|
||||||
const STACK_GAP_PX = 12;
|
const STACK_GAP_PX = 12;
|
||||||
|
|
||||||
export default function View() {
|
export default function View() {
|
||||||
const room = useCall((state) => state.room);
|
const room = getRoom();
|
||||||
const layoutVersion = useCall((state) => state.layoutVersion);
|
const layoutVersion = useCall((state) => state.layoutVersion);
|
||||||
|
|
||||||
const usersInFocusedViewHidden = useCall(
|
const usersInFocusedViewHidden = useCall(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { RoomEvent } from "livekit-client";
|
import { RoomEvent } from "livekit-client";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useCall } from "../../store";
|
import { useCall, getRoom } from "../../store";
|
||||||
import Base from "../../components/modals/base";
|
import Base from "../../components/modals/base";
|
||||||
|
|
||||||
const TILE_ASPECT_RATIO = 16 / 9;
|
const TILE_ASPECT_RATIO = 16 / 9;
|
||||||
|
|
@ -82,7 +82,7 @@ function calculateOptimalGridLayout(
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function View() {
|
export default function View() {
|
||||||
const room = useCall((state) => state.room);
|
const room = getRoom();
|
||||||
const layoutVersion = useCall((state) => state.layoutVersion);
|
const layoutVersion = useCall((state) => state.layoutVersion);
|
||||||
const activeScreenShareParticipantIds = useCall(
|
const activeScreenShareParticipantIds = useCall(
|
||||||
(state) => state.activeScreenShareParticipantIds,
|
(state) => state.activeScreenShareParticipantIds,
|
||||||
|
|
|
||||||
|
|
@ -3,45 +3,72 @@ import type { RawMessage } from "../values";
|
||||||
import Text from "@tensamin/markdown/text";
|
import Text from "@tensamin/markdown/text";
|
||||||
import { AlertTriangle } from "lucide-react";
|
import { AlertTriangle } from "lucide-react";
|
||||||
|
|
||||||
import { cn, Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui";
|
import {
|
||||||
import { useIsMobile } from "@tensamin/ui";
|
Avatar,
|
||||||
|
AvatarFallback,
|
||||||
|
AvatarImage,
|
||||||
|
cn,
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@tensamin/ui";
|
||||||
import {
|
import {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
ContextMenuContent,
|
ContextMenuContent,
|
||||||
ContextMenuItem,
|
ContextMenuItem,
|
||||||
ContextMenuTrigger,
|
ContextMenuTrigger,
|
||||||
} from "@tensamin/ui";
|
} from "@tensamin/ui";
|
||||||
|
import Wrapper from "@tensamin/user/wrapper";
|
||||||
|
import { useChat } from "../context";
|
||||||
|
|
||||||
function MessageComponent({
|
function MessageComponent({
|
||||||
|
grouped,
|
||||||
message,
|
message,
|
||||||
}: {
|
}: {
|
||||||
|
grouped: boolean;
|
||||||
message: RawMessage & {
|
message: RawMessage & {
|
||||||
failed?: boolean;
|
failed?: boolean;
|
||||||
};
|
};
|
||||||
}) {
|
}) {
|
||||||
const isMobile = useIsMobile();
|
const { userId } = useChat();
|
||||||
const actuallyFailed = message.failed && message.message_state === "awaiting";
|
const actuallyFailed = message.failed && message.message_state === "awaiting";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`w-full flex justify-start transition-opacity duration-150 ${actuallyFailed || message.message_state === "awaiting" ? "opacity-50" : ""}`}
|
className={`${grouped ? "" : "pt-3"} w-full flex justify-start transition-opacity duration-150 ${actuallyFailed || message.message_state === "awaiting" ? "opacity-50" : ""}`}
|
||||||
>
|
>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenuTrigger
|
<ContextMenuTrigger
|
||||||
render={
|
render={
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"selection-foreground flex gap-1 items-center justify-center max-w-[80%] rounded-lg px-2 py-px whitespace-pre-wrap break-all",
|
"group hover:bg-muted/50 select-text! justify-start flex gap-1 items-center w-full px-2 whitespace-pre-wrap break-all",
|
||||||
{
|
{
|
||||||
"bg-(--destructive)/75 text-destructive-foreground":
|
"bg-(--destructive)/15 text-destructive-foreground":
|
||||||
actuallyFailed,
|
actuallyFailed,
|
||||||
"bg-primary text-primary-foreground":
|
|
||||||
!actuallyFailed && message.sent_by_self,
|
|
||||||
"bg-muted": !message.sent_by_self,
|
|
||||||
"select-none": isMobile,
|
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
<Wrapper
|
||||||
|
loading={"State not achievable"}
|
||||||
|
userId={message.sent_by_self ? "own" : userId}
|
||||||
|
component={(user) => (
|
||||||
|
<>
|
||||||
|
{grouped ? (
|
||||||
|
<p className="w-9 text-xs group-hover:visible invisible text-muted-foreground">
|
||||||
|
{new Date(message.send_time).toLocaleString([], {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<Avatar className="mr-1 mb-auto mt-1 w-10">
|
||||||
|
<AvatarImage src={user.avatar} />
|
||||||
|
<AvatarFallback>
|
||||||
|
{user.display.slice(0, 2).toUpperCase()}
|
||||||
|
</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
)}
|
||||||
{message.failed && message.message_state === "awaiting" && (
|
{message.failed && message.message_state === "awaiting" && (
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
|
|
@ -50,8 +77,24 @@ function MessageComponent({
|
||||||
<TooltipTrigger render={<AlertTriangle size={17} />} />
|
<TooltipTrigger render={<AlertTriangle size={17} />} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
<div className="flex flex-col">
|
||||||
|
{!grouped && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<p className="font-medium">{user.display}</p>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{new Date(message.send_time).toLocaleString([], {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<Text value={message.content} />
|
<Text value={message.content} />
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ContextMenuContent>
|
<ContextMenuContent>
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ export default function Screen() {
|
||||||
<div
|
<div
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
id="chat_container"
|
id="chat_container"
|
||||||
className="min-h-0 flex-1 overflow-y-auto px-2.5"
|
className="min-h-0 flex-1 overflow-y-auto"
|
||||||
style={{
|
style={{
|
||||||
overflowAnchor: "none",
|
overflowAnchor: "none",
|
||||||
paddingBottom: "8px",
|
paddingBottom: "8px",
|
||||||
|
|
@ -465,8 +465,8 @@ export default function Screen() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="w-full flex justify-start">
|
<div className="w-full flex justify-start">
|
||||||
<div className="max-w-[80%] rounded-lg bg-muted px-2 py-px text-sm text-foreground/55 whitespace-pre-wrap break-all">
|
<div className="text-sm text-foreground/55 px-2.5">
|
||||||
This is the start of your conversation with{" "}
|
Conversation start
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -481,6 +481,13 @@ export default function Screen() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lastMessage = messages[messageIndex - 1];
|
||||||
|
const isGrouped =
|
||||||
|
lastMessage &&
|
||||||
|
lastMessage.sent_by_self === message.sent_by_self &&
|
||||||
|
Math.round(lastMessage.send_time / 10000) ===
|
||||||
|
Math.round(message.send_time / 10000);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={message.send_time}
|
key={message.send_time}
|
||||||
|
|
@ -492,10 +499,9 @@ export default function Screen() {
|
||||||
left: 0,
|
left: 0,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
transform: `translateY(${virtualRow.start + verticalOffset}px)`,
|
transform: `translateY(${virtualRow.start + verticalOffset}px)`,
|
||||||
padding: "4px 0",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Message message={message} />
|
<Message grouped={isGrouped} message={message} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
@ -509,17 +515,25 @@ export default function Screen() {
|
||||||
className="pointer-events-none absolute left-0 top-0 -z-10 overflow-hidden opacity-0"
|
className="pointer-events-none absolute left-0 top-0 -z-10 overflow-hidden opacity-0"
|
||||||
style={{ width: scrollWidth > 0 ? `${scrollWidth}px` : "100%" }}
|
style={{ width: scrollWidth > 0 ? `${scrollWidth}px` : "100%" }}
|
||||||
>
|
>
|
||||||
{messages.map((message) => (
|
{messages.map((message, messageIndex) => {
|
||||||
|
const lastMessage = messages[messageIndex - 1];
|
||||||
|
const isGrouped =
|
||||||
|
lastMessage &&
|
||||||
|
lastMessage.sent_by_self === message.sent_by_self &&
|
||||||
|
Math.round(lastMessage.send_time / 10000) ===
|
||||||
|
Math.round(message.send_time / 10000);
|
||||||
|
|
||||||
|
return (
|
||||||
<div
|
<div
|
||||||
key={`measure-${message.send_time}`}
|
key={`measure-${message.send_time}`}
|
||||||
ref={(element) => {
|
ref={(element) => {
|
||||||
setMeasurementRef(message.send_time, element);
|
setMeasurementRef(message.send_time, element);
|
||||||
}}
|
}}
|
||||||
style={{ padding: "4px 0" }}
|
|
||||||
>
|
>
|
||||||
<Message message={message} />
|
<Message grouped={isGrouped} message={message} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ export function renderBlocks(blocks: MarkdownBlock[]): React.ReactElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p key={blockIndex} className="tm-md-p">
|
<p key={blockIndex}>
|
||||||
{block.text.split("\n").map((line, lineIndex) => (
|
{block.text.split("\n").map((line, lineIndex) => (
|
||||||
<React.Fragment key={lineIndex}>
|
<React.Fragment key={lineIndex}>
|
||||||
{lineIndex > 0 ? <br /> : null}
|
{lineIndex > 0 ? <br /> : null}
|
||||||
|
|
@ -645,7 +645,6 @@ export const markdownStyles = `
|
||||||
.tm-md-h4 { font-size: 1.1rem; }
|
.tm-md-h4 { font-size: 1.1rem; }
|
||||||
.tm-md-h5 { font-size: 1rem; }
|
.tm-md-h5 { font-size: 1rem; }
|
||||||
.tm-md-h6 { font-size: 0.95rem; opacity: 0.9; }
|
.tm-md-h6 { font-size: 0.95rem; opacity: 0.9; }
|
||||||
.tm-md-p { margin: 0.25rem 0; }
|
|
||||||
.tm-md-blockquote { margin: 0.45rem 0; padding-left: 0.75rem; opacity: 0.95; }
|
.tm-md-blockquote { margin: 0.45rem 0; padding-left: 0.75rem; opacity: 0.95; }
|
||||||
.tm-md-blockquote p { margin: 0.2rem 0; }
|
.tm-md-blockquote p { margin: 0.2rem 0; }
|
||||||
.tm-md-pre { margin: 0.45rem 0; padding: 0.65rem 0.75rem; border-radius: 0.5rem; background: hsl(var(--muted)); overflow-x: auto; }
|
.tm-md-pre { margin: 0.45rem 0; padding: 0.65rem 0.75rem; border-radius: 0.5rem; background: hsl(var(--muted)); overflow-x: auto; }
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ export function Provider(props: {
|
||||||
typeof createTransportClient<Schemas>
|
typeof createTransportClient<Schemas>
|
||||||
> | null>(null);
|
> | null>(null);
|
||||||
const identificationStartedRef = useRef(false);
|
const identificationStartedRef = useRef(false);
|
||||||
|
const identificationCancelRef = useRef(false);
|
||||||
|
|
||||||
// Load ttp url
|
// Load ttp url
|
||||||
const [ttpUrl, setTtpUrl] = useState<string | null>(null);
|
const [ttpUrl, setTtpUrl] = useState<string | null>(null);
|
||||||
|
|
@ -242,6 +243,23 @@ export function Provider(props: {
|
||||||
return client.subscribePush(handler);
|
return client.subscribePush(handler);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Check for error_no_iota
|
||||||
|
useEffect(() => {
|
||||||
|
if (!connected) return;
|
||||||
|
|
||||||
|
return subscribePush((message) => {
|
||||||
|
if (message.type !== "error_no_iota") return;
|
||||||
|
|
||||||
|
identificationCancelRef.current = true;
|
||||||
|
setIdentified(false);
|
||||||
|
setIdentifying(false);
|
||||||
|
setError("We couldn't reach your Iota");
|
||||||
|
setErrorDescription(
|
||||||
|
"You could try to restart your Iota, check for updates or check your network connection.",
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}, [connected, subscribePush]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!connected || !identified) {
|
if (!connected || !identified) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -363,6 +381,7 @@ export function Provider(props: {
|
||||||
clearReconnectTimer();
|
clearReconnectTimer();
|
||||||
scheduleReconnectReset();
|
scheduleReconnectReset();
|
||||||
identificationStartedRef.current = false;
|
identificationStartedRef.current = false;
|
||||||
|
identificationCancelRef.current = false;
|
||||||
setConnected(true);
|
setConnected(true);
|
||||||
setIdentified(false);
|
setIdentified(false);
|
||||||
setError("");
|
setError("");
|
||||||
|
|
@ -483,6 +502,11 @@ export function Provider(props: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (identificationCancelRef.current) {
|
||||||
|
identificationStartedRef.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (identificationStartedRef.current) {
|
if (identificationStartedRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -551,10 +575,12 @@ export function Provider(props: {
|
||||||
const finalResponse = await send("challenge_response", {
|
const finalResponse = await send("challenge_response", {
|
||||||
challenge: decryptedChallenge,
|
challenge: decryptedChallenge,
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
if (!identificationCancelRef.current) {
|
||||||
setError("Identification Failed");
|
setError("Identification Failed");
|
||||||
setErrorDescription(
|
setErrorDescription(
|
||||||
"Unable to complete secure identification. Please verify your credentials and try again.",
|
"Unable to complete secure identification. Please verify your credentials and try again.",
|
||||||
);
|
);
|
||||||
|
}
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -562,7 +588,7 @@ export function Provider(props: {
|
||||||
setFreshContacts(finalResponse.data.contacts);
|
setFreshContacts(finalResponse.data.contacts);
|
||||||
setFreshCommunities(finalResponse.data.communities);
|
setFreshCommunities(finalResponse.data.communities);
|
||||||
setFreshCalls(finalResponse.data.calls);
|
setFreshCalls(finalResponse.data.calls);
|
||||||
if (cancelled) {
|
if (cancelled || identificationCancelRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -574,6 +600,10 @@ export function Provider(props: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (identificationCancelRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isStopSendingError(identificationError)) {
|
if (isStopSendingError(identificationError)) {
|
||||||
setError("Connection closed");
|
setError("Connection closed");
|
||||||
setErrorDescription(
|
setErrorDescription(
|
||||||
|
|
@ -604,7 +634,7 @@ export function Provider(props: {
|
||||||
: "Unable to complete secure identification because the transport request failed.",
|
: "Unable to complete secure identification because the transport request failed.",
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (!cancelled) {
|
if (!cancelled && !identificationCancelRef.current) {
|
||||||
setIdentifying(false);
|
setIdentifying(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue