Skip to content

Commit 3486cd2

Browse files
committed
add comments to clarify cases
1 parent 51df84e commit 3486cd2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extensions/positron-assistant/src/participants.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,23 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
188188
const positronContext = await positron.ai.getPositronChatContext(request);
189189
log.debug(`[context] Positron context for request ${request.id}:\n${JSON.stringify(positronContext, null, 2)}`);
190190

191-
// Build a list of languages for which we have active sessions.
192-
//
193191
// See IChatRuntimeSessionContext for the structure of the active
194192
// session context objects
195193
const activeSessions: Set<string> = new Set();
196194
let hasVariables = false;
197195
let hasConsoleSessions = false;
198196
for (const reference of request.references) {
199197
const value = reference.value as any;
198+
199+
// Build a list of languages for which we have active sessions.
200200
if (value.activeSession) {
201201
activeSessions.add(value.activeSession.languageId);
202202
if (value.activeSession.mode === positron.LanguageRuntimeSessionMode.Console) {
203203
hasConsoleSessions = true;
204204
}
205205
}
206+
207+
// Check if there are variables defined in the session.
206208
if (value.variables && value.variables.length > 0) {
207209
hasVariables = true;
208210
}
@@ -281,8 +283,10 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
281283
// TODO: Remove this restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
282284
// The logic above with TOOL_TAG_REQUIRES_ACTIVE_SESSION will handle checking for active sessions once this is removed.
283285
return activeSessions.has('python');
286+
// Only include the getPlot tool if there is a plot available.
284287
case PositronAssistantToolName.GetPlot:
285288
return positronContext.plots?.hasPlots === true;
289+
// Only include the inspectVariables tool if there are variables defined.
286290
case PositronAssistantToolName.InspectVariables:
287291
return hasVariables;
288292
// Otherwise, include the tool if it is tagged for use with Positron Assistant.

0 commit comments

Comments
 (0)