fix: honor user-provided session names
Summary
Skip auto-generating session names when the user explicitly provides one. This respects user intent and eliminates unnecessary inference calls.
This also made a change which I believe not just makes it more testable, but also reduces a pitfall. Instead of letting the inference based rename outlive the primary inference call, it binds the two together. This keeps parallel and likely is invisible unless the rename somehow is accidentally a long completion.
Type of Change
- [ ] Feature
- [x] Bug fix
- [x] Refactor / Code quality
- [x] Performance improvement
- [ ] Documentation
- [x] Tests
- [ ] Security fix
- [ ] Build / Release
- [ ] Other (specify below)
AI Assistance
- [x] This PR was created or reviewed with AI assistance
I know what I want, but still struggle with rust, so I used an agent to investigate the several ways of how to do what I want. I also used it to adapt some similar mermaid diagrams to this, so it is easy to understand the mechanics.
Testing
backfilled tests after making the session rename bound to the lifecycle of the first inference call.
Skip auto-generating session names when the user explicitly provides one. This respects user intent and eliminates unnecessary inference calls.
Screenshots/Demos (for UX changes)
Before: Always renamed, ignoring user input
sequenceDiagram
participant User
participant Agent
participant SessionManager
participant LLM
User->>Agent: reply(message, session: "My Project")
rect rgb(255, 200, 200)
Note over Agent,LLM: Unconditional: always spawns naming task
Agent->>LLM: tokio::spawn(generate_session_name)
LLM-->>SessionManager: update name to "Generated Name"
Note over User,SessionManager: User's "My Project" overwritten
end
Agent-->>User: response stream
After: Only renames when user didn't provide name
sequenceDiagram
participant User
participant Agent
participant SessionManager
participant LLM
User->>Agent: reply(message, session: "My Project")
rect rgb(191, 223, 255)
Agent->>Agent: Check user_set_name
alt user_set_name == true
Note over Agent: Skip naming (honor user choice)
else user_set_name == false
Agent->>LLM: tokio::spawn(generate_session_name)
LLM-->>SessionManager: update name to "Generated Name"
end
end
Agent-->>User: response stream
Note over User,SessionManager: User's "My Project" preserved