Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,424 changes: 0 additions & 1,424 deletions bun.lock

This file was deleted.

1,625 changes: 0 additions & 1,625 deletions mobile/bun.lock

This file was deleted.

7,981 changes: 7,981 additions & 0 deletions mobile/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion mobile/src/core/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// The parts of the phone's core that run outside React Native, run under Vitest: the
// pairing-string check, the model helpers, and the formatting the transcript and list share.

import { describe, expect, test } from "vitest";
import { describe, expect, test, vi } from "vitest";

vi.mock("./prefs", () => ({ loadPrefs: () => ({}), savePrefs: () => {} }));

test("new setup selects the full catalog while edits preserve an empty selection", () => {
const listed = Array.from({ length: 12 }, (_, i) => ({ id: `combo-${i}` }));
Expand Down
4 changes: 3 additions & 1 deletion mobile/src/core/readAck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vi.doMock("./prefs", () => ({ loadPrefs: () => ({}), savePrefs: () => {} }));
const { markRead, resetStore, useStore } = await import("./store");
const chat = (unread_count: number): Chat => ({ id: "chat", kind: "dm", bot_ids: [], is_pinned: false, created_at: 0, messages: [], unread_count });
const unread = () => useStore.getState().chats[0].unread_count;
const settle = async () => { await new Promise((resolve) => setTimeout(resolve, 0)); };
const settle = async () => { await vi.dynamicImportSettled(); };

test("read acknowledgement keeps failures and revoked or newer unread state honest", async () => {
resetStore();
Expand Down Expand Up @@ -62,10 +62,12 @@ test("read acknowledgement keeps failures and revoked or newer unread state hone

useStore.setState({ chats: [chat(5)] });
markRead("chat");
await settle();
const revoked = pending.shift()!;
useStore.setState({ appActive: false });
useStore.setState({ appActive: true });
markRead("chat");
await settle();
const current = pending.shift()!;
revoked.resolve('{"result":null}');
await settle();
Expand Down
4 changes: 2 additions & 2 deletions mobile/src/core/reading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ beforeEach(async () => {

async function flush() {
// markRead imports the native bridge asynchronously.
await new Promise((resolve) => setTimeout(resolve, 0));
await vi.dynamicImportSettled();
}

function reply(id: string, kind: "reply" | "permission" | "failure" = "reply") {
Expand All @@ -96,7 +96,7 @@ function reply(id: string, kind: "reply" | "permission" | "failure" = "reply") {

function notification(chatId: string, body: string): Notification {
return { date: 1, request: { identifier: chatId, trigger: null, content: {
title: "Chef", subtitle: null, body, data: { chat_id: chatId }, sound: "default",
title: "Chef", subtitle: null, categoryIdentifier: null, body, data: { chat_id: chatId }, sound: "default",
} } };
}

Expand Down
4 changes: 3 additions & 1 deletion mobile/src/ui/modelDraft.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { describe, expect, test } from "vitest";
import { describe, expect, test, vi } from "vitest";

vi.mock("../core/prefs", () => ({ loadPrefs: () => ({}), savePrefs: () => {} }));
import { defaultModelId, selectedModelIds } from "../core/model";
import { addModel, chooseDefaultModel, startModelDraft, takeModelListing, toggleModel, useModelDraft } from "./modelDraft";

Expand Down
23 changes: 23 additions & 0 deletions mobile/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [{
name: "metro-literal-requires",
transform(code, id) {
// Metro bundles these synchronous requires; Vitest must route them through
// its module executor so each file's native boundary mocks apply.
const modules = id.endsWith("/src/core/store.ts")
? ["../../modules/beans-core"]
: id.endsWith("/src/i18n/index.ts") ? ["../core/prefs"] : [];
const imports: string[] = [];
for (const [index, module] of modules.entries()) {
const literal = `require(${JSON.stringify(module)})`;
if (!code.includes(literal)) continue;
if (id.endsWith("/src/core/store.ts")) {
code = code.replaceAll(literal, `(await import(${JSON.stringify(module)}))`);
} else {
imports.push(`import * as metroRequire${index} from ${JSON.stringify(module)};`);
code = code.replaceAll(literal, `metroRequire${index}`);
}
}
if (modules.length) return { code: imports.join("\n") + "\n" + code, map: null };
},
}],
oxc: { jsx: { runtime: "automatic", importSource: "react" } },
test: {
environment: "node",
server: { deps: { inline: ["zustand"] } },
include: ["src/**/*.test.{ts,tsx}"],
pool: "forks",
isolate: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/beans-blobatar/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for (const { entry, out, format } of bundles) {
const output = result.outputFiles[0];
if (!output) throw new Error(`build of ${entry} produced no output`);
const path = join(dir, out);
if (format === "iife") assertJSCGlobals(path, output.contents.toString("utf8"));
if (format === "iife") assertJSCGlobals(path, Buffer.from(output.contents).toString("utf8"));
await mkdir(dirname(path), { recursive: true });
await writeFile(path, output.contents);
}
Expand Down
Loading
Loading