This commit is contained in:
Tim Janik 2025-02-02 23:48:33 +01:00 committed by GitHub
commit 67eb5ea7f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 4 deletions

Binary file not shown.

View file

@ -159,7 +159,7 @@
id="msg-input"
dir="auto"
></textarea>
<button v-if="!isGenerating" class="btn btn-primary ml-2" @click="sendMessage" :disabled="inputMsg.length === 0">Send</button>
<button v-if="!isGenerating" class="btn btn-primary ml-2" @click="sendMessage" :disabled="inputMsg.length === 0" id="msg-send">Send</button>
<button v-else class="btn btn-neutral ml-2" @click="stopGeneration">Stop</button>
</div>
</div>

View file

@ -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<Message>} */
messages: [],
viewingConvId: StorageUtils.getNewConvId(),
inputMsg: '',
inputMsg: initial_msg,
isGenerating: false,
/** @type {Array<Message> | 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 = `<div style="margin:2em auto">