Skip to content

feat(mcp): show PostHog exec payload in permission dialog#2080

Merged
skoob13 merged 2 commits intomainfrom
feat/posthog-exec-payload-preview
May 7, 2026
Merged

feat(mcp): show PostHog exec payload in permission dialog#2080
skoob13 merged 2 commits intomainfrom
feat/posthog-exec-payload-preview

Conversation

@skoob13
Copy link
Copy Markdown
Contributor

@skoob13 skoob13 commented May 7, 2026

Problem

Beautify the formatting of PostHog MCP tools.

Screenshot 2026-05-07 at 09 32 30

Changes

  • Agent: set _meta.claudeCode.toolName on the requestPermission toolCall in handlePostHogExecApprovalFlow so the renderer routes the dialog to McpPermission.
  • Renderer: in McpPermission, format the body via a new formatPosthogExecBody helper that pretty-prints JSON call payloads (and passes other args — e.g. search regex — through unchanged); verbs without args (tools/info/schema) render no body since the title already conveys the action.
  • Move the PostHog-specific exec-display helpers out of the generic mcp-apps feature into a new posthog-mcp feature.
  • Storybook fixtures for info / tools / search verbs alongside the existing call story.

How did you test this code?

  • 14 agent permission-handler tests + 28 renderer posthog-exec-display tests pass (including a new assertion that _meta.claudeCode.toolName is set in the destructive PostHog flow, and new tests for formatPosthogExecBody).
  • Storybook: Permissions/PermissionSelector → McpPostHogExec shows pretty-printed { "query": "select 1" } body; sibling stories (McpPostHogExecInfo/Tools/Search) show no body or the regex.

Publish to changelog?

no

The PostHog exec destructive flow was rendering only "The agent wants to run X on PostHog" with no payload because the agent didn't tag the permission request with `_meta.claudeCode.toolName`, so the renderer fell through to DefaultPermission. Setting that meta routes the dialog to McpPermission, which unwraps the `call <subTool> <json>` command and shows the JSON args pretty-printed.

Also moves the PostHog-specific exec-display helpers out of the generic mcp-apps feature into their own posthog-mcp feature, and adds a formatPosthogExecBody helper so the dialog body matches the chat row's unwrapped preview.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/posthog-mcp/utils/posthog-exec-display.test.ts:204-230
**Non-parameterised tests in `formatPosthogExecBody` suite**

The team's stated preference is parameterised tests. The six new `it()` blocks here are testing the same function with different inputs/outputs and are a textbook candidate for `it.each`. For example, the five cases that check input→output could collapse to a single `it.each` table, and the two `undefined` / `""` cases to another `it.each`, keeping the intent clear without repeating `expect(formatPosthogExecBody(...)).toBe(...)` every time.

Reviews (1): Last reviewed commit: "feat(code): show PostHog exec payload in..." | Re-trigger Greptile

@skoob13 skoob13 changed the title feat(code): show PostHog exec payload in permission dialog feat(mcp): show PostHog exec payload in permission dialog May 7, 2026
@skoob13 skoob13 requested review from a team May 7, 2026 07:44
@skoob13 skoob13 enabled auto-merge (squash) May 7, 2026 07:53
@skoob13 skoob13 merged commit c3876ad into main May 7, 2026
15 checks passed
@skoob13 skoob13 deleted the feat/posthog-exec-payload-preview branch May 7, 2026 07:56
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.

2 participants