feat(posthog-integration): detect existing PostHog, surface the other commands - #1190
Open
gewenyu99 wants to merge 14 commits into
Open
feat(posthog-integration): detect existing PostHog, surface the other commands#1190gewenyu99 wants to merge 14 commits into
gewenyu99 wants to merge 14 commits into
Conversation
… tricks (#1066) Co-authored-by: Claude <noreply@anthropic.com>
Conflicts resolved against main's intro-screen refactor, which landed after PR #1066 was opened: - IntroScreenLayout now owns the "Privacy & data" row and appends it to every intro menu, so `introMenuOptions` no longer carries a `privacy` view or a route to one. - `CONTINUE_MENU_OPTIONS` and the screen-local menu construction it replaced are gone. `introMenuOptions` is the single source, and the screen's label-width test measures its output instead of a second copy of the list. - Main added a 20-column cap on intro menu labels, which "Explore wizard tricks" exceeds by one, so it can no longer be used verbatim. - `ProgramReadyContext` gained `setPosthogSdkDetected`, so the two contexts main added since (run-non-interactive, the detect test stub) implement it. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
…stHog is found The detected headline stated the detection and stopped there, leaving the re-run user a fact and no reason to pick either option. It now names three things worth doing on a project that already has PostHog, and says plainly that continuing may overwrite work — which is the fear the original issue quotes, in the words the reporter used. Two paragraphs rather than one line, so `introHeadline` returns `string[]` and the screen renders them in the same 64-column block `more-info` uses. A single line still centers; a wrapped block aligns left, since centered prose reads ragged. The "PostHog ✔" row's label is padded to the width the layout hardcodes for its own rows. Unpadded, its tick sat two columns left of the three above it. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
… names The list sits directly under a sentence promising auditing, source maps and self-drive, but rendered in `PROGRAM_REGISTRY` order — so it opened with revenue-analytics, and whatever program was appended most recently would keep displacing what the copy had just promised. Featured ids are an explicit list rather than a reordering of the registry: the registry drives CLI dispatch, and this is a presentation concern. The sort is stable, so everything unfeatured keeps registry order behind them and a new program lands at the bottom. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
`useKeyBindings` gives every mounted component every keystroke — there is no focus scope. The command list is a picker in the intro's `body` slot, so the `Back` menu the layout rendered underneath it was a second picker: one arrow key moved both cursors, and the screen showed two focus markers. That view now renders without a menu and binds Esc to go back, which is how the framework picker has always worked — it clears `showContinue` while it's up so nothing else is navigable. Esc registers only for that view, so no other view advertises a hint it doesn't need. Selecting a command also captures `intro menu selected` now, the same event the menu rows fire. Which trick a re-run user picks is the measure of whether offering them beat re-integrating, and the picker was the one path that reported nothing. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
… centers The intro renders each program as "<command path><description>" on one line inside a block it centers. A row wider than the terminal stops the block from centering at all — it pins to the left edge while the title above it stays centered, which is what made the list look misaligned rather than merely wide. Three rows were over an 80-column terminal: doctor at 94, warehouse at 85, revenue-analytics at 79. The other eight already fit. What pushed those three over was a trailing parenthetical of examples, or a clause restating what the command name says — so the short forms are better `--help` lines too, which is the other place these strings render. A test pins every launchable row inside the 80-column budget, so the next long description fails there rather than silently un-centering the list. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
PromptLabel carries a leading space; the filter row below it was flush left, so on every filterable picker with a message the two header lines sat one column apart. Indenting the filter row is the narrow fix: PromptLabel is also used by ConfirmationInput and GroupedPickerMenu, which have no marker column to hang, so changing it there would move more than this. The marker column still hangs one column left of both, with option labels one right — the header lines now agree with each other rather than each landing on its own column. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
One conflict, both sides adding a different import to run-wizard.ts: main's `maybeStampAiSdkDetected` and this branch's `getProgramConfig`. Kept both. The stamp runs inside the auth step, which the intro-gate loop sits above, so a program switched at the intro authenticates under its own config and the two don't interact. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
…e noise Audit pass over this branch's own commits. The detection block hardcoded its label padding three separate ways — `Directory` bare at 9, `Program` at 7 plus two literal spaces, `Skill` at 5 plus five — so a row label of any other length put its tick in its own column. `PostHog ` with trailing spaces was a fourth copy of that, working around the block rather than fixing it. One `DetectionLine` now pads to the widest label a screen passes, which also lines up `PostHog SDK` on the revenue intro, wrong since before this branch. Everything else here is subtraction: the featured-program ordering reads as "these, then the rest" rather than a rank function fed to a stable sort; COMMANDS_LABEL is inlined at its one use; two tests that could not fail are gone (one asserted two constants differ, one restated a sibling); the label column test no longer walks a view that renders no menu; and the comments that narrated their own code are cut to the one line that says why. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
…ection The intro's list was derived — every CLI program that wasn't a family parent, in registry order. That rule picked the wrong things. It dropped `audit`, the one command a project with PostHog already installed most wants, purely because `audit web-analytics` claims it as a parent; the leaf survived and the parent didn't, so the menu advertised one narrow audit and hid the comprehensive one. `audit` is a real program with its own steps and run, so nothing stopped the intro handing off to it. It's now an explicit ordered list. A program earns a row by being worth a re-run user's time, which no field on the config can tell us: `migrate` and `audit web-analytics` are out, `audit` is in, and the order is chosen rather than inherited from PROGRAM_REGISTRY. Five descriptions reworded to match — they render in `--help` too, where they read better short. Also reverts the ALL_COMMANDS list added earlier on this branch. bin.ts is back to main's `use()` chain, where the commands are visible at the point they're registered. Its only other consumer was a test asserting the registry agreed with that list; the two dead `command` fields it was written to catch are still deleted, which was the actual fix. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
gewenyu99
marked this pull request as ready for review
September 2, 2026 01:57
gewenyu99
requested review from
TueHaulund,
arnohillen,
fasyy612 and
ksvat
and removed request for
a team
September 2, 2026 01:57
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
AGENTS.md goes back to main's one line — bin.ts is main's again, so the note describing it was both longer and wrong. Every comment this branch added is one line now. The ones that went were narrating their own code or restating a test's name; what's left is the constraint the code can't show: a column width, a leading space in a sibling component, why a view renders no menu. Also drops a `marginY` on the picker's filter row that reached the branch through a merge rather than a commit, and was never anything this PR needed. Generated-By: PostHog Desktop Task-Id: 5a773d7d-c2dc-444b-a8dd-6eea3ebcadc3
sarahxsanders
approved these changes
Sep 2, 2026
| this.emitChange(); | ||
| } | ||
|
|
||
| switchProgram(program: ProgramId): void { |
Collaborator
There was a problem hiding this comment.
this doesn't look like it updates the run's identity, so it would still report as posthog-integration so we might lose some visibility here
according to PHC you can setTag inside switchProgram
Collaborator
Author
There was a problem hiding this comment.
Ohhhhh that's a good caatch
`posthog_sdk_detected` is a package.json scan result, but it rode along on every screen-transition and setup event regardless of `scanConsent` — so a repo with a PostHog dependency reported that fact before the user had answered, and after they answered "don't share". Route it through wizard-session like `discovered_features`: the property is absent unless consent is granted, and absent stays unambiguous against a `false` verdict. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
start-tui stamps `program_id` once at launch. A user who leaves the integration intro for another command kept reporting under `posthog-integration` for the rest of the run, so the switch was invisible in analytics. Re-stamp the tag inside switchProgram, next to the router and session updates that already follow the new program. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
TaskStreamPush bakes its program id, session id, and event-plan path in at construction, and it was constructed before the intro's program switch could happen — so a user who left the integration intro for another command had the whole run pushed to the web app under `posthog-integration`, with the event plan watcher tailing the wrong file. Build and attach it after the switch loop instead; nothing before that point produces a task to push. The signal handler stays registered ahead of the loop, so Ctrl-C on the intro still restores the terminal and runs the cleanups — it now tolerates a stream that does not exist yet rather than reporting a run that never started. Also note on eventsAuditConfig that `wizard audit events` resolves to the context-mill `audit-events` skill, not to it — dropping its command word in this branch retires a path the family already replaced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on @joshtronic's #1066 — detection, the command picker, and the in-session program switch are his. This branch merges
maininto it and reworks the copy.Screen.Recording.2026-09-01.at.9.56.16.PM.mov