Skip to content

add chat history session#13

Merged
Gabry848 merged 6 commits intomasterfrom
features/chat_history
Jan 17, 2026
Merged

add chat history session#13
Gabry848 merged 6 commits intomasterfrom
features/chat_history

Conversation

@Gabry848
Copy link
Copy Markdown
Collaborator

This pull request introduces a comprehensive chat history feature to the application, including both backend documentation and a new frontend UI for managing chat sessions. The changes implement a server-managed chat history system, update the documentation to reflect the new SSE streaming protocol, and add React Native components for browsing, pinning, and deleting chat histories. Additionally, demo data is provided for development and testing.

Key changes include:

Chat History UI Components

  • Added a new ChatHistory React Native component that displays a list of chat sessions, supports infinite scroll, pull-to-refresh, pinning/unpinning, and deletion of chats. The component handles loading states, error handling, and empty state UI. (src/components/BotChat/ChatHistory.tsx)
  • Introduced a ChatHistoryItem component to render individual chat session entries, showing title, preview, timestamp, message count, and action buttons for pinning and deleting. (src/components/BotChat/ChatHistoryItem.tsx)

Demo Data

  • Provided a demo chat history dataset for development and UI testing, following the ChatHistoryItemData structure. (src/data/demoChatHistory.ts)

Backend Protocol and Documentation

  • Added detailed documentation for the new chat SSE streaming protocol, describing request/response formats, event types, client integration, best practices, and troubleshooting. This clarifies how the server now manages chat history via chat_id, removing the need for the client to send the entire message history with each request. (IA_docs/CHAT_SSE_STREAMING.md)

Integration Points

  • Updated the main chat screen to import chat history service functions and manage the currentChatId state, preparing for integration with the new chat history features. (src/navigation/screens/BotChat.tsx) [1] [2]

References:

  • Chat History UI: [1] [2]
  • Demo Data:
  • SSE Streaming Documentation:
  • Integration Updates: [1] [2]

…feature

- Added support for loading more chat history with pagination.
- Implemented pull-to-refresh functionality for chat history.
- Introduced pinning and unpinning of chat items with UI updates.
- Updated chat history API to support fetching with pagination and pinning.
- Refactored chat initialization to handle existing chats and new chat creation.
- Improved error handling and user feedback during chat operations.
- Updated UI components to reflect new features and improve user experience.
@claude
Copy link
Copy Markdown

claude bot commented Jan 17, 2026

Pull Request Review: Chat History Session Feature

This PR introduces a comprehensive chat history management system. Overall, this is a well-structured implementation with good separation of concerns.

Strengths

  • Clean separation between UI components and service layer
  • Proper TypeScript interfaces and React patterns
  • Comprehensive API documentation
  • Infinite scroll, pull-to-refresh, pin/unpin functionality
  • Good error handling with try-catch blocks

Critical Issues (Must Fix Before Merge)

  1. Hardcoded Timezone Offset (ChatHistoryItem.tsx:35)

    • Line: const diffInMs = now.getTime() - date.getTime() + (240 * 60 * 1000);
    • Issue: 240 minutes hardcoded offset breaks for other timezones
    • Fix: Use proper timezone handling or remove offset
  2. Race Condition (ChatHistory.tsx:54-58)

    • Ref check not atomic, multiple calls could pass
    • Fix: Use AbortController or debounce
  3. Missing useEffect Dependencies (ChatHistory.tsx:164)

    • loadChatHistory not in dependency array
    • Could cause stale closure issues

High Priority Issues

  1. Inconsistent Error Handling

    • Mix of console.error, setState, and Alerts
    • Need consistent strategy
  2. No Loading State for Pin Toggle (ChatHistory.tsx:123-150)

    • Users might click multiple times
    • Add per-item loading state
  3. Dynamic Import Anti-pattern (ChatHistory.tsx:125)

    • toggleChatPin already imported at top
    • Remove unnecessary dynamic import

Medium Priority

  1. BotChat.tsx Complexity (403 lines)

    • Handles too many concerns
    • Extract into smaller hooks
  2. Client-side Re-sorting Performance (ChatHistory.tsx:140-146)

    • Full re-sort on every pin toggle
    • Inefficient with large lists
  3. Missing Tests

    • No tests for chatHistoryService
    • No component tests
    • No integration tests

Low Priority Polish

  1. Hardcoded Italian Locale (ChatHistoryItem.tsx:47)

    • toLocaleDateString('it-IT')
    • Use i18n instead
  2. Demo Data Unused

    • demoChatHistory.ts created but never used
    • Either use or remove
  3. Magic Numbers

    • LIMIT=20, keyboardVerticalOffset=35
    • Extract to constants

Security

Good: Token management, server-side sessions
Recommendations: Validate chat_id, ensure XSS protection, add rate limiting

Performance

  • Consider React.memo for ChatHistoryItem
  • Add getItemLayout to FlatList
  • Review onEndReachedThreshold value

Test Coverage

Missing tests for all new components and services. Aim for 70% coverage.

Verdict

Request Changes - Critical issues (especially timezone) must be fixed before merge.

Estimated effort:

  • Critical: 2-3 hours
  • High priority: 4-5 hours
  • Medium: 6-8 hours (can be follow-up)

Great work overall! Well-designed feature with high code quality, just needs polish on the issues above.

@Gabry848 Gabry848 merged commit cfaccd6 into master Jan 17, 2026
1 check passed
Gabry848 added a commit that referenced this pull request Jan 28, 2026
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.

1 participant