Add pwa & stuff #75

Merged
alois merged 48 commits from dev into main 2026-08-18 22:32:16 +03:00
8 changed files with 3065 additions and 6002 deletions
Showing only changes of commit 99c38162a6 - Show all commits

chore(babysit): cleanup slop
Some checks failed
/ release (push) Has been cancelled
/ build-mobile (push) Has been cancelled
/ build-web (push) Has been cancelled
/ build-desktop (linux) (push) Has been cancelled

Alois 2026-08-07 23:41:49 +02:00
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24

View file

@ -1,18 +0,0 @@
import { describe, expect, it } from "vitest";
import { mtp } from "@tensamin/shared/data";
import { onlineStatusOptions } from "./status-options";
describe("sidebar status requests", () => {
it.each(onlineStatusOptions)("sends $label as $value", ({ value }) => {
expect(mtp.SetUserState.request.parse({ UserState: value })).toEqual({
UserState: value,
});
});
it("keeps status text on the profile operation", () => {
expect(mtp.ChangeUserData.request.parse({ Status: "At lunch" })).toEqual({
Status: "At lunch",
});
});
});

View file

@ -1,15 +0,0 @@
import { describe, expect, it } from "vitest";
import { onlineStatusOptions } from "./status-options";
describe("status options", () => {
it("uses the exact client protocol values", () => {
expect(onlineStatusOptions).toEqual([
{ label: "Online", value: "user_online" },
{ label: "Idle", value: "user_idle" },
{ label: "Do not disturb", value: "user_dnd" },
{ label: "Away", value: "user_wc" },
{ label: "Offline", value: "user_invisible" },
]);
});
});

@ -1 +1 @@
Subproject commit 486541b9483356ff49ff3ec7016f87d3ecbeaa0e
Subproject commit 11a1d79409857b734e948dd8c3e28e6ba721d15f

View file

@ -46,9 +46,5 @@
"@methanium/ui": "*",
"mtp": "*",
"sonner": "^2.0.7"
},
"overrides": {
"@methanium/ui": "https://git.methanium.net/methanium/ui/releases/download/0.0.22/methanium-ui.tgz",
"mtp": "https://git.methanium.net/methanium/mtp/releases/download/0.2.0-dev-a692bed/mtp-0.2.0.tgz"
}
}

View file

@ -1,19 +0,0 @@
import { describe, expect, it } from "vitest";
import { removeMissingContactSnapshots } from "./sync";
describe("authoritative contact cache updates", () => {
it("removes missing users and keeps the latest authoritative set", () => {
const contacts = [{ UserId: 2 }, { UserId: 3 }, { UserId: 4 }];
expect(removeMissingContactSnapshots(contacts, [3, 99])).toEqual([
{ UserId: 2 },
{ UserId: 4 },
]);
});
it("does not let a delayed state notification recreate a removed contact", () => {
const contacts = [{ UserId: 2 }];
const afterMissing = removeMissingContactSnapshots(contacts, [2]);
expect(removeMissingContactSnapshots(afterMissing, [])).toEqual([]);
});
});

View file

@ -1,65 +0,0 @@
import { describe, expect, it } from "vitest";
import {
accountUserSchema,
mtp,
publicUserSchema,
userPresencePreferenceSchema,
} from "./data";
const profile = {
Display: "Alice",
IotaId: 1,
OmikronConnections: [],
PublicKey: "aGVsbG8=",
SubEnd: 0,
SubLevel: 0,
UserId: 1,
Username: "alice",
};
describe("presence protocol schemas", () => {
it.each([
"user_online",
"user_idle",
"user_dnd",
"user_wc",
"user_invisible",
])("accepts writable preference %s", (state) => {
expect(userPresencePreferenceSchema.parse(state)).toBe(state);
expect(mtp.SetUserState.request.parse({ UserState: state })).toEqual({
UserState: state,
});
});
it("keeps invisible private to the account schema", () => {
expect(
accountUserSchema.parse({ ...profile, OnlineStatus: "user_invisible" })
.OnlineStatus,
).toBe("user_invisible");
expect(
publicUserSchema.safeParse({ ...profile, OnlineStatus: "user_invisible" })
.success,
).toBe(false);
expect(
publicUserSchema.parse({ ...profile, OnlineStatus: "user_offline" })
.OnlineStatus,
).toBe("user_offline");
});
it("does not put state changes or lowercase status in ChangeUserData", () => {
const statePayload = mtp.ChangeUserData.request.safeParse({
OnlineStatus: "user_online",
});
expect(statePayload.success ? statePayload.data : undefined).toEqual({});
expect(mtp.ChangeUserData.request.parse({ Status: "At lunch" })).toEqual({
Status: "At lunch",
});
const lowercasePayload = mtp.ChangeUserData.request.safeParse({
status: "At lunch",
});
expect(
lowercasePayload.success ? lowercasePayload.data : undefined,
).toEqual({});
});
});

View file

@ -1,45 +0,0 @@
import { describe, expect, it } from "vitest";
import { accountUserSchema, publicUserSchema } from "@tensamin/shared/data";
import { mergeTransientPresence } from "./context";
const profile = {
Display: "Alice",
IotaId: 1,
OmikronConnections: [],
PublicKey: "aGVsbG8=",
SubEnd: 0,
SubLevel: 0,
UserId: 7,
Username: "alice",
};
describe("transient presence overlay", () => {
it("keeps private invisible state on the account without persisting it", () => {
const account = accountUserSchema.parse({
...profile,
OnlineStatus: "user_online",
});
const overlay = new Map([[7, "user_invisible" as const]]);
expect(mergeTransientPresence(account, overlay).OnlineStatus).toBe(
"user_invisible",
);
expect(publicUserSchema.safeParse(account).success).toBe(false);
});
it("merges public live state into a profile without changing durable fields", () => {
const contact = publicUserSchema.parse({
...profile,
OnlineStatus: "user_online",
});
const overlay = new Map([[7, "user_offline" as const]]);
const merged = mergeTransientPresence(contact, overlay);
expect(merged).toMatchObject({
UserId: 7,
Username: "alice",
OnlineStatus: "user_offline",
});
});
});

8535
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff