@@ -1,8 +1,10 @@
11 import { useState, useEffect } from "react";
22
3-export function useModelSettings(onError?: (error: string) => void) {
3+export function useSettings(onError?: (error: string) => void) {
44 const [selectedModel, setSelectedModel] = useState<string>("gpt-oss");
55 const [maxPromptLength, setMaxPromptLength] = useState<"none" | 1024 | 4096>("none");
6+ const [location, setLocation] = useState<string | undefined>(undefined);
7+ const [currentTime, setCurrentTime] = useState<string | undefined>(undefined);
68
79 // Load settings from API and validate model against available models
810 useEffect(() => {
@@ -20,8 +22,10 @@ export function useModelSettings(onError?: (error: string) => void) {
2022 }
2123 const settingsData = await settingsRes.json();
2224 const settings = settingsData.settings || {};
23- const savedModel = settings.selectedModel || "gpt-oss";
25+ const savedModel = settings.selectedModel || "";
2426 const savedMaxPromptLength = settings.maxPromptLength || "none";
27+ const savedLocation = settings.location;
28+ const savedCurrentTime = settings.currentTime;
2529
2630 // Get available models
2731 const modelsRes = await fetch("/api/models");
@@ -38,6 +42,25 @@ export function useModelSettings(onError?: (error: string) => void) {
3842
3943 // Set maxPromptLength
4044 setMaxPromptLength(savedMaxPromptLength);
45+ // Set location and currentTime
46+ setLocation(savedLocation);
47+ setCurrentTime(savedCurrentTime);
48+
49+ // Post current time in ISO format to settings on app start
50+ const currentTimeISO = new Date().toISOString();
51+ try {
52+ await fetch("/api/settings", {
53+ method: "POST",
54+ headers: { "Content-Type": "application/json" },
55+ body: JSON.stringify({ currentTime: currentTimeISO }),
56+ });
57+ setCurrentTime(currentTimeISO);
58+ } catch (error) {
59+ // Silently fail - don't block app startup if time update fails
60+ if (onError && error instanceof Error) {
61+ onError(error.message);
62+ }
63+ }
4164
4265 if (availableModels.length === 0) {
4366 // No models available, keep default
@@ -69,8 +92,10 @@ export function useModelSettings(onError?: (error: string) => void) {
6992 onError(error.message);
7093 }
7194 // On error, keep defaults
72- setSelectedModel("gpt-oss");
95+ setSelectedModel("");
7396 setMaxPromptLength("none");
97+ setLocation(undefined);
98+ setCurrentTime(undefined);
7499 }
75100 };
76101
@@ -132,3 +157,4 @@ export function useModelSettings(onError?: (error: string) => void) {
132157 handleMaxPromptLengthChange,
133158 };
134159 }
160+