experiment(notebooks): AI summarizer + prompter edit panel#3472
Draft
mariusandra wants to merge 2 commits into
Draft
experiment(notebooks): AI summarizer + prompter edit panel#3472mariusandra wants to merge 2 commits into
mariusandra wants to merge 2 commits into
Conversation
Replace the vendored raw-JSON-textarea edit panel on PostHog entity nodes
(Query, FeatureFlag, Experiment, Survey, EarlyAccessFeature, Cohort,
Person, Group, Recording) with a universal AI editing interface:
- core NotebookNodeAIService: prompt construction from per-tag affordance
knowledge, single model call returning {props, summary}, Zod-validated
parsing with one retry, FNV-1a summary cache keyed on tagName+props
(shell-managed panel props excluded), best-effort live-entity enrichment
via the existing embed REST getters.
- core PostHogNotebookNodeAIModel transport: direct LLM-gateway
/v1/chat/completions (claude-haiku-4-5, streaming SSE) with sticky
fallback to a Max conversations turn when the gateway rejects the login.
- api-client: llmGatewayChatCompletion + region-derived llmGatewayUrl
(same OAuth bearer the agent path uses against the gateway).
- core notebookNodeSummary: deterministic instant summaries (trends/
funnel/retention/SQL/events + entity tags) shown while AI streams in.
- ui NotebookNodeAIEditPanel + hooks: summary view with streaming cursor,
change-request prompt committing through the shell's updateProps (full
replacement semantics incl. key deletion), collapsible raw-JSON escape
hatch.
- 62 unit tests incl. parameterized retry/parse cases.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…remount React StrictMode's double-mount aborts the first useQuery signal; the service coalesces concurrent summarize calls onto one shared promise, so the abort killed the call for the surviving subscriber and the AI summary never arrived. The summary call now runs unsignalled — it is cheap, cache-filling, and should complete even if the panel closes. Verified live against us.posthog.com through the LLM gateway. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
React Doctor found 1 issue in 1 file · 1 error. Errors
Reviewed by React Doctor for commit |
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.
Experiment 1/3: universal AI editing interface for notebook nodes
Replaces the generic raw-JSON edit panel for embed nodes (Query, FeatureFlag, Experiment, Survey, EarlyAccessFeature, Cohort, Person, Group, Recording) with a summarizer + prompter:
Architecture
NotebookNodeAIServiceinpackages/core/src/notebooks/— prompt construction, single-call{props, summary}, Zod validation, retry, FNV-1a summary cache, live-entity enrichment for entity nodes./v1/chat/completions(claude-haiku-4-5, streaming) — the desktop OAuth token is accepted straight from the renderer with open CORS. Max AI conversations as sticky fallback. Agent SDK rejected (seconds of spawn latency).notebookNodeAIKnowledge.ts) covering all query kinds; deterministic summarizer innotebookNodeSummary.ts.Verified
Live against us.posthog.com on a real Trend node: both change requests applied correctly (verified in raw JSON:
math:"dau",-30d,ActionsPie/ActionsBar, breakdown add/remove). 62 unit tests with a faked model; full-repo typecheck and Biome clean.Known dragons
displayisActionsBar(props are correct; view layer doesn't do bars yet).🤖 Generated with Claude Code
Screenshots
Edit panel open on a Trend node — instant deterministic summary already replaced by the streamed AI summary:
After the change request "make it a bar chart of unique users, split by browser" — updated summary + re-rendered chart (~1.8s end-to-end):
Raw JSON escape hatch showing the exact props the model produced: