-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refinements of tools/terminals in user ui
- Loading branch information
1 parent
cb7dfb3
commit 7d2adb9
Showing
12 changed files
with
251 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import Env from '$lib/components/tool/Env.svelte'; | ||
import { ChatService } from '$lib/services'; | ||
import { currentAssistant } from '$lib/stores'; | ||
import { masked } from '$lib/components/tool/Env.svelte'; | ||
let dialog: HTMLDialogElement; | ||
let envs: { key: string; value: string; editing: string }[] = $state([]); | ||
let error = $state(''); | ||
export async function show() { | ||
const newEnvs = await ChatService.getAssistantEnv($currentAssistant.id); | ||
envs = Object.entries(newEnvs).map(([key, value]) => ({ key, value, editing: masked })); | ||
envs.push({ key: '', value: '', editing: '' }); | ||
error = ''; | ||
dialog.showModal(); | ||
} | ||
async function save() { | ||
const newEnv = envs.reduce( | ||
(acc, { key, value }) => { | ||
if (key) { | ||
acc[key] = value; | ||
} | ||
return acc; | ||
}, | ||
{} as Record<string, string> | ||
); | ||
try { | ||
await ChatService.saveAssistantEnv($currentAssistant.id, newEnv); | ||
} catch (e) { | ||
error = e.toString(); | ||
return; | ||
} | ||
dialog.close(); | ||
} | ||
onMount(() => { | ||
show(); | ||
}); | ||
</script> | ||
|
||
<dialog | ||
bind:this={dialog} | ||
class="w-full max-w-3xl rounded-3xl bg-gray-50 text-black dark:bg-gray-950 dark:text-gray-50" | ||
> | ||
<Env {envs} /> | ||
{#if error} | ||
<p class="p-5 text-sm text-red-500">{error}</p> | ||
{/if} | ||
<div class="flex w-full items-center justify-end gap-2 p-5"> | ||
<button class="p-3 px-6" onclick={() => dialog.close()}> Cancel </button> | ||
<button class="rounded-3xl bg-blue p-3 px-6 text-white" onclick={() => save()}> Save </button> | ||
</div> | ||
</dialog> | ||
|
||
<style lang="postcss"> | ||
dialog::backdrop { | ||
@apply bg-black bg-opacity-60; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.