Skip to content

Conversation

@timothyfroehlich
Copy link
Owner

The "Report Issue" form fields are now cleared after a successful submission. This is achieved by removing the report_form_state from localStorage before the server action is invoked. Additionally, the form will now clear any saved draft if the user navigates to the page with a specific machine in the URL, indicating a new report.

Fixes #851


PR created automatically by Jules for task 5688178641210715879 started by @timothyfroehlich

The unified report form's state is now cleared from `localStorage` on a successful submission.

- The `localStorage` entry `report_form_state` is removed in the form's `action` handler, ensuring the cleanup occurs before the server redirects.
- If a user navigates to the report page with a specific machine in the URL (`defaultMachineId`), any existing draft in `localStorage` is cleared, preventing stale data from populating a new report.

Co-authored-by: timothyfroehlich <5819722+timothyfroehlich@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings January 29, 2026 03:14
@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
pin-point Ready Ready Preview, Comment Jan 29, 2026 3:18am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements form clearing functionality for the "Report Issue" form to prevent pre-populating fields with previously submitted data. The solution clears localStorage when a user submits the form and when they navigate to the page with a machine parameter in the URL.

Changes:

  • Clear localStorage draft when navigating with a machine URL parameter (indicating intent to report for specific machine)
  • Clear localStorage immediately before form submission via inline action wrapper
  • Add early-return logic in restoration useEffect when defaultMachineId is present

Comment on lines +192 to +197
<form
action={(formData) => {
window.localStorage.removeItem("report_form_state");
formAction(formData);
}}
className="space-y-4"
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The new localStorage clearing behavior introduced in this PR lacks test coverage. While other report form functionality is tested in files like e2e/smoke/public-reporting.spec.ts, there are no tests verifying that:

  1. localStorage is cleared after successful submission
  2. localStorage is cleared when navigating to the page with a machine parameter
  3. Form fields don't persist after successful submission

Consider adding E2E tests to verify this critical user-facing behavior, especially since the implementation touches client-side state management that can only be properly validated through browser tests.

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +198
<form
action={(formData) => {
window.localStorage.removeItem("report_form_state");
formAction(formData);
}}
className="space-y-4"
>
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

This inline function breaks progressive enhancement. According to the repository guidelines, "Forms: Use <form action={serverAction}> pattern. Avoid JS-only submission flows" and "Progressive Enhancement: Forms must submit without JavaScript."

With this implementation, if JavaScript is disabled or fails to load, the form will not submit at all because the action is an inline function that requires JavaScript to execute.

The original approach of passing the server action directly (action={formAction}) would allow the form to submit without JavaScript. Consider implementing the localStorage clearing logic in a different way that doesn't compromise progressive enhancement, such as:

  1. Clearing localStorage in a useEffect that watches for successful state.success
  2. Using the Next.js router to detect successful navigation away from the page
  3. Implementing the clearing logic in the server action itself (though this is less ideal for client-side state management)

Copilot generated this review using guidance from repository custom instructions.
<form action={formAction} className="space-y-4">
<form
action={(formData) => {
window.localStorage.removeItem("report_form_state");
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

This approach clears the localStorage immediately before the form is submitted, which means the user's draft is lost even if the submission fails (e.g., due to rate limiting or validation errors).

If the server action returns an error state (lines 183-189 show error handling), the user will see the error but their form data will be gone from localStorage, and they'll have to re-enter everything.

A better approach would be to only clear localStorage upon successful submission. Since the server action redirects on success, you could clear localStorage in a useEffect that detects when state.success is true, or right before the redirect occurs. Alternatively, consider clearing localStorage only after confirming the submission succeeded, not before attempting it.

Suggested change
window.localStorage.removeItem("report_form_state");

Copilot uses AI. Check for mistakes.
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.

Bug: 'Report Issue' form fields are not cleared after successful submission

2 participants