From 189e0acfb1d563ce148766fbefccc7ea0cac16d9 Mon Sep 17 00:00:00 2001 From: Webifi Date: Tue, 29 Aug 2023 13:50:50 -0500 Subject: [PATCH 1/2] Add option to copy profile as URL --- src/lib/ChatSettingsModal.svelte | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/ChatSettingsModal.svelte b/src/lib/ChatSettingsModal.svelte index 640b83b..b35b30f 100644 --- a/src/lib/ChatSettingsModal.svelte +++ b/src/lib/ChatSettingsModal.svelte @@ -35,6 +35,7 @@ import { openModal } from 'svelte-modals' import PromptConfirm from './PromptConfirm.svelte' import { getChatModelOptions, getImageModelOptions } from './Models.svelte' + import { faClipboard } from '@fortawesome/free-regular-svg-icons' export let chatId:number export const show = () => { showSettings() } @@ -97,6 +98,20 @@ showSettingsModal && showSettings() } + const copySettingsAsUri = () => { + // location.protocol + '//' + location.host + location.pathname + const uri = '#/chat/new?petals=true&' + Object.entries(chatSettings).reduce((a, [k, v]) => { + const t = typeof v + if (t === 'boolean' || t === 'string' || t === 'number') { + a.push(encodeURI(k) + '=' + encodeURI(v as any)) + } + return a + }, [] as string[]).join('&') + const profileUri = window.location.protocol + '//' + window.location.host + window.location.pathname + uri + navigator.clipboard.writeText(profileUri) + return profileUri + } + const cloneProfile = () => { showProfileMenu = false const clone = JSON.parse(JSON.stringify(chat.settings)) @@ -312,6 +327,9 @@ { showProfileMenu = false; profileFileInput.click() }}> Restore Profile JSON + { showProfileMenu = false; copySettingsAsUri() }}> + Copy Profile URL to Clipboard + Delete Profile From 0d4f12d9007ac54dbde3eb54d4172d4348af80a0 Mon Sep 17 00:00:00 2001 From: Webifi Date: Tue, 29 Aug 2023 13:55:22 -0500 Subject: [PATCH 2/2] Apply profile changes from URI before start --- src/lib/NewChat.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/NewChat.svelte b/src/lib/NewChat.svelte index ae9c8e1..0c5877c 100644 --- a/src/lib/NewChat.svelte +++ b/src/lib/NewChat.svelte @@ -2,7 +2,7 @@ import { querystring } from 'svelte-spa-router' import { addChat, setChatSettingValueByKey } from './Storage.svelte' import { replace } from 'svelte-spa-router' - import { getProfile } from './Profiles.svelte' + import { getProfile, restartProfile } from './Profiles.svelte' import { getChatDefaults } from './Settings.svelte' // Create the new chat instance then redirect to it @@ -14,6 +14,7 @@ setChatSettingValueByKey(chatId, k as any, urlParams.get(k)) } }) - + + restartProfile(chatId) replace(`/chat/${chatId}`)