Compare commits

...

2 Commits

Author SHA1 Message Date
e0025f7fad Release KCL 81 (#7463) 2025-06-12 16:20:41 +00:00
2a13888c54 Checkbox for variable creation in command bar flows (#7452)
* Draft: Constrain with Expression: prevent throwaway variables
Fixes #7252

* WIP tests
2025-06-12 10:58:07 -04:00
16 changed files with 85 additions and 84 deletions

View File

@ -302,7 +302,7 @@ test.describe('Command bar tests', () => {
// Assert that the an alternative variable name is chosen, // Assert that the an alternative variable name is chosen,
// since the default variable name is already in use (distance) // since the default variable name is already in use (distance)
await page.getByRole('button', { name: 'Create new variable' }).click() await cmdBar.variableCheckbox.click()
await expect(page.getByPlaceholder('Variable name')).toHaveValue( await expect(page.getByPlaceholder('Variable name')).toHaveValue(
'length001' 'length001'
) )

View File

@ -281,10 +281,7 @@ test.describe('Feature Tree pane', () => {
await test.step('Add a named constant for distance argument and submit', async () => { await test.step('Add a named constant for distance argument and submit', async () => {
await expect(cmdBar.currentArgumentInput).toBeVisible() await expect(cmdBar.currentArgumentInput).toBeVisible()
const addVariableButton = page.getByRole('button', { await cmdBar.variableCheckbox.click()
name: 'Create new variable',
})
await addVariableButton.click()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await cmdBar.expectState({ await cmdBar.expectState({
stage: 'review', stage: 'review',

View File

@ -172,6 +172,10 @@ export class CmdBarFixture {
return this.page.getByTestId('cmd-bar-arg-value') return this.page.getByTestId('cmd-bar-arg-value')
} }
get variableCheckbox() {
return this.page.getByTestId('cmd-bar-variable-checkbox')
}
get cmdOptions() { get cmdOptions() {
return this.page.getByTestId('cmd-bar-option') return this.page.getByTestId('cmd-bar-option')
} }
@ -191,7 +195,7 @@ export class CmdBarFixture {
* Clicks the Create new variable button for kcl input * Clicks the Create new variable button for kcl input
*/ */
createNewVariable = async () => { createNewVariable = async () => {
await this.page.getByRole('button', { name: 'Create new variable' }).click() await this.variableCheckbox.click()
} }
/** /**

View File

@ -3807,7 +3807,7 @@ sketch002 = startSketchOn(extrude001, face = rectangleSegmentA001)
stage: 'arguments', stage: 'arguments',
}) })
await page.keyboard.insertText(newAngle) await page.keyboard.insertText(newAngle)
await page.getByRole('button', { name: 'Create new variable' }).click() await cmdBar.variableCheckbox.click()
await expect(page.getByPlaceholder('Variable name')).toHaveValue( await expect(page.getByPlaceholder('Variable name')).toHaveValue(
'angle001' 'angle001'
) )

20
rust/Cargo.lock generated
View File

@ -1792,7 +1792,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-bumper" name = "kcl-bumper"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1803,7 +1803,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-derive-docs" name = "kcl-derive-docs"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1812,7 +1812,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-directory-test-macro" name = "kcl-directory-test-macro"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"proc-macro2", "proc-macro2",
@ -1822,7 +1822,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-language-server" name = "kcl-language-server"
version = "0.2.80" version = "0.2.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1843,7 +1843,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-language-server-release" name = "kcl-language-server-release"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1863,7 +1863,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-lib" name = "kcl-lib"
version = "0.2.80" version = "0.2.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"approx 0.5.1", "approx 0.5.1",
@ -1940,7 +1940,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-python-bindings" name = "kcl-python-bindings"
version = "0.3.80" version = "0.3.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"kcl-lib", "kcl-lib",
@ -1955,7 +1955,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-test-server" name = "kcl-test-server"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"hyper 0.14.32", "hyper 0.14.32",
@ -1968,7 +1968,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-to-core" name = "kcl-to-core"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1982,7 +1982,7 @@ dependencies = [
[[package]] [[package]]
name = "kcl-wasm-lib" name = "kcl-wasm-lib"
version = "0.1.80" version = "0.1.81"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bson", "bson",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-bumper" name = "kcl-bumper"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
repository = "https://github.com/KittyCAD/modeling-api" repository = "https://github.com/KittyCAD/modeling-api"
rust-version = "1.76" rust-version = "1.76"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-derive-docs" name = "kcl-derive-docs"
description = "A tool for generating documentation from Rust derive macros" description = "A tool for generating documentation from Rust derive macros"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app" repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-directory-test-macro" name = "kcl-directory-test-macro"
description = "A tool for generating tests from a directory of kcl files" description = "A tool for generating tests from a directory of kcl files"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app" repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kcl-language-server-release" name = "kcl-language-server-release"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
authors = ["KittyCAD Inc <kcl@kittycad.io>"] authors = ["KittyCAD Inc <kcl@kittycad.io>"]
publish = false publish = false

View File

@ -2,7 +2,7 @@
name = "kcl-language-server" name = "kcl-language-server"
description = "A language server for KCL." description = "A language server for KCL."
authors = ["KittyCAD Inc <kcl@kittycad.io>"] authors = ["KittyCAD Inc <kcl@kittycad.io>"]
version = "0.2.80" version = "0.2.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-lib" name = "kcl-lib"
description = "KittyCAD Language implementation and tools" description = "KittyCAD Language implementation and tools"
version = "0.2.80" version = "0.2.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app" repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kcl-python-bindings" name = "kcl-python-bindings"
version = "0.3.80" version = "0.3.81"
edition = "2021" edition = "2021"
repository = "https://github.com/kittycad/modeling-app" repository = "https://github.com/kittycad/modeling-app"
exclude = ["tests/*", "files/*", "venv/*"] exclude = ["tests/*", "files/*", "venv/*"]

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-test-server" name = "kcl-test-server"
description = "A test server for KCL" description = "A test server for KCL"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "kcl-to-core" name = "kcl-to-core"
description = "Utility methods to convert kcl to engine core executable tests" description = "Utility methods to convert kcl to engine core executable tests"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app" repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kcl-wasm-lib" name = "kcl-wasm-lib"
version = "0.1.80" version = "0.1.81"
edition = "2021" edition = "2021"
repository = "https://github.com/KittyCAD/modeling-app" repository = "https://github.com/KittyCAD/modeling-app"
rust-version = "1.83" rust-version = "1.83"

View File

@ -286,65 +286,65 @@ function CommandBarKclInput({
)} )}
</span> </span>
</label> </label>
{createNewVariable ? ( <div className="flex items-baseline gap-4 mx-4">
<div className="flex items-baseline gap-4 mx-4 border-solid border-0 border-b border-chalkboard-50"> <input
<label type="checkbox"
htmlFor="variable-name" id="variable-checkbox"
className="text-base text-chalkboard-80 dark:text-chalkboard-20" data-testid="cmd-bar-variable-checkbox"
> checked={createNewVariable}
Variable name onChange={(e) => {
</label> setCreateNewVariable(e.target.checked)
<input }}
type="text" className="bg-chalkboard-10 dark:bg-chalkboard-80"
id="variable-name" />
name="variable-name" <label
className="flex-1 border-none bg-transparent focus:outline-none" htmlFor="variable-checkbox"
placeholder="Variable name" className="text-blue border-none bg-transparent font-sm flex gap-1 items-center pl-0 pr-1"
value={newVariableName} >
autoCapitalize="off" Create new variable
autoCorrect="off" </label>
autoComplete="off" {createNewVariable && (
spellCheck="false" <>
autoFocus <input
onChange={(e) => setNewVariableName(e.target.value)} type="text"
onKeyDown={(e) => { id="variable-name"
if ( name="variable-name"
e.currentTarget.value === '' && className="flex-1 border-solid border-0 border-b border-chalkboard-50 bg-transparent focus:outline-none"
e.key === 'Backspace' && placeholder="Variable name"
arg.createVariable !== 'force' value={newVariableName}
) { autoCapitalize="off"
setCreateNewVariable(false) autoCorrect="off"
autoComplete="off"
spellCheck="false"
autoFocus
onChange={(e) => setNewVariableName(e.target.value)}
onKeyDown={(e) => {
if (
e.currentTarget.value === '' &&
e.key === 'Backspace' &&
arg.createVariable !== 'force'
) {
setCreateNewVariable(false)
}
}}
onKeyUp={(e) => {
if (e.key === 'Enter' && canSubmit) {
handleSubmit()
}
}}
/>
<span
className={
isNewVariableNameUnique
? 'text-succeed-60 dark:text-succeed-40'
: 'text-destroy-60 dark:text-destroy-40'
} }
}}
onKeyUp={(e) => {
if (e.key === 'Enter' && canSubmit) {
handleSubmit()
}
}}
/>
<span
className={
isNewVariableNameUnique
? 'text-succeed-60 dark:text-succeed-40'
: 'text-destroy-60 dark:text-destroy-40'
}
>
{isNewVariableNameUnique ? 'Available' : 'Unavailable'}
</span>
</div>
) : (
arg.createVariable !== 'disallow' && (
<div className="flex justify-between gap-2 px-4">
<button
onClick={() => setCreateNewVariable(true)}
className="text-blue border-none bg-transparent font-sm flex gap-1 items-center pl-0 pr-1"
> >
<CustomIcon name="plus" className="w-5 h-5" /> {isNewVariableNameUnique ? 'Available' : 'Unavailable'}
Create new variable </span>
</button> </>
</div> )}
) </div>
)}
</form> </form>
) )
} }