Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 11, 2024
1 parent d7511a6 commit 1c48a71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
21 changes: 13 additions & 8 deletions app/src/lib/components/CheckFinalResponse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { createEventDispatcher } from 'svelte';
import { Button } from './ui/button';
import { getSessionContext } from '@/stores/sessionContext.svelte';
import RenderAudioSource from '@/components/RenderAudioSource.svelte';
export let content: string;
Expand All @@ -17,7 +18,7 @@
generate: { summary: string };
}>();
const { sessionId$, sessionCompleted$ } = getSessionContext();
const { sessionId$, sessionCompleted$, audioSource$ } = getSessionContext();
function getSummary() {
const replacePrefixRegex = new RegExp(FINAL_RESPONSE_PREFIX, 'gi');
Expand All @@ -42,13 +43,17 @@
on:click={() => dispatch('generate', { summary: getSummary() })}>Generate Audiocast</Button
>

<Button
variant="ghost"
class="bg-gray-800 hover:bg-gray-700 text-emerald-600 hover:text-emerald-600"
on:click={() => dispatch('reviewSource', { summary: getSummary() })}
>
Review Source
</Button>
{#if $audioSource$}
<RenderAudioSource audioSource={$audioSource$} />
{:else}
<Button
variant="ghost"
class="bg-gray-800 hover:bg-gray-700 text-emerald-600 hover:text-emerald-600"
on:click={() => dispatch('reviewSource', { summary: getSummary() })}
>
Review Source
</Button>
{/if}

<Button
variant="ghost"
Expand Down
18 changes: 7 additions & 11 deletions app/src/lib/components/RenderAudioSource.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
import * as Drawer from './ui/drawer';
import { Button } from './ui/button';
import { parse } from 'marked';
import { cn } from '@/utils/ui.utils';
export let audioSource: string;
let snapPoints = [0.4, 0.75, 0.9];
let snapPoints = [0.75, 0.9];
let activeSnapPoint = snapPoints[0];
</script>

<Drawer.Root {snapPoints} bind:activeSnapPoint direction="bottom" dismissible shouldScaleBackground>
<Drawer.Trigger>
<Button variant="ghost" class="bg-gray-800 hover:bg-gray-700 text-white px-16"
>Show AudioSource
<Button variant="ghost" class="bg-gray-800 hover:bg-gray-700 text-white"
>Manage Audiocast Sources
</Button>
</Drawer.Trigger>

Expand All @@ -23,13 +22,10 @@
<Drawer.Content class="border-neutral-800 pb-40 block h-full w-full rounded-t-md">
<Drawer.Title
class="text-2xl px-4 py-2 mx-auto md:max-w-3xl xl:max-w-4xl w-full gradient-gray-to-emerald font-medium"
>Audiocast Source</Drawer.Title
>
<div
class={cn('h-full overflow-hidden', {
'overflow-y-auto': activeSnapPoint > snapPoints[0]
})}
>
>Audiocast Source
</Drawer.Title>

<div class="h-full overflow-hidden overflow-y-auto">
<div
class="mx-auto relative w-full h-[calc(100%+120px)] max-w-full px-4 py-2 md:max-w-3xl xl:max-w-4xl"
>
Expand Down
7 changes: 2 additions & 5 deletions app/src/routes/chat/[sessionId=sessionId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import { onMount } from 'svelte';
import { debounce } from 'throttle-debounce';
import Spinner from '@/components/Spinner.svelte';
import RenderAudioSource from '@/components/RenderAudioSource.svelte';
export let data;
const { session$, addChatItem, updateChatContent, sessionId$, fetchingSource$, audioSource$ } =
const { session$, addChatItem, updateChatContent, sessionId$, fetchingSource$ } =
getSessionContext();
let searchTerm = '';
Expand Down Expand Up @@ -102,9 +101,7 @@
{@const finalResponse = item.content.includes(FINAL_RESPONSE_SUFFIX)}
<ChatListItem type={item.role} content={item.content} loading={item.loading} />

{#if finalResponse && $audioSource$}
<RenderAudioSource audioSource={$audioSource$} />
{:else if finalResponse}
{#if finalResponse}
<ChatListActionItems {sessionId} let:ongenerate let:onreviewSource let:onstartNew>
{#if $fetchingSource$}
<Spinner />
Expand Down

0 comments on commit 1c48a71

Please sign in to comment.