Skip to content

Commit

Permalink
[prompt]: use common variable ID for the #file: use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
legomushroom committed Jan 29, 2025
1 parent 9b9093e commit c9750df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IConfigurationService } from '../../../../../platform/configuration/com
* @param isRoot If the reference is the root reference in the references tree.
* This object most likely was explicitly attached by the user.
*/
const toChatVariable = (
export const toChatVariable = (
reference: Pick<IPromptFileReference, 'uri' | 'isPromptSnippet'>,
isRoot: boolean,
): IChatRequestVariableEntry => {
Expand Down
23 changes: 12 additions & 11 deletions src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import { ImplicitContextAttachmentWidget } from './attachments/implicitContextAt
import { InstructionAttachmentsWidget } from './attachments/instructionsAttachment/instructionAttachments.js';
import { IChatWidget } from './chat.js';
import { ChatAttachmentModel, EditsAttachmentModel } from './chatAttachmentModel.js';
import { toChatVariable } from './chatAttachmentModel/chatInstructionAttachmentsModel.js';
import { hookUpResourceAttachmentDragAndContextMenu, hookUpSymbolAttachmentDragAndContextMenu } from './chatContentParts/chatAttachmentsContentPart.js';
import { IDisposableReference } from './chatContentParts/chatCollections.js';
import { CollapsibleListPool, IChatCollapsibleListItem } from './chatContentParts/chatReferencesContentPart.js';
Expand Down Expand Up @@ -193,17 +194,17 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
continue;
}

for (const childUri of variable.allValidReferencesUris) {
contextArr.push({
id: variable.id,
name: basename(childUri.path),
value: childUri,
isSelection: false,
enabled: true,
isFile: true,
isDynamic: true,
});
}
// the usual URIs list of prompt instructions is `bottom-up`, therefore
// we do the same here - first add all child references to the list
contextArr.push(
...variable.allValidReferences.map((link) => {
return toChatVariable(link, false);
}),
);
// then add the root reference itself
contextArr.push(
toChatVariable(variable, true),
);
}

contextArr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { URI } from '../../../../../../base/common/uri.js';
import { assert } from '../../../../../../base/common/assert.js';
import { IDynamicVariable } from '../../../common/chatVariables.js';
import { IRange } from '../../../../../../editor/common/core/range.js';
import { FilePromptParser } from '../../../common/promptSyntax/parsers/filePromptParser.js';
import { ILogService } from '../../../../../../platform/log/common/log.js';
import { FilePromptParser } from '../../../common/promptSyntax/parsers/filePromptParser.js';
import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';

Expand Down

0 comments on commit c9750df

Please sign in to comment.