Skip to content

48107 frontend [ tasks ] fix forms state#267

Open
aicarma-artyom-maslov wants to merge 3 commits into
masterfrom
frontend/tasks/48107__Fix_forms_state
Open

48107 frontend [ tasks ] fix forms state#267
aicarma-artyom-maslov wants to merge 3 commits into
masterfrom
frontend/tasks/48107__Fix_forms_state

Conversation

@aicarma-artyom-maslov

@aicarma-artyom-maslov aicarma-artyom-maslov commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Touches task completion/revert flows and localStorage draft persistence; incorrect flush/cancel timing could still lose or resurrect draft data, but changes are localized with new tests.

Overview
Fixes task form draft behavior so in-progress output edits are not lost or incorrectly re-saved when the server refreshes task data, the card unmounts, or the user completes or reverts a task.

TaskCard now uses a flushable debounce for localStorage drafts: pending saves are flushed before output is reloaded from the server or on unmount, and cancelled on complete/revert so stale drafts are not written back. Output field keys are scoped with task.id to avoid collisions when switching tasks. On revert, the action includes clearOutputTaskIds for the current task and its revert chain.

localStorage helpers gain bulk draft removal and drop the storage key when no drafts remain.

ExtraFieldFile refreshes the displayed attachment list when props change (unless an upload is in progress) and merges new uploads against the latest file state via a ref.

Tests cover debounce flush/cancel, storage cleanup, draft persistence edge cases, and file-field sync during upload.

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

Note

Fix task form state to prevent draft loss and stale data on revert or complete

  • Replaces throttle-debounce's debounce with a new createFlushableDebounce utility that supports explicit flush and cancel, so pending draft saves can be controlled at key moments.
  • TaskCard flushes pending saves when task output data changes or on unmount, and cancels pending saves before completing or reverting a task.
  • On revert, setTaskReverted now accepts clearOutputTaskIds to remove drafts for the current task and related revert tasks in a single localStorage operation.
  • ExtraFieldFile uses a ref to track files-in-flight so uploads and deletions always operate on the latest file list even if props change mid-upload.
  • saveOutputsToStorage now removes the localStorage key entirely when no drafts remain instead of storing an empty array.

Macroscope summarized 76294ad.

Comment thread frontend/src/public/components/TaskCard/TaskCard.tsx
Comment thread frontend/src/public/components/TaskCard/TaskCard.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c07282f. Configure here.

Comment thread frontend/src/public/components/TaskCard/TaskCard.tsx
Comment thread frontend/src/public/components/TemplateEdit/ExtraFields/File/ExtraFieldFile.tsx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Web client changes request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant