Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fill_login: count saved logins with no username instead of listing blanks
AdityaUmale00ff350b9a3b
diff --git a/server/login-fill.test.ts b/server/login-fill.test.tsindex 34e8676c09..fbd4f28fc0 100644--- a/server/login-fill.test.ts+++ b/server/login-fill.test.ts@@ -352,6 +352,15 @@ describe("one-time codes and fields", () => {expect((await fill("carol")).text).toContain('has the username "carol"');});+ it("counts logins with no username instead of listing blanks, and says they can't be picked by name", async () => {+ const saved = [{ host: "example.com", username: "" }, { host: "example.com", username: "alice" }, { host: "example.com", username: "" }];+ const { page, fill } = setup("https://example.com/login", LOGIN_FORM, saved, { submit: false });+ const note = "A login with no username can't be chosen by name: ask the person to add its username where it is saved (Settings → Vault, or the password manager it comes from), or call request_sign_in so the person signs in.";+ expect((await fill()).text).toBe(`There are 3 saved logins for example.com: alice, 2 with no username saved. ${note} Call fill_login again with the username to use.`);+ expect((await fill("carol")).text).toBe(`No saved login for example.com has the username "carol". The usernames saved there: alice, 2 with no username saved. ${note}`);+ expect(page.typed).toEqual([]);+ });+it("says when the page has no login fields", async () => {const { page, fill } = setup("https://example.com/", `<main><input type="search" name="q"><input type="hidden" name="x"></main>`, [{ host: "example.com", username: "alice" }]);const outcome = await fill();diff --git a/server/login-fill.ts b/server/login-fill.tsindex fb77ce1c5c..c4b96978d7 100644--- a/server/login-fill.ts+++ b/server/login-fill.ts@@ -305,6 +305,13 @@ function listed(logins: Array<LoginPlace & { username: string }>): string {return `Your saved logins: ${shown.join(", ")}${logins.length > shown.length ? ` and ${logins.length - shown.length} more` : ""}.`;}+function usernames(logins: FillCandidate[]): string {+ const named = logins.map((login) => login.username).filter(Boolean);+ const blank = logins.length - named.length;+ if (!blank) return `${named.join(", ")}.`;+ return `${[...named, `${blank} with no username saved`].join(", ")}. A login with no username can't be chosen by name: ask the person to add its username where it is saved (Settings → Vault, or the password manager it comes from), or call request_sign_in so the person signs in.`;+}+function joinWords(words: string[]): string {return words.length <= 1 ? words.join("") : `${words.slice(0, -1).join(", ")} and ${words.at(-1)}`;}@@ -385,11 +392,11 @@ export async function fillLogin(input: FillLoginInput, deps: FillLoginDeps): Proif (wanted) {chosen = all.filter((login) => login.username.toLowerCase() === wanted.toLowerCase());if (!chosen.length) {- return { ok: false, host: pageHost, text: `No saved login for ${pageHost} has the username ${JSON.stringify(wanted)}. The usernames saved there: ${all.map((login) => login.username).join(", ")}.` };+ return { ok: false, host: pageHost, text: `No saved login for ${pageHost} has the username ${JSON.stringify(wanted)}. The usernames saved there: ${usernames(all)}` };}}if (chosen.length > 1) {- return { ok: false, host: pageHost, text: `There are ${chosen.length} saved logins for ${pageHost}: ${chosen.map((login) => login.username).join(", ")}. Call fill_login again with the username to use.` };+ return { ok: false, host: pageHost, text: `There are ${chosen.length} saved logins for ${pageHost}: ${usernames(chosen)} Call fill_login again with the username to use.` };}const login = chosen[0]!;if (!loginOriginCheck(pageUrl, login).ok) {