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