Compare commits

..
Author SHA1 Message Date
jialin 1451a49da2 feat: namespace browser storage keys by deploy path 2026-07-15 09:46:27 +08:00
27 changed files with 59 additions and 122 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
"@ant-design/pro-components": "3.1.0-0",
"@antv/g6": "^5.0.51",
"@braintree/sanitize-url": "^7.1.1",
"@gpustack/core-ui": "^1.0.38",
"@gpustack/core-ui": "^1.0.36",
"@huggingface/gguf": "^0.1.7",
"@huggingface/hub": "^0.15.1",
"@huggingface/tasks": "^0.11.6",
+5 -5
View File
@@ -24,8 +24,8 @@ importers:
specifier: ^7.1.1
version: 7.1.2
'@gpustack/core-ui':
specifier: ^1.0.38
version: 1.0.38(czdvzceysqw7iv6pct2ucnb23e)
specifier: ^1.0.36
version: 1.0.36(czdvzceysqw7iv6pct2ucnb23e)
'@huggingface/gguf':
specifier: ^0.1.7
version: 0.1.18
@@ -1481,8 +1481,8 @@ packages:
resolution: {integrity: sha512-KWk80UPIzPmUg+P0rKh6TqspRw0G6eux1PuJr+zz47ftMaZ9QDwbGzHZbtzWkl5hgayM/qrKRutllRC7D/vVXQ==, tarball: https://registry.npmjs.org/@formatjs/intl-utils/-/intl-utils-2.3.0.tgz}
deprecated: the package is rather renamed to @formatjs/ecma-abstract with some changes in functionality (primarily selectUnit is removed and we don't plan to make any further changes to this package
'@gpustack/core-ui@1.0.38':
resolution: {integrity: sha512-7+38qgsFwubb1HyQreICkG1aWcXHM48MXoLY8D14aO6GYWYaO6G4NSkBrXHgpAnB4y3ReYfObH8l3Naq/0YgZw==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.38.tgz}
'@gpustack/core-ui@1.0.36':
resolution: {integrity: sha512-gF8ShMZ2SKYo3+skfsI3zo+aBSsXqKGMX+jWaKv81e38bDwJw71C33TR64d+6MyV9iUoFOoSK+ht1GefyvR17g==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.36.tgz}
peerDependencies:
'@ant-design/icons': ^6.1.0
'@ant-design/pro-components': 3.1.0-0
@@ -10802,7 +10802,7 @@ snapshots:
'@formatjs/intl-utils@2.3.0': {}
'@gpustack/core-ui@1.0.38(czdvzceysqw7iv6pct2ucnb23e)':
'@gpustack/core-ui@1.0.36(czdvzceysqw7iv6pct2ucnb23e)':
dependencies:
'@ant-design/icons': 6.2.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@ant-design/pro-components': 3.1.0-0(antd@6.3.7(date-fns@2.30.0)(moment@2.30.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
-31
View File
@@ -9,15 +9,6 @@
}
}
@keyframes tableEmptyFadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.scroll-table {
.ant-table {
.ant-table-container {
@@ -27,27 +18,5 @@
scrollbar-color: var(--color-scrollbar-thumb) transparent;
}
}
// Reserve a stable block for the empty/loading state so the first-load
// spinner and the empty result occupy the same height as eventual data —
// this removes the layout jump when entering the page. Scoped to
// `.ant-table-content` so it only targets x-scroll tables (whose empty
// row lives here) and leaves fixed-height `scroll.y` tables untouched.
// Height must match the `minHeight` passed to <NoResult> in
// use-no-resource-result.
.ant-table-content {
.ant-table-placeholder {
> .ant-table-cell {
height: calc(100vh - 300px);
}
// NoResult renders nothing while loading and mounts an <Empty> only
// once the request settles, so this fires exactly when the empty
// state appears — a seamless fade-in instead of a hard pop.
.ant-empty {
animation: tableEmptyFadeIn 0.3s ease-in-out;
}
}
}
}
}
+2 -1
View File
@@ -1,3 +1,4 @@
import { nsLocalJSONStorage } from '@gpustack/core-ui/utils';
import { getDefaultStore } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
@@ -8,7 +9,7 @@ export interface PaginationState {
export const paginationAtom = atomWithStorage<Record<string, any>>(
'paginationStatus',
{},
undefined,
nsLocalJSONStorage,
{ getOnInit: true }
);
+10 -7
View File
@@ -1,4 +1,5 @@
import { COLOR_PRIMARY } from '@/config/theme';
import { nsLocal, nsLocalJSONStorage } from '@gpustack/core-ui/utils';
import { atom } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
@@ -23,9 +24,7 @@ export const defaultSettings: UserSettings = {
export const getStorageUserSettings = () => {
if (typeof window === 'undefined') return defaultSettings;
try {
const savedSettings = JSON.parse(
localStorage.getItem('userSettings') || '{}'
);
const savedSettings = JSON.parse(nsLocal.get('userSettings') || '{}');
return {
...defaultSettings,
...savedSettings
@@ -35,9 +34,13 @@ export const getStorageUserSettings = () => {
}
};
export const userSettingsAtom = atomWithStorage<UserSettings>('userSettings', {
...getStorageUserSettings()
});
export const userSettingsAtom = atomWithStorage<UserSettings>(
'userSettings',
{
...getStorageUserSettings()
},
nsLocalJSONStorage
);
export const userSettingsHelperAtom = atom(
(get) => get(userSettingsAtom),
@@ -59,6 +62,6 @@ export const hideModalTemporarilyAtom = atom<boolean>(false);
export const collapsedMenuGroupsAtom = atomWithStorage<string[]>(
'collapsedMenuGroups',
[],
undefined,
nsLocalJSONStorage,
{ getOnInit: true }
);
+3 -1
View File
@@ -1,9 +1,11 @@
import { nsLocalJSONStorage } from '@gpustack/core-ui/utils';
import { getDefaultStore } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
export const tabActiveAtom = atomWithStorage<Map<string, any>>(
'tabActiveStatus',
new Map()
new Map(),
nsLocalJSONStorage
);
export const setActiveStatus = (key: string, value: any) => {
+10 -4
View File
@@ -1,7 +1,12 @@
import { nsLocal, nsLocalJSONStorage } from '@gpustack/core-ui/utils';
import { atom } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
export const userAtom = atomWithStorage<any>('userInfo', null);
export const userAtom = atomWithStorage<any>(
'userInfo',
null,
nsLocalJSONStorage
);
// Backs the `currentOrganizationId` localStorage key. Stays null in
// builds with no Org context (single-tenant), and is shared with any
@@ -9,7 +14,8 @@ export const userAtom = atomWithStorage<any>('userInfo', null);
// without one side having to import from the other.
export const currentOrganizationIdAtom = atomWithStorage<number | null>(
'currentOrganizationId',
null
null,
nsLocalJSONStorage
);
export const GPUStackVersionAtom = atom<{
@@ -70,7 +76,7 @@ export const getCurrentOrgNamespace = (
const getStoredCurrentOrgId = (): number | null => {
try {
const raw = localStorage.getItem('currentOrganizationId');
const raw = nsLocal.get('currentOrganizationId');
if (!raw) return null;
const value = JSON.parse(raw);
return typeof value === 'number' ? value : null;
@@ -108,7 +114,7 @@ export const getOrgById = (
const target = String(id);
for (const key of ORG_CACHE_KEYS) {
try {
const raw = localStorage.getItem(key);
const raw = nsLocal.get(key);
if (!raw) continue;
const list = JSON.parse(raw) as CachedOrg[];
if (!Array.isArray(list)) continue;
+4 -5
View File
@@ -1,18 +1,17 @@
import { defaultSettings } from '@/atoms/settings';
import { nsLocal } from '@gpustack/core-ui/utils';
import { getDefaultStore } from 'jotai';
export const clearStorageUserSettings = () => {
try {
const savedSettings = JSON.parse(
localStorage.getItem('userSettings') || '{}'
);
const savedSettings = JSON.parse(nsLocal.get('userSettings') || '{}');
// colorPrimary is an enterprise-wide branding setting (set by admins
// and applied by `onAppInit` from /enterprise/settings), not a per-user
// preference. Preserve it across login — otherwise the next layout
// mount triggers `atomWithStorage.onMount`, re-reads localStorage,
// and falls back to the default color until a full page refresh
// re-runs `applyEnterpriseSettings`.
localStorage.setItem(
nsLocal.set(
'userSettings',
JSON.stringify({
...savedSettings,
@@ -26,7 +25,7 @@ export const clearStorageUserSettings = () => {
export const resetStorageUserSettings = () => {
try {
localStorage.setItem(
nsLocal.set(
'userSettings',
JSON.stringify({
...defaultSettings,
+2 -8
View File
@@ -40,11 +40,6 @@ export default function useWatchList<T = Record<string, any>>(API: string) {
}
});
const cancelWatch = useMemoizedFn(() => {
chunkRequestRef.current?.current?.cancel?.();
listRequestTokenRef.current?.cancel?.();
});
const queryAllDataList = async (
params: Global.SearchParams,
options?: any
@@ -83,15 +78,14 @@ export default function useWatchList<T = Record<string, any>>(API: string) {
useEffect(() => {
createWatchChunkRequest();
return () => {
cancelWatch();
chunkRequestRef.current?.cancel?.();
listRequestTokenRef.current?.cancel?.();
};
}, []);
return {
watchDataList,
setWatchDataList,
startWatch: createWatchChunkRequest,
cancelWatch,
deleteItemFromCache: handleDeleteItemFromCache
};
}
+3 -5
View File
@@ -1,5 +1,6 @@
import externalLinks from '@/constants/external-links';
import { GithubFilled } from '@ant-design/icons';
import { nsLocal } from '@gpustack/core-ui/utils';
import { useIntl } from '@umijs/max';
import { Tooltip } from 'antd';
import { useEffect, useState } from 'react';
@@ -66,7 +67,7 @@ type CacheEntry = { value: number; time: number };
const readCache = (): CacheEntry | null => {
try {
const raw = localStorage.getItem(CACHE_KEY);
const raw = nsLocal.get(CACHE_KEY);
if (!raw) return null;
const parsed = JSON.parse(raw);
if (typeof parsed?.value !== 'number' || typeof parsed?.time !== 'number') {
@@ -80,10 +81,7 @@ const readCache = (): CacheEntry | null => {
const writeCache = (value: number) => {
try {
localStorage.setItem(
CACHE_KEY,
JSON.stringify({ value, time: Date.now() })
);
nsLocal.set(CACHE_KEY, JSON.stringify({ value, time: Date.now() }));
} catch {
// ignore quota errors
}
-1
View File
@@ -232,7 +232,6 @@ const APIKeys: React.FC = () => {
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataSource.dataList}
rowSelection={rowSelection}
@@ -395,7 +395,6 @@ const Clusters: React.FC = () => {
>
<SealTable
rowKey="id"
emptyMinHeight="calc(100vh - 300px)"
loadChildren={getWorkerPoolList}
sortDirections={TABLE_SORT_DIRECTIONS}
expandedRowKeys={expandedRowKeys}
@@ -200,7 +200,6 @@ const Credentials: React.FC = () => {
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
tableLayout="fixed"
columns={columns}
dataSource={dataSource.dataList}
@@ -362,7 +362,6 @@ const GPUService: React.FC = () => {
/>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataSource.dataList}
rowSelection={rowSelection}
@@ -154,7 +154,6 @@ const GPUServicePublicKeys: React.FC = () => {
/>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataSource.dataList}
rowSelection={rowSelection}
@@ -150,7 +150,6 @@ const GPUServiceStorageTypes: React.FC = () => {
/>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataSource.dataList}
rowSelection={rowSelection}
-1
View File
@@ -151,7 +151,6 @@ const GPUServiceStorage: React.FC = () => {
/>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataSource.dataList}
rowSelection={rowSelection}
+4 -4
View File
@@ -5,7 +5,9 @@ import { PageActionType } from '@/config/types';
import useBodyScroll from '@/hooks/use-body-scroll';
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
import useTableRowSelection from '@/hooks/use-table-row-selection';
import useWatchList from '@/hooks/use-watch-list';
import useNoResourceResult from '@/pages/llmodels/hooks/use-no-resource-result';
import { MODEL_ROUTE_TARGETS } from '@/pages/model-routes/apis';
import { TargetStatusValueMap } from '@/pages/model-routes/config';
import useOpenPlayground from '@/pages/model-routes/hooks/use-open-playground';
import useGranfanaLink from '@/pages/resources/hooks/use-grafana-link';
@@ -90,7 +92,6 @@ interface ModelsProps {
loadend: boolean;
total: number;
filterValues?: Record<string, any>;
targetList?: any[];
}
const getFormattedData = (record: any, extraData = {}) => ({
@@ -128,8 +129,7 @@ const Models: React.FC<ModelsProps> = ({
queryParams,
loading,
loadend,
total,
targetList = []
total
}) => {
const { generateFormValues, clusterList, workerList } =
useDeploymentsContext();
@@ -155,6 +155,7 @@ const Models: React.FC<ModelsProps> = ({
expandedRowKeys
} = useExpandedRowKeys(expandAtom);
const { handleOpenPlayGround } = useOpenPlayground();
const { watchDataList: targetList } = useWatchList(MODEL_ROUTE_TARGETS);
const { openViewLogsModal, openViewLogsModalStatus, closeViewLogsModal } =
useViewInstanceLogs();
@@ -613,7 +614,6 @@ const Models: React.FC<ModelsProps> = ({
></PageTools>
<SealTable
columns={columns}
emptyMinHeight="calc(100vh - 300px)"
sortDirections={TABLE_SORT_DIRECTIONS}
dataSource={dataSource}
rowSelection={rowSelection}
-10
View File
@@ -3,8 +3,6 @@ import useSetChunkRequest from '@/hooks/use-chunk-request';
import { usePaginationStatus } from '@/hooks/use-pagination-status';
import { useTableMultiSort } from '@/hooks/use-table-sort';
import useUpdateChunkedList from '@/hooks/use-update-chunk-list';
import useWatchList from '@/hooks/use-watch-list';
import { MODEL_ROUTE_TARGETS } from '@/pages/model-routes/apis';
import { TableOrder, TableProvider } from '@gpustack/core-ui';
import { useMemoizedFn } from 'ahooks';
import _ from 'lodash';
@@ -33,11 +31,6 @@ const Models = forwardRef((props, ref) => {
const { setChunkRequest, createAxiosToken } = useSetChunkRequest();
const { setChunkRequest: setModelInstanceChunkRequest } =
useSetChunkRequest();
const {
watchDataList: targetList,
startWatch: startTargetsWatch,
cancelWatch: cancelTargetsWatch
} = useWatchList(MODEL_ROUTE_TARGETS);
const [modelInstances, setModelInstances] = useState<any[]>([]);
const [dataSource, setDataSource] = useState<{
dataList: ListItem[];
@@ -262,7 +255,6 @@ const Models = forwardRef((props, ref) => {
cacheInsDataListRef.current = [];
chunkInstanceRequedtRef.current?.current?.cancel?.();
instancesToken.current?.cancel?.();
cancelTargetsWatch();
});
const resumeRequestsOnPageActive = useMemoizedFn(async () => {
@@ -273,7 +265,6 @@ const Models = forwardRef((props, ref) => {
await getAllModelInstances();
await createModelsInstanceChunkRequest();
await createModelsChunkRequest();
await startTargetsWatch();
});
const handleOnCancelViewLogs = useMemoizedFn(async () => {
@@ -492,7 +483,6 @@ const Models = forwardRef((props, ref) => {
total={dataSource.total}
deleteIds={dataSource.deletedIds}
filterValues={filterValues}
targetList={targetList}
></TableList>
</TableProvider>
);
-1
View File
@@ -159,7 +159,6 @@ const MaasProvider: React.FC = () => {
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
rowKey="id"
tableLayout="fixed"
sortDirections={TABLE_SORT_DIRECTIONS}
-1
View File
@@ -364,7 +364,6 @@ const ModelRoutes: React.FC = () => {
>
<SealTable
rowKey="id"
emptyMinHeight="calc(100vh - 300px)"
loadChildren={loadChildrenData}
sortDirections={TABLE_SORT_DIRECTIONS}
expandedRowKeys={expandedRowKeys}
+2 -2
View File
@@ -123,14 +123,14 @@ const GPUList: React.FC<GPUListProps> = ({ clusterId, source }) => {
columns={columns}
sortDirections={TABLE_SORT_DIRECTIONS}
showSorterTooltip={false}
scroll={{ x: 'max-content' }}
className={'scroll-table'}
tableLayout={'auto'}
dataSource={dataSource.dataList}
loading={{
spinning: dataSource.loading,
size: 'middle'
}}
rowKey="id"
scroll={{ x: 900 }}
onChange={handleTableChange}
pagination={{
showSizeChanger: true,
@@ -340,7 +340,6 @@ const ModelFiles = () => {
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
rowKey="id"
tableLayout="fixed"
sortDirections={TABLE_SORT_DIRECTIONS}
+2 -1
View File
@@ -303,7 +303,7 @@ const Workers: React.FC<WorkersProps> = ({ clusterId, source }) => {
columns={columns}
sortDirections={TABLE_SORT_DIRECTIONS}
showSorterTooltip={false}
scroll={{ x: 'max-content' }}
tableLayout={'auto'}
className={'scroll-table'}
dataSource={dataSource.dataList}
loading={{
@@ -311,6 +311,7 @@ const Workers: React.FC<WorkersProps> = ({ clusterId, source }) => {
size: 'middle'
}}
rowKey="id"
scroll={{ x: 900 }}
onChange={handleTableChange}
rowSelection={source === 'clusterDetail' ? undefined : rowSelection}
pagination={{
-1
View File
@@ -186,7 +186,6 @@ const Users: React.FC = () => {
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
className={'scroll-table'}
columns={columns}
dataSource={dataList}
rowSelection={rowSelection}
+8 -24
View File
@@ -10,6 +10,7 @@
import { queryClusterList } from '@/pages/cluster-management/apis';
import { ProviderValueMap } from '@/pages/cluster-management/config';
import { queryResourceEvents } from '@/pages/usage/apis/resource';
import { nsSession } from '@gpustack/core-ui/utils';
// Probes the caller's cluster list once so access predicates can gate
// GPU Service (Kubernetes-only). Cheap (one list request) and never
@@ -33,20 +34,13 @@ export const probeHasKubernetesCluster = async (): Promise<
const value = (res?.items ?? []).some(
(c) => c?.provider === ProviderValueMap.Kubernetes
);
try {
window.sessionStorage.setItem(HAS_K8S_CLUSTER_KEY, JSON.stringify(value));
} catch {
// sessionStorage may be unavailable (Safari private mode); the
// access predicate already handles a missing value as "unknown".
}
// nsSession swallows write errors (Safari private mode); the access
// predicate already handles a missing value as "unknown".
nsSession.set(HAS_K8S_CLUSTER_KEY, JSON.stringify(value));
return value;
} catch (error) {
console.error('probeHasKubernetesCluster error', error);
try {
window.sessionStorage.removeItem(HAS_K8S_CLUSTER_KEY);
} catch {
// ignore
}
nsSession.remove(HAS_K8S_CLUSTER_KEY);
return undefined;
}
};
@@ -69,22 +63,12 @@ export const probeHasResourceEvents = async (): Promise<
}
);
const value = (res?.pagination?.total ?? 0) > 0;
try {
window.sessionStorage.setItem(
HAS_RESOURCE_EVENTS_KEY,
JSON.stringify(value)
);
} catch {
// sessionStorage may be unavailable; predicate treats missing as unknown.
}
// nsSession swallows write errors; predicate treats missing as unknown.
nsSession.set(HAS_RESOURCE_EVENTS_KEY, JSON.stringify(value));
return value;
} catch (error) {
console.error('probeHasResourceEvents error', error);
try {
window.sessionStorage.removeItem(HAS_RESOURCE_EVENTS_KEY);
} catch {
// ignore
}
nsSession.remove(HAS_RESOURCE_EVENTS_KEY);
return undefined;
}
};
+3 -2
View File
@@ -1,3 +1,4 @@
import { NS_STORE_NAME } from '@gpustack/core-ui/utils';
import localStore from './store';
const IS_FIRST_LOGIN = 'is_first_login';
@@ -5,7 +6,7 @@ const IS_FIRST_LOGIN = 'is_first_login';
const REMEMBER_ME_KEY = 'r_m';
const CRYPT_TEXT = 'seal';
const store = localStore.createInstance({ name: '_xWXJKJ_S1Sna_' });
const store = localStore.createInstance({ name: NS_STORE_NAME });
// Kept to remove credentials saved by the old "remember me" feature.
const removeRememberMe = (key: string) => {
@@ -37,9 +38,9 @@ const writeColumnSettings = (key: string, data: any) => {
export {
CRYPT_TEXT,
IS_FIRST_LOGIN,
REMEMBER_ME_KEY,
readColumnSettings,
readState,
REMEMBER_ME_KEY,
removeRememberMe,
writeColumnSettings,
writeState