t3code icon indicating copy to clipboard operation
t3code copied to clipboard

Fix project action preview settings persistence

Open keeperxy opened this issue 4 months ago • 2 comments

What Changed

  • Preserve previewUrl and autoOpenPreview when creating or updating project actions.
  • Use a shared mapper for both save paths and omit preview settings when the preview URL is cleared.
  • Add regression coverage for saving and removing project action preview settings.

Why

Project actions allow users to configure an optional preview URL. However, when an action was created or edited with a preview URL, saving the action silently discarded both the URL and the associated auto-open preference. Reopening the action therefore showed an empty preview URL field.

The form already included previewUrl and autoOpenPreview in its payload, but ChatView rebuilt the ProjectScript without those fields before calling the project update command. As a result, the preview settings never reached persistence.

Using the same mapper for create and update keeps both save paths consistent. It also ensures that intentionally clearing the preview URL removes the associated preview settings instead of retaining stale values.

Validation

  • pnpm exec vp test apps/web/src/projectScripts.test.ts
  • pnpm exec vp check
  • pnpm exec vp run typecheck

Checklist

  • [x] This PR is small and focused
  • [x] I explained what changed and why
  • [x] No UI changes; screenshots are not applicable
  • [x] No animation or interaction changes; a video is not applicable

[!NOTE] Low Risk Localized persistence fix with unit tests; no auth, security, or broad architectural changes.

Overview Fixes a bug where project action create/update dropped previewUrl and autoOpenPreview before updateProject, so preview settings never saved even though the form sent them.

Introduces shared buildProjectScript in projectScripts.ts for both save paths. It maps core fields plus preview options when a URL is set, and omits preview fields when previewUrl is null so clearing the URL does not leave stale values. ChatView saveProjectScript / updateProjectScript now call this helper instead of inline ProjectScript objects. Regression tests cover saving preview settings and omitting them when the URL is cleared.

Reviewed by Cursor Bugbot for commit e88ef5189aa19a139084f4e98f9a09696b834429. Bugbot is set up for automated code reviews on this repo. Configure here.

[!NOTE]

Fix project action preview settings persistence when saving or updating scripts

  • Adds a buildProjectScript utility in projectScripts.ts that conditionally includes previewUrl and autoOpenPreview only when previewUrl is non-null, omitting those fields otherwise.
  • Updates saveProjectScript and updateProjectScript in ChatView.tsx to use buildProjectScript instead of inline object construction, ensuring preview settings are correctly persisted or cleared.
  • Behavioral Change: Previously, updating a script with a null previewUrl could leave stale preview fields on the stored object; now those fields are explicitly removed.

Macroscope summarized e88ef51.

keeperxy avatar Jul 09 '26 21:07 keeperxy

[!IMPORTANT]

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c03d6612-1226-40f4-adc0-a26109e2fac7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jul 09 '26 21:07 coderabbitai[bot]

Approvability

Verdict: Approved

Straightforward bug fix that adds missing preview settings persistence via a new helper function. The change is small, self-contained, and includes unit tests validating the behavior.

You can customize Macroscope's approvability policy. Learn more.

macroscopeapp[bot] avatar Jul 09 '26 21:07 macroscopeapp[bot]