Skip to content

optimize ConversationStateService#1320

Merged
iceljc merged 2 commits intoSciSharp:masterfrom
yileicn:master
Apr 9, 2026
Merged

optimize ConversationStateService#1320
iceljc merged 2 commits intoSciSharp:masterfrom
yileicn:master

Conversation

@yileicn
Copy link
Copy Markdown
Member

@yileicn yileicn commented Apr 9, 2026

No description provided.

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add read-only mode support to ConversationStateService

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add _isReadOnly flag to track read-only state
• Prevent state persistence when conversation loaded in read-only mode
• Simplify conversation ID assignment logic
Diagram
flowchart LR
  Load["Load method"] -->|"set _isReadOnly flag"| ReadOnlyFlag["_isReadOnly field"]
  ReadOnlyFlag -->|"check in Save"| SaveMethod["Save method"]
  SaveMethod -->|"skip persistence"| Prevention["Prevent state save"]
Loading

Grey Divider

File Changes

1. src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs ✨ Enhancement +4/-2

Implement read-only mode with state persistence guard

• Added _isReadOnly private field to track read-only state
• Modified Load method to set _isReadOnly flag and always assign conversationId
• Updated Save method to check _isReadOnly flag and skip persistence when true
• Simplified conversation ID assignment by removing conditional null assignment

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 9, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines ConversationStateService’s read-only behavior so the service can still expose a valid ConversationId while ensuring state persistence is skipped when operating in read-only mode.

Changes:

  • Introduced an internal _isReadOnly flag to track read-only loads.
  • Updated Load to always set _conversationId (even in read-only mode).
  • Updated Save to short-circuit when the service is in read-only mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iceljc iceljc merged commit 9b74463 into SciSharp:master Apr 9, 2026
4 checks passed
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.

3 participants