Skip to content

feat(loops): edit instructions inline on loop detail#3717

Merged
charlesvien merged 3 commits into
mainfrom
posthog-code/loops-inline-instructions
Jul 23, 2026
Merged

feat(loops): edit instructions inline on loop detail#3717
charlesvien merged 3 commits into
mainfrom
posthog-code/loops-inline-instructions

Conversation

@MattPua

@MattPua MattPua commented Jul 22, 2026

Copy link
Copy Markdown
Member

Problem

Editing a loop's instructions on the detail page meant opening the full 4-step edit wizard just to tweak the prompt. The instructions were shown read-only in the config panel.

Changes

CleanShot 2026-07-22 at 11 00 20@2x
  • Pull Instructions out of the shared Configuration panel into its own box
  • The box is a textarea you click straight into to edit (no Edit/Save buttons)
  • Saves on blur via the existing PATCH (useUpdateLoop); a subtle "Saving…" shows while in flight
  • Escape reverts to the saved value without saving
  • Guards: blank input reverts, no-op saves are skipped, textarea is disabled mid-save (no double-submit), errors revert and toast

How did you test this?

  • pnpm --filter @posthog/ui typecheck passes
  • biome check clean on the changed file
  • Not manually run in-app yet

Automatic notifications

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

Created with PostHog Code

Pull instructions out of the config panel into its own box that's
editable in place. Click into the textarea to edit, saves on blur via
the existing PATCH; Escape reverts. Removes the round-trip through the
full edit wizard just to tweak the prompt.

Generated-By: PostHog Code
Task-Id: 8a18478b-2989-4a7c-93f6-c54d3db955f0
@trunk-io

trunk-io Bot commented Jul 22, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 1cafb41.

Generated-By: PostHog Code
Task-Id: e5c17bb5-1f87-40c7-9891-0fa72f3e63a9
@MattPua
MattPua requested a review from charlesvien July 22, 2026 15:13
@MattPua
MattPua marked this pull request as ready for review July 22, 2026 15:13
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/ui/src/features/loops/components/LoopDetailView.tsx:317-324
**Instruction Formatting Is Stripped**

When instructions contain meaningful leading spaces or trailing newlines, blur sends `value.trim()` instead of the text entered. The saved prompt silently loses that formatting; trimming should only detect blank input, while comparison and persistence should use the original value.

```suggestion
    if (!value.trim()) {
      if (textareaRef.current) textareaRef.current.value = loop.instructions;
      return;
    }
    if (value === loop.instructions || updateLoop.isPending) return;
    updateLoop.mutate(
      { instructions: value },
```

### Issue 2 of 2
packages/ui/src/features/loops/components/LoopDetailView.tsx:349-351
**Background Updates Discard Drafts**

The textarea key is the last saved instructions value, so a detail-query refresh that returns changed instructions remounts the field. If someone is typing when a window-focus refresh or concurrent update arrives, their unblurred draft disappears without warning.

Reviews (1): Last reviewed commit: "fix(loops): align inline editor with qui..." | Re-trigger Greptile

Comment thread packages/ui/src/features/loops/components/LoopDetailView.tsx
Comment thread packages/ui/src/features/loops/components/LoopDetailView.tsx Outdated
Generated-By: PostHog Code
Task-Id: e5c17bb5-1f87-40c7-9891-0fa72f3e63a9
@charlesvien
charlesvien merged commit d714c54 into main Jul 23, 2026
32 checks passed
@charlesvien
charlesvien deleted the posthog-code/loops-inline-instructions branch July 23, 2026 04:15
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