Skip to content

feat(desktop): Implement loops ➿#3411

Draft
charlesvien wants to merge 60 commits into
mainfrom
feat/loops
Draft

feat(desktop): Implement loops ➿#3411
charlesvien wants to merge 60 commits into
mainfrom
feat/loops

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 14, 2026

Copy link
Copy Markdown
Member

Problem

Loops put recurring PostHog work on autopilot. Instead of kicking off the same agent task by hand every time, you define a loop once and it runs itself on PostHog's managed cloud infrastructure: on a schedule, when a GitHub event fires, or when your own code calls its API. This PR adds the desktop UI to create and manage them. The backend API lives in the posthog repo [companion PR].

Changes

  • New top-level Loops section (Alpha-badged in the sidebar): a landing page with a prompt composer, your loops and starter templates, plus a loop detail view with run history, enable/pause and "Run now".
  • The composer launches an interactive cloud loop-builder: a sandbox agent drafts the loop with you and presents it through the loops-review card, whose Create button is the only path that creates the loop. Templates and "Create manually" open the guided wizard (Prompt, When, Options, Review) with a clickable stepper.
  • Triggers: schedule via a plain frequency picker (Hourly / Daily / Weekdays / Weekly / Once) that shows cron it can't represent as read-only "Custom" instead of rewriting it, GitHub events per repository, or an authenticated API endpoint.
  • Attach a loop to a context: post runs to the feed, keep context.md updated and/or maintain a canvas (forces team visibility). Each context gets its own Loops tab with a scoped composer.
  • Per-channel notifications (push, email, Slack), an Auto-fix pull requests toggle and model/adapter/reasoning effort behind Advanced; leaving the model unset lets the backend pick per run.
  • Safety-limit rejections from the backend surface as a distinct "Safety limit reached" message with the reason instead of a generic failure.
  • Hand-written @posthog/api-client loops module (CRUD, run/trigger with idempotency keys, run history, preview) until the OpenAPI client regenerates.
  • New agent finish tool, gated to background cloud runs: the agent marks its task run completed or failed so the sandbox tears down instead of idling to a timeout.
  • MCP apps get a lazy config resolver so cloud runs (which never open a local session) can render the loops-review card on desktop, and OAuth now requests the explicit scope list (including loop:read/loop:write and llm_gateway:read) instead of *, with a scope version bump forcing re-auth.

How did you test this?

  • CI is green on the head commit: typecheck, unit-test, e2e, integration-test, visual-regression, build and quality all pass.
  • 154 unit tests across the 10 new or changed test files pass locally: loop form validation and cron parsing, the builder prompt, the api-client loops module, finish tool gating and task-run updates, the mcp-apps config resolver, and the OAuth scope guards.
  • Exercised the landing page, cloud loop-builder, create wizard and context attachment in the running desktop app.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

React Doctor found 10 issues in 6 files · 10 warnings.

10 warnings

src/features/loops/components/LoopBuilderComposer.tsx

src/features/loops/components/LoopFallbacks.tsx

src/features/loops/components/LoopForm.tsx

src/features/loops/components/LoopTemplatesSection.tsx

src/features/loops/components/LoopTriggerEditor.tsx

src/features/loops/components/LoopsListView.tsx

Reviewed by React Doctor for commit c840d74.

@charlesvien

Copy link
Copy Markdown
Member Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(loops): remove mobile UI, desktop-..." | Re-trigger Greptile

Comment thread packages/ui/src/features/loops/loopFormTypes.ts Outdated
@charlesvien
charlesvien force-pushed the feat/loops branch 5 times, most recently from cbd07a3 to 7312c2e Compare July 15, 2026 07:04
@posthog

posthog Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

@charlesvien
charlesvien force-pushed the feat/loops branch 2 times, most recently from 3c14317 to 75e0cf0 Compare July 17, 2026 01:52
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.

1 participant