Skip to content

test(onboarding): end-to-end funnel telemetry harness - #1050

Closed
sahrizvi wants to merge 1 commit into
feat/onboarding-telemetryfrom
test/onboarding-telemetry-e2e
Closed

test(onboarding): end-to-end funnel telemetry harness#1050
sahrizvi wants to merge 1 commit into
feat/onboarding-telemetryfrom
test/onboarding-telemetry-e2e

Conversation

@sahrizvi

@sahrizvi sahrizvi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Adds an opt-in end-to-end test for the onboarding funnel telemetry. Stacked on #1049 — based on that branch, so the diff here is just the harness.

Why this exists

Every other telemetry test in the repo spies inside a single process. That cannot see the thing that actually matters: altimate-code tui renders the TUI on the process main thread and runs the HTTP server in a Bun Worker, and each thread loads its own instance of the telemetry module with its own buffer.

This spawns the real CLI in a PTY with its telemetry endpoint pointed at a local sink, drives it with keystrokes, and asserts on the envelopes that arrive over HTTP.

It has already paid for itself: it caught launch_id differing between the two threads, which made the correlation id useless for the exact join it was added to provide (fixed in #1049). No single-process test could have seen it, and two plausible fixes were wrong before the third worked — each ruled out by running this, not by reasoning.

Coverage

  • A full first run through Big Pickle — the eight Part 1 events, their properties, and that every event across both threads and two different session ids shares one launch_id. Big Pickle needs no signup, so the run stays entirely local.
  • Quitting at the pickeronboarding_abandoned{last_stage: model_picker} arrives after process exit. This is the only proof that the flush-on-exit path delivers.

Running it

ALTIMATE_E2E=1 bun test test/e2e/

Skipped without that flag, so it cannot flake anyone's commit. Two scenarios, ~27s.

Notes for anyone extending it

Four things cost me time here and are documented in the code so they don't cost the next person the same:

  • A throwaway HOME is essential — a developer machine has credentials, so the first-run gate never opens and the funnel never starts.
  • The CLI must run from packages/opencode, as the dev script does. The JSX runtime comes from the workspace bunfig.toml and bun only picks it up from that directory; the project under test goes in as the positional argument.
  • Steps are paced with sleeps rather than by waiting on events or screen text. Events arrive on the flush interval and lag the UI by seconds, and terminal output is per-cell ANSI so a visible label is split across escape sequences and never matches a substring search.
  • Uses bun-pty, not @lydell/node-pty — the latter loads a platform-specific native package that is absent in this workspace and fails completely silently: no output, no error, no exit.

What it does not cover

Gateway OAuth (needs a real browser and account), the activation events beyond the menu (need a live model), and rare failure paths unless deliberately induced.

🤖 Generated with Claude Code

https://claude.ai/code/session_018SLUQF3xgZHsGZHSjxe7vb


Summary by cubic

Add an opt-in end-to-end telemetry test harness for the onboarding funnel by launching the real CLI in a PTY and capturing events via a local HTTP sink. It verifies a single launch_id across threads and that onboarding_abandoned is flushed on exit.

  • New Features

    • Drives two flows: full Big Pickle first run; quit at model picker.
    • Asserts event properties and one launch_id across TUI and Worker sessions.
    • Opt-in via ALTIMATE_E2E=1; skipped otherwise.
  • Dependencies

    • Added dev dependency bun-pty@0.4.8.

Written for commit 0d7bc17. Summary will update on new commits.

Review in cubic

Opt-in via ALTIMATE_E2E=1; skipped otherwise, so it cannot flake anyone's
commit. Two scenarios, ~27s total.

Every other telemetry test in this repo spies inside one process, which cannot
see the thing that actually matters: the TUI renders on the main thread and the
server runs in a Bun Worker, each with its own Telemetry module instance and its
own buffer. This spawns the real CLI in a PTY with its telemetry endpoint
pointed at a local sink, drives it with keystrokes, and asserts on the envelopes
that arrive over HTTP.

It has already earned its place — it caught `launch_id` differing between the
two threads, which made the correlation id useless for the exact join it exists
to provide. No single-process test could have seen that.

Covered:

- A full first run through Big Pickle: the eight Part 1 events, their
  properties, and that every event across both threads and two different session
  ids shares one launch_id.
- Quitting at the picker: `onboarding_abandoned{last_stage: model_picker}`
  arrives after process exit, which is the only proof the flush-on-exit path
  delivers.

Notes for anyone extending it:

- A throwaway HOME is essential. A developer machine has credentials, so the
  first-run gate never opens and the funnel never starts.
- The CLI must run from packages/opencode, as the `dev` script does — the JSX
  runtime comes from the workspace bunfig.toml, and bun only picks it up from
  there. The project under test is passed as the positional argument.
- Steps are paced with sleeps, not by waiting on events or screen text. Events
  arrive on the flush interval and lag the UI by seconds; terminal output is
  per-cell ANSI, so a visible label is split across escape sequences and never
  matches a substring search.
- bun-pty, not @lydell/node-pty: the latter loads a platform-specific native
  package that is absent in this workspace and fails silently — no output, no
  error, no exit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018SLUQF3xgZHsGZHSjxe7vb
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fc5fcb6e-f0c7-4ef3-8f08-b4f419933ce3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@sahrizvi sahrizvi closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant