Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): expansion of current-tab generic mention when non editor tabs are opened #6910

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vscode/src/commands/context/open-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function getContextFileFromTabs(): Promise<ContextItem[]> {
// Get open tabs from the current editor
const tabGroups = vscode.window.tabGroups.all
const openTabs = tabGroups.flatMap(group =>
group.tabs.map(tab => tab.input)
group.tabs.map(tab => tab.input).filter(Boolean)
) as vscode.TabInputText[]

return (
Expand Down
10 changes: 8 additions & 2 deletions vscode/src/commands/execute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ export async function executeDefaultCommand(

export function selectedCodePromptWithExtraFiles(
primary: ContextItem,
other: ContextItem[]
other: ContextItem[],
wrapJoinedMentions = true
): PromptString {
const primaryMention = ps`@${PromptString.fromDisplayPathLineRange(primary.uri, primary.range)}`
const otherMentions = other.map(
item => ps`@${PromptString.fromDisplayPathLineRange(item.uri, item.range)}`
)
if (otherMentions.length === 0) {
return primaryMention
}

const joinedMentions = PromptString.join(otherMentions, ps` `)
return ps`${primaryMention}${
otherMentions.length > 0 ? ps` ( ${PromptString.join(otherMentions, ps` `)} )` : ''
wrapJoinedMentions ? ps` ( ${joinedMentions} )` : ps` ${joinedMentions}`
}`
}
2 changes: 1 addition & 1 deletion vscode/src/prompts/prompt-hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ async function hydrateWithOpenTabs(promptText: PromptString): Promise<[PromptStr
return [
promptText.replaceAll(
PROMPT_EDITOR_OPEN_TABS_PLACEHOLDER,
selectedCodePromptWithExtraFiles(firstOpenTab, otherOpenTabs)
selectedCodePromptWithExtraFiles(firstOpenTab, otherOpenTabs, false)
),
[firstOpenTab, ...otherOpenTabs],
]
Expand Down
Loading