fix: Address code review findings (backend validation, hydration efficiency, plot readability)
This commit is contained in:
@@ -91,7 +91,7 @@ async def stream_agent_events(
|
|||||||
encoded_plots: list[str] = []
|
encoded_plots: list[str] = []
|
||||||
for fig in plots:
|
for fig in plots:
|
||||||
buf = io.BytesIO()
|
buf = io.BytesIO()
|
||||||
fig.savefig(buf, format="png", transparent=True)
|
fig.savefig(buf, format="png")
|
||||||
plot_bytes = buf.getvalue()
|
plot_bytes = buf.getvalue()
|
||||||
assistant_plots.append(plot_bytes)
|
assistant_plots.append(plot_bytes)
|
||||||
encoded_plots.append(base64.b64encode(plot_bytes).decode('utf-8'))
|
encoded_plots.append(base64.b64encode(plot_bytes).decode('utf-8'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from pydantic import BaseModel, EmailStr
|
from pydantic import BaseModel, EmailStr
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Literal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# --- Auth Schemas ---
|
# --- Auth Schemas ---
|
||||||
@@ -17,10 +17,10 @@ class UserResponse(BaseModel):
|
|||||||
id: str
|
id: str
|
||||||
email: str
|
email: str
|
||||||
display_name: str
|
display_name: str
|
||||||
theme_preference: str
|
theme_preference: Literal["light", "dark"]
|
||||||
|
|
||||||
class ThemeUpdate(BaseModel):
|
class ThemeUpdate(BaseModel):
|
||||||
theme: str
|
theme: Literal["light", "dark"]
|
||||||
|
|
||||||
# --- History Schemas ---
|
# --- History Schemas ---
|
||||||
|
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ def main():
|
|||||||
st.pyplot(fig)
|
st.pyplot(fig)
|
||||||
# Convert fig to bytes
|
# Convert fig to bytes
|
||||||
buf = io.BytesIO()
|
buf = io.BytesIO()
|
||||||
fig.savefig(buf, format="png", transparent=True)
|
fig.savefig(buf, format="png")
|
||||||
plot_bytes_list.append(buf.getvalue())
|
plot_bytes_list.append(buf.getvalue())
|
||||||
|
|
||||||
if final_state.get("dfs"):
|
if final_state.get("dfs"):
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { Button } from "./components/ui/button"
|
|||||||
import { useTheme } from "./components/theme-provider"
|
import { useTheme } from "./components/theme-provider"
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { setTheme } = useTheme()
|
const { setThemeLocal } = useTheme()
|
||||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||||
const [user, setUser] = useState<UserResponse | null>(null)
|
const [user, setUser] = useState<UserResponse | null>(null)
|
||||||
const [authMode, setAuthMode] = useState<"login" | "register">("login")
|
const [authMode, setAuthMode] = useState<"login" | "register">("login")
|
||||||
@@ -37,7 +37,7 @@ function App() {
|
|||||||
setUser(userData)
|
setUser(userData)
|
||||||
setIsAuthenticated(true)
|
setIsAuthenticated(true)
|
||||||
if (userData.theme_preference) {
|
if (userData.theme_preference) {
|
||||||
setTheme(userData.theme_preference as "light" | "dark")
|
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||||
}
|
}
|
||||||
// Load history after successful auth
|
// Load history after successful auth
|
||||||
loadHistory()
|
loadHistory()
|
||||||
@@ -67,7 +67,7 @@ function App() {
|
|||||||
setUser(userData)
|
setUser(userData)
|
||||||
setIsAuthenticated(true)
|
setIsAuthenticated(true)
|
||||||
if (userData.theme_preference) {
|
if (userData.theme_preference) {
|
||||||
setTheme(userData.theme_preference as "light" | "dark")
|
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||||
}
|
}
|
||||||
loadHistory()
|
loadHistory()
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ type Theme = "light" | "dark"
|
|||||||
interface ThemeContextType {
|
interface ThemeContextType {
|
||||||
theme: Theme
|
theme: Theme
|
||||||
setTheme: (theme: Theme) => void
|
setTheme: (theme: Theme) => void
|
||||||
|
setThemeLocal: (theme: Theme) => void
|
||||||
toggleTheme: () => void
|
toggleTheme: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,12 +36,16 @@ export function ThemeProvider({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setThemeLocal = (newTheme: Theme) => {
|
||||||
|
setThemeState(newTheme)
|
||||||
|
}
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
setTheme(theme === "light" ? "dark" : "light")
|
setTheme(theme === "light" ? "dark" : "light")
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeContext.Provider value={{ theme, setTheme, toggleTheme }}>
|
<ThemeContext.Provider value={{ theme, setTheme, setThemeLocal, toggleTheme }}>
|
||||||
{children}
|
{children}
|
||||||
</ThemeContext.Provider>
|
</ThemeContext.Provider>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user