Skip to content
Closed
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
36,880 changes: 0 additions & 36,880 deletions package-lock.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,39 @@ import { sleep, waitForElements } from '../utils/generalUtils'
* @returns Promise<{items: WebElement[], texts: string[]}> Array of menu items and their text labels
*/
export async function getQuickActionsCommands(webview: WebviewView): Promise<{ items: WebElement[]; texts: string[] }> {
try {
await writeToChat('/', webview, false)
await sleep(2000)
await writeToChat('/', webview, false)
await sleep(2000)

const menuItems = await waitForElements(
webview,
By.css('.mynah-detailed-list-item.mynah-ui-clickable-item.target-command'),
10000
)
const menuItems = await waitForElements(
webview,
By.css('.mynah-detailed-list-item.mynah-ui-clickable-item.target-command'),
10000
)

const menuTexts = []
for (let i = 0; i < menuItems.length; i++) {
try {
const text = await menuItems[i].getText()
menuTexts.push(text)
console.log(`Command ${i + 1}: ${text}`)
} catch (e) {
menuTexts.push('')
console.log(`Could not get text for command ${i + 1}`)
}
}

console.log(`Found ${menuItems.length} quick action command items`)
return { items: menuItems, texts: menuTexts }
} catch (e) {
console.error('Error getting quick action commands:', e)
return { items: [], texts: [] }
const menuTexts = []
for (let i = 0; i < menuItems.length; i++) {
const text = await menuItems[i].getText()
menuTexts.push(text)
}

return { items: menuItems, texts: menuTexts }
}

/**
* Clicks a specific quick action command by name
* @param webview The WebviewView instance
* @param commandName The name of the command to click
* @returns Promise<boolean> True if command was found and clicked, false otherwise
*/
export async function clickQuickActionsCommand(webview: WebviewView, commandName: string): Promise<boolean> {
try {
const { items, texts } = await getQuickActionsCommands(webview)
if (items.length === 0) {
console.log('No quick action commands found to click')
return false
}
const indexToClick = texts.findIndex((text) => text === commandName)
export async function clickQuickActionsCommand(webview: WebviewView, commandName: string): Promise<void> {
const { items, texts } = await getQuickActionsCommands(webview)
if (items.length === 0) {
throw new Error('No quick action commands found')
}
const indexToClick = texts.findIndex((text) => text === commandName)

if (indexToClick === -1) {
console.log(`Command "${commandName}" not found`)
return false
}
console.log(`Clicking on command: ${commandName}`)
await items[indexToClick].click()
await sleep(3000)
console.log('Command clicked successfully')
return true
} catch (e) {
console.error('Error clicking quick action command:', e)
return false
if (indexToClick === -1) {
throw new Error(`Command "${commandName}" not found`)
}
await items[indexToClick].click()
await sleep(3000)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ import { waitForElement } from '../utils/generalUtils'
* @param webviewView The WebviewView instance
*/
export async function listModels(webviewView: WebviewView): Promise<void> {
try {
const selectElement = await waitForElement(webviewView, By.css('.mynah-form-input.auto-width'))
const options = await selectElement.findElements(By.css('option'))
const optionTexts = await Promise.all(options.map(async (option) => await option.getText()))

console.log('Available model options:', optionTexts)
} catch (e) {
console.error('Error listing model options:', e)
throw e
}
const selectElement = await waitForElement(webviewView, By.css('.mynah-form-input.auto-width'))
const options = await selectElement.findElements(By.css('option'))
const optionTexts = await Promise.all(options.map(async (option) => await option.getText()))
console.log('Available model options:', optionTexts)
}

/**
Expand All @@ -28,25 +22,19 @@ export async function listModels(webviewView: WebviewView): Promise<void> {
* @param modelName The exact name of the model to select
*/
export async function selectModel(webviewView: WebviewView, modelName: string): Promise<void> {
try {
const selectElement = await waitForElement(webviewView, By.css('.mynah-form-input.auto-width'))
await selectElement.click()
const options = await selectElement.findElements(By.css('option'))
let targetOption: WebElement | undefined
for (const option of options) {
const optionText = await option.getText()
if (optionText === modelName) {
targetOption = option
break
}
const selectElement = await waitForElement(webviewView, By.css('.mynah-form-input.auto-width'))
await selectElement.click()
const options = await selectElement.findElements(By.css('option'))
let targetOption: WebElement | undefined
for (const option of options) {
const optionText = await option.getText()
if (optionText === modelName) {
targetOption = option
break
}
if (!targetOption) {
throw new Error(`Model option "${modelName}" not found`)
}
await targetOption.click()
console.log(`Selected model option: ${modelName}`)
} catch (e) {
console.error('Error selecting model option:', e)
throw e
}
if (!targetOption) {
throw new Error(`Model option "${modelName}" not found`)
}
await targetOption.click()
}

This file was deleted.

Loading
Loading