From 04fe0fd70456409eb571893a7de8b690829f5a7f Mon Sep 17 00:00:00 2001 From: harness Date: Thu, 26 Nov 2026 23:05:56 +0530 Subject: [PATCH 1/3] fix(inbox): let the door bind where the proxy can reach it The door listened on 127.0.0.1 unconditionally. That is right when the publisher (tailscale serve, Cloudflare Access, a TLS proxy) runs on the same machine, and wrong when it runs elsewhere: tailscale serve on a host proxies to the container's address, while a 127.0.0.1 listener inside a container answers its own loopback only. The published address then answers 502 and the door logs nothing, because no request ever arrives. PLANNOTATOR_INBOX_AUTH_BIND sets the listen address (loopback when unset or blank). It does not widen who may come in: Host is still checked by doorAnswersHost and every request still needs a session. --- packages/server/inbox-auth-door.ts | 6 ++++-- packages/shared/inbox/auth-door-bind.test.ts | 20 +++++++++++++++++++ packages/shared/inbox/auth-door.ts | 21 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 packages/shared/inbox/auth-door-bind.test.ts diff --git a/packages/server/inbox-auth-door.ts b/packages/server/inbox-auth-door.ts index 106bbd6c0c..ce7ec289f2 100644 --- a/packages/server/inbox-auth-door.ts +++ b/packages/server/inbox-auth-door.ts @@ -37,6 +37,7 @@ import { markFromAuthDoor, PASSKEY_API_PATH, PASSKEY_JS_PATH, + doorBindAddress, PASSKEY_PAGE_PATH, passkeyOrigin, passkeyOrigins, @@ -369,9 +370,10 @@ export function createInboxAuthDoor(context: InboxAuthDoorContext) { return; } instance = made; + const bind = doorBindAddress(); try { listener = Bun.serve({ - hostname: "127.0.0.1", + hostname: bind, port: active.port, idleTimeout: 0, maxRequestBodySize: context.maxRequestBodySize, @@ -382,7 +384,7 @@ export function createInboxAuthDoor(context: InboxAuthDoorContext) { instance = null; const code = (error as NodeJS.ErrnoException)?.code ?? ""; const busy = /EADDRINUSE|in use/i.test(`${code} ${error instanceof Error ? error.message : String(error)}`); - return fail(busy ? `Port ${active.port} is in use by another program.` : `Could not listen on 127.0.0.1:${active.port}.`); + return fail(busy ? `Port ${active.port} is in use by another program.` : `Could not listen on ${bind}:${active.port}.`); } settings = active; state.url = `${active.baseUrl}/`; diff --git a/packages/shared/inbox/auth-door-bind.test.ts b/packages/shared/inbox/auth-door-bind.test.ts new file mode 100644 index 0000000000..89f12816f6 --- /dev/null +++ b/packages/shared/inbox/auth-door-bind.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, test } from "bun:test"; +import { DEFAULT_INBOX_AUTH_BIND, doorBindAddress, INBOX_AUTH_BIND_ENV } from "./auth-door"; + +describe("the address the door listens on", () => { + test("nothing asked for is loopback, because the proxy is usually on this machine", () => { + expect(DEFAULT_INBOX_AUTH_BIND).toBe("127.0.0.1"); + expect(doorBindAddress({})).toBe("127.0.0.1"); + expect(doorBindAddress({ [INBOX_AUTH_BIND_ENV]: "" })).toBe("127.0.0.1"); + expect(doorBindAddress({ [INBOX_AUTH_BIND_ENV]: " " })).toBe("127.0.0.1"); + }); + + test("the address asked for, and nothing around it", () => { + expect(doorBindAddress({ [INBOX_AUTH_BIND_ENV]: "0.0.0.0" })).toBe("0.0.0.0"); + expect(doorBindAddress({ [INBOX_AUTH_BIND_ENV]: " 172.27.0.2\n" })).toBe("172.27.0.2"); + }); + + test("the name is the one the guide and the container's own setup use", () => { + expect(INBOX_AUTH_BIND_ENV).toBe("PLANNOTATOR_INBOX_AUTH_BIND"); + }); +}); diff --git a/packages/shared/inbox/auth-door.ts b/packages/shared/inbox/auth-door.ts index a957f3df5b..2a6c8a48d3 100644 --- a/packages/shared/inbox/auth-door.ts +++ b/packages/shared/inbox/auth-door.ts @@ -34,6 +34,27 @@ export const INBOX_AUTH_ALLOW_ENV = "PLANNOTATOR_INBOX_AUTH_ALLOW"; /** The secret better-auth signs sessions with. Generated into the data folder when unset. */ export const INBOX_AUTH_SECRET_ENV = "PLANNOTATOR_AUTH_SECRET"; export const DEFAULT_INBOX_AUTH_PORT = 19501; +/** + * The address the door listens on. `127.0.0.1` is the right default because the thing that publishes + * the door (`tailscale serve`, Cloudflare Access, a TLS proxy) usually runs on this same machine. + * + * It is the wrong address when that proxy runs somewhere else and reaches this machine over its own + * network: in a container or a VM, `tailscale serve` on the host proxies to the container's address, + * while a listener bound to `127.0.0.1` inside the container answers its own loopback only. The + * published address then answers 502 and the door logs nothing, because no request ever reaches it. + * `PLANNOTATOR_INBOX_AUTH_BIND=0.0.0.0` (or the machine's address) is what such a setup needs. + * + * Binding wider does not widen who may come in: `Host` is still checked by `doorAnswersHost` and + * every request still needs a session. + */ +export const INBOX_AUTH_BIND_ENV = "PLANNOTATOR_INBOX_AUTH_BIND"; +export const DEFAULT_INBOX_AUTH_BIND = "127.0.0.1"; + +/** The address the door's listener takes: `PLANNOTATOR_INBOX_AUTH_BIND`, or loopback when it is unset or blank. */ +export function doorBindAddress(env: NodeJS.ProcessEnv = process.env): string { + const asked = (env[INBOX_AUTH_BIND_ENV] ?? "").trim(); + return asked === "" ? DEFAULT_INBOX_AUTH_BIND : asked; +} /** Better-auth's own base path; nothing else may take it. */ export const AUTH_BASE_PATH = "/api/auth"; export const AUTH_LOGIN_PATH = "/login"; From 95d6874ba1d06d44c406f80461aa68b435c30ad4 Mon Sep 17 00:00:00 2001 From: harness Date: Fri, 27 Nov 2026 01:46:21 +0530 Subject: [PATCH 2/3] Zosma branding: our mark in the window, the favicon, the manifest and the door The owner, 2026-11-26: "Branding is fully plannotator. It must be zosma ai logo and all." This fork is what our team signs in to, so the product it shows is Zosma's: - The sidebar's logo item is the Zosma mark (a new ZosmaMark component: the site's own Z path, white on the brand blue #017CF3) beside "Zosma Inbox", not the studio's Tater sprite. The sprite and its CSS stay for upstream's weekly merge. - The tab icon is a new 'zosma' favicon style and the default: a hand-built 16/32/48 .ico and a 64 px PNG in packages/core/favicon.ts, drawn from the same path. Glass, Yellow and Face stay, so nothing anyone picked is lost; 'classic' still reads as unset and now shows Zosma. - The manifest (name, short_name, icons, apple-touch-icon) and /app-icon/ carry zosma-180, zosma-192 and zosma-512, so an installed Inbox is Zosma too. - The door (sign-in and passkeys pages) wears the mark on the brand tile and says "Sign in to Zosma Inbox". - The window's is "Zosma Inbox"; the tab icon dialog offers Zosma first. Tests: core/favicon.test.ts (the new style's bytes are a real .ico with three frames and a PNG with the mark's blue in it), server/inbox-app-icons.test.ts (the manifest and the three zosma icons). typecheck clean. --- apps/inbox/index.html | 2 +- .../inbox-notifications-and-agents.md | 2 +- docs/agent-guides/inbox-window.md | 6 +- docs/agent-guides/server-and-storage.md | 6 +- packages/core/favicon-style.ts | 11 +- packages/core/favicon.test.ts | 57 ++++++++-- packages/core/favicon.ts | 106 ++++++++++++++++-- packages/inbox/assets/app-icon/zosma-180.png | Bin 0 -> 4159 bytes packages/inbox/assets/app-icon/zosma-512.png | Bin 0 -> 11877 bytes packages/inbox/assets/tab-icon/zosma-192.png | Bin 0 -> 4324 bytes packages/inbox/components/Sidebar.tsx | 6 +- packages/inbox/components/TabIconChoice.tsx | 6 +- packages/inbox/components/ZosmaMark.tsx | 26 +++++ packages/inbox/faviconChoice.ts | 5 +- packages/inbox/inbox.css | 2 + packages/inbox/tabIconArt.ts | 10 +- packages/server/inbox-app-icons.test.ts | 16 ++- packages/server/inbox-app-icons.ts | 18 ++- packages/server/inbox-auth-login.ts | 27 +++-- 19 files changed, 243 insertions(+), 63 deletions(-) create mode 100644 packages/inbox/assets/app-icon/zosma-180.png create mode 100644 packages/inbox/assets/app-icon/zosma-512.png create mode 100644 packages/inbox/assets/tab-icon/zosma-192.png create mode 100644 packages/inbox/components/ZosmaMark.tsx diff --git a/apps/inbox/index.html b/apps/inbox/index.html index c4499ac90f..9fff52c19d 100644 --- a/apps/inbox/index.html +++ b/apps/inbox/index.html @@ -5,7 +5,7 @@ <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> - <title>Plannotator Inbox + Zosma Inbox