Skip to content

Commit

Permalink
openctx: use the exact mention.uri for items (#4228)
Browse files Browse the repository at this point in the history
  • Loading branch information
keegancsmith committed May 22, 2024
1 parent d744c61 commit 9e083b4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ data class ContextItemOpenCtx(
val isTooLarge: Boolean? = null,
val provider: String? = null,
val type: TypeEnum, // Oneof: openctx
val originalUri: String,
val providerUri: String,
val description: String? = null,
val data: Any? = null,
Expand Down
4 changes: 4 additions & 0 deletions lib/shared/src/codebase-context/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ export interface ContextItemOpenCtx extends ContextItemCommon {
provider: 'openctx'
title: string
uri: URI
/**
* originalUri is stored since vscode-uri will incorrectly escape query parameters in toString.
*/
originalUri: string
providerUri: string
description?: string
data?: any
Expand Down
1 change: 1 addition & 0 deletions vscode/src/chat/context/chatContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function getChatContextItemsForMention(
...item,
type: 'openctx',
uri: URI.parse(item.uri),
originalUri: item.uri,
provider: 'openctx',
})
)
Expand Down
3 changes: 2 additions & 1 deletion vscode/src/editor/utils/editor-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ async function resolveContextMentionProviderContextItem(

const mention = {
...item,
uri: item.uri.toString(),
uri: item.originalUri,
}

const items = await openCtxClient.items({ message: input.toString(), mention }, item.providerUri)
Expand All @@ -344,6 +344,7 @@ async function resolveContextMentionProviderContextItem(
type: 'openctx',
title: item.title,
uri: URI.parse(item.url || item.providerUri),
originalUri: item.url || item.providerUri,
providerUri: item.providerUri,
content: item.ai.content,
provider: 'openctx',
Expand Down

0 comments on commit 9e083b4

Please sign in to comment.