Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ is-terminal = "0.4.16"
anstream = "0.6.18"
url = "2.5.7"
open = "5.3.2"
urlencoding = "2.1"
Comment thread
michaelneale marked this conversation as resolved.
Outdated

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["wincred"] }
Expand Down
14 changes: 11 additions & 3 deletions crates/goose-cli/src/commands/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use axum::{
ws::{Message, WebSocket, WebSocketUpgrade},
Request, State,
},
http::StatusCode,
http::{StatusCode, Uri},
middleware::{self, Next},
response::{Html, IntoResponse, Response},
routing::get,
Expand Down Expand Up @@ -222,15 +222,23 @@ pub async fn handle_web(
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(
std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")),
"Web session".to_string(),
)
.await
.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(
Expand Down
23 changes: 23 additions & 0 deletions crates/goose-cli/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ async function loadSessionIfExists() {
resumeDiv.innerHTML = `<em>Session resumed: ${sessionData.messages.length} messages loaded</em>`;
messagesContainer.appendChild(resumeDiv);

// Load all messages from session
sessionData.messages.forEach(msg => {
addMessage(msg.content, msg.role, msg.timestamp);
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this related?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, accidentally added that to the commit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, so please remove?


// Update page title with session description if available
if (sessionData.metadata && sessionData.metadata.description) {
Expand Down Expand Up @@ -509,6 +513,25 @@ messageInput.addEventListener('input', () => {
// Initialize WebSocket connection
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);
}
}

// Populate query parameter if present
Comment thread
michaelneale marked this conversation as resolved.
Outdated
getQueryParam();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this means if you reload the page, we put the query into the box again? is that what you want?

@40u5 40u5 Nov 17, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my new pr, it removes the q parameter from the URL so that it wouldn't keep adding the text into the box on reload. open webui does something similar where it submits the message when the q= parameter is included.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is your new PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant new changes to the current pr

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using the URL class seems cleaner, something like:

function getQueryParam() {
const url = new URL(window.location.href);
const query = url.searchParams.get('q');

if (query) {
    messageInput.value = query;
    url.searchParams.delete('q');
    window.history.replaceState({}, '', url.toString());
}

}


// Focus on input
messageInput.focus();

Expand Down