"Fix" automation saving after AI prompt.
This commit is contained in:
parent
be52250fb4
commit
abea3d6ac2
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
let focus = false
|
let isFocused = false
|
||||||
let textarea: HTMLTextAreaElement
|
let textarea: HTMLTextAreaElement
|
||||||
let scrollable = false
|
let scrollable = false
|
||||||
|
|
||||||
|
@ -27,8 +27,16 @@
|
||||||
$: minHeightString = getStyleString("min-height", minHeight)
|
$: minHeightString = getStyleString("min-height", minHeight)
|
||||||
$: dispatch("scrollable", scrollable)
|
$: dispatch("scrollable", scrollable)
|
||||||
|
|
||||||
|
export function focus() {
|
||||||
|
textarea.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function contents() {
|
||||||
|
return textarea.value
|
||||||
|
}
|
||||||
|
|
||||||
const onBlur = () => {
|
const onBlur = () => {
|
||||||
focus = false
|
isFocused = false
|
||||||
updateValue()
|
updateValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +73,7 @@
|
||||||
style={`${heightString}${minHeightString}`}
|
style={`${heightString}${minHeightString}`}
|
||||||
class="spectrum-Textfield spectrum-Textfield--multiline"
|
class="spectrum-Textfield spectrum-Textfield--multiline"
|
||||||
class:is-disabled={disabled}
|
class:is-disabled={disabled}
|
||||||
class:is-focused={focus}
|
class:is-focused={isFocused}
|
||||||
>
|
>
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
<textarea
|
<textarea
|
||||||
|
@ -77,7 +85,7 @@
|
||||||
{readonly}
|
{readonly}
|
||||||
{id}
|
{id}
|
||||||
on:input={onChange}
|
on:input={onChange}
|
||||||
on:focus={() => (focus = true)}
|
on:focus={() => (isFocused = true)}
|
||||||
on:blur={onBlur}
|
on:blur={onBlur}
|
||||||
on:blur
|
on:blur
|
||||||
on:keypress
|
on:keypress
|
||||||
|
|
|
@ -173,13 +173,22 @@
|
||||||
try {
|
try {
|
||||||
const resp = await API.generateJs({ prompt, bindings })
|
const resp = await API.generateJs({ prompt, bindings })
|
||||||
code = resp.code
|
code = resp.code
|
||||||
|
|
||||||
|
if (code === "") {
|
||||||
|
throw new Error(
|
||||||
|
"we didn't understand your prompt, please phrase your request in another way"
|
||||||
|
)
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
if (e instanceof Error) {
|
||||||
|
notifications.error(`Unable to generate code: ${e.message}`)
|
||||||
|
} else {
|
||||||
notifications.error("Unable to generate code, please try again later.")
|
notifications.error("Unable to generate code, please try again later.")
|
||||||
|
}
|
||||||
code = previousContents
|
code = previousContents
|
||||||
popoverWidth = 300
|
|
||||||
promptLoading = false
|
promptLoading = false
|
||||||
popover.hide()
|
resetPopover()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
value = code
|
value = code
|
||||||
|
@ -532,7 +541,7 @@
|
||||||
<div class="prompt-spinner">
|
<div class="prompt-spinner">
|
||||||
<Spinner size="20" color="white" />
|
<Spinner size="20" color="white" />
|
||||||
</div>
|
</div>
|
||||||
{:else if suggestedCode}
|
{:else if suggestedCode !== null}
|
||||||
<Button on:click={acceptSuggestion}>Accept</Button>
|
<Button on:click={acceptSuggestion}>Accept</Button>
|
||||||
<Button on:click={rejectSuggestion}>Reject</Button>
|
<Button on:click={rejectSuggestion}>Reject</Button>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
Loading…
Reference in New Issue