feat(server): update gql endpoint & workspace doc match test (#11104)

This commit is contained in:
darkskygit
2025-03-25 10:09:22 +00:00
parent bf4107feac
commit 1bb324eeed
20 changed files with 355 additions and 139 deletions

View File

@@ -1,5 +1,6 @@
import type {
ChatHistoryOrder,
ContextMatchedDocChunk,
ContextMatchedFileChunk,
CopilotContextCategory,
CopilotContextDoc,
@@ -312,7 +313,10 @@ declare global {
contextId: string,
content: string,
limit?: number
) => Promise<ContextMatchedFileChunk[] | undefined>;
) => Promise<{
files?: ContextMatchedFileChunk[];
docs?: ContextMatchedDocChunk[];
}>;
}
// TODO(@Peng): should be refactored to get rid of implement details (like messages, action, role, etc.)

View File

@@ -556,9 +556,12 @@ export class ChatPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
private async _getMatchedContexts(userInput: string) {
const contextId = await this.getContextId();
const matched = contextId
? (await AIProvider.context?.matchContext(contextId, userInput)) || []
: [];
// TODO(@akumatus): adapt workspace docs
const { files: matched = [] } =
(contextId &&
(await AIProvider.context?.matchContext(contextId, userInput))) ||
{};
const contexts = this.chatContextValue.chips.reduce(
(acc, chip, index) => {
if (chip.state !== 'finished') {

View File

@@ -341,7 +341,9 @@ export class CopilotClient {
limit,
},
});
return res.currentUser?.copilot?.contexts?.[0]?.matchContext;
const { matchFiles: files, matchWorkspaceDocs: docs } =
res.currentUser?.copilot?.contexts?.[0] || {};
return { files, docs };
}
async chatText({