added sidebar contextual information for firefox (#5433)
Signed-off-by: 40u5 <meswag74@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ use axum::{
|
|||||||
ws::{Message, WebSocket, WebSocketUpgrade},
|
ws::{Message, WebSocket, WebSocketUpgrade},
|
||||||
Query, Request, State,
|
Query, Request, State,
|
||||||
},
|
},
|
||||||
http::StatusCode,
|
http::{StatusCode, Uri},
|
||||||
middleware::{self, Next},
|
middleware::{self, Next},
|
||||||
response::{Html, IntoResponse, Response},
|
response::{Html, IntoResponse, Response},
|
||||||
routing::get,
|
routing::get,
|
||||||
@@ -240,7 +240,7 @@ pub async fn handle_web(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn serve_index() -> Result<Redirect, (http::StatusCode, String)> {
|
async fn serve_index(uri: Uri) -> Result<Redirect, (http::StatusCode, String)> {
|
||||||
let session = SessionManager::create_session(
|
let session = SessionManager::create_session(
|
||||||
std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")),
|
std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")),
|
||||||
"Web session".to_string(),
|
"Web session".to_string(),
|
||||||
@@ -249,7 +249,13 @@ async fn serve_index() -> Result<Redirect, (http::StatusCode, String)> {
|
|||||||
.await
|
.await
|
||||||
.map_err(|err| (http::StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?;
|
.map_err(|err| (http::StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?;
|
||||||
|
|
||||||
Ok(Redirect::to(&format!("/session/{}", session.id)))
|
let redirect_url = if let Some(query) = uri.query() {
|
||||||
|
format!("/session/{}?{}", session.id, query)
|
||||||
|
} else {
|
||||||
|
format!("/session/{}", session.id)
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Redirect::to(&redirect_url))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn serve_session(
|
async fn serve_session(
|
||||||
|
|||||||
@@ -475,7 +475,6 @@ async function loadSessionIfExists() {
|
|||||||
resumeDiv.innerHTML = `<em>Session resumed: ${sessionData.messages.length} messages loaded</em>`;
|
resumeDiv.innerHTML = `<em>Session resumed: ${sessionData.messages.length} messages loaded</em>`;
|
||||||
messagesContainer.appendChild(resumeDiv);
|
messagesContainer.appendChild(resumeDiv);
|
||||||
|
|
||||||
|
|
||||||
// Update page title with session description if available
|
// Update page title with session description if available
|
||||||
if (sessionData.metadata && sessionData.metadata.description) {
|
if (sessionData.metadata && sessionData.metadata.description) {
|
||||||
document.title = `goose chat - ${sessionData.metadata.description}`;
|
document.title = `goose chat - ${sessionData.metadata.description}`;
|
||||||
@@ -510,6 +509,24 @@ messageInput.addEventListener('input', () => {
|
|||||||
// Initialize WebSocket connection
|
// Initialize WebSocket connection
|
||||||
connectWebSocket();
|
connectWebSocket();
|
||||||
|
|
||||||
|
// Read 'q' parameter from URL and set it to the message input
|
||||||
|
function getQueryParam() {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const queryParam = urlParams.get('q');
|
||||||
|
if (queryParam) {
|
||||||
|
messageInput.value = queryParam;
|
||||||
|
urlParams.delete('q');
|
||||||
|
|
||||||
|
let newUrl = window.location.pathname;
|
||||||
|
if (urlParams.toString()) {
|
||||||
|
newUrl = `${window.location.pathname}?${urlParams.toString()}`;
|
||||||
|
}
|
||||||
|
window.history.replaceState({}, '', newUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getQueryParam();
|
||||||
|
|
||||||
// Focus on input
|
// Focus on input
|
||||||
messageInput.focus();
|
messageInput.focus();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user