-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/save empty conversations #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Fix 'children' prop missing error by passing undefined instead of empty - All 11 tests still passing - Resolves TypeScript compilation error
TDD Red Phase - Failing tests: - conversation-title: Edit button should show for new conversations - page: Should allow editing title without messages - page: Should save empty conversation when title is changed These tests expect: 1. Edit button visible on new/empty conversations 2. Title editable before sending first message 3. Conversation saved when title is edited (even with no messages) Tests currently failing - implementation to follow
TDD Green Phase - Implementation: - Remove edit button conditional in conversation-title.tsx - Create conversation ID when title changes on empty conversation - Save empty conversations to localStorage - Update auto-save to support conversations without messages Features: - Edit button now visible on new conversations - Title can be changed before sending first message - Conversations persist even with no messages/files Testing: - Updated conversation-title.test.tsx selector to be more specific - Updated page.test.tsx to check localStorage directly - All 508 tests passing
Issue: Title was saving to localStorage but not updating in the header Root cause: Auto-save useEffect was calling createConversation without passing the conversationTitle parameter, causing it to overwrite the user's title with an auto-generated one. Solution: Pass conversationTitle to createConversation when updating an existing conversation, ensuring the user's custom title is preserved in both storage and the UI. All tests passing.
Issue: Title would revert to 'New Conversation' after being changed, even though it saved correctly in localStorage/history. Root Cause: conversationTitle was in the auto-save useEffect dependency array, causing it to re-run every time the title changed. This triggered the auto-save logic which would sometimes overwrite the user's custom title with an auto-generated one. Solution: Remove conversationTitle from dependencies since title updates are already handled by handleTitleChange and updateConversationTitle. The auto-save should only trigger on content changes (messages, files, aiTheme), not title changes. All tests passing.
Issue: Title would update in localStorage but revert to 'New Conversation' in the header after being changed. Root Cause: The auto-save useEffect was using a stale conversationTitle value from closure. Since conversationTitle was removed from dependencies to prevent infinite loops, the effect closure captured the old value and kept using 'New Conversation' instead of the updated title. Solution: Introduce conversationTitleRef to track the current title value. This ref is updated immediately when the title changes and is always current when the auto-save effect runs. The ref bypasses React's batching and closure staleness issues. Changes: - Added conversationTitleRef to track current title - Update ref in all places where setConversationTitle is called - Auto-save effect now uses conversationTitleRef.current for latest value - handleTitleChange also saves full conversation to ensure sync All tests passing (17 passed, 13 skipped).
…condition Issue: When loading a conversation from history, the title would not update in the header (e.g., loading 'Test 5' would still show 'New Conversation'). Root Cause: In handleLoadConversation, conversationTitleRef was being updated AFTER setCurrentConversationId. This caused the auto-save effect (triggered by the ID change) to run with the old/stale ref value before the ref was updated with the new title. Solution: Update the title and ref BEFORE setting the conversation ID. This ensures conversationTitleRef.current has the correct value when the auto-save effect runs. Order of operations now: 1. Set title state and ref (with new title) 2. Set conversation ID (triggers auto-save) 3. Auto-save uses the already-updated ref value All tests passing.
Simplification: Instead of manually updating conversationTitleRef.current in multiple places, use a useEffect to automatically keep the ref in sync with the conversationTitle state. This ensures the ref is always current and reduces code duplication. Benefits: - Single source of truth for title updates - Eliminates manual ref assignments scattered throughout the code - Prevents missing ref updates when title state changes - Cleaner and more maintainable code The useEffect runs whenever conversationTitle changes, ensuring conversationTitleRef.current is always up-to-date when the auto-save effect needs it. All tests passing (17 passed, 13 skipped).
Issue: Title updates in localStorage and sidebar but not in header until page refresh. Documented attempted fixes, suspected root causes, and possible solutions for future debugging. Status: Open - requires further investigation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.