fix: ai gen minor fixes (#2626)

This commit is contained in:
HugoCasa
2023-11-14 09:59:25 +01:00
committed by GitHub
parent a285ca24b0
commit da79afaeb1
4 changed files with 15 additions and 4 deletions

View File

@@ -373,7 +373,7 @@
const thisTs = Date.now()
copilotTs = thisTs
await sleep(500)
await sleep(200)
if (copilotTs === thisTs) {
abortController?.abort()
abortController = new AbortController()

View File

@@ -659,6 +659,7 @@
$copilotDrawerStore?.closeDrawer()
select(module.id)
await tick()
await tick()
focusCopilot()
let isFirstInLoop = false
@@ -675,7 +676,6 @@
if (hubScript) {
module.editor?.setCode(hubScript.content)
} else if (module.source === 'custom') {
module.editor?.setCode('')
const deltaStore = writable<string>('')
const unsubscribe = deltaStore.subscribe(async (delta) => {
module.editor?.append(delta)

View File

@@ -145,6 +145,16 @@
}
$: updateSchema(lang, args, $dbSchemas)
let codeDiv: HTMLDivElement | undefined
let lastScrollHeight = 0
function updateScroll() {
if (codeDiv && lastScrollHeight !== codeDiv.scrollHeight) {
codeDiv.scrollTop = codeDiv.scrollHeight
lastScrollHeight = codeDiv.scrollHeight
}
}
$: $generatedCode && updateScroll()
</script>
{#if genLoading}
@@ -264,7 +274,7 @@
</svelte:fragment>
<div class="block text-primary">
{#if genLoading}
<div class="w-[42rem] min-h-[3rem] max-h-[34rem] overflow-y-scroll">
<div class="w-[42rem] min-h-[3rem] max-h-[34rem] overflow-y-scroll" bind:this={codeDiv}>
{#if $generatedCode.length > 0}
<div class="overflow-x-scroll">
<HighlightCode language={lang} code={$generatedCode} /></div

View File

@@ -132,7 +132,8 @@ async function getResourceTypes(scriptOptions: CopilotOptions) {
const resourceTypes = await ResourceService.queryResourceTypes({
workspace,
text: elems.join(';')
text: elems.join(';'),
limit: 3
})
return resourceTypes