Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(debug): define rpc helper before sign-in navigation

Steven Enamakelac93618b1b3e
diff --git a/scripts/__tests__/debug-web-ui.test.mjs b/scripts/__tests__/debug-web-ui.test.mjs
index 8c6d2d492d..f7c5689903 100644
--- a/scripts/__tests__/debug-web-ui.test.mjs
+++ b/scripts/__tests__/debug-web-ui.test.mjs
@@ -5,6 +5,7 @@ import test from "node:test";
import {
coreLaunchSpec,
devConnectUrl,
+ ensureSignedInChat,
mergeChildEnv,
freePort,
isLoopback,
@@ -14,6 +15,31 @@ import {
waitFor,
} from "../debug/web-ui-lib.mjs";
+test("ensureSignedInChat opens the canonical chat route from an authenticated home", async () => {
+ let visible = false;
+ let navigatedTo;
+ const page = {
+ getByRole(role, options) {
+ assert.equal(role, "textbox");
+ assert.equal(options.name, "Message input");
+ return {
+ isVisible: async () => visible,
+ waitFor: async ({ state }) => {
+ assert.equal(state, "visible");
+ assert.equal(visible, true);
+ },
+ };
+ },
+ async goto(url) {
+ navigatedTo = url;
+ visible = true;
+ },
+ };
+
+ await ensureSignedInChat(page, "http://localhost:1420");
+ assert.equal(navigatedTo, "http://localhost:1420/#/chat");
+});
+
test("coreLaunchSpec isolates the core from operator credentials, storage, and dotenv", () => {
const inheritedEnv = {
OPENHUMAN_BACKEND_API_KEY: "inherited",
diff --git a/scripts/debug/web-ui.mjs b/scripts/debug/web-ui.mjs
index 74f1dbdd9c..5a28dd36e1 100644
--- a/scripts/debug/web-ui.mjs
+++ b/scripts/debug/web-ui.mjs
@@ -156,10 +156,13 @@ async function signIn(page, rpc, appOrigin) {
await page.getByText("Welcome to OpenHuman").waitFor({ timeout: 120_000 });
log("signing in through the GitHub provider button (mock backend)…");
await page.getByRole("button", { name: "GitHub" }).click();
- await waitFor(async () => (await rpc("openhuman.auth_get_state")).isAuthenticated, {
- timeoutMs: 120_000,
- what: "the core's authenticated state after mock sign-in",
- });
+ await waitFor(
+ async () => (await rpc("openhuman.auth_get_state")).isAuthenticated,
+ {
+ timeoutMs: 120_000,
+ what: "the core's authenticated state after mock sign-in",
+ },
+ );
await ensureSignedInChat(page, appOrigin);
}
@@ -266,15 +269,6 @@ async function main() {
return file;
};
- // The first load compiles the app's modules on demand; give it room.
- page.setDefaultNavigationTimeout(120_000);
- await page.goto(devConnectUrl(appOrigin, rpcUrl, token));
- if (opts.signIn) {
- await signIn(page, rpc, appOrigin);
- log(`signed in ${page.url()}`);
- }
- await screenshot("ready");
-
const rpc = async (method, params = {}) => {
const res = await fetch(rpcUrl, {
method: "POST",
@@ -288,6 +282,16 @@ async function main() {
if (body.error) throw new Error(`${method}: ${body.error.message}`);
return body.result;
};
+
+ // The first load compiles the app's modules on demand; give it room.
+ page.setDefaultNavigationTimeout(120_000);
+ await page.goto(devConnectUrl(appOrigin, rpcUrl, token));
+ if (opts.signIn) {
+ await signIn(page, rpc, appOrigin);
+ log(`signed in ${page.url()}`);
+ }
+ await screenshot("ready");
+
const mock = {
url: mockUrl,
set: (key, value) =>