-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update new prompt input to support recent changes to current prompt i…
…nput
- Loading branch information
Showing
7 changed files
with
260 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ContextItemSource, type SerializedContextItem, displayPath } from '@sourcegraph/cody-shared' | ||
import * as v from 'valibot' | ||
import { URI } from 'vscode-uri' | ||
|
||
/** | ||
* The structure of an openctx context item with a tooltip. | ||
*/ | ||
const OpenCtxItemWithTooltipSchema = v.object({ | ||
type: v.literal('openctx'), | ||
mention: v.object({ | ||
data: v.object({ | ||
tooltip: v.string(), | ||
}), | ||
}), | ||
}) | ||
|
||
export function tooltipForContextItem(item: SerializedContextItem): string | undefined { | ||
if (item.type === 'repository') { | ||
return `Repository: ${item.repoName ?? item.title ?? 'unknown'}` | ||
} | ||
if (item.type === 'tree') { | ||
return item.title || 'Local workspace' | ||
} | ||
if (item.type === 'file') { | ||
return item.isTooLarge | ||
? item.source === ContextItemSource.Initial | ||
? 'File is too large. Select a smaller range of lines from the file.' | ||
: 'File is too large. Try adding the file again with a smaller range of lines.' | ||
: displayPath(URI.parse(item.uri)) | ||
} | ||
if (v.is(OpenCtxItemWithTooltipSchema, item)) { | ||
return item.mention.data.tooltip | ||
} | ||
if (item.type === 'openctx') { | ||
return item.uri | ||
} | ||
return undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.