Skip to content

Convert ChatPromptReference back to IChatRequestVariableEntry #278049

@DonJayamanne

Description

@DonJayamanne

For Copilot CLI Sessions to be restored properly we need a way to convert ChatPromptReference back to IChatRequestVariableEntry

Today we have a way to convert IChatRequestVariableEntry into ChatPromptReference

export namespace ChatPromptReference {
	export function to(variable: IChatRequestVariableEntry, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][], logService: ILogService): vscode.ChatPromptReference | undefined {
        }
}

The current approach is not sufficient, and only handles file and generic
It is not a lossless conversion.

	private convertReferenceToVariable(ref: vscode.ChatPromptReference) {
		const value = ref.value && typeof ref.value === 'object' && 'uri' in ref.value && 'range' in ref.value
			? typeConvert.Location.from(ref.value as vscode.Location)
			: ref.value;
		const range = ref.range ? { start: ref.range[0], endExclusive: ref.range[1] } : undefined;
		const isFile = URI.isUri(value) || (value && typeof value === 'object' && 'uri' in value);
		return {
			id: ref.id,
			name: ref.id,
			value,
			modelDescription: ref.modelDescription,
			range,
			kind: isFile ? 'file' as const : 'generic' as const
		};
	}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions