Skip to content

Commit 3100b65

Browse files
authored
docs: update documentation for resolved issues (#25)
Updated documentation to reflect completed fixes: 1. FUTURE-WORK.md: - Moved conversation sorting & title fixes to "Recently Completed" - Added technical details and PR references - Updated coverage stats (63.29%) 2. conversation-sorting-rearranges-on-selection.md: - Added complete resolution section documenting PR #24 - Explained the three-location bug (saveConversation, handleLoadConversation, auto-save effect) - Documented the root cause: auto-save effect dependency on currentConversationId - Added solution with code examples 3. conversation-title-not-updating-in-ui.md: - Updated status to RESOLVED with PR #22 reference - Clarified root cause: component display logic, not state management - Added test count (511 tests passing) 4. conversation-title.test.tsx: - Changed BUG comment to "Fixed" since issue is resolved All issues documented as resolved with proper cross-references.
1 parent d028443 commit 3100b65

4 files changed

Lines changed: 127 additions & 26 deletions

File tree

FUTURE-WORK.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
# Future Work & Known Issues
22

3-
## ✅ Recently Completed (Oct 20, 2025)
3+
## ✅ Recently Completed (November 4, 2025)
44

5-
### CI/CD Pipeline & Code Quality
5+
### Conversation Sorting & Management Fixes
6+
**Status**: ✅ COMPLETE
7+
**What We Fixed**:
8+
- ✅ Conversation sorting stability - lists no longer rearrange when selecting conversations
9+
- ✅ Pin/Star feature - keep important conversations at the top
10+
- ✅ Conversation title UI bug - titles update immediately without page refresh
11+
- ✅ Empty conversation saving - create and name conversations before adding content
12+
13+
**Technical Details**:
14+
- **Root Cause**: Three locations where `saveConversation()` was updating timestamps during loads:
15+
1. `saveConversation()` function itself - added `updateTimestamp` parameter (PR #23)
16+
2. `handleLoadConversation()` - now uses `updateTimestamp: false`
17+
3. Auto-save effect - removed `currentConversationId` from dependencies
18+
- **Pin Feature**: Added `isPinned` field with visual distinction and toggle functionality
19+
- **Tests**: 8 new TDD tests for sorting/pinning, all 532 tests passing ✅
20+
- **Coverage**: Improved to 63.29% (statements)
21+
22+
**Related PRs**:
23+
- PR #23 - `feat/conversation-sorting-and-pinning`
24+
- PR #24 - `fix/auto-save-timestamp-complete`
25+
- PR #22 - `fix/conversation-title-ui-update`
26+
27+
**Documentation**:
28+
- `docs/04-development/issues/conversation-sorting-rearranges-on-selection.md`
29+
- `docs/04-development/issues/conversation-title-not-updating-in-ui.md`
30+
31+
---
32+
33+
### CI/CD Pipeline & Code Quality (Oct 20, 2025)
634
**Status**: ✅ COMPLETE
735
**What We Fixed**:
836
- ✅ CI/CD pipeline with automated checks (ESLint, Jest, builds)
@@ -13,12 +41,6 @@
1341
- ✅ Adjusted coverage thresholds to match actual coverage (51%/51%/44%)
1442
- ✅ Resolved merge conflicts with main branch
1543

16-
**Coverage Thresholds**:
17-
- Statements: 51% (actual: 51.2%)
18-
- Lines: 51% (actual: 51.2%)
19-
- Branches: 65% (actual: 65.6%)
20-
- Functions: 44% (actual: 44.9%)
21-
2244
**Related Commits**:
2345
- `4f49ecd` - ESLint fixes and font optimization
2446
- `efe1acd` - Coverage threshold adjustment

docs/04-development/issues/conversation-sorting-rearranges-on-selection.md

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
# Issue: Conversation Sorting Rearranges When Selected
22

3-
**Status:** ✅ RESOLVED
3+
**Status:** ✅ RESOLVED (November 4, 2025)
44
**Priority:** Medium
55
**Date Reported:** November 4, 2025
66
**Date Resolved:** November 4, 2025
7-
**Branch:** feat/conversation-sorting-and-pinning
8-
**Tests:** 8 new tests, all 519 tests passing ✅
7+
**Related PRs:**
8+
- PR #23 - `feat/conversation-sorting-and-pinning` (Initial fix)
9+
- PR #24 - `fix/auto-save-timestamp-complete` (Complete fix)
10+
**Tests:** 8 new TDD tests, all 532 tests passing ✅
911

1012
## Problem Description
1113

1214
The conversation history list constantly rearranges when a conversation is selected. This makes it difficult to find and navigate between conversations because the list order keeps changing based on which conversation was last accessed.
1315

14-
## Current Behavior
16+
## Current Behavior (FIXED)
1517

16-
When you click on a conversation in the sidebar:
18+
**Before Fix:**
19+
When you clicked on a conversation in the sidebar:
1720
1. The conversation loads correctly
1821
2. The `updatedAt` timestamp is updated to current time
1922
3. `loadConversations()` sorts by `updatedAt` descending
2023
4. The selected conversation jumps to the top of the list
2124
5. All other conversations shift down
2225

23-
**Result:** The list constantly reshuffles, making navigation confusing.
26+
**After Fix:**
27+
When you click on a conversation:
28+
1. The conversation loads correctly
29+
2. The `updatedAt` timestamp is **NOT** updated
30+
3. The list order remains stable
31+
4. The selected conversation stays in its position ✅
32+
33+
Timestamps are now only updated when you send a new message.
2434

2535
## Root Cause
2636

37+
Found **THREE** locations where `saveConversation()` was incorrectly updating timestamps:
38+
2739
**File:** `src/lib/storage.ts`
2840

2941
### saveConversation() - Lines 207-225
@@ -371,6 +383,71 @@ className={`
371383
2. **Loading vs Saving:** Loading an existing conversation shouldn't update its timestamp
372384
3. **TDD Success:** Writing tests first helped design the API correctly (`updateTimestamp` parameter)
373385
4. **Migration-Friendly:** `isPinned ?? false` ensures backwards compatibility with existing conversations
386+
5. **Three-Location Bug:** Issue persisted because fixes were applied piecemeal - needed to fix all three:
387+
-`saveConversation()` function itself
388+
-`handleLoadConversation()` call site
389+
- ✅ Auto-save effect dependencies (the main culprit)
390+
391+
---
392+
393+
## Complete Resolution (November 4, 2025)
394+
395+
### The Final Fix - PR #24: `fix/auto-save-timestamp-complete`
396+
397+
After PR #23 was merged, the issue **still persisted**. Investigation revealed the auto-save effect was the main culprit:
398+
399+
**Problem:** Auto-save effect depended on `currentConversationId`
400+
```typescript
401+
// BEFORE (BUGGY):
402+
useEffect(() => {
403+
// ... save conversation ...
404+
}, [messages, files, aiTheme, currentConversationId, isLoaded]); // ❌ currentConversationId triggers effect
405+
```
406+
407+
**What happened:**
408+
1. User clicks conversation → `handleLoadConversation()` called
409+
2. `setCurrentConversationId(conversation.id)`**triggers effect**
410+
3. Effect runs and calls `saveConversation()` without `false`
411+
4. Timestamp updates, conversation jumps to top
412+
413+
**Solution:** Remove `currentConversationId` from dependencies
414+
```typescript
415+
// AFTER (FIXED):
416+
useEffect(() => {
417+
if (isLoaded && !isLoadingConversationRef.current) {
418+
if (messages.length > 0) { // Only save when there's content
419+
if (!currentConversationId) {
420+
// New conversation
421+
saveConversation(conversation);
422+
} else {
423+
// Existing conversation - don't update timestamp
424+
saveConversation(conversation, false);
425+
}
426+
}
427+
}
428+
}, [messages, files, aiTheme, isLoaded]); // ✅ No currentConversationId
429+
```
430+
431+
**Explicit timestamp update** added when user sends messages:
432+
```typescript
433+
onComplete: (fullText) => {
434+
const aiMessage: Message = { id: aiMessageId, role: 'ai', content: fullText };
435+
setMessages((prev) => [...prev, aiMessage]);
436+
437+
// Update timestamp when conversation actually changes
438+
if (currentConversationId) {
439+
const conversation = createConversation([...messages, userMessage, aiMessage], files, aiTheme, conversationTitleRef.current);
440+
conversation.id = currentConversationId;
441+
saveConversation(conversation, true); // ✅ Explicitly update timestamp
442+
}
443+
}
444+
```
445+
446+
**Test Results:**
447+
- All 532 tests passing ✅
448+
- Manual testing: Conversations stay in place when selected ✅
449+
- Manual testing: Conversations move to top when new message sent ✅
450+
- Browser localStorage cache needed to be cleared for existing users
374451

375452
---
376453

docs/04-development/issues/conversation-title-not-updating-in-ui.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
# Issue: Conversation Title Not Updating in UI
22

3-
**Status:** ✅ RESOLVED
3+
**Status:** ✅ RESOLVED (November 4, 2025)
44
**Priority:** High
55
**Date Reported:** November 2, 2025
66
**Date Resolved:** November 4, 2025
77
**Original Branch:** feat/save-empty-conversations
88
**Fix Branch:** fix/conversation-title-ui-update
9-
**Commit:** a1dd36c
9+
**PR:** #22
10+
**Commit:** a1dd36c
11+
**Tests:** 3 new TDD tests added, all 511 tests passing ✅
1012

1113
## Problem Description
1214

1315
When updating a conversation title or loading a conversation from history, the title displays correctly in the sidebar conversation history but does NOT update in the main header until a full page refresh.
1416

15-
## Steps to Reproduce
17+
**Root Cause:** Component display logic, not state management. The `ConversationTitle` component was overriding the title prop with "New Conversation" when `messages.length === 0`, even though the parent was passing the correct custom title.
18+
19+
## Steps to Reproduce (FIXED)
1620

1721
### Scenario 1: New Conversation Title Update
1822
1. Click "New Conversation" button
1923
2. Click "Edit conversation title" button
2024
3. Change title to "Research 1"
2125
4. Click save (checkmark button)
22-
5. **Expected:** Header shows "Research 1"
23-
6. **Actual:** Header still shows "New Conversation"
24-
7. Title shows correctly in sidebar history
25-
8. Full page refresh (Ctrl+R) shows correct title
26+
5. **Expected:** Header shows "Research 1" ✅ NOW WORKS
27+
6. **Before:** Header still shows "New Conversation" ❌
28+
7. Title shows correctly in sidebar history ✅
2629

2730
### Scenario 2: Load Existing Conversation
2831
1. Have existing conversation titled "Test 5"
2932
2. Click on "Test 5" in conversation history sidebar
30-
3. **Expected:** Header shows "Test 5"
31-
4. **Actual:** Header still shows "New Conversation" (or previous title)
32-
5. Title shows correctly in sidebar history
33-
6. Full page refresh (Ctrl+R) shows correct title
33+
3. **Expected:** Header shows "Test 5" ✅ NOW WORKS
34+
4. **Before:** Header still shows "New Conversation" (or previous title) ❌
35+
5. Title shows correctly in sidebar history ✅
3436

3537
## Current Implementation
3638

src/__tests__/components/conversation-title.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ describe('ConversationTitle', () => {
426426

427427
describe('Custom Title Display (Bug Fix)', () => {
428428
it('displays custom title even when isNewConversation is true and has no messages', () => {
429-
// BUG: When a new conversation gets a custom title but has no messages yet,
429+
// Fixed: When a new conversation gets a custom title but has no messages yet,
430430
// it should show the custom title, not "New Conversation"
431431
render(<ConversationTitle {...defaultProps} title="My Custom Title" isNewConversation={true} />);
432432

0 commit comments

Comments
 (0)