Skip to content

Restore relay analytics, add /start/ with ad-specific pages, stop app sessions forking old conversations - #285

Merged
TeoSlayer merged 10 commits into
TeoSlayer:mainfrom
pstayets:combined-fixes
Nov 12, 2026
Merged

TeoSlayer merged 10 commits into
TeoSlayer:mainfrom
pstayets:combined-fixes

Conversation

@pstayets

@pstayets pstayets commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This combines #282, #283 and #284 into one PR, and fixes the two flaky CI checks that were failing them. Each change is its own commit, so the history stays readable.

What changes for the user?

Commit Was Change
Refuse a production deploy that leaves relay analytics unset #282 Relay analytics (downloads, installs, sessions, viewers, MCP) stopped at 2026-09-23 17:11 UTC, four minutes after the 0.23.1 deploy. The relay only sends when vars.POSTHOG_ENABLED === "1", and Wrangler replaces every var on deploy. npm run deploy:production now refuses a config without an explicit "0" or "1".
Add a one-screen landing page at /start/ for paid traffic #283 A phone-first page to test against / with paid X traffic: what shell does in one line, then install, start your agent, scan the QR code, plus "Send these steps to my laptop" (share sheet). It gets exactly /'s CSP, Google Analytics, first-party events and X pixel via one isLandingPath() check. It reports as its own route (start / landing_start) and is noindex.
Stop app-started sessions from forking an old agent conversation #284 Any shell command starts the daemon with os.Environ(). Run inside Claude Code, that carried the conversation's id into the daemon and every browser-started session, so starting claude from the app ran claude --resume <old id> --fork-session. Fixed with three guards: the daemon's environment, browser-started sessions' environment, and handoffAllowed() (browser starts never hand off). Typed shell claude inside Claude Code still forks, as intended.
Stop two CI checks failing at random new app: the live-browser canary deleted its temp directory while Chrome was still writing its profile on exit, and threw ENOTEMPTY after every check had passed (6 of the last 40 runs); rmSync now retries. windows: the installer test gave python -m http.server 10 s to answer on a cold runner (3 of the last 40 runs, including main at 7ef9cd4); it now waits 60 s and reports if the server process exits.
Let each ad link to its own version of /start/, set up in PostHog new An ad links to /start/?utm_content=<page>, 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 (via /flags?v=2, public token, a throwaway id, 800 ms timeout). New pages or wording changes are PostHog edits, not deploys. Only a short page key is read from the URL, fields are validated and set as text, and anything unknown, slow or blocked shows the default page. Events carry landing_variant (the page key or default).

Verification

  • npm run typecheck passes. npm test: 67 files, 778 tests passed, plus the installer, Docker entrypoint, deploy guard, landing SEO and mobile checks.
  • go vet ./... and gofmt are clean. go test -race -count=1 ./... passes: all 9 packages.
  • Evidence from the original PRs still applies:
    • Headless Chrome screenshots of /start/: fits one screen at 390×664 and at 1440×900.
    • The fresh-HOME end-to-end install → session → phone scan.
    • Real old and fixed binaries started from inside a Claude Code conversation: the old daemon inherited 3 conversation variables, the fixed one 0.
  • Not run locally: the app job (it needs Postgres; the only change in its scope is the canary's cleanup line), the Windows job, and the QEMU jobs. CI covers them.

Access and privacy

No change to authorization, terminal input, encryption or stored content. /start/ loads only what / loads, under the same opt-out and GPC/DNT checks. The daemon and browser-started sessions now inherit less: no agent conversation identity.

  • No real share links, credentials, private terminal content or deployment secrets are included.
  • The changelog is updated. Its Unreleased section has one Added and two Fixed entries.

Rollout

  • Web deploy: in the private wrangler.production.jsonc, add "POSTHOG_ENABLED": "1" to vars and "/start/*" to assets.run_worker_first. The deploy guard refuses the config until both are there.
  • CLI release: needed for the daemon fix. An affected machine is fixed once the new daemon replaces the running one (shell service install, a restart, or signing in again).

Supersedes #282, #283 and #284.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN

pstayet and others added 4 commits September 29, 2026 12:18
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
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 <id> --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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
- 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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
pstayet and others added 2 commits September 29, 2026 12:29
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
"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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
@pstayets

Copy link
Copy Markdown
Contributor Author

@TeoSlayer could you take a look at this one when you get a chance? We need it to start the paid X ads. They'll point at the new /start/ page, and without the relay analytics fix we can't see whether the ad traffic leads to installs or sessions.

All 15 checks are green. To deploy it, wrangler.production.jsonc needs two additions:

  • "POSTHOG_ENABLED": "1" in vars
  • "/start/*" in assets.run_worker_first

The deploy guard refuses the config until both are in. Thanks!

An ad links to /start/?utm_content=<page>. 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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
@pstayets pstayets changed the title Restore relay analytics, add the /start/ landing page, stop app sessions forking old conversations Restore relay analytics, add /start/ with ad-specific pages, stop app sessions forking old conversations Sep 29, 2026
teovl and others added 3 commits November 12, 2026 11:03
# Conflicts:
#	CHANGELOG.md
#	cmd/shell/agent_loop.go
#	standalone/server.test.ts
#	vite.config.ts
#	wrangler.example.jsonc
@TeoSlayer
TeoSlayer merged commit 6679461 into TeoSlayer:main Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants