Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Desktop: explain in Phone & devices when the secure link ended for older phone apps (#5162)
Milind Soni05054406b435
diff --git a/electron/companion-account-messages.mjs b/electron/companion-account-messages.mjsnew file mode 100644index 0000000000..d8ec48c6ff--- /dev/null+++ b/electron/companion-account-messages.mjs@@ -0,0 +1,44 @@+// What a person reads when the secure connection service refuses or fails: one line per control-plane code.+import { ControlPlaneError } from "./control-plane-client.mjs";++export const FRIENDLY_MESSAGES = Object.freeze({+ invalid_email: "Enter a valid email address.",+ invalid_request: "The secure connection request was not accepted. Check the details and try again.",+ invalid_otp: "That code is not valid. Check the email and try again.",+ otp_expired: "That code expired. Email yourself a new one.",+ unauthorized: "Your sign-in expired. Email yourself a new code to reconnect.",+ forbidden: "The secure connection request was not allowed. Try signing in again.",+ signed_out: "Your sign-in expired. Email yourself a new code to reconnect.",+ network_unavailable: "OpenMausBot could not reach its secure connection service. Check your internet and try again.",+ rate_limited: "Too many attempts were made. Wait a little, then try again.",+ credential_rotation_rate_limited: "This computer was reconnected too often. Wait a little, then try again.",+ installation_limit_reached: "This account has reached its computer limit. Remove an old computer and try again.",+ installation_exists: "This computer is already connected. Try again to recover it.",+ endpoint_busy: "The secure connection is still being prepared. Try again in a moment.",+ endpoint_rate_limited: "The secure connection service is busy right now. Local Wi-Fi and Tailscale pairing still work; try again in {wait}.",+ update_required: "This version of MausBot can no longer make secure links. Update MausBot, then try again. Local Wi-Fi and Tailscale pairing still work.",+ endpoint_capacity: "Secure HTTPS links are temporarily full. Try again in {wait}, or pair on this Wi-Fi or with Tailscale.",+ endpoint_unavailable: "The secure connection service could not finish setup. Local Wi-Fi and Tailscale pairing still work. If this keeps happening, contact support with the error reference.",+ endpoint_cleanup_pending: "The secure connection is still being removed. Try signing out again shortly.",+ control_plane_unavailable: "Secure access is not available right now. Local pairing still works.",+ internal_error: "The secure connection service had a problem. Local pairing still works; try again.",+ invalid_response: "The secure connection service returned an unexpected response. Try again.",+ request_failed: "The secure connection request could not be completed. Local pairing still works; try again.",+});++function retryWait(retryAfterMs) {+ const seconds = Math.ceil((retryAfterMs ?? 0) / 1_000);+ if (!(seconds > 0)) return "a few minutes";+ if (seconds < 90) return `${seconds} seconds`;+ return `${Math.round(seconds / 60)} minutes`;+}++export function friendlyCompanionAccountError(error) {+ const code = error instanceof ControlPlaneError ? error.code : "";+ const message = (FRIENDLY_MESSAGES[code] ?? FRIENDLY_MESSAGES.request_failed)+ .replace("{wait}", () => retryWait(error.retryAfterMs));+ const reference = error instanceof ControlPlaneError && error.requestId+ ? ` Reference: ${error.requestId}.`+ : "";+ return `${message}${reference}`;+}diff --git a/electron/companion-account-service.d.mts b/electron/companion-account-service.d.mtsindex 6f4c99c84b..64636d0d0f 100644--- a/electron/companion-account-service.d.mts+++ b/electron/companion-account-service.d.mts@@ -12,6 +12,8 @@ export declare const COMPANION_INSTALLATION_CREDENTIAL_FIELD: string;export declare const COMPANION_INSTALLATION_EXPIRY_FIELD: string;export declare const COMPANION_ACCOUNT_CLEANUP_PENDING_FIELD: string;export declare const COMPANION_ENDPOINT_PAUSED_FIELD: string;+export declare const COMPANION_TUNNEL_RETIRED_FIELD: string;+export declare const COMPANION_TUNNEL_WAITING_FIELD: string;export declare const PHONE_UNUSED_RELEASE_MS: number;export type CredentialDocument = Record<string, unknown>;@@ -36,6 +38,9 @@ export interface CompanionAccountState {message?: string;/** The address was given back after 30 days with no paired phone seen; prepare() brings it back. */paused?: true;+ /** The secure address was ended for old phone apps: a phone that has not used the encrypted connection must be+ * updated and paired again. */+ tunnelRetired?: true;}export interface CompanionAccountService {diff --git a/electron/companion-account-service.mjs b/electron/companion-account-service.mjsindex 70e7da7492..e55b441fa5 100644--- a/electron/companion-account-service.mjs+++ b/electron/companion-account-service.mjs@@ -12,6 +12,8 @@ import {withoutManagedCompanionTunnelAccess,} from "./managed-companion-tunnel.mjs";import { MANAGED_ENDPOINT_PHONES_UNUSED } from "./companion-endpoint-need.mjs";+import { FRIENDLY_MESSAGES, friendlyCompanionAccountError } from "./companion-account-messages.mjs";+export { friendlyCompanionAccountError };export { managedEndpointNeed, PHONE_UNUSED_RELEASE_MS } from "./companion-endpoint-need.mjs";@@ -28,6 +30,12 @@ export const COMPANION_ACCOUNT_CLEANUP_PENDING_FIELD = "companionAccountCleanupPexport const COMPANION_ENDPOINT_RELEASE_PENDING_FIELD = "companionEndpointReleasePending";/** The address was given back while phones were paired but unused; the control plane keeps its hostname. */export const COMPANION_ENDPOINT_PAUSED_FIELD = "companionEndpointPaused";+/** The control plane ended this computer's secure address for old phone apps: phones connect through the relay only. */+export const COMPANION_TUNNEL_RETIRED_FIELD = "companionTunnelRetired";+/** The control plane holds no address for this computer although an old phone would use one (ended for old phone+ * apps, or every account full): the watchdog keeps asking, so the address returns when the relay is switched off+ * or room frees up. */+export const COMPANION_TUNNEL_WAITING_FIELD = "companionTunnelWaiting";const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;const INSTALLATION_ID = UUID;@@ -116,6 +124,8 @@ function withoutCompanionAccount(credentials) {COMPANION_ACCOUNT_CLEANUP_PENDING_FIELD,COMPANION_ENDPOINT_RELEASE_PENDING_FIELD,COMPANION_ENDPOINT_PAUSED_FIELD,+ COMPANION_TUNNEL_RETIRED_FIELD,+ COMPANION_TUNNEL_WAITING_FIELD,]) {delete next[field];}@@ -147,6 +157,8 @@ function withProvisionedAccount(credentials, { accountToken, user, installation,delete next[COMPANION_ACCOUNT_CLEANUP_PENDING_FIELD];delete next[COMPANION_ENDPOINT_RELEASE_PENDING_FIELD];delete next[COMPANION_ENDPOINT_PAUSED_FIELD];+ delete next[COMPANION_TUNNEL_RETIRED_FIELD];+ delete next[COMPANION_TUNNEL_WAITING_FIELD];return next;}@@ -171,50 +183,10 @@ function withAuthenticatedAccount(return next;}-const FRIENDLY_MESSAGES = Object.freeze({- invalid_email: "Enter a valid email address.",- invalid_request: "The secure connection request was not accepted. Check the details and try again.",- invalid_otp: "That code is not valid. Check the email and try again.",- otp_expired: "That code expired. Email yourself a new one.",- unauthorized: "Your sign-in expired. Email yourself a new code to reconnect.",- forbidden: "The secure connection request was not allowed. Try signing in again.",- signed_out: "Your sign-in expired. Email yourself a new code to reconnect.",- network_unavailable: "OpenMausBot could not reach its secure connection service. Check your internet and try again.",- rate_limited: "Too many attempts were made. Wait a little, then try again.",- credential_rotation_rate_limited: "This computer was reconnected too often. Wait a little, then try again.",- installation_limit_reached: "This account has reached its computer limit. Remove an old computer and try again.",- installation_exists: "This computer is already connected. Try again to recover it.",- endpoint_busy: "The secure connection is still being prepared. Try again in a moment.",- endpoint_rate_limited: "The secure connection service is busy right now. Local Wi-Fi and Tailscale pairing still work; try again in {wait}.",- endpoint_capacity: "Secure HTTPS links are temporarily full. Try again in {wait}, or pair on this Wi-Fi or with Tailscale.",- endpoint_unavailable: "The secure connection service could not finish setup. Local Wi-Fi and Tailscale pairing still work. If this keeps happening, contact support with the error reference.",- endpoint_cleanup_pending: "The secure connection is still being removed. Try signing out again shortly.",- control_plane_unavailable: "Secure access is not available right now. Local pairing still works.",- internal_error: "The secure connection service had a problem. Local pairing still works; try again.",- invalid_response: "The secure connection service returned an unexpected response. Try again.",- request_failed: "The secure connection request could not be completed. Local pairing still works; try again.",-});--function retryWait(retryAfterMs) {- const seconds = Math.ceil((retryAfterMs ?? 0) / 1_000);- if (!(seconds > 0)) return "a few minutes";- if (seconds < 90) return `${seconds} seconds`;- return `${Math.round(seconds / 60)} minutes`;-}--export function friendlyCompanionAccountError(error) {- const code = error instanceof ControlPlaneError ? error.code : "";- const message = (FRIENDLY_MESSAGES[code] ?? FRIENDLY_MESSAGES.request_failed)- .replace("{wait}", () => retryWait(error.retryAfterMs));- const reference = error instanceof ControlPlaneError && error.requestId- ? ` Reference: ${error.requestId}.`- : "";- return `${message}${reference}`;-}--function publicState({ available, status, email, endpoint, message, paused }) {+function publicState({ available, status, email, endpoint, message, paused, tunnelRetired }) {const state = { available: Boolean(available), status };if (paused === true) state.paused = true;+ if (tunnelRetired === true) state.tunnelRetired = true;const normalizedEmail = normalizeAccountEmail(email);if (normalizedEmail) state.email = normalizedEmail;const accessEndpoint = (() => {@@ -367,6 +339,7 @@ export function createCompanionAccountService({const persistedAccess = managedCompanionTunnelAccess(document);const available = healthy || Boolean(account);const paused = Boolean(account) && !persistedAccess && document[COMPANION_ENDPOINT_PAUSED_FIELD] === true;+ const tunnelRetired = Boolean(account) && !persistedAccess && document[COMPANION_TUNNEL_RETIRED_FIELD] === true;if (!healthy) {return publicState({available,@@ -375,6 +348,7 @@ export function createCompanionAccountService({endpoint: persistedAccess?.endpoint,message: FRIENDLY_MESSAGES.control_plane_unavailable,paused,+ tunnelRetired,});}if (@@ -387,11 +361,11 @@ export function createCompanionAccountService({) {phase = null;}- if (phase) return publicState({ available, ...phase, paused });+ if (phase) return publicState({ available, ...phase, paused, tunnelRetired });if (!account) return publicState({ available, status: "signed-out" });const access = persistedAccess;if (!access) {- if (onDemand) return publicState({ available, status: "ready", email: account.email, paused });+ if (onDemand) return publicState({ available, status: "ready", email: account.email, paused, tunnelRetired });return publicState({available,status: "error",@@ -556,9 +530,32 @@ export function createCompanionAccountService({return (phase = null), settledState();};if (onDemand && (await currentNeed()) === false) return withoutTunnel();+ let relayOnly = null;const endpoint = await client.ensureEndpoint(installation.credential, { appVersion: identity.appVersion, ...(await relay.legacyDevices().then((count) => (count === null ? {} : { legacyDevices: count }))) })- .catch((error) => (error?.code === "relay_capable" ? null : Promise.reject(error)));- if (!endpoint) return withoutTunnel();+ .catch((error) => {+ if (error?.code !== "relay_capable") throw error;+ relayOnly = error.tunnel ?? "none";+ return null;+ });+ if (!endpoint) {+ // The control plane holds no tunnel for this computer any more: stop the connector and forget the address, so+ // nothing keeps dialling or advertising one that is gone. "retired" is remembered for the notice in Settings.+ if (managedCompanionTunnelAccess(credentials())) {+ await stopManagedEndpoint();+ await updateCredentials(withoutManagedCompanionTunnelAccess);+ writeLog(`companion account: the secure address ended (${relayOnly}); phones connect through the relay`);+ }+ await updateCredentials((document) => {+ const next = { ...document };+ if (relayOnly === "retired") next[COMPANION_TUNNEL_RETIRED_FIELD] = true;+ else delete next[COMPANION_TUNNEL_RETIRED_FIELD];+ // With the address forgotten nothing else would ask again: this keeps the watchdog asking.+ if (relayOnly === "retired" || relayOnly === "full") next[COMPANION_TUNNEL_WAITING_FIELD] = true;+ else delete next[COMPANION_TUNNEL_WAITING_FIELD];+ return next;+ });+ return withoutTunnel();+ }try {await updateCredentials((document) =>withProvisionedAccount(document, {@@ -852,7 +849,10 @@ export function createCompanionAccountService({const document = credentials();if (!storedAccount(document) || companionAccountCleanupPending(document)) return null;if (!managedCompanionTunnelAccess(document)) {- if (!savedAddress(document) || autoRetryTimer !== null) return null;+ // Waiting: the control plane ended the address or had no room. Asked again on every watchdog tick while an+ // old phone still needs it, as a desktop that kept its address does.+ const waiting = document[COMPANION_TUNNEL_WAITING_FIELD] === true;+ if ((!savedAddress(document) && !waiting) || autoRetryTimer !== null) return null;return (await currentNeed()) === true ? retryWork() : null;}const need = await currentNeed();diff --git a/electron/companion-account-service.test.mjs b/electron/companion-account-service.test.mjsindex a1576bb96a..94213007e9 100644--- a/electron/companion-account-service.test.mjs+++ b/electron/companion-account-service.test.mjs@@ -8,6 +8,8 @@ import {COMPANION_ACCOUNT_USER_ID_FIELD,COMPANION_CLIENT_INSTANCE_FIELD,COMPANION_ENDPOINT_PAUSED_FIELD,+ COMPANION_TUNNEL_RETIRED_FIELD,+ COMPANION_TUNNEL_WAITING_FIELD,COMPANION_ENDPOINT_RELEASE_PENDING_FIELD,COMPANION_INSTALLATION_CREDENTIAL_FIELD,COMPANION_INSTALLATION_EXPIRY_FIELD,@@ -1429,6 +1431,94 @@ describe("Companion account on demand", () => {f.service.dispose();});+ it("stops the connector, forgets the address and says so when old phone apps no longer get a tunnel", async () => {+ const retired = new ControlPlaneError("relay_capable", 409, "", 0, "retired");+ expect(retired.tunnel).toBe("retired");+ expect(new ControlPlaneError("relay_capable", 409, "", 0, "anything").tunnel).toBeNull();+ expect(new ControlPlaneError("endpoint_capacity", 503, "", 0, "retired").tunnel).toBeNull();+ const client = readyClient({ ensureEndpoint: vi.fn(async () => Promise.reject(retired)) });+ const f = onDemandFixture({ client, relay: { capable: () => true, legacyDevices: async () => 1 } });+ f.companion.need = true;+ const state = await f.service.retry();+ expect(client.ensureEndpoint).toHaveBeenCalledWith(expect.any(String), { appVersion: "1.2.3", legacyDevices: 1 });+ expect(state).toEqual({ available: true, status: "ready", email: "[email protected]", tunnelRetired: true });+ expect(f.store.read()[COMPANION_TUNNEL_RETIRED_FIELD]).toBe(true);+ expect(f.store.read()[COMPANION_TUNNEL_WAITING_FIELD]).toBe(true);+ expect(f.store.read()).not.toHaveProperty(MANAGED_COMPANION_ENDPOINT_FIELD);+ expect(f.stopManagedEndpoint).toHaveBeenCalled();+ f.service.dispose();+ });++ it("keeps asking on the watchdog after the address ended or the accounts were full, so a relay outage hands it back", async () => {+ for (const tunnel of ["retired", "full"]) {+ const refused = new ControlPlaneError("relay_capable", 409, "", 0, tunnel);+ const client = readyClient({ ensureEndpoint: vi.fn(async () => Promise.reject(refused)) });+ const f = onDemandFixture({ client, relay: { capable: () => true, legacyDevices: async () => 1 } });+ f.companion.need = true;+ await f.service.restore();+ await f.service.retry();+ expect(client.ensureEndpoint).toHaveBeenCalledTimes(1);+ expect(f.store.read()[COMPANION_TUNNEL_WAITING_FIELD]).toBe(true);+ expect(f.store.read()).not.toHaveProperty(MANAGED_COMPANION_ENDPOINT_FIELD);++ // Nobody opens Phone & devices: each watchdog tick asks again, and after the hour a manual Retry counts for.+ for (let tick = 2; tick <= 5; tick += 1) {+ f.clock.now += HOUR_MS;+ await f.watchdog();+ expect(client.ensureEndpoint, `${tunnel} tick ${tick}`).toHaveBeenCalledTimes(tick);+ }+ expect(await f.service.state()).toEqual({+ available: true, status: "ready", email: "[email protected]", ...(tunnel === "retired" ? { tunnelRetired: true } : {}),+ });++ // The relay is switched off (or room frees up): the next tick gets the address back and the notice goes.+ client.ensureEndpoint.mockImplementation(async () => ({ endpoint: { url: ENDPOINT }, connectorToken: CONNECTOR_TOKEN }));+ f.clock.now += HOUR_MS;+ await f.watchdog();+ expect(f.store.read()[MANAGED_COMPANION_ENDPOINT_FIELD]).toBe(ENDPOINT);+ expect(f.store.read()).not.toHaveProperty(COMPANION_TUNNEL_RETIRED_FIELD);+ expect(f.store.read()).not.toHaveProperty(COMPANION_TUNNEL_WAITING_FIELD);+ expect(await f.service.state()).not.toHaveProperty("tunnelRetired");+ f.service.dispose();+ }+ });++ it("stops asking once no old phone needs an address, and after a plain relay_capable", async () => {+ const refused = new ControlPlaneError("relay_capable", 409, "", 0, "retired");+ const client = readyClient({ ensureEndpoint: vi.fn(async () => Promise.reject(refused)) });+ const f = onDemandFixture({ client, relay: { capable: () => true, legacyDevices: async () => 1 } });+ f.companion.need = true;+ await f.service.restore();+ await f.service.retry();+ // The old phone was paired again on the encrypted connection: nothing needs the address.+ f.companion.need = false;+ for (let tick = 0; tick < 3; tick += 1) {+ f.clock.now += HOUR_MS;+ await f.watchdog();+ }+ expect(client.ensureEndpoint).toHaveBeenCalledTimes(1);+ f.service.dispose();++ const plain = readyClient({ ensureEndpoint: vi.fn(async () => Promise.reject(new ControlPlaneError("relay_capable", 409))) });+ const g = onDemandFixture({ client: plain, relay: { capable: () => true, legacyDevices: async () => 1 } });+ g.companion.need = true;+ await g.service.restore();+ await expect(g.service.retry()).resolves.toEqual({ available: true, status: "ready", email: "[email protected]" });+ expect(g.store.read()).not.toHaveProperty(COMPANION_TUNNEL_WAITING_FIELD);+ expect(g.store.read()).not.toHaveProperty(COMPANION_TUNNEL_RETIRED_FIELD);+ for (let tick = 0; tick < 3; tick += 1) {+ g.clock.now += HOUR_MS;+ await g.watchdog();+ }+ expect(plain.ensureEndpoint).toHaveBeenCalledTimes(1);+ g.service.dispose();+ });++ it("tells a desktop below the minimum version to update", async () => {+ const message = friendlyCompanionAccountError(new ControlPlaneError("update_required", 426));+ expect(message).toBe("This version of MausBot can no longer make secure links. Update MausBot, then try again. Local Wi-Fi and Tailscale pairing still work.");+ });+it("signs a relay-capable computer in without a tunnel when no phone needs one", async () => {for (const relayCapable of [true, false]) {const f = onDemandFixture({ initial: {}, relay: { capable: () => relayCapable, legacyDevices: async () => 0 } });diff --git a/electron/control-plane-client.mjs b/electron/control-plane-client.mjsindex b5d9ae21d3..642eb418cd 100644--- a/electron/control-plane-client.mjs+++ b/electron/control-plane-client.mjs@@ -64,11 +64,16 @@ const reportableAppVersion = (value) => {const MAX_RETRY_AFTER_MS = 24 * 60 * 60 * 1_000;+/** What `409 relay_capable` may say about the tunnel this computer goes without: old phone apps no longer get one+ * ("retired"), or every account is at its limit ("full"). */+const RELAY_ONLY_REASONS = new Set(["retired", "full"]);+export class ControlPlaneError extends Error {- constructor(code, status = 0, requestId = "", retryAfterMs = 0) {+ constructor(code, status = 0, requestId = "", retryAfterMs = 0, tunnel = null) {super(code);this.name = "ControlPlaneError";this.code = code;+ this.tunnel = code === "relay_capable" && RELAY_ONLY_REASONS.has(tunnel) ? tunnel : null;this.status = status;this.requestId = REQUEST_ID.test(requestId) ? requestId : "";this.retryAfterMs =@@ -244,6 +249,7 @@ export function createControlPlaneClient({response.status,response.headers.get("x-request-id") ?? "",retryAfterMilliseconds(response.headers.get("retry-after")),+ stringValue(plainObject(payload)?.tunnel),);}if (!allowEmpty && !plainObject(payload)) {@@ -382,7 +388,8 @@ export function createControlPlaneClient({},/** `legacyDevices`: paired phones that can't use the encrypted connection; a relay-capable desktop with none gets- * `409 relay_capable` instead of a new tunnel. */+ * `409 relay_capable` instead of a new tunnel. The error's `tunnel` is "retired" when old phone apps no longer+ * get one and "full" when every account is at its limit; otherwise null. */async ensureEndpoint(installationCredential, { appVersion, legacyDevices } = {}) {if (typeof installationCredential !== "string" ||diff --git a/electron/control-plane-client.test.mjs b/electron/control-plane-client.test.mjsindex 26adc19b67..6a93473307 100644--- a/electron/control-plane-client.test.mjs+++ b/electron/control-plane-client.test.mjs@@ -274,6 +274,22 @@ describe("control-plane desktop client", () => {expect(fetchImpl).toHaveBeenCalledTimes(9);});+ it("reads why a relay-capable computer goes without a tunnel, and nothing else from the body", async () => {+ for (const [body, tunnel] of [+ [{ error: "relay_capable", tunnel: "retired" }, "retired"],+ [{ error: "relay_capable", tunnel: "full" }, "full"],+ [{ error: "relay_capable" }, null],+ [{ error: "relay_capable", tunnel: "<b>anything</b>" }, null],+ [{ error: "endpoint_capacity", tunnel: "retired" }, null],+ ]) {+ const client = createControlPlaneClient({+ baseURL: "https://accounts.openmausbot.com",+ fetchImpl: vi.fn(async () => jsonResponse(body, { status: 409 })),+ });+ await expect(client.ensureEndpoint(INSTALL, { appVersion: "0.1.152", legacyDevices: 1 })).rejects.toMatchObject({ code: body.error, tunnel });+ }+ });+it("maps bounded server error codes and hides arbitrary response text", async () => {const client = createControlPlaneClient({baseURL: "https://accounts.openmausbot.com",diff --git a/src/components/PairedPhones.tsx b/src/components/PairedPhones.tsxindex 326ba47397..930c70c777 100644--- a/src/components/PairedPhones.tsx+++ b/src/components/PairedPhones.tsx@@ -44,6 +44,7 @@ export function PhoneRow({ device, connected, state, c, onRemoved, defaultOpen =<div className="truncate text-[14px] font-medium text-ink">{device.name}</div><div className="truncate text-[12px] text-ink-secondary">{phoneSubtitle(device, connected, e2eEnabled)}</div>{c.account?.paused && <div className="truncate text-[12px] text-ink-secondary">{t("remote.devices.paused")}</div>}+ {c.account?.tunnelRetired && !device.e2eAt && <div className="text-[12px] leading-relaxed text-warning">{t("remote.devices.retired")}</div>}</div><buttononClick={() => setOpen((value) => !value)}diff --git a/src/components/PhoneDevicesSection.test.ts b/src/components/PhoneDevicesSection.test.tsindex ff321d4438..d4bc1e2981 100644--- a/src/components/PhoneDevicesSection.test.ts+++ b/src/components/PhoneDevicesSection.test.ts@@ -18,6 +18,7 @@ import {pairingSurfaceCopy,RouteNotices,shouldHydrateCompanionEmail,+ showTunnelRetiredNotice,} from "./PhoneDevicesSection";import type { PhoneSetupController } from "./PhoneSetupFlow";@@ -249,3 +250,16 @@ describe("the update's notes about routes it kept on", () => {expect(renderToStaticMarkup(createElement(RouteNotices, { c, notices: [] }))).toBe("");});});++describe("the notice after the secure address ended for old phone apps", () => {+ const phone = (extra: Record<string, unknown> = {}) => ({ id: "p", name: "Phone", lastSeenAt: 1, ...extra }) as never;++ it("shows only while a paired phone has not used the encrypted connection", () => {+ expect(showTunnelRetiredNotice({ tunnelRetired: true }, { devices: [phone()] })).toBe(true);+ expect(showTunnelRetiredNotice({ tunnelRetired: true }, { devices: [phone({ e2eAt: 5 }), phone()] })).toBe(true);+ expect(showTunnelRetiredNotice({ tunnelRetired: true }, { devices: [phone({ e2eAt: 5 })] })).toBe(false);+ expect(showTunnelRetiredNotice({ tunnelRetired: true }, { devices: [] })).toBe(false);+ expect(showTunnelRetiredNotice({}, { devices: [phone()] })).toBe(false);+ expect(showTunnelRetiredNotice(null, null)).toBe(false);+ });+});diff --git a/src/components/PhoneDevicesSection.tsx b/src/components/PhoneDevicesSection.tsxindex 27447f94cb..abad196c1c 100644--- a/src/components/PhoneDevicesSection.tsx+++ b/src/components/PhoneDevicesSection.tsx@@ -142,6 +142,14 @@ export function shouldResumePausedAddress(return account?.paused === true && account.available && state?.enabled === true && !state.error && state.devices.length > 0;}+/** The secure address was ended for old phone apps and a phone here still depends on it: say what to do, once. */+export function showTunnelRetiredNotice(+ account: Pick<CompanionAccountState, "tunnelRetired"> | null,+ state: Pick<CompanionState, "devices"> | null,+): boolean {+ return account?.tunnelRetired === true && Boolean(state?.devices.some((device) => !device.e2eAt));+}+export const relative = (at: number) => {const seconds = Math.round((Date.now() - at) / 1000);if (seconds < 90) return t("remote.time.justNow");@@ -373,6 +381,11 @@ export function PhoneDevicesSection({ profileEmail = "", focusRequest = 0, simpl<section className="flex flex-col gap-2" data-devices-block="paired"><div className="text-[13px] font-medium text-ink">{t("devices.paired")}</div>+ {showTunnelRetiredNotice(c.account, state) && (+ <p role="status" data-devices-notice="tunnel-retired" className="rounded-xl bg-inset px-3 py-2.5 text-[13px] leading-relaxed text-ink">+ {t("remote.devices.retiredNotice")}+ </p>+ )}<OpenCodeRow c={c} state={state} />{pairedCount ? <PairedPhones c={c} state={state} /> : !state.pairing && <div className="text-[12px] text-ink-secondary">{t("devices.pairedNone")}</div>}<PhonesList />diff --git a/src/locales/en.json b/src/locales/en.jsonindex 6eadfb9bc8..cc56755085 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -4590,6 +4590,8 @@"remote.checkAgain": "Check again","remote.devices.lastSeen": "Last seen {when}","remote.devices.paused": "Paused after 30 days unused. It reconnects when you open this page.",+ "remote.devices.retired": "This phone has an older MausBot app. Update the app, then pair it again here.",+ "remote.devices.retiredNotice": "Phones now reach this computer through MausBot Relay, and the older secure link has been switched off. A phone with an older MausBot app can no longer connect away from your Wi-Fi. Update the MausBot app on that phone, then pair it again here in Settings → Phone & devices.","remote.devices.remove": "Remove {name}","remote.devices.allowView": "Allow computer view","remote.devices.allowViewDetail": "Full interactive access from this device.",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 92fb28a9b5..e81cfe5a03 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -4334,6 +4334,8 @@"remote.checkAgain": "Verificar novamente","remote.devices.lastSeen": "Visto por último {when}","remote.devices.paused": "Pausado após 30 dias sem uso. Ele se reconecta quando você abre esta página.",+ "remote.devices.retired": "Este celular tem um app MausBot mais antigo. Atualize o app e depois pareie o celular de novo aqui.",+ "remote.devices.retiredNotice": "Agora os celulares chegam a este computador pelo MausBot Relay, e o link seguro antigo foi desativado. Um celular com um app MausBot mais antigo não consegue mais se conectar fora do seu Wi-Fi. Atualize o app MausBot nesse celular e depois pareie de novo aqui, em Configurações → Celular e dispositivos.","remote.devices.remove": "Remover {name}","remote.devices.allowView": "Permitir ver o computador","remote.devices.allowViewDetail": "Acesso interativo completo a partir deste dispositivo.",diff --git a/src/types/ogb.d.ts b/src/types/ogb.d.tsindex 0e72d1dea6..0325030100 100644--- a/src/types/ogb.d.ts+++ b/src/types/ogb.d.ts@@ -539,6 +539,9 @@ export interface CompanionAccountState {/** The HTTPS address was given back after 30 days with no paired phone* seen. Opening the phone page calls prepare(), which brings it back. */paused?: boolean;+ /** The secure address was ended for old phone apps: a phone that has not used the encrypted connection must be+ * updated and paired again. */+ tunnelRetired?: boolean;}export type AndroidUsbDevice = {