fix: enhance session resolution in sessionSupportsFork method#303624
fix: enhance session resolution in sessionSupportsFork method#303624TylerLeonhardt merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts how contributed chat sessions are looked up when determining whether a session supports forking, addressing cases where the session may be stored under either the original resource or an alias.
Changes:
- Update
ChatSessionsService.sessionSupportsForkto check both the rawsessionResourcekey and the alias-resolved key when reading from_sessions.
| const session = this._sessions.get(sessionResource) | ||
| // Try to resolve in case an alias was used | ||
| ?? this._sessions.get(this._resolveResource(sessionResource)); | ||
| return !!session?.session.forkSession; | ||
| } |
There was a problem hiding this comment.
sessionSupportsFork now checks both the direct key and the alias-resolved key, but forkChatSession still only looks up _sessions.get(this._resolveResource(sessionResource)). In the alias scenario this can make the UI enable the Fork action while the actual fork call still throws "does not support forking" because it resolves to the untitled placeholder session. Consider centralizing the lookup (e.g., a private helper that tries direct then resolved) and using it in both sessionSupportsFork and forkChatSession so the capability check and execution path stay consistent.
See below for a potential fix:
private getSessionForResource(sessionResource: URI): ContributedChatSessionData | undefined {
// First try the direct key, then fall back to the alias-resolved key.
return this._sessions.get(sessionResource)
?? this._sessions.get(this._resolveResource(sessionResource));
}
public sessionSupportsFork(sessionResource: URI): boolean {
const session = this.getSessionForResource(sessionResource);
return !!session?.session.forkSession;
}
public async forkChatSession(sessionResource: URI, request: IChatSessionRequestHistoryItem | undefined, token: CancellationToken): Promise<IChatSessionItem> {
const session = this.getSessionForResource(sessionResource);
ref #300501