From 55a4c01d41a68aeeb91bc70644184821536f464a Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 09:12:48 -0700 Subject: [PATCH 1/7] Refuse a production deploy that leaves relay analytics unset Relay PostHog events (downloads, installs, sessions, viewers, MCP results) stopped at 2026-09-23 17:11 UTC, four minutes after the 0.23.1 release, and have not come back through 0.23.3. The capture code is unchanged since the last good release; the relay only sends when vars.POSTHOG_ENABLED is "1", and Wrangler replaces every Worker var on deploy. The production config used since 0.23.1 leaves the flag out, so relay analytics turned off silently while the accounts app, whose flag is committed, kept reporting. The production guard now requires POSTHOG_ENABLED to be "0" or "1", as it already does for MCP_CONTROL_ENABLED, so the choice is always written down. The example config sets it to "0" so self-hosters see the flag. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- CHANGELOG.md | 11 +++++++++++ docs/self-hosting.md | 5 ++++- scripts/deploy-production.mjs | 6 ++++++ tests/production-deploy.test.ts | 14 ++++++++++++-- wrangler.example.jsonc | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c5619f..b1d4177f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve ## Unreleased +### Fixed + +- `npm run deploy:production` refuses a config that does not set + `POSTHOG_ENABLED` to `"0"` or `"1"`. Since 0.23.1 the relay has been + deployed with a config that left the flag out, and because Wrangler replaces + every Worker variable on deploy, relay analytics (downloads, installs, + sessions, viewers and MCP results) silently stopped on 23 September. The + accounts app was unaffected because its flag is committed. Production needs + `"POSTHOG_ENABLED": "1"` in `wrangler.production.jsonc` and a redeploy to + restore it. + ## [0.23.3] — 2026-09-25 ### Fixed diff --git a/docs/self-hosting.md b/docs/self-hosting.md index ee30ad38..e4bc3bad 100644 --- a/docs/self-hosting.md +++ b/docs/self-hosting.md @@ -70,7 +70,10 @@ Objects, Rate Limiting, Analytics Engine, and static assets. Keep every documentation path in `run_worker_first`: a page served straight from the assets binding is never counted. `npm run deploy:production` refuses a production config that routes fewer of these paths through the Worker than -`wrangler.example.jsonc` does. +`wrangler.example.jsonc` does, or one that does not set `POSTHOG_ENABLED` to +`"0"` or `"1"`. Wrangler replaces every Worker variable on deploy, so a config +that leaves the flag out turns relay analytics off without any error. The +example keeps it `"0"`; a self-hosted relay sends nothing to PostHog. The private statistics dashboard is optional and configured with Worker secrets (`npx wrangler secret put `): diff --git a/scripts/deploy-production.mjs b/scripts/deploy-production.mjs index 6e4b2e09..343ae67d 100644 --- a/scripts/deploy-production.mjs +++ b/scripts/deploy-production.mjs @@ -25,6 +25,12 @@ export function validateProductionConfig(config) { !["0", "1"].includes(config.vars?.MCP_CONTROL_ENABLED)) { throw new Error("production target, pinned account, or explicit control gate is invalid"); } + // Wrangler replaces every Worker var on deploy. A config that omits the flag + // silently turns relay analytics off (installs, sessions, viewers, MCP), so + // the choice must be written down, the same way as the control gate. + if (!["0", "1"].includes(config.vars?.POSTHOG_ENABLED)) { + throw new Error("production config must set vars.POSTHOG_ENABLED to \"0\" or \"1\""); + } } export function deployProduction({ argv = [], configPath = resolve("wrangler.production.jsonc"), executor } = {}) { diff --git a/tests/production-deploy.test.ts b/tests/production-deploy.test.ts index 7565e2fd..1f29d113 100644 --- a/tests/production-deploy.test.ts +++ b/tests/production-deploy.test.ts @@ -9,7 +9,7 @@ const valid = () => ({ name: "shell-online", account_id: "a".repeat(32), compatibility_flags: ["enable_request_signal"], routes: [{ pattern: "shell.online" }, { pattern: "stats.shell.online" }], - vars: { MCP_CONTROL_ENABLED: "0" }, + vars: { MCP_CONTROL_ENABLED: "0", POSTHOG_ENABLED: "1" }, }); describe("production deploy guard", () => { it("refuses an older or unknown release identity", () => { @@ -21,7 +21,17 @@ describe("production deploy guard", () => { }); it("accepts the explicit production target with either control state", () => { expect(() => validateProductionConfig(valid())).not.toThrow(); - expect(() => validateProductionConfig({ ...valid(), vars: { MCP_CONTROL_ENABLED: "1" } })).not.toThrow(); + expect(() => validateProductionConfig({ ...valid(), vars: { MCP_CONTROL_ENABLED: "1", POSTHOG_ENABLED: "1" } })).not.toThrow(); + }); + it("accepts relay analytics explicitly on or off", () => { + expect(() => validateProductionConfig({ ...valid(), vars: { MCP_CONTROL_ENABLED: "0", POSTHOG_ENABLED: "0" } })).not.toThrow(); + }); + // Regression: 0.23.1 deployed with a config that omitted the flag, and every + // relay event stopped reaching PostHog while the accounts app kept reporting. + it.each([undefined, "", "true", "yes", 1])("refuses a config whose relay analytics flag is %s", (value) => { + const vars: Record = { MCP_CONTROL_ENABLED: "0" }; + if (value !== undefined) vars.POSTHOG_ENABLED = value; + expect(() => validateProductionConfig({ ...valid(), vars })).toThrow("POSTHOG_ENABLED"); }); it.each([ { name: "shell-online-staging" }, { account_id: undefined }, { routes: [] }, diff --git a/wrangler.example.jsonc b/wrangler.example.jsonc index 58cc9dc5..85de4c8c 100644 --- a/wrangler.example.jsonc +++ b/wrangler.example.jsonc @@ -4,7 +4,7 @@ "main": "./worker/index.ts", "compatibility_date": "2026-08-19", "compatibility_flags": ["enable_request_signal"], - "vars": { "MCP_CONTROL_ENABLED": "0" }, + "vars": { "MCP_CONTROL_ENABLED": "0", "POSTHOG_ENABLED": "0" }, "workers_dev": true, "assets": { "directory": "./dist", From 23dd748b574beb42be02d17b68e923901c66d047 Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 12:02:27 -0700 Subject: [PATCH 2/7] Add a one-screen landing page at /start/ for paid traffic Paid X traffic is almost all phones, and on the home page it bounces in about a second. /start/ is a shorter page to test against it: one line on what shell does, then install, start your agent, and scan the QR code. On a phone, "Send these steps to my laptop" opens the share sheet. The page gets exactly what "/" gets: the same Content-Security-Policy, Google Analytics, first-party events and X base pixel (attributed to /start/). It reports as its own route ("start" in PostHog, "landing_start" on the statistics dashboard) so the two pages can be compared, and it is noindex so the home page stays the one search engines show. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- CHANGELOG.md | 10 + shared/landing-paths.ts | 10 + shared/posthog.ts | 6 +- shared/public-attribution.ts | 1 + start/index.html | 92 ++++++++++ tests/analytics.test.ts | 2 + tests/csp-ga.test.ts | 9 + tests/posthog.test.ts | 5 + tests/x-pixel.test.ts | 9 +- vite.config.ts | 1 + web/analytics.ts | 6 +- web/posthog.ts | 2 + web/start.css | 346 +++++++++++++++++++++++++++++++++++ web/start.ts | 81 ++++++++ web/x-pixel.ts | 5 +- worker/analytics.ts | 2 + worker/index.ts | 5 +- wrangler.example.jsonc | 1 + 18 files changed, 583 insertions(+), 10 deletions(-) create mode 100644 shared/landing-paths.ts create mode 100644 start/index.html create mode 100644 web/start.css create mode 100644 web/start.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d4177f..8587878e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve ## Unreleased +### Added + +- A one-screen landing page at `/start/` for paid traffic, to test against + the home page. It says what shell does in one line and gives the three + setup steps: install, start your agent (`shell claude`, or tap Codex, + Hermes, OpenCode or Cursor), and scan the QR code. On a phone, "Send these + steps to my laptop" opens the share sheet. The page gets the home page's + analytics and X pixel, is kept out of search results, and reports as its + own route (`start`, `landing_start` on the statistics dashboard). + ### Fixed - `npm run deploy:production` refuses a config that does not set diff --git a/shared/landing-paths.ts b/shared/landing-paths.ts new file mode 100644 index 00000000..e70beb04 --- /dev/null +++ b/shared/landing-paths.ts @@ -0,0 +1,10 @@ +/** + * The public landing pages. "/" is the home page; "/start/" is a one-screen + * page for paid traffic, tested against it. Both get the landing page's + * analytics, X pixel and Content-Security-Policy, and nothing else does. + */ +export const START_PATH = "/start/"; + +export function isLandingPath(pathname: string): boolean { + return pathname === "/" || pathname === "" || pathname === START_PATH; +} diff --git a/shared/posthog.ts b/shared/posthog.ts index 84e1887a..0ad08018 100644 --- a/shared/posthog.ts +++ b/shared/posthog.ts @@ -18,8 +18,8 @@ const EVENTS = new Set([ ]); const VALUES: Record> = { surface: new Set(["landing", "docs", "terminal", "app", "game", "relay"]), - route: new Set(["landing", "docs", "terminal", "login", "signup", "reset", "feedback", "account", "sessions", "session", "audit", "team", "join", "terms", "privacy", "machines", "game", "cli_authorize"]), - target: new Set(["install", "brew_install", "source_build", "run", "docs_command", "share", "skill", "start_nav", "start_hero", "start_footer", "start_bottom", "demo", "github_star", "signup_nav", "signup_hero", "signup_team", "signup_footer", "github", "signup", "signin", "docs", "app", "feedback", "session", "machine", "team", "vault", "automation", "account", "command", "invite", "cli", "unknown"]), + route: new Set(["landing", "start", "docs", "terminal", "login", "signup", "reset", "feedback", "account", "sessions", "session", "audit", "team", "join", "terms", "privacy", "machines", "game", "cli_authorize"]), + target: new Set(["install", "brew_install", "source_build", "run", "docs_command", "share", "skill", "start_nav", "start_hero", "start_footer", "start_bottom", "start_share", "demo", "github_star", "signup_nav", "signup_hero", "signup_team", "signup_footer", "github", "signup", "signin", "docs", "app", "feedback", "session", "machine", "team", "vault", "automation", "account", "command", "invite", "cli", "unknown"]), source: new Set(["x", "google", "github", "reddit", "hacker_news", "bing", "youtube", "linkedin", "facebook", "instagram", "direct", "internal", "other", "app", "newsletter", "product_hunt", "discord", "slack", "mastodon", "bluesky", "podcast"]), device: new Set(["mobile", "tablet", "desktop", "bot", "cli", "unknown"]), outcome: new Set([...OPERATION_OUTCOMES, "unsupported_os", "unsupported_arch", "download_failed", "checksum_mismatch", "unknown", "matched", "limit", "reset", "revoked", "error", "busy", "too_large", "conflict", "in_flight", "delivered", "delivery_uncertain"]), @@ -108,7 +108,7 @@ export function posthogPayload(event: string, id: string, input: Record + + + + + + + + + + + + + + + + + + + + + + + + + + + Use any coding agent from your phone | shell.online + + +
+
+ shell.online +
+ +
+
+

Use any coding agent from your phone.

+

Free and open source. No account needed.

+
+ +
+

How it works

+
    +
  1. +
    + + On your laptop, install shellInstall shell +
    + + +
    +
    +
    + curl -fsSL https://shell.online/install | sh + +
    +
  2. +
  3. +
    + + Start your agent through shell +
    +
    + shell claude + +
    +

    or + + + + +

    +
  4. +
  5. +
    + + Scan the QR code it prints with this phoneyour phone +
    +
  6. +
+
+
+ +
+ +

+
+
+ + + diff --git a/tests/analytics.test.ts b/tests/analytics.test.ts index 8766e2da..a2c5147a 100644 --- a/tests/analytics.test.ts +++ b/tests/analytics.test.ts @@ -152,6 +152,8 @@ describe("analytics", () => { it("names every documentation page, and keeps unknown paths apart from 404s", () => { expect(documentTarget("/", 200, "0.15.1")).toBe("landing"); + expect(documentTarget("/start/", 200, "0.15.1")).toBe("landing_start"); + expect(documentTarget("/start/", 404, "0.15.1")).toBe("not_found"); expect(documentTarget("/docs/", 200, "0.15.1")).toBe("docs"); expect(documentTarget("/app/", 200, "0.15.1")).toBe("docs_app"); expect(documentTarget("/cli/", 200, "0.15.1")).toBe("docs_cli"); diff --git a/tests/csp-ga.test.ts b/tests/csp-ga.test.ts index 00926ca0..e51367de 100644 --- a/tests/csp-ga.test.ts +++ b/tests/csp-ga.test.ts @@ -41,6 +41,15 @@ describe("secureAssetResponse CSP Google Analytics endpoints", () => { expect(privatePolicy).not.toMatch(/twitter|t\.co|ads-twitter/); } }); + it("gives the /start/ landing page the home page's analytics and X origins, and keeps it out of search", () => { + const home = csp(secureAssetResponse(htmlResponse(), "/", "shell.online")); + const start = secureAssetResponse(htmlResponse(), "/start/", "shell.online"); + expect(csp(start)).toBe(home); + expect(start.headers.get("X-Robots-Tag")).toBe("noindex, nofollow, noarchive"); + for (const [path, host] of [["/start", "shell.online"], ["/start/x", "shell.online"], ["/start/", "app.shell.online"]]) { + expect(csp(secureAssetResponse(htmlResponse(), path, host))).not.toMatch(/twitter|googletagmanager/); + } + }); it("allows GA on public landing page (/) HTML on shell.online", () => { const res = secureAssetResponse(htmlResponse(), "/", "shell.online"); const policy = csp(res); diff --git a/tests/posthog.test.ts b/tests/posthog.test.ts index 1ea56c53..cb1d0c11 100644 --- a/tests/posthog.test.ts +++ b/tests/posthog.test.ts @@ -165,6 +165,9 @@ describe("PostHog explicit capture boundary", () => { const payload = posthogPayload("$pageview", ID, { surface: "terminal", route: "terminal", target: SECRET, source: SECRET, url: SECRET, content: SECRET, token: SECRET, $current_url: SECRET, $set: { email: SECRET } }); expect(JSON.stringify(payload)).not.toContain(SECRET); expect(payload?.properties.$current_url).toBe("https://shell.online/s/:session"); + const start = posthogPayload("$pageview", ID, { surface: "landing", route: "start" }); + expect(start?.properties).toMatchObject({ $current_url: "https://shell.online/start/", $pathname: "/start/", $host: "shell.online", route: "start" }); + expect(posthogPayload("landing_cta", ID, { target: "start_share" })?.properties.target).toBe("start_share"); expect(payload?.properties.$process_person_profile).toBe(false); expect(payload?.properties.$geoip_disable).toBe(true); expect(posthogPayload(SECRET, ID)).toBeNull(); @@ -174,6 +177,8 @@ describe("PostHog explicit capture boundary", () => { for (const url of ["http://shell.online/", "https://evil.shell.online/", "https://stats.shell.online/", "https://app.shell.online/auth/callback?code=SECRET", "https://shell.online:444/", "https://shell.online/unknown"]) expect(analyticsRoute(new URL(url))).toBeNull(); expect(analyticsRoute(new URL(`https://app.shell.online/sessions/${SECRET}?token=${SECRET}`))).toEqual({ surface: "app", route: "session" }); expect(analyticsRoute(new URL("https://app.shell.online/game"))).toEqual({ surface: "game", route: "game" }); + expect(analyticsRoute(new URL("https://shell.online/start/?utm_source=x&utm_medium=paid_social"))).toEqual({ surface: "landing", route: "start" }); + expect(analyticsRoute(new URL("https://shell.online/start/other"))).toBeNull(); }); it("uses a finite acquisition source, never a raw URL/campaign/click ID", () => { expect(analyticsSource(new URL(`https://shell.online/?twclid=${SECRET}`), "")).toBe("x"); diff --git a/tests/x-pixel.test.ts b/tests/x-pixel.test.ts index c651fbf0..12d7666e 100644 --- a/tests/x-pixel.test.ts +++ b/tests/x-pixel.test.ts @@ -25,13 +25,19 @@ describe("X base pixel", () => { ["config", "rfilf"], ]); }); - it.each(["/"])("loads on public %s", async path => { + it.each(["/", "/start/"])("loads on public %s", async path => { dom(`https://shell.online${path}?utm_source=x&twclid=valid_click-123`); (await import("../web/x-pixel")).initXPixel(); expect(scripts).toHaveLength(1); }); + it("attributes the /start/ visit to /start/, not the home page", async () => { + const w = dom("https://shell.online/start/?utm_source=x&utm_medium=paid_social"); + (await import("../web/x-pixel")).initXPixel(); + expect(Array.from(w.twq!.queue[0])).toEqual(["set", { page_location: "https://shell.online/start/" }]); + }); it.each([ "https://shell.online/s/abcdefghijklmnopqrstuvwxyz012345#salt=SECRET", + "https://shell.online/start", "https://shell.online/start/extra", "https://shell.online/start/?password=SECRET", "https://app.shell.online/", "https://stats.shell.online/", "http://shell.online/", "https://shell.online/docs/", "https://shell.online/cli/", "https://shell.online/docs/v0.23.0/security/", "http://localhost:5178/", "https://shell.online/oauth/callback", "https://shell.online/?password=SECRET", @@ -62,6 +68,7 @@ describe("X base pixel", () => { }); it("is wired only to the landing entry point", () => { expect(readFileSync("web/landing.ts", "utf8")).toContain("initXPixel();"); + expect(readFileSync("web/start.ts", "utf8")).toContain("initXPixel();"); expect(readFileSync("web/documentation-entry.ts", "utf8")).not.toContain("x-pixel"); expect(readFileSync("web/main.ts", "utf8")).not.toContain("x-pixel"); expect(readFileSync("app/src/components/ProductAnalytics.tsx", "utf8")).not.toContain("x-pixel"); diff --git a/vite.config.ts b/vite.config.ts index 2559065a..be613c16 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -126,6 +126,7 @@ export default defineConfig({ input: { main: resolve(import.meta.dirname, "index.html"), documentation: resolve(import.meta.dirname, "web/documentation.html"), + start: resolve(import.meta.dirname, "start/index.html"), }, }, }, diff --git a/web/analytics.ts b/web/analytics.ts index 08934ef1..7b62965e 100644 --- a/web/analytics.ts +++ b/web/analytics.ts @@ -2,6 +2,7 @@ import { resolveDocumentationRoute } from "../shared/documentation"; import { RELEASE_VERSION } from "../shared/release"; import { campaignMedium, isPublicEvent, publicSource } from "../shared/public-attribution"; import { trackProduct } from "./posthog"; +import { isLandingPath, START_PATH } from "../shared/landing-paths"; const GA_ID = "G-101HMD03VD"; const LEGACY_CONSENT_COOKIE = "shell_analytics_consent"; @@ -10,7 +11,7 @@ const GA_COOKIE_MAX_AGE = 7_776_000; // 90 days const PUBLIC_HOST = "shell.online"; function isPublicPath(pathname: string): boolean { - if (pathname === "/" || pathname === "") return true; + if (isLandingPath(pathname)) return true; return resolveDocumentationRoute(pathname, RELEASE_VERSION) !== null; } @@ -60,6 +61,7 @@ function canonicalPageLocation(url: URL): string { function pageTitleFor(pathname: string): string { if (pathname === "/" || pathname === "") return "Your terminal, anywhere | shell.online"; + if (pathname === START_PATH) return "Use any coding agent from your phone | shell.online"; const guide = resolveDocumentationRoute(pathname, RELEASE_VERSION); if (guide) return `${guide.kind === "docs" ? "Getting started" : guide.kind} | shell.online docs`; return "shell.online"; @@ -105,7 +107,7 @@ export function initAnalytics(): void { if (!publicLoaded) { publicLoaded = true; - sendPublicEvent("page_loaded", url.pathname === "/" ? "landing" : "docs", url); + sendPublicEvent("page_loaded", isLandingPath(url.pathname) ? "landing" : "docs", url); } gtagLoaded = true; diff --git a/web/posthog.ts b/web/posthog.ts index 4bac98a0..ca352a9d 100644 --- a/web/posthog.ts +++ b/web/posthog.ts @@ -1,4 +1,5 @@ import { resolveDocumentationRoute } from "../shared/documentation"; +import { START_PATH } from "../shared/landing-paths"; import { RELEASE_VERSION } from "../shared/release"; import { sendPosthog, type PosthogCaptureContext } from "../shared/posthog"; import { campaignMedium, campaignSource, classifyReferrer, publicSource } from "../shared/public-attribution"; @@ -29,6 +30,7 @@ export function analyticsRoute(url: URL): { surface: string; route: string; guid if (url.hostname === "shell.online") { if (/^\/s\/[A-Za-z0-9_-]{32}\/?$/.test(url.pathname)) return { surface: "terminal", route: "terminal" }; if (url.pathname === "/") return { surface: "landing", route: "landing" }; + if (url.pathname === START_PATH) return { surface: "landing", route: "start" }; const guide = resolveDocumentationRoute(url.pathname, RELEASE_VERSION); if (guide) return { surface: "docs", route: "docs", guide: guide.kind }; } diff --git a/web/start.css b/web/start.css new file mode 100644 index 00000000..2b7b65f1 --- /dev/null +++ b/web/start.css @@ -0,0 +1,346 @@ +@font-face { + font-family: "Uncut Sans"; + src: url("/fonts/uncut-sans-variable.woff2") format("woff2"); + font-weight: 300 700; + font-display: swap; +} + +/* The one-screen landing page for paid traffic (/start/). Same palette as the home page. */ +.start-root { + --ink: #1c251f; + --muted: #586258; + --faint: #6b7468; + --paper: #f7f8f2; + --card: #ffffff; + --line: #e3e7dc; + --well: #f3f5ee; + --tint: #eef4d6; + --lime: #d5f568; + background: var(--paper); + color: var(--ink); + -webkit-text-size-adjust: 100%; +} +.start-root body { + margin: 0; + background: var(--paper); + font-family: "Uncut Sans", system-ui, -apple-system, "Segoe UI", sans-serif; + line-height: 1.45; +} +.start-root *, +.start-root *::before, +.start-root *::after { + box-sizing: border-box; +} +.start-root code, +.start-root button[data-agent] { + font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; +} +.start-root button { + font: inherit; + color: inherit; + cursor: pointer; +} +.start-root :focus-visible { + outline: 2px solid var(--ink); + outline-offset: 2px; +} + +.start { + min-height: 100dvh; + max-width: 1280px; + margin: 0 auto; + padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom)); + display: flex; + flex-direction: column; +} +.start-brand a { + display: inline-flex; + align-items: center; + gap: 8px; + font-size: 17px; + font-weight: 650; + color: inherit; + text-decoration: none; +} +.start-mark { + width: 18px; + height: 18px; + border-radius: 5px; + background: var(--lime); + border: 1.5px solid var(--ink); +} + +.start-layout { + display: flex; + flex-direction: column; + gap: 22px; + margin-top: 22px; +} +.start-intro { + display: flex; + flex-direction: column; + gap: 8px; +} +.start-intro h1 { + margin: 0; + font-size: 34px; + line-height: 1.03; + font-weight: 700; + letter-spacing: -0.035em; + text-wrap: balance; +} +.start-intro p { + margin: 0; + font-size: 15px; + font-weight: 500; + color: var(--muted); +} + +.start-how { + display: flex; + flex-direction: column; + gap: 8px; +} +.start-how h2 { + margin: 0 0 2px; + font-size: 13px; + font-weight: 600; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--muted); +} +.start-steps { + margin: 0; + padding: 0; + list-style: none; + display: flex; + flex-direction: column; + gap: 8px; +} +.start-step { + padding: 12px; + background: var(--card); + border: 1px solid var(--line); + border-radius: 14px; + display: flex; + flex-direction: column; + gap: 8px; +} +.start-step-head { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; +} +.start-number { + width: 24px; + height: 24px; + flex: none; + border-radius: 50%; + background: var(--tint); + color: #3d4a3f; + font-size: 13px; + font-weight: 700; + display: inline-flex; + align-items: center; + justify-content: center; +} +.start-step-last .start-number { + background: var(--lime); + color: var(--ink); +} +.start-step-title { + flex: 1; + min-width: 0; + font-size: 16px; + font-weight: 600; +} + +.start-os { + display: none; + gap: 4px; + padding: 3px; + border-radius: 9px; + background: var(--well); +} +.start-os button { + min-height: 30px; + padding: 0 12px; + font-size: 13px; + font-weight: 600; + border-radius: 7px; + border: 1px solid transparent; + background: transparent; + color: var(--muted); +} +.start-os button[aria-pressed="true"] { + background: var(--card); + border-color: var(--line); + color: var(--ink); +} + +.start-command { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 6px 6px 10px; + border-radius: 9px; + background: var(--well); +} +.start-command code { + flex: 1; + min-width: 0; + font-size: 11px; + letter-spacing: -0.02em; + white-space: nowrap; + overflow-x: auto; + scrollbar-width: none; +} +#start-run { + font-size: 14px; + letter-spacing: 0; +} +.start-copy { + display: none; + flex: none; + min-height: 36px; + padding: 0 14px; + font-size: 14px; + font-weight: 600; + border-radius: 8px; + border: 1px solid #dce2d7; + background: var(--card); +} + +.start-agents { + margin: 0; + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + font-size: 13px; + color: var(--faint); +} +.start-agents button { + min-height: 28px; + padding: 3px 7px; + font-size: 12px; + border-radius: 6px; + border: 1px solid var(--line); + background: transparent; + color: #3d4a3f; +} +.start-agents button[aria-pressed="true"] { + border-color: var(--ink); + background: var(--tint); +} + +.start-send { + margin-top: auto; + padding-top: 16px; + display: flex; + flex-direction: column; + gap: 6px; +} +#start-send { + min-height: 52px; + border: 0; + border-radius: 14px; + background: var(--ink); + color: var(--paper); + font-size: 17px; + font-weight: 650; +} +#start-status:empty { + display: none; +} +#start-status { + margin: 0; + font-size: 14px; + color: var(--muted); + text-align: center; +} + +.start-desktop-only { + display: none; +} + +/* The smallest phones: keep the install command on one line. */ +@media (max-width: 379px) { + .start-command code { + font-size: 10px; + } +} + +/* A laptop: the steps sit beside the headline, copy buttons and the OS switch appear, and there is nothing to send. */ +@media (min-width: 900px) { + .start { + padding: 24px 64px 48px; + min-height: 100dvh; + } + .start-layout { + flex: 1; + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 72px; + align-items: center; + margin-top: 0; + } + .start-intro { + gap: 16px; + } + .start-how, + .start-steps { + gap: 12px; + } + .start-intro h1 { + font-size: 60px; + line-height: 1.02; + } + .start-intro p { + font-size: 18px; + } + .start-step { + padding: 18px 20px; + border-radius: 16px; + gap: 12px; + } + .start-number { + width: 28px; + height: 28px; + font-size: 14px; + } + .start-step-title { + font-size: 18px; + } + .start-os { + display: flex; + } + .start-command { + padding-left: 14px; + border-radius: 10px; + } + .start-command code, + #start-run { + font-size: 15px; + letter-spacing: 0; + } + .start-copy { + display: inline-block; + } + .start-agents { + font-size: 14px; + } + .start-agents button { + font-size: 13px; + } + .start-send { + display: none; + } + .start-phone-only { + display: none; + } + .start-desktop-only { + display: inline; + } +} diff --git a/web/start.ts b/web/start.ts new file mode 100644 index 00000000..401db3b2 --- /dev/null +++ b/web/start.ts @@ -0,0 +1,81 @@ +import { initAnalytics, trackPublicEvent } from "./analytics"; +import { initXPixel } from "./x-pixel"; +import { observeProductPage } from "./posthog"; +import { agentCommand } from "./landing-brands"; + +const INSTALL = { + unix: "curl -fsSL https://shell.online/install | sh", + windows: "irm https://shell.online/install.ps1 | iex", +} as const; + +/* The link a phone sends on. Plain, so the laptop visit is not counted as a second ad click. */ +const SHARE_URL = "https://shell.online/start/"; + +export function initStart(): void { + initAnalytics(); + initXPixel(); + observeProductPage(); + + const install = document.querySelector("#start-install"); + const run = document.querySelector("#start-run"); + const status = document.querySelector("#start-status"); + const say = (text: string) => { + if (status) status.textContent = text; + }; + + const osButtons = [...document.querySelectorAll("[data-os]")]; + const setOs = (os: string) => { + if (os !== "unix" && os !== "windows") return; + if (install) install.textContent = INSTALL[os]; + osButtons.forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.os === os))); + }; + setOs(/Windows/i.test(navigator.userAgent) ? "windows" : "unix"); + osButtons.forEach((b) => b.addEventListener("click", () => setOs(b.dataset.os ?? ""))); + + // An example is also a choice: tapping one swaps it into step 2. + const agentButtons = [...document.querySelectorAll("[data-agent]")]; + agentButtons.forEach((b) => + b.addEventListener("click", () => { + const command = agentCommand(b.dataset.agent ?? ""); + if (!command || !run) return; + run.textContent = command; + agentButtons.forEach((other) => other.setAttribute("aria-pressed", String(other === b))); + }), + ); + + document.querySelectorAll("[data-copy]").forEach((button) => + button.addEventListener("click", () => { + const target = button.dataset.copy === "run" ? "run" : "install"; + const text = (target === "run" ? run : install)?.textContent ?? ""; + trackPublicEvent("copy", target); + navigator.clipboard?.writeText(text).then( + () => { + button.textContent = "Copied"; + window.setTimeout(() => (button.textContent = "Copy"), 1600); + }, + () => say("Select the command and copy it."), + ); + }), + ); + + document.querySelector("#start-send")?.addEventListener("click", async () => { + trackPublicEvent("cta_click", "start_share"); + const shareData = { title: "Set up shell.online", text: "Set up shell on my laptop:", url: SHARE_URL }; + if (navigator.share) { + try { + await navigator.share(shareData); + return; + } catch (error) { + if ((error as DOMException)?.name === "AbortError") return; + } + } + try { + await navigator.clipboard.writeText(SHARE_URL); + say("Link copied. Paste it into a message or note to yourself."); + } catch { + say(`Open ${SHARE_URL.replace("https://", "")} on your laptop.`); + } + }); +} + +initStart(); diff --git a/web/x-pixel.ts b/web/x-pixel.ts index c4c16461..4dd6120b 100644 --- a/web/x-pixel.ts +++ b/web/x-pixel.ts @@ -1,4 +1,5 @@ import { hasAnalyticsOptOut, isGpcOrDnt, isPublicAnalyticsUrl } from "./analytics"; +import { isLandingPath } from "../shared/landing-paths"; // Public advertiser ID, not the server-side Conversion API token. export const X_PIXEL_ID = "rfilf"; @@ -14,7 +15,7 @@ type PixelQueue = ((...args: unknown[]) => void) & { export function initXPixel(): void { try { const url = new URL(window.location.href); - if (url.pathname !== "/" || !isPublicAnalyticsUrl(url) || isGpcOrDnt() || hasAnalyticsOptOut()) return; + if (!isLandingPath(url.pathname) || !isPublicAnalyticsUrl(url) || isGpcOrDnt() || hasAnalyticsOptOut()) return; // The vendor extracts this value itself. Refuse malformed/unbounded click IDs. const clicks = url.searchParams.getAll("twclid"); if (clicks.length > 1 || (clicks.length === 1 && !/^[A-Za-z0-9_-]{1,256}$/.test(clicks[0]))) return; @@ -28,7 +29,7 @@ export function initXPixel(): void { w.twq = twq; // Keep landing-page attribution, never the raw query/fragment or referrer. // The vendor replaces both location and a nonempty referrer with this URL. - twq("set", { page_location: "https://shell.online/" }); + twq("set", { page_location: `https://shell.online${url.pathname || "/"}` }); // Disable vendor defaults that capture button text, form fields, dataLayer // events and timed engagement. These switches are verified against uwt.js // by the real-script browser gate, not just a mocked queue. diff --git a/worker/analytics.ts b/worker/analytics.ts index bb9f1b9a..d371e07a 100644 --- a/worker/analytics.ts +++ b/worker/analytics.ts @@ -1,4 +1,5 @@ import { resolveDocumentationRoute } from "../shared/documentation"; +import { START_PATH } from "../shared/landing-paths"; import type { UniqueSurface } from "../shared/stats"; import { campaignSource, classifyReferrer, PUBLIC_CTA_TARGETS } from "../shared/public-attribution"; export { campaignSource, classifyReferrer } from "../shared/public-attribution"; @@ -265,6 +266,7 @@ export function uniqueSurface(event: AnalyticsEvent, target: string): UniqueSurf export function documentTarget(pathname: string, status: number, currentVersion: string): string { if (status === 404) return "not_found"; if (pathname === "/") return "landing"; + if (pathname === START_PATH) return "landing_start"; const route = resolveDocumentationRoute(pathname, currentVersion); if (route) return route.kind === "docs" ? "docs" : `docs_${route.kind.replace(/-/g, "_")}`; if (SESSION_PATH.test(pathname)) return "session"; diff --git a/worker/index.ts b/worker/index.ts index ea331a02..ce602153 100644 --- a/worker/index.ts +++ b/worker/index.ts @@ -1,4 +1,5 @@ import { DurableObject } from "cloudflare:workers"; +import { isLandingPath } from "../shared/landing-paths"; import { sendPosthog } from "../shared/posthog"; import { relayOperation, httpOutcome, type OperationOutcome } from "../shared/analytics-operations"; import { safeSource } from "../shared/public-attribution"; @@ -4219,7 +4220,7 @@ function isStatsRequestHost(request: Request, url: URL): boolean { } function isPublicAnalyticsPath(pathname: string): boolean { - if (pathname === "/" || pathname === "") return true; + if (isLandingPath(pathname)) return true; return resolveDocumentationRoute(pathname, RELEASE_VERSION) !== null; } @@ -4227,7 +4228,7 @@ export function secureAssetResponse(response: Response, pathname: string, hostna const headers = new Headers(response.headers); const isHtmlDocument = headers.get("Content-Type")?.toLowerCase().startsWith("text/html") ?? false; const gaAllowed = isHtmlDocument && hostname === "shell.online" && isPublicAnalyticsPath(pathname); - const xAllowed = gaAllowed && pathname === "/"; + const xAllowed = gaAllowed && isLandingPath(pathname); const xCollectors = xAllowed ? " https://analytics.twitter.com https://t.co https://ads-twitter.com https://ads-api.twitter.com" : ""; const posthogAllowed = gaAllowed || (isHtmlDocument && hostname === "shell.online" && /^\/s\/[A-Za-z0-9_-]{32}\/?$/.test(pathname)); headers.set("Content-Security-Policy", [ diff --git a/wrangler.example.jsonc b/wrangler.example.jsonc index 85de4c8c..89b22bb9 100644 --- a/wrangler.example.jsonc +++ b/wrangler.example.jsonc @@ -33,6 +33,7 @@ "/e2ee/*", "/docker/*", "/self-hosting/*", + "/start/*", "/" ] }, From 13258f1dab033b29b04d250c0225b21298668f1f Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 12:15:37 -0700 Subject: [PATCH 3/7] Stop app-started sessions from forking an old agent conversation Any shell command starts the daemon when none is running, and startDetachedDaemon gave it os.Environ(). Run from inside Claude Code, that carried CLAUDE_CODE_CHILD_SESSION and CLAUDE_CODE_SESSION_ID into the daemon, and from there into every session the browser asked for. prepareCommandLaunch saw a bare `claude` inside a Claude conversation and rewrote it to `claude --resume --fork-session`, so starting Claude from the app reopened the conversation the daemon happened to be born in, every time, until the daemon restarted. OpenCode had the same path, including its "continue the latest session" fallback. Three independent guards, so one regression cannot bring it back: - The daemon starts without any agent harness's identity variables. - Sessions the daemon launches for the browser start without them too, which also covers a daemon an older release already started with them. - A session the browser asked for (SHELL_ONLINE_SESSION_ORIGIN set) never hands off. Typing `shell claude` inside Claude Code still does. harnessIdentityVariables is the one list; a test checks it covers every adapter's detection and strip variables. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- CHANGELOG.md | 11 ++++++ cmd/shell/agent_loop.go | 4 ++- cmd/shell/daemon_unix.go | 2 +- cmd/shell/daemon_windows.go | 2 +- cmd/shell/handoff.go | 37 ++++++++++++++++++++ cmd/shell/handoff_test.go | 67 +++++++++++++++++++++++++++++++++++++ cmd/shell/main.go | 2 +- 7 files changed, 121 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8587878e..baa94488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,17 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve accounts app was unaffected because its flag is committed. Production needs `"POSTHOG_ENABLED": "1"` in `wrangler.production.jsonc` and a redeploy to restore it. +- Starting `claude` (or `opencode`) from the app no longer reopens an old + agent conversation. Any `shell` command starts the background daemon when + none is running, and it passed on its whole environment. Run from inside + Claude Code, that included the conversation's id, so every session the app + then asked for was treated as a handoff and forked that conversation instead + of starting fresh, until the daemon restarted. The daemon and the sessions it + starts no longer carry an agent conversation's identity, and a session the + app asks for never hands off. Typing `shell claude` inside Claude Code still + forks the conversation, as before. Machines already affected are fixed once + the new release's daemon replaces the running one (`shell service install`, + a restart, or signing in again). ## [0.23.3] — 2026-09-25 diff --git a/cmd/shell/agent_loop.go b/cmd/shell/agent_loop.go index 485126dd..e95caf24 100644 --- a/cmd/shell/agent_loop.go +++ b/cmd/shell/agent_loop.go @@ -247,7 +247,9 @@ func performAgentCommand( // not silently weaken E2EE or widen file sharing on the wrapper itself. arguments := append([]string{"--"}, browserCommandArguments(command.Command)...) launch := exec.CommandContext(ctx, self, arguments...) - launch.Env = os.Environ() + // Never an agent conversation's identity, even from a daemon an older + // release started with one: the browser asked for a new program. + launch.Env = detachedEnvironment(os.Environ()) if command.Name != "" { // The launched shell reads this when it publishes the session, so // the name chosen in the browser survives to the session list. diff --git a/cmd/shell/daemon_unix.go b/cmd/shell/daemon_unix.go index 371c4736..956ec9df 100644 --- a/cmd/shell/daemon_unix.go +++ b/cmd/shell/daemon_unix.go @@ -134,7 +134,7 @@ func startDetachedDaemon(self string) { defer null.Close() command := exec.Command(self, "daemon") - command.Env = os.Environ() + command.Env = detachedEnvironment(os.Environ()) command.Stdin = null command.Stdout = null command.Stderr = null diff --git a/cmd/shell/daemon_windows.go b/cmd/shell/daemon_windows.go index 1ae0bb83..85d26e1f 100644 --- a/cmd/shell/daemon_windows.go +++ b/cmd/shell/daemon_windows.go @@ -102,7 +102,7 @@ func startDetachedDaemon(self string) { defer null.Close() command := exec.Command(self, "daemon") - command.Env = os.Environ() + command.Env = detachedEnvironment(os.Environ()) command.Stdin = null command.Stdout = null command.Stderr = null diff --git a/cmd/shell/handoff.go b/cmd/shell/handoff.go index 1ef90ed7..a37a027a 100644 --- a/cmd/shell/handoff.go +++ b/cmd/shell/handoff.go @@ -83,6 +83,43 @@ func prepareCommandLaunch(arguments, environment []string, allowHandoff bool) co return launch } +// harnessIdentityVariables are the variables an agent harness sets to tell a +// tool subprocess which conversation it belongs to. They are right for the one +// command the agent ran, and wrong for anything that outlives it. +// +// The daemon is the case that matters: any shell command starts it when none +// is running, so a first command typed inside Claude Code used to leave a +// daemon carrying that conversation's id. Every session the browser then asked +// for inherited it, read as a handoff, and forked that old conversation instead +// of starting the program that was asked for, until the daemon next restarted. +// +// Keep this a superset of every adapter's detection and strip lists; +// TestHarnessIdentityVariablesCoverEveryAdapter checks. +var harnessIdentityVariables = []string{ + "CLAUDECODE", + "CLAUDE_CODE_CHILD_SESSION", + "CLAUDE_CODE_SESSION_ID", + "CLAUDE_CODE_BRIDGE_SESSION_ID", + "CLAUDE_CODE_REMOTE_SESSION_ID", + "OPENCODE", + "OPENCODE_PID", + "OPENCODE_SESSION_ID", + "AGENT", +} + +// detachedEnvironment is the environment for a process that outlives the +// command that started it: this one, minus any agent conversation's identity. +func detachedEnvironment(environment []string) []string { + return removeEnvironmentVariables(environment, harnessIdentityVariables...) +} + +// handoffAllowed reports whether a launch may fork the agent conversation it +// was started from. Only a background launch someone typed may. A session the +// browser asked for never does: it asked for the program, started fresh. +func handoffAllowed(foreground bool, environment []string) bool { + return !foreground && environmentValue(environment, sessionOriginEnvironment) == "" +} + func environmentValue(environment []string, name string) string { prefix := name + "=" for _, entry := range environment { diff --git a/cmd/shell/handoff_test.go b/cmd/shell/handoff_test.go index f6b3ebaa..c255ceab 100644 --- a/cmd/shell/handoff_test.go +++ b/cmd/shell/handoff_test.go @@ -233,3 +233,70 @@ func TestOpencodeAdapterFallsBackToContinueWhenUnresolvable(t *testing.T) { t.Fatalf("arguments = %#v, want %#v", launch.Arguments, wantArguments) } } + +func TestHarnessIdentityVariablesCoverEveryAdapter(t *testing.T) { + listed := map[string]bool{} + for _, name := range harnessIdentityVariables { + listed[name] = true + } + for _, adapter := range harnessAdapters { + // With a session id, every adapter rewrites without touching disk. + _, stripped, _ := adapter.Rewrite(adapter.Binary, testClaudeSessionID) + for _, name := range stripped { + if !listed[name] { + t.Errorf("%s strips %s, which harnessIdentityVariables does not list", adapter.Binary, name) + } + } + } + for _, name := range []string{"CLAUDE_CODE_CHILD_SESSION", "CLAUDE_CODE_SESSION_ID", "OPENCODE", "OPENCODE_SESSION_ID"} { + if !listed[name] { + t.Errorf("harnessIdentityVariables does not list detection variable %s", name) + } + } +} + +func TestDetachedEnvironmentDropsAgentConversationIdentity(t *testing.T) { + got := detachedEnvironment([]string{ + "PATH=/usr/bin", + "CLAUDECODE=1", + "CLAUDE_CODE_CHILD_SESSION=1", + "CLAUDE_CODE_SESSION_ID=" + testClaudeSessionID, + "OPENCODE=1", + "OPENCODE_SESSION_ID=" + testOpencodeSessionID, + "HOME=/home/someone", + "SHELL_ONLINE_CONFIG=/tmp/config.json", + }) + want := []string{"PATH=/usr/bin", "HOME=/home/someone", "SHELL_ONLINE_CONFIG=/tmp/config.json"} + if !reflect.DeepEqual(got, want) { + t.Fatalf("detachedEnvironment = %#v, want %#v", got, want) + } +} + +// Regression: a daemon first started from inside a Claude Code conversation +// passed that conversation's id to every browser-started session, so starting +// `claude` from the app forked that old conversation again, every time. +func TestBrowserStartedSessionNeverForksAnAgentConversation(t *testing.T) { + inherited := []string{ + "CLAUDECODE=1", + "CLAUDE_CODE_CHILD_SESSION=1", + "CLAUDE_CODE_SESSION_ID=" + testClaudeSessionID, + sessionOriginEnvironment + "=cmd_123", + } + // Even if the variables reach the session, the browser's request is not a handoff. + launch := prepareCommandLaunch([]string{"claude"}, inherited, handoffAllowed(false, inherited)) + if launch.Handoff != "" || !reflect.DeepEqual(launch.Arguments, []string{"claude"}) { + t.Fatalf("browser-started claude handed off: %#v", launch) + } + // And they no longer reach it: the daemon and its sessions start without them. + if value := environmentValue(detachedEnvironment(inherited), "CLAUDE_CODE_SESSION_ID"); value != "" { + t.Fatalf("detached environment kept the conversation id %q", value) + } + // Typed inside Claude Code, `shell claude` still forks the conversation, as before. + typed := inherited[:3] + if launch := prepareCommandLaunch([]string{"claude"}, typed, handoffAllowed(false, typed)); launch.Handoff != claudeConversationHandoff { + t.Fatalf("typed shell claude no longer hands off: %#v", launch) + } + if handoffAllowed(true, typed) { + t.Fatal("a foreground launch must not hand off") + } +} diff --git a/cmd/shell/main.go b/cmd/shell/main.go index 23ebb2bb..e9b7d583 100644 --- a/cmd/shell/main.go +++ b/cmd/shell/main.go @@ -160,7 +160,7 @@ func run(arguments []string, stdout, stderr io.Writer) int { if len(command) == 0 { command = []string{defaultShellCommand()} } - launch := prepareCommandLaunch(command, os.Environ(), !*foreground) + launch := prepareCommandLaunch(command, os.Environ(), handoffAllowed(*foreground, os.Environ())) command = launch.Arguments fileService, err := openSharedFileService(*shareFiles, *filesRoot) if err != nil { From ea7800e0a89c50c34901b89f39f3526c2d274eab Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 12:19:23 -0700 Subject: [PATCH 4/7] Stop two CI checks failing at random - app: the live-browser canary deleted its temp directory while Chrome was still writing its profile into it on exit, and threw ENOTEMPTY after every check had passed (6 of the last 40 CI runs). rmSync now retries, which is what maxRetries exists for. - windows: the installer test gave `python -m http.server` ten seconds to answer; on a cold hosted runner it sometimes did not (3 of the last 40 runs, including main at 7ef9cd4). It now waits up to a minute and says so if the server process exits instead. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- scripts/test-install-windows.ps1 | 4 +++- scripts/test-terminal-live-browser.mjs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/test-install-windows.ps1 b/scripts/test-install-windows.ps1 index ac590fbf..8a655bca 100644 --- a/scripts/test-install-windows.ps1 +++ b/scripts/test-install-windows.ps1 @@ -14,8 +14,10 @@ try { Set-Content -NoNewline -Path (Join-Path $downloads "SHA256SUMS") -Value "$digest $artifact`n" $server = Start-Process python -ArgumentList "-m", "http.server", "18787", "--bind", "127.0.0.1", "--directory", $root -PassThru -WindowStyle Hidden - $deadline = [DateTime]::UtcNow.AddSeconds(10) + # A cold hosted runner can take well over ten seconds to start Python. + $deadline = [DateTime]::UtcNow.AddSeconds(60) do { + if ($server.HasExited) { throw "The test download server (python -m http.server) exited with code $($server.ExitCode)" } try { Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:18787/downloads/SHA256SUMS" | Out-Null break diff --git a/scripts/test-terminal-live-browser.mjs b/scripts/test-terminal-live-browser.mjs index 6fd89ead..44e287e8 100644 --- a/scripts/test-terminal-live-browser.mjs +++ b/scripts/test-terminal-live-browser.mjs @@ -681,7 +681,9 @@ try { if (runtime) { try { process.kill(-runtime.pid, "SIGTERM"); } catch {} await delay(300); } try { await transport?.close(); } catch {} try { await vite?.close(); } catch {} - rmSync(temp, { recursive: true, force: true }); + // Chrome may still be writing its profile here as it exits, which made this + // throw ENOTEMPTY after every check had passed. Node retries exactly that. + rmSync(temp, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); } process.exitCode = failed ? 1 : 0; From e1a0434df08cd47359c4de607e29004982ac719a Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 12:29:12 -0700 Subject: [PATCH 5/7] Build the /start/ page in the standalone image too The self-hosted image copies each source directory it builds from, and vite.config.ts now has start/index.html as an entry. Without the copy, `npm run build:standalone` fails with "Cannot resolve entry module start/index.html" and the container check goes red. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- standalone/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/standalone/Dockerfile b/standalone/Dockerfile index 0bd2031c..8d7e98fb 100644 --- a/standalone/Dockerfile +++ b/standalone/Dockerfile @@ -3,6 +3,7 @@ WORKDIR /src COPY package.json package-lock.json ./ RUN npm ci COPY index.html tsconfig.web.json vite.config.ts ./ +COPY start ./start COPY web ./web COPY shared ./shared COPY docs ./docs From 98e3c3e5d86fdb019462fd007175b0a979f451aa Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 12:37:19 -0700 Subject: [PATCH 6/7] Wait for the grid message instead of a fixed 40 ms in the relay test "passes the host's grid on once per change" sent a new grid and asserted after a fixed 40 ms. On a busy CI runner the relay's message had not arrived yet: the viewer's last size was still 173x51, not 90x30 (web job, run 36619589961). It now waits up to two seconds for the expected size, then settles, so the exactly-once and never-resize assertions still hold. 10/10 local runs pass with every core busy. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- standalone/server.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/standalone/server.test.ts b/standalone/server.test.ts index 437aed85..e9bf13c8 100644 --- a/standalone/server.test.ts +++ b/standalone/server.test.ts @@ -199,6 +199,11 @@ function sizes(received: Array): Array> } const settle = () => new Promise((resolve) => setTimeout(resolve, 40)); +/* Wait for what a test expects to arrive, not a fixed time a busy runner can overrun. */ +async function until(condition: () => boolean, timeout = 2000): Promise { + const end = Date.now() + timeout; + while (!condition() && Date.now() < end) await new Promise((resolve) => setTimeout(resolve, 10)); +} describe("standalone relay with a host that owns its grid", () => { test("passes the host's grid on once per change and never resizes for a viewer", async () => { @@ -216,6 +221,7 @@ describe("standalone relay with a host that owns its grid", () => { host.socket.send(JSON.stringify({ type: "terminal_grid", cols: 173, rows: 51 })); await settle(); phone.socket.close(); + await until(() => sizes(desk.received).length > 0); await settle(); expect(sizes(desk.received)).toEqual([{ type: "terminal_size", cols: 173, rows: 51, dynamic: true }]); @@ -223,6 +229,8 @@ describe("standalone relay with a host that owns its grid", () => { host.socket.send(JSON.stringify({ type: "terminal_grid", cols: 3, rows: 51 })); host.socket.send(JSON.stringify({ type: "terminal_grid", cols: 90, rows: 30 })); + await until(() => sizes(desk.received).at(-1)?.cols === 90); + // Then long enough that a duplicate or an intermediate size would also have arrived. await settle(); expect(sizes(desk.received).at(-1)).toEqual({ type: "terminal_size", cols: 90, rows: 30, dynamic: true }); expect(sizes(desk.received)).toHaveLength(2); From a746744cbd573a105297767f83a15775d12acd29 Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 29 Sep 2026 13:19:05 -0700 Subject: [PATCH 7/7] Let each ad link to its own version of /start/, set up in PostHog An ad links to /start/?utm_content=. The page asks PostHog's /flags endpoint for the payload of the start-landing-pages flag and takes that page's headline, subline, step 2 agent and button text from it, so a new page or a wording change is an edit in PostHog, not a deploy. - The request uses the public project token and a throwaway id, never the visitor's analytics id or cookies, and gives up after 800 ms. - Only a short page key (/^[a-z0-9][a-z0-9_-]{0,31}$/) is read from the URL, and every payload field is validated and set as text, never markup. An unknown page, a bad payload, or PostHog being slow or blocked shows the default page. - Replaceable text stays hidden until the page is decided (at most ~0.8 s), with a CSS fallback that reveals it after 1.2 s even if the script never runs. - The page is decided before the page view is sent, and every event from the visit carries landing_variant: the page key, or "default". The posthog payload allowlist accepts only that key format, not raw campaign text. - "Send to my laptop" keeps the page key, so the laptop shows the same page. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN --- CHANGELOG.md | 6 +++ shared/posthog.ts | 4 ++ start/index.html | 8 ++-- tests/start-pages.test.ts | 95 ++++++++++++++++++++++++++++++++++++++ web/posthog.ts | 13 +++++- web/start-pages.ts | 97 +++++++++++++++++++++++++++++++++++++++ web/start.css | 15 ++++++ web/start.ts | 28 +++++++++-- 8 files changed, 256 insertions(+), 10 deletions(-) create mode 100644 tests/start-pages.test.ts create mode 100644 web/start-pages.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index baa94488..7cc0689a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve steps to my laptop" opens the share sheet. The page gets the home page's analytics and X pixel, is kept out of search results, and reports as its own route (`start`, `landing_start` on the statistics dashboard). +- Ad-specific versions of `/start/`, set up in PostHog without a deploy. An ad + links to `/start/?utm_content=`, and the page takes that page's + headline, subline, step 2 agent and button text from the payload of the + `start-landing-pages` feature flag. An unknown page, or PostHog being slow or + blocked, shows the default page. Events from the visit record the page key + as `landing_variant`, so results can be compared page by page. ### Fixed diff --git a/shared/posthog.ts b/shared/posthog.ts index 0ad08018..f5fe01da 100644 --- a/shared/posthog.ts +++ b/shared/posthog.ts @@ -96,6 +96,10 @@ export function posthogPayload(event: string, id: string, input: Record
-

Use any coding agent from your phone.

-

Free and open source. No account needed.

+

Use any coding agent from your phone.

+

Free and open source. No account needed.

@@ -62,7 +62,7 @@

How it works

Start your agent through shell
- shell claude + shell claude

or @@ -83,7 +83,7 @@

How it works

- +

diff --git a/tests/start-pages.test.ts b/tests/start-pages.test.ts new file mode 100644 index 00000000..32e06260 --- /dev/null +++ b/tests/start-pages.test.ts @@ -0,0 +1,95 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; +import { loadPage, pageFromPayload, payloadFromFlags, requestedPage, START_PAGES_FLAG } from "../web/start-pages"; +import { POSTHOG_ORIGIN, POSTHOG_TOKEN, posthogPayload } from "../shared/posthog"; + +const payload = { + pages: { + pocket: { headline: "Your coding agent, in your pocket.", subline: "Free. No account needed.", agent: "codex", send: "Send to my laptop" }, + partial: { headline: "Just a headline." }, + }, +}; +const flags = (body: unknown, enabled = true) => ({ flags: { [START_PAGES_FLAG]: { key: START_PAGES_FLAG, enabled, metadata: { payload: body } } } }); + +afterEach(() => vi.unstubAllGlobals()); + +describe("which /start/ page an ad asked for", () => { + it("reads a short page key from utm_content", () => { + expect(requestedPage(new URL("https://shell.online/start/?utm_source=x&utm_content=Pocket"))).toBe("pocket"); + expect(requestedPage(new URL("https://shell.online/start/?utm_content=v2_codex-a"))).toBe("v2_codex-a"); + }); + it.each(["", "a b", "