feat(webui): show the full token-usage picture in settings (#6638)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-12 18:13:06 +08:00
1 parent b49218b6a3
commit e6b23c7356
42 files changed
+1116 -342

No files matched your search

+10 -3
View File
@@ -942,6 +942,9 @@ function Shell({
const { skills, loading: skillsLoading, error: skillsError } = useSkills(getToken);
const [settingsSnapshot, setSettingsSnapshot] = useState<SettingsPayload | null>(null);
const [settingsLoading, setSettingsLoading] = useState(true);
const settingsSnapshotRef = useRef(settingsSnapshot);
settingsSnapshotRef.current = settingsSnapshot;
const settingsOwnsSnapshot = view !== "chat" && view !== "remote";
const settingsRefreshGenerationRef = useRef(0);
const [pendingAutomationMessage, setPendingAutomationMessage] = useState<{
id: string;
@@ -1082,10 +1085,14 @@ function Shell({
}, [client]);
useEffect(() => {
if (settingsOwnsSnapshot || settingsSnapshotRef.current !== null) {
setSettingsLoading(false);
return;
}
let cancelled = false;
const requestGeneration = settingsRefreshGenerationRef.current;
setSettingsLoading(true);
fetchSettings(getToken())
fetchSettings(getToken(), "", client)
.then((payload) => {
if (!cancelled && requestGeneration === settingsRefreshGenerationRef.current) {
setSettingsSnapshot(payload);
@@ -1102,7 +1109,7 @@ function Shell({
return () => {
cancelled = true;
};
}, [getToken]);
}, [client, getToken, settingsOwnsSnapshot]);
useEffect(() => {
try {
@@ -1925,7 +1932,7 @@ function Shell({
let cancelled = false;
let retryTimer: number | undefined;
const refreshSettings = (generation: number, attempt = 0): void => {
void fetchSettings(getToken())
void fetchSettings(getToken(), "", client)
.then((payload) => {
if (!cancelled && generation === settingsRefreshGenerationRef.current) {
setSettingsSnapshot(payload);