Skip to content

feat(events): Emit event when title generation is finished - #788

Merged
murdore merged 1 commit into
juspay:releasefrom
Yaswanth-2874:BZ-48087-emit-events-after-conversation-title-is-generated
Jan 28, 2026
Merged

murdore merged 1 commit into
juspay:releasefrom
Yaswanth-2874:BZ-48087-emit-events-after-conversation-title-is-generated

Conversation

@Yaswanth-2874

@Yaswanth-2874 Yaswanth-2874 commented Jan 22, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

What does this PR do?

Adds event emission for conversation title generation in the RedisConversationMemoryManager. When a conversation title is generated (or fails to generate), an event is emitted via the NeuroLink event emitter, enabling real-time monitoring and integration.

Related Issues

Does this PR close any issues?

Relates to: feature request for event-driven updates on conversation metadata.

Type of Change

  • New feature (non-breaking change which adds functionality)

Motivation and Context

Why is this change needed? What problem does it solve?

  • Enables external systems or UI to react to conversation title generation in real time.
  • Improves observability and integration for downstream consumers.
  • Supports use cases like live session lists, notifications, and analytics.

Changes Made

  • Added new event types to NeuroLinkEvents:
    • conversation:titleGenerated
  • Updated RedisConversationMemoryManager to accept an event emitter.
  • Emits conversation:titleGenerated on successful title generation
  • Updated factory and initializer to pass the event emitter through to the manager.
  • Updated NeuroLink to wire up its internal emitter to the conversation memory system.

Breaking Changes

  • No breaking changes

Testing

How has this been tested?

  • Manual testing: Verified that events are emitted and can be listened to via neurolink.getEventEmitter().
  • Existing tests pass.

Manual Testing Steps

  1. Set up NeuroLink with Redis conversation memory enabled.
  2. Listen for conversation:titleGenerated.
  3. Start a new conversation and verify that the appropriate event is emitted with correct payload.

Code Quality

  • Code follows the project's style guidelines (ESLint passes)
  • Code is properly formatted (Prettier applied)
  • Self-review of code completed
  • No console.log statements (using logger instead)
  • No hardcoded API keys or secrets
  • TypeScript strict mode compliance
  • Proper error handling implemented

Documentation

  • JSDoc comments added/updated for public APIs
  • CHANGELOG.md updated (if applicable)

Commit Message Format

  • Commit message follows format: feat(conversation): emit events for title generation

Dependencies

  • No dependency changes

Performance Impact

  • No performance impact

Security Considerations

  • No security implications

Deployment Notes

  • No special deployment steps

Screenshots / Videos

N/A

Reviewer Checklist

  • Code follows project style and conventions
  • Changes are well-documented
  • Tests provide adequate coverage
  • No obvious performance issues
  • No security vulnerabilities introduced
  • Breaking changes are properly documented
  • Documentation is clear and accurate

Additional Notes

This PR enables event-driven workflows for conversation metadata, making it easier to build reactive UIs and integrations.


Pre-submission Checklist

  • Read and followed the Contributing Guidelines
  • Verified all automated pre-commit checks pass
  • Tested changes locally with pnpm test
  • Built the project successfully with pnpm build
  • Run pnpm run validate:all and all checks pass
  • Reviewed your own code for obvious issues
  • Ensured commit messages follow semantic format
  • Updated relevant documentation
  • Added tests for new functionality
  • Checked that CI/CD pipeline passes (after creating PR)

Summary by CodeRabbit

Release Notes

  • New Features
    • Added event system support for conversation memory management. Applications can now listen to and respond to conversation events, including a new "conversation:titleGenerated" event for real-time title generation notifications.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

Adds optional event emitter parameter threading through conversation memory factory and initializer, enabling RedisConversationMemoryManager to emit a conversation:titleGenerated event after title generation. New event type added to NeuroLinkEvents interface.

Changes

Cohort / File(s) Summary
Factory & Initializer Chain
src/lib/core/conversationMemoryFactory.ts, src/lib/core/conversationMemoryInitializer.ts
Added optional eventEmitter?: TypedEventEmitter<NeuroLinkEvents> parameter; threaded through function signatures and forwarded to Redis manager instantiation
Redis Memory Manager
src/lib/core/redisConversationMemoryManager.ts
Added private eventEmitter member; updated constructor to accept optional emitter parameter; emits conversation:titleGenerated event after session title generation
Neurolink Integration
src/lib/neurolink.ts
Updated initializeConversationMemory call sites to pass this.emitter as second argument
Type Definitions
src/lib/types/common.ts
Added conversation:titleGenerated event key to NeuroLinkEvents type

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • murdore

Poem

🐰 A memory that speaks!
Through Redis threads, our emitter glides,
Titles now echo their event-driven rides,
The rabbit hops with conversational glee—
'Tis born, 'tis told, events run free! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding event emission when conversation title generation is finished.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/lib/core/redisConversationMemoryManager.ts`:
- Around line 410-417: The success path emits "conversation:titleGenerated" via
this.eventEmitter.emit but the catch/error path doesn't notify listeners; update
the error handling in the title-generation flow (the block around
this.eventEmitter.emit in redisConversationMemoryManager.ts) to also emit a
failure event (e.g., "conversation:titleGenerationFailed") when title creation
throws, including the same identifiers (sessionId, normalizedUserId/userId), the
error (or error.message), and a timestamp, and guard the emit with the existing
this.eventEmitter check so listeners receive a clear failure signal.

In `@src/lib/types/common.ts`:
- Around line 190-192: The public event map currently exports only the success
event "conversation:titleGenerated"; add the missing failure event
"conversation:titleGenerationFailed" to the same map in the types declaration so
consumers can type and discover the failure case. Locate the event map
definition (where "conversation:titleGenerated" is declared) and add an entry
for "conversation:titleGenerationFailed": unknown (matching the shape used for
other events), update any exported types that derive from this map if necessary
so the new key is included in the public type union.

Comment thread src/lib/core/redisConversationMemoryManager.ts
Comment thread src/lib/types/common.ts
@Yaswanth-2874
Yaswanth-2874 force-pushed the BZ-48087-emit-events-after-conversation-title-is-generated branch from 0d4d0b8 to 0418e24 Compare January 23, 2026 06:41
@murdore

murdore commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

@Yaswanth-2874 this is a good feature that is required for everybody. I need you to update all the relevant documentation. Add one line in the readme.md in the current quarters feature release like we add for every feature release. Also update the feature document with details of how to access the document needs to be updated with all of the new features that we release.

@Yaswanth-2874
Yaswanth-2874 force-pushed the BZ-48087-emit-events-after-conversation-title-is-generated branch 2 times, most recently from 32f20d5 to 00483ef Compare January 28, 2026 05:40
@murdore
murdore force-pushed the BZ-48087-emit-events-after-conversation-title-is-generated branch from 00483ef to 4d192ad Compare January 28, 2026 14:29
@murdore
murdore merged commit aab4a1f into juspay:release Jan 28, 2026
8 of 9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 8.40.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants