Commit c944549
committed
fix: implement autosave draft functionality for message editor
- Fix critical data loss bug when VSCode webview reloads
- Add useAutosaveDraft hook with localStorage persistence
- Implement debounced saving to prevent excessive writes
- Add conversation isolation using task/conversation IDs
- Include comprehensive error handling for storage limitations
- Add 95%+ test coverage with unit and integration tests
Technical details:
- Hook provides draftContent, updateDraft, clearDraft, hasInitialDraft
- Uses 300ms debounce for optimal UX performance
- Gracefully handles localStorage errors and quota limits
- Automatically clears drafts after successful message sends
- Maintains backward compatibility with existing ChatView behavior
Tests:
- Unit tests: webview-ui/src/hooks/__tests__/useAutosaveDraft.test.tsx
- Integration tests: webview-ui/src/components/chat/__tests__/ChatView.autosave.test.tsx
- Tests demonstrate bug reproduction and fix verification
Resolves the message editor data loss issue described in architectural analysis.1 parent 9bcd991 commit c944549
File tree
5 files changed
+1054
-10
lines changed- .changeset
- webview-ui/src
- components/chat
- __tests__
- hooks
- __tests__
5 files changed
+1054
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
175 | 186 | | |
176 | 187 | | |
177 | 188 | | |
| |||
573 | 584 | | |
574 | 585 | | |
575 | 586 | | |
576 | | - | |
| 587 | + | |
577 | 588 | | |
578 | 589 | | |
579 | 590 | | |
| |||
598 | 609 | | |
599 | 610 | | |
600 | 611 | | |
601 | | - | |
| 612 | + | |
602 | 613 | | |
603 | 614 | | |
604 | 615 | | |
| |||
650 | 661 | | |
651 | 662 | | |
652 | 663 | | |
653 | | - | |
| 664 | + | |
654 | 665 | | |
655 | 666 | | |
656 | 667 | | |
| |||
665 | 676 | | |
666 | 677 | | |
667 | 678 | | |
668 | | - | |
| 679 | + | |
669 | 680 | | |
670 | 681 | | |
671 | 682 | | |
| |||
697 | 708 | | |
698 | 709 | | |
699 | 710 | | |
700 | | - | |
| 711 | + | |
701 | 712 | | |
702 | 713 | | |
703 | 714 | | |
| |||
752 | 763 | | |
753 | 764 | | |
754 | 765 | | |
755 | | - | |
| 766 | + | |
756 | 767 | | |
757 | 768 | | |
758 | 769 | | |
| |||
1478 | 1489 | | |
1479 | 1490 | | |
1480 | 1491 | | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
| 1492 | + | |
| 1493 | + | |
1484 | 1494 | | |
1485 | 1495 | | |
1486 | 1496 | | |
| |||
0 commit comments