Skip to content

Commit

Permalink
Fix error UX:
Browse files Browse the repository at this point in the history
 - Modal was closing on error
 - Errors prevented retrying
 - Errros stuck around for future runs, when no longer contextual
  • Loading branch information
scosman committed Nov 18, 2024
1 parent 24ee1f6 commit b542c9f
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@
return sample.input
}
let topic_generation_error: KilnError | null = null
let generate_subtopics: boolean = false
let num_subtopics_to_generate: number = 6
let custom_topics_string: string = ""
async function open_generate_subtopics_modal() {
// Avoid having a trillion of these hidden in the DOM
generate_subtopics = true
// Clear any previous error
topic_generation_error = null
await tick()
const modal = document.getElementById(`${id}-generate-subtopics`)
// @ts-expect-error dialog is not a standard element
Expand Down Expand Up @@ -85,6 +88,9 @@
// @ts-expect-error dialog is not a standard element
modal?.close()
// Optional: remove it from DOM
generate_subtopics = false
// Scroll to bottom of added topics
scroll_to_bottom_of_element_by_id(`${id}-subtopics`)
}
Expand All @@ -100,7 +106,6 @@
}
let topic_generating: boolean = false
let topic_generation_error: KilnError | null = null
async function generate_topics() {
try {
topic_generating = true
Expand Down Expand Up @@ -155,14 +160,15 @@
}
} finally {
topic_generating = false
generate_subtopics = false
}
}
let generate_samples_modal: boolean = false
async function open_generate_samples_modal() {
// Avoid having a trillion of these hidden in the DOM
generate_samples_modal = true
// Clear any previous error
sample_generation_error = null
await tick()
const modal = document.getElementById(`${id}-generate-samples`)
// @ts-expect-error dialog is not a standard element
Expand Down Expand Up @@ -190,6 +196,9 @@
// @ts-expect-error dialog is not a standard element
modal?.close()
// Optional: remove it from DOM
generate_samples_modal = false
// Scroll to bottom of added samples
scroll_to_bottom_of_element_by_id(`${id}-samples`)
}
Expand Down Expand Up @@ -251,7 +260,6 @@
}
} finally {
sample_generating = false
generate_samples_modal = false
}
}
Expand Down Expand Up @@ -405,14 +413,14 @@
<div class="flex flex-row justify-center">
<div class="loading loading-spinner loading-lg my-12"></div>
</div>
{:else if topic_generation_error}
<div class="flex flex-col gap-2 text-sm">
<div class="text-error">{topic_generation_error.message}</div>
</div>
{:else}
<div class="flex flex-col gap-2">
{#if topic_generation_error}
<div class="alert alert-error">
{topic_generation_error.message}
</div>
{/if}
<div class="flex-grow font-medium">Generate topics</div>

<div class="flex flex-row items-center gap-4 mt-4 mb-2">
<div class="flex-grow font-medium text-sm">Topic Count</div>
<IncrementUi bind:value={num_subtopics_to_generate} />
Expand Down Expand Up @@ -467,12 +475,13 @@
<div class="flex flex-row justify-center">
<div class="loading loading-spinner loading-lg my-12"></div>
</div>
{:else if sample_generation_error}
<div class="flex flex-col gap-2 text-sm">
<div class="text-error">{sample_generation_error.message}</div>
</div>
{:else}
<div class="flex flex-col gap-2">
{#if sample_generation_error}
<div class="alert alert-error">
{sample_generation_error.message}
</div>
{/if}
<div class="flex flex-row items-center gap-4 mt-4 mb-2">
<div class="flex-grow font-medium text-sm">Sample Count</div>
<IncrementUi bind:value={num_samples_to_generate} />
Expand Down

0 comments on commit b542c9f

Please sign in to comment.