Skip to content

Commit

Permalink
Add toolbar buttons for text-to-cad and prompt-to-edit (#4938)
Browse files Browse the repository at this point in the history
* Add toolbar buttons for text-to-cad and prompt-to-edit
Resolves #4890

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: windows-16-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: windows-16-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: windows-16-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: namespace-profile-macos-8-cores)

* `preventDefault` on <kbd>Enter</kbd> with textarea input so buttons aren't clicked as well

* A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: windows-16-cores)

* Trigger CI

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <[email protected]>
  • Loading branch information
3 people authored and guptaarnav committed Jan 7, 2025
1 parent 913b957 commit a347172
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 9 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions e2e/playwright/text-to-cad-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ test.describe('Text-to-CAD tests', () => {
const cmdSearchBar = page.getByPlaceholder('Search commands')
await expect(cmdSearchBar).toBeVisible()

const textToCadCommand = page.getByText('Text-to-CAD')
const textToCadCommand = page.getByRole('option', { name: 'Text-to-CAD' })
await expect(textToCadCommand.first()).toBeVisible()
// Click the Text-to-CAD command
await textToCadCommand.first().click()

// Enter the prompt.
const prompt = page.getByText('Prompt')
const prompt = page.getByRole('textbox', { name: 'Prompt' })
await expect(prompt.first()).toBeVisible()

// Type the prompt.
Expand Down Expand Up @@ -224,13 +224,13 @@ test.describe('Text-to-CAD tests', () => {
const cmdSearchBar = page.getByPlaceholder('Search commands')
await expect(cmdSearchBar).toBeVisible()

const textToCadCommand = page.getByText('Text-to-CAD')
const textToCadCommand = page.getByRole('option', { name: 'Text-to-CAD' })
await expect(textToCadCommand.first()).toBeVisible()
// Click the Text-to-CAD command
await textToCadCommand.first().click()

// Enter the prompt.
const prompt = page.getByText('Prompt')
const prompt = page.getByRole('textbox', { name: 'Prompt' })
await expect(prompt.first()).toBeVisible()

const badPrompt = 'akjsndladf lajbhflauweyfaaaljhr472iouafyvsssssss'
Expand Down Expand Up @@ -314,13 +314,13 @@ test.describe('Text-to-CAD tests', () => {
const cmdSearchBar = page.getByPlaceholder('Search commands')
await expect(cmdSearchBar).toBeVisible()

const textToCadCommand = page.getByText('Text-to-CAD')
const textToCadCommand = page.getByRole('option', { name: 'Text-to-CAD' })
await expect(textToCadCommand.first()).toBeVisible()
// Click the Text-to-CAD command
await textToCadCommand.first().click()

// Enter the prompt.
const prompt = page.getByText('Prompt')
const prompt = page.getByRole('textbox', { name: 'Prompt' })
await expect(prompt.first()).toBeVisible()

const badPrompt = 'akjsndladflajbhflauweyf15;'
Expand Down Expand Up @@ -392,13 +392,13 @@ test.describe('Text-to-CAD tests', () => {
const cmdSearchBar = page.getByPlaceholder('Search commands')
await expect(cmdSearchBar).toBeVisible()

const textToCadCommand = page.getByText('Text-to-CAD')
const textToCadCommand = page.getByRole('option', { name: 'Text-to-CAD' })
await expect(textToCadCommand.first()).toBeVisible()
// Click the Text-to-CAD command
await textToCadCommand.first().click()

// Enter the prompt.
const prompt = page.getByText('Prompt')
const prompt = page.getByRole('textbox', { name: 'Prompt' })
await expect(prompt.first()).toBeVisible()

// Type the prompt.
Expand Down Expand Up @@ -604,7 +604,7 @@ async function sendPromptFromCommandBar(page: Page, promptStr: string) {
await page.waitForTimeout(1000)

// Enter the prompt.
const prompt = page.getByText('Prompt')
const prompt = page.getByRole('textbox', { name: 'Prompt' })
await expect(prompt.first()).toBeVisible()

// Type the prompt.
Expand Down
1 change: 1 addition & 0 deletions src/components/CommandBar/CommandBarTextareaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function CommandBarTextareaInput({
target.selectionStart = selectionStart + 1
target.selectionEnd = selectionStart + 1
} else if (event.key === 'Enter') {
event.preventDefault()
formRef.current?.dispatchEvent(
new Event('submit', { bubbles: true })
)
Expand Down
29 changes: 29 additions & 0 deletions src/lib/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,35 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
links: [],
},
],
'break',
[
{
id: 'text-to-cad',
onClick: ({ commandBarSend }) =>
commandBarSend({
type: 'Find and select command',
data: { name: 'Text-to-CAD', groupId: 'modeling' },
}),
icon: 'sparkles',
status: 'available',
title: 'Text-to-CAD',
description: 'Generate geometry from a text prompt.',
links: [],
},
{
id: 'prompt-to-edit',
onClick: ({ commandBarSend }) =>
commandBarSend({
type: 'Find and select command',
data: { name: 'Prompt-to-edit', groupId: 'modeling' },
}),
icon: 'sparkles',
status: 'available',
title: 'Prompt-to-Edit',
description: 'Edit geometry based on a text prompt.',
links: [],
},
],
],
},
sketching: {
Expand Down

0 comments on commit a347172

Please sign in to comment.