diff --git a/core/http/endpoints/localai/welcome.go b/core/http/endpoints/localai/welcome.go index 76f7f1a4a969..d21d853c41f1 100644 --- a/core/http/endpoints/localai/welcome.go +++ b/core/http/endpoints/localai/welcome.go @@ -64,8 +64,13 @@ func WelcomeEndpoint(appConfig *config.ApplicationConfig, // The client expects a JSON response return c.JSON(200, summary) } else { - // Render index - return c.Render(200, "views/index", summary) + // Check if this is the manage route + templateName := "views/index" + if strings.HasSuffix(c.Request().URL.Path, "/manage") || c.Request().URL.Path == "/manage" { + templateName = "views/manage" + } + // Render appropriate template + return c.Render(200, templateName, summary) } } } diff --git a/core/http/routes/ui.go b/core/http/routes/ui.go index 03cb3c9b7c90..776547e5c979 100644 --- a/core/http/routes/ui.go +++ b/core/http/routes/ui.go @@ -21,6 +21,7 @@ func RegisterUIRoutes(app *echo.Echo, var processingOps = services.NewOpCache(galleryService) app.GET("/", localai.WelcomeEndpoint(appConfig, cl, ml, processingOps)) + app.GET("/manage", localai.WelcomeEndpoint(appConfig, cl, ml, processingOps)) // P2P app.GET("/p2p/", func(c echo.Context) error { diff --git a/core/http/static/chat.js b/core/http/static/chat.js index 1307b1b5486c..055cc85e96cb 100644 --- a/core/http/static/chat.js +++ b/core/http/static/chat.js @@ -1237,3 +1237,55 @@ document.addEventListener("alpine:init", () => { } }); +// Check for message from index page on load +document.addEventListener('DOMContentLoaded', function() { + // Wait for Alpine to be ready + setTimeout(() => { + const chatData = localStorage.getItem('localai_index_chat_data'); + if (chatData) { + try { + const data = JSON.parse(chatData); + const input = document.getElementById('input'); + + if (input && data.message) { + // Set the message in the input + input.value = data.message; + + // Process files if any + if (data.imageFiles && data.imageFiles.length > 0) { + data.imageFiles.forEach(file => { + images.push(file.data); + }); + } + + if (data.audioFiles && data.audioFiles.length > 0) { + data.audioFiles.forEach(file => { + audios.push(file.data); + }); + } + + if (data.textFiles && data.textFiles.length > 0) { + data.textFiles.forEach(file => { + fileContents.push({ name: file.name, content: file.data }); + currentFileNames.push(file.name); + }); + } + + // Clear localStorage + localStorage.removeItem('localai_index_chat_data'); + + // Auto-submit after a short delay to ensure everything is ready + setTimeout(() => { + if (input.value.trim()) { + processAndSendMessage(input.value); + } + }, 500); + } + } catch (error) { + console.error('Error processing chat data from index:', error); + localStorage.removeItem('localai_index_chat_data'); + } + } + }, 300); +}); + diff --git a/core/http/views/404.html b/core/http/views/404.html index 2a25b028ee51..231d85b0e456 100644 --- a/core/http/views/404.html +++ b/core/http/views/404.html @@ -9,9 +9,9 @@
The page you're looking for doesn't exist or has been moved