Skip to content

chore: genie chat corrections#4

Merged
Vishnu7025 merged 1 commit into
developfrom
vishnu-dev-new
Jun 3, 2026
Merged

chore: genie chat corrections#4
Vishnu7025 merged 1 commit into
developfrom
vishnu-dev-new

Conversation

@Vishnu7025

@Vishnu7025 Vishnu7025 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Release Notes

  • New Features

    • Multi-session chat: Create, manage, and switch between multiple chat conversations.
    • Persistent chat message history for each session.
    • Rename chat sessions for better organization.
    • Redesigned chat interface with session history sidebar and improved message display.
    • Quick action buttons for common workflows.
  • Chores

    • Added chat session and message infrastructure.

@Vishnu7025 Vishnu7025 merged commit eacba43 into develop Jun 3, 2026
1 check was pending
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c32ebb4-685a-4c1f-bb3c-ba7899734b7e

📥 Commits

Reviewing files that changed from the base of the PR and between f09b88f and b8f82b3.

📒 Files selected for processing (14)
  • nextgenie/nextgenie/doctype/genie_chat_message/__init__.py
  • nextgenie/nextgenie/doctype/genie_chat_message/genie_chat_message.js
  • nextgenie/nextgenie/doctype/genie_chat_message/genie_chat_message.json
  • nextgenie/nextgenie/doctype/genie_chat_message/genie_chat_message.py
  • nextgenie/nextgenie/doctype/genie_chat_message/test_genie_chat_message.py
  • nextgenie/nextgenie/doctype/genie_chat_session/__init__.py
  • nextgenie/nextgenie/doctype/genie_chat_session/genie_chat_session.js
  • nextgenie/nextgenie/doctype/genie_chat_session/genie_chat_session.json
  • nextgenie/nextgenie/doctype/genie_chat_session/genie_chat_session.py
  • nextgenie/nextgenie/doctype/genie_chat_session/test_genie_chat_session.py
  • nextgenie/nextgenie/page/nextgenie/nextgenie.css
  • nextgenie/nextgenie/page/nextgenie/nextgenie.html
  • nextgenie/nextgenie/page/nextgenie/nextgenie.js
  • nextgenie/nextgenie/page/nextgenie/nextgenie.py

📝 Walkthrough

Walkthrough

This PR introduces a session-based chat system with AI integration. It adds two Frappe DocTypes for persistent storage, completely redesigns the frontend with a three-panel layout, and implements backend endpoints for session/message management and Ollama-powered AI replies.

Changes

Session-Based Chat with AI Integration

Layer / File(s) Summary
Data Models: Genie Chat Session and Message DocTypes
nextgenie/nextgenie/doctype/genie_chat_session/genie_chat_session.json, genie_chat_session.py, genie_chat_session.js, test_genie_chat_session.py, nextgenie/nextgenie/doctype/genie_chat_message/genie_chat_message.json, genie_chat_message.py, genie_chat_message.js, test_genie_chat_message.py
Introduces Genie Chat Session with read-only title and user fields, and Genie Chat Message with read-only session, sender, and message fields. Both DocTypes enable System Manager CRUD permissions and include Python/JavaScript stub classes with test scaffolds.
Backend API: Session and Message Management Endpoints
nextgenie/nextgenie/page/nextgenie/nextgenie.py (sessions, messages, date utility)
Implements whitelisted endpoints: get_sessions, create_session, update_session_title, get_session_messages, add_chat_message, clear_session_messages. Adds _friendly_date utility to format creation timestamps as relative labels (e.g., "Just now", "Yesterday").
Backend API: AI Reply Generation with Ollama
nextgenie/nextgenie/page/nextgenie/nextgenie.py (get_ai_reply)
Implements get_ai_reply endpoint that retrieves prior session messages, formats them with an HR-assistant system prompt, calls local Ollama /api/generate endpoint, and returns parsed response or fallback error messages on connection/parsing failure.
Frontend UI: Layout, Markup, and Styling
nextgenie/nextgenie/page/nextgenie/nextgenie.html, nextgenie.css
Restructures layout into three panels—left history panel (session list), middle main chat area (header with status dot, messages, input), right capabilities sidebar (HR modules, quick actions, privacy notice). Introduces CSS design tokens, removes old glass styling, adds message entry animations and typing indicator with animated dots.
Frontend Logic: Session Initialization and State Management
nextgenie/nextgenie/page/nextgenie/nextgenie.js (page setup, session loading)
Page initialization renders template, hides Frappe headers, manages client state (sessions, activeId). loadSessions fetches all user sessions or creates initial one; renders session list and loads active session's messages from backend.
Frontend Logic: Message Rendering and User Interaction
nextgenie/nextgenie/page/nextgenie/nextgenie.js (message rendering, sendMessage, event handlers)
Implements text-only message bubble rendering, typing indicator control, and session-aware send flow: append user bubble, optionally rename session on first message, persist to backend, fetch AI reply, show typing, append bot response, handle errors. Event handlers wire send/clear/new-chat buttons, Enter key, and quick-action items.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Frontend Client
  participant Page as Page Load
  participant API as Backend Endpoints
  participant Ollama as Ollama Server
  participant DB as Frappe DocType Records
  
  Page->>Client: Load NextGenie page
  Client->>API: get_sessions()
  API->>DB: Fetch user's Genie Chat Session records
  DB-->>API: Session list
  API-->>Client: Sessions with friendly dates
  Client->>Client: Render session history panel
  Client->>API: get_session_messages(session_id)
  API->>DB: Fetch Genie Chat Message records
  DB-->>API: Ordered message list
  API-->>Client: Message history
  Client->>Client: Render message bubbles, ready for input
  
  Client->>Client: User types and sends message
  Client->>Client: Append user bubble immediately
  Client->>API: add_chat_message(session_id, 'User', text)
  API->>DB: Insert new Genie Chat Message
  DB-->>API: Confirmation
  Client->>Client: Show typing indicator
  Client->>API: get_ai_reply(session_id, message)
  API->>DB: Load prior session messages
  API->>Ollama: POST /api/generate (prompt with context)
  alt AI Success
    Ollama-->>API: Response text
    API-->>Client: AI reply
    Client->>Client: Hide typing, append bot bubble
    Client->>API: add_chat_message(session_id, 'Genie', reply)
  else Connection Error
    Ollama--X API: Connection refused
    API-->>Client: Error message
    Client->>Client: Hide typing, append error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐰 A new chat flows through sessions deep,
Where messages in databases sleep,
Three panels dance, a UI grand,
With Ollama's wisdom at command,
The user speaks, the Genie replies,
In a session that never dies. 🎭

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vishnu-dev-new

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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