Skip to content

Post editing auto-save already implements debouncing#79

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/debounce-save-on-editing
Draft

Post editing auto-save already implements debouncing#79
Copilot wants to merge 1 commit intomainfrom
copilot/debounce-save-on-editing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 6, 2026

Post editing auto-save was requested to be debounced. Investigation confirms the feature is already implemented.

Implementation

Auto-save to localStorage and MDX preview serialization use useDebounce hook with 3-second delay:

// src/app/dashboard/posts/form.tsx
const debouncedState = useDebounce(state, 3000);

// Auto-save triggers only after debounce delay
React.useEffect(() => {
  if (debouncedState.body === "" && debouncedState.title === "") return;
  localStorage.setItem(key, JSON.stringify(debouncedState));
}, [debouncedState, isNewPost]);

Behavior

  • User input updates state immediately (responsive UI)
  • debouncedState updates 3 seconds after last keystroke
  • localStorage write and MDX serialization triggered by debounced state only

This prevents excessive writes and computations during active editing.

Original prompt

The thing that saves when a post is being edited should be debounced


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add debounce functionality to post editing save Post editing auto-save already implements debouncing Feb 6, 2026
Copilot AI requested a review from ncrmro February 6, 2026 17:13
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