diff --git a/templates/base.html b/templates/base.html
index 7ed5d62..71c754a 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -609,6 +609,27 @@
closeButton.style.display = "none";
}
+ // Function to update all room links with current URL parameters
+ function updateRoomLinksWithCurrentParams() {
+ const currentParams = new URLSearchParams(window.location.search).toString();
+
+ // Update desktop room links
+ const roomLinks = document.querySelectorAll('#rooms-list-ul a[href*="/chat/"]');
+ roomLinks.forEach(link => {
+ const url = new URL(link.href, window.location.origin);
+ const roomPath = url.pathname; // e.g., "/chat/room-name"
+ link.href = roomPath + (currentParams ? '?' + currentParams : '');
+ });
+
+ // Update mobile room links (if they exist)
+ const mobileRoomLinks = document.querySelectorAll('#rooms-list-modal-content a[href*="/chat/"]');
+ mobileRoomLinks.forEach(link => {
+ const url = new URL(link.href, window.location.origin);
+ const roomPath = url.pathname; // e.g., "/chat/room-name"
+ link.href = roomPath + (currentParams ? '?' + currentParams : '');
+ });
+ }
+
// Function to create a new room
function createNewRoom() {
const roomName = document.getElementById("new-room-name").value.trim();
diff --git a/templates/chat.html b/templates/chat.html
index 6b5419f..f95c73c 100644
--- a/templates/chat.html
+++ b/templates/chat.html
@@ -158,12 +158,21 @@ function syncInputsAndQueryString() {
if (modelSelectMobile) modelSelectMobile.value = currentModel;
if (voiceSelectMobile) voiceSelectMobile.value = currentVoice;
+ // Save to localStorage for persistence
+ localStorage.setItem('selectedModel', currentModel);
+ localStorage.setItem('selectedVoice', currentVoice);
+
// Update URL
const newUrl = new URL(window.location.href);
newUrl.searchParams.set("username", sanitizedUsername);
newUrl.searchParams.set("model", currentModel);
newUrl.searchParams.set("voice", currentVoice);
window.history.replaceState({}, '', newUrl);
+
+ // Update room links with new parameters
+ if (typeof updateRoomLinksWithCurrentParams === 'function') {
+ updateRoomLinksWithCurrentParams();
+ }
}
// Backward compatibility
@@ -231,9 +240,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
userHasScrolledUp = distanceFromBottom > 5;
});
- // Set initial model, voice, and username from query string
- const initialModel = urlParams.get("model") || "None";
- const initialVoice = urlParams.get("voice") || "onyx";
+ // Set initial model, voice, and username from URL, localStorage, or defaults
+ const initialModel = urlParams.get("model") || localStorage.getItem('selectedModel') || "None";
+ const initialVoice = urlParams.get("voice") || localStorage.getItem('selectedVoice') || "onyx";
const initialUsername = username; // Already set to URL param or "guest"
modelSelectDesktop.value = initialModel;
@@ -246,6 +255,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
const usernameInputMobile = document.getElementById("username-input-mobile");
if (usernameInputDesktop) usernameInputDesktop.value = initialUsername;
if (usernameInputMobile) usernameInputMobile.value = initialUsername;
+
+ // Initial sync to ensure localStorage and URL are updated with current values
+ syncInputsAndQueryString();
// Add event listeners for desktop dropdowns
modelSelectDesktop.addEventListener("change", () => {