diff --git a/examples/server/public/index.html.gz b/examples/server/public/index.html.gz index 582ccc0d3..ddebeb463 100644 Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ diff --git a/examples/server/webui/index.html b/examples/server/webui/index.html index d3893ea4e..c496445e2 100644 --- a/examples/server/webui/index.html +++ b/examples/server/webui/index.html @@ -159,7 +159,7 @@ id="msg-input" dir="auto" > - + diff --git a/examples/server/webui/src/main.js b/examples/server/webui/src/main.js index 90f4ca368..2216f4223 100644 --- a/examples/server/webui/src/main.js +++ b/examples/server/webui/src/main.js @@ -1,5 +1,5 @@ import './styles.scss'; -import { createApp, defineComponent, shallowRef, computed, h } from 'vue/dist/vue.esm-bundler.js'; +import { createApp, defineComponent, shallowRef, computed, h, nextTick } from 'vue/dist/vue.esm-bundler.js'; import MarkdownIt from 'markdown-it'; import TextLineStream from 'textlinestream'; @@ -373,6 +373,10 @@ async function* sendSSEPostRequest(url, fetchOptions) { } }; +const usp = new URLSearchParams (window.location.search); +const initial_query = usp.get ('q'); +const initial_msg = initial_query || usp.get ('m') || ''; + const mainApp = createApp({ components: { VueMarkdown, @@ -385,7 +389,7 @@ const mainApp = createApp({ /** @type {Array} */ messages: [], viewingConvId: StorageUtils.getNewConvId(), - inputMsg: '', + inputMsg: initial_msg, isGenerating: false, /** @type {Array | null} */ pendingMsg: null, // the on-going message from assistant @@ -660,7 +664,13 @@ const mainApp = createApp({ }); mainApp.config.errorHandler = alert; try { - mainApp.mount('#app'); + const appInstance = mainApp.mount('#app'); + nextTick().then(() => { + if (initial_query) + appInstance.sendMessage(); + else if (initial_msg) + setTimeout(() => document.getElementById('msg-input').focus(), 1); + }); } catch (err) { console.error(err); document.getElementById('app').innerHTML = `