Skip to content

chore(inbox): Slim down inbox Create PR prompt and auto-launch#2370

Merged
andrewm4894 merged 4 commits into
mainfrom
posthog-code/inbox-create-pr-clean-prompt
May 26, 2026
Merged

chore(inbox): Slim down inbox Create PR prompt and auto-launch#2370
andrewm4894 merged 4 commits into
mainfrom
posthog-code/inbox-create-pr-clean-prompt

Conversation

@andrewm4894
Copy link
Copy Markdown
Member

@andrewm4894 andrewm4894 commented May 26, 2026

Summary

The Create PR button on an inbox report was inlining the entire researched summary into a single prompt and dumping the user back into TaskInput so they had to read, edit and submit it themselves. The wall of text made the task feel intimidating and meant people often abandoned it before kicking it off — even though the report was already actionable.

This change makes Create PR behave like Discuss: a short, intent-only prompt that points the agent at the inbox MCP tools, with the task created and launched in auto mode in one click.

  • New buildCreatePrReportPrompt util (+ tests) — short prompt that references the report by ID, links the deeplink, and tells the agent to use the inbox MCP tools to fetch summary/signals/reviewers itself.
  • New useCreatePrReport hook mirroring useDiscussReport. Hardcodes executionMode: "auto", cloudRunSource: "signal_report", navigates straight to the task on success.
  • ReportDetailPane swaps the navigateToTaskInput wall-of-text path for the hook. The Create PR button now shows a spinner and disables while the task is being created (same UX as Discuss).

Before

Act on this signal report. Investigate the root cause, implement the fix, and open a PR if appropriate.

{entire ~2-5k character researched summary inlined here, then user has to read/edit/submit}

After

image image

Act on PostHog inbox report `` (inbox item). Use the inbox MCP tools to fetch the report, its signals, and any suggested reviewers; investigate the root cause; implement the fix; and open a PR.

Then the task is created immediately in auto mode and the user is dropped on the task detail page — no extra click required.

Test plan

  • Unit tests for the new prompt builder pass (`vitest run src/renderer/features/inbox/utils/buildCreatePrReportPrompt.test.ts`)
  • On an actionable inbox report, click Create PR → spinner appears on the button, toast "Starting PR task…" shows, then you land on the task detail page with the slim prompt and execution mode = auto
  • If no cloud repository is set, the user gets the "Pick a cloud repository before creating a PR" toast (mirrors Discuss)
  • If GitHub integration is missing, the user gets the "Connect a GitHub integration to create a PR" toast
  • Cmd/Ctrl+Enter shortcut still kicks off Create PR (the keyboard handler is unchanged)
  • Discuss flow is unaffected

The Create PR button on an inbox report was inlining the entire researched
summary into a single prompt and dumping the user back into TaskInput so they
had to read, edit and submit it themselves. The wall of text made the task
feel intimidating and slowed people down enough that they often dropped off
before actually kicking it off.

Mirror the Discuss flow: build a short, intent-only prompt that tells the
agent to fetch the report through the inbox MCP tools, then create the task
directly in auto mode and jump to it - same UX shape as Discuss, just for
implementation instead of conversation.

- new `buildCreatePrReportPrompt` util + tests for the short prompt shape
- new `useCreatePrReport` hook that mirrors `useDiscussReport`, hardcoding
  `executionMode: "auto"` and `cloudRunSource: "signal_report"`
- `ReportDetailPane` swaps `navigateToTaskInput` for the hook, shows a
  spinner while the task is being created, and disables the button while
  in-flight

Generated-By: PostHog Code
Task-Id: 4884e8d3-538d-4b19-9dc9-3b76a07df269
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

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

---

### Issue 1 of 3
apps/code/src/renderer/features/inbox/utils/buildCreatePrReportPrompt.test.ts:5-19
The first two tests exercise the same function with different `isDevBuild` values — a textbook candidate for a parameterised test. The project style guide prefers `it.each` / `describe.each` for cases like this to avoid repeating the setup.

```suggestion
  it.each([
    { isDevBuild: false, expectedScheme: "posthog-code" },
    { isDevBuild: true, expectedScheme: "posthog-code-dev" },
  ])(
    "uses $expectedScheme:// in builds where isDevBuild=$isDevBuild",
    ({ isDevBuild, expectedScheme }) => {
      const prompt = buildCreatePrReportPrompt({ reportId: "abc123", isDevBuild });
      expect(prompt).toContain(`${expectedScheme}://inbox/abc123`);
    },
  );
```

### Issue 2 of 3
apps/code/src/renderer/features/inbox/hooks/useCreatePrReport.ts:36-60
`resolveDefaultModel` is identical to the version in `useDiscussReport.ts` (only the log string differs). Extracting it to a shared utility (e.g., `utils/resolveDefaultModel.ts`) would keep it OnceAndOnlyOnce and mean future changes to the query logic only need to happen in one place.

### Issue 3 of 3
apps/code/src/renderer/features/inbox/hooks/useCreatePrReport.ts:151-160
The analytics event records `created_from: "command-menu"` even though this task is created from the inbox detail pane — the same inherited value that exists in `useDiscussReport`. Since the new hook deliberately introduces a distinct code path for inbox Create PR, this is a good opportunity to use a more accurate source label so the two flows can be distinguished in analytics.

```suggestion
        track(ANALYTICS_EVENTS.TASK_CREATED, {
          auto_run: true,
          created_from: "inbox_report",
          repository_provider: "github",
          workspace_mode: "cloud",
          has_branch: false,
          cloud_run_source: "signal_report",
          cloud_pr_authorship_mode: "user",
          adapter,
        });
```

Reviews (1): Last reviewed commit: "Slim down the inbox "Create PR" prompt a..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/features/inbox/utils/buildCreatePrReportPrompt.test.ts Outdated
Comment thread apps/code/src/renderer/features/inbox/hooks/useCreatePrReport.ts Outdated
Comment thread apps/code/src/renderer/features/inbox/hooks/useCreatePrReport.ts
Address Greptile review on #2370.

- Pull `resolveDefaultModel` into a shared util so the inbox Discuss and
  Create PR hooks aren't carrying identical copies of the preview-config
  lookup. Both hooks now import from `utils/resolveDefaultModel`.
- Collapse the two prod/dev deeplink scheme tests for
  `buildCreatePrReportPrompt` into a single `it.each` block.

Skipping the analytics `created_from: "command-menu"` → `"inbox_report"`
suggestion: that label is a typed enum (`TaskCreatedFrom = "cli" |
"command-menu"`), so adding a new value would touch the analytics schema
and diverge from the Discuss flow this hook intentionally mirrors. Out of
scope for the prompt-slim PR.

Generated-By: PostHog Code
Task-Id: 4884e8d3-538d-4b19-9dc9-3b76a07df269
@andrewm4894 andrewm4894 changed the title Slim down inbox Create PR prompt and auto-launch chore(inbox): Slim down inbox Create PR prompt and auto-launch May 26, 2026
@andrewm4894 andrewm4894 self-assigned this May 26, 2026
The slim Create PR / Discuss prompts no longer inline the report
summary, so the agent depends on the inbox MCP returning the report.
Add a guard clause so it stops and reports instead of proceeding on a
hallucinated understanding when the fetch fails.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fed962bda7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +63 to +67
const githubUserIntegrationId =
getUserIntegrationIdForRepo(cloudRepository);
if (!githubUserIntegrationId) {
toast.error("Connect a GitHub integration to create a PR");
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Delay missing-integration error until repo mappings load

This new Create PR path treats getUserIntegrationIdForRepo(...) returning undefined as “no GitHub integration,” but that mapping is populated asynchronously by useUserRepositoryIntegration (it is built from async repository queries). If the user clicks Create PR before those queries finish, we now show a false "Connect a GitHub integration" error and abort task creation, even when the integration exists. Please gate this check on the integration-loading state (or trigger a refresh/retry) before surfacing the missing-integration toast.

Useful? React with 👍 / 👎.

const cloudRegion = useAuthStateValue((state) => state.cloudRegion);

const createPrReport = useCallback(async () => {
if (isCreatingPr) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Harden in-flight guard against rapid double submission

The isCreatingPr guard is state-based and is checked before setIsCreatingPr(true) runs, so two very fast triggers (e.g., double-click or key-repeat on Cmd/Ctrl+Enter) in the same render frame can both pass this check and start parallel createTask calls. That can create duplicate PR tasks for a single report. Use a synchronous in-flight ref/mutex (or set-and-check atomically) so re-entrant calls are blocked immediately.

Useful? React with 👍 / 👎.

Comment on lines +108 to +111
workspaceMode: "cloud",
executionMode: "auto",
adapter,
model,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid auto-running Create PR for reports awaiting user input

This flow now always creates tasks with executionMode: "auto" while ReportDetailPane still exposes Create PR for pending_input / requires_human_input reports. In that state the user is expected to supply missing context, but bypassing TaskInput removes the pre-run input step and immediately launches an implementation run with incomplete requirements, which can lead to avoidable failed or low-quality PR tasks. Gate auto-run to immediately-actionable reports or keep a manual-input path for pending-input reports.

Useful? React with 👍 / 👎.

@andrewm4894 andrewm4894 merged commit 2d9aadc into main May 26, 2026
15 checks passed
@andrewm4894 andrewm4894 deleted the posthog-code/inbox-create-pr-clean-prompt branch May 26, 2026 14:47
Basit-Balogun10 pushed a commit to Basit-Balogun10/posthog-code that referenced this pull request May 27, 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.

2 participants