Extract memind_adm admin server, add local dev tooling, and remove image-generation.
Split platform admin and ops APIs into standalone admin-server.mjs with network guards; simplify billing to RMB token pricing, refactor user auth, and add rsync deploy plus local-test scripts and docs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -306,12 +306,6 @@ export function usePageEditSubChat({
|
||||
}
|
||||
}, [connectSubSession, start]);
|
||||
|
||||
const newSession = useCallback(async () => {
|
||||
if (chatState === 'streaming' || chatState === 'loading' || chatState === 'connecting') return;
|
||||
await close({ merge: false });
|
||||
await start();
|
||||
}, [chatState, close, start]);
|
||||
|
||||
const startedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -341,7 +335,6 @@ export function usePageEditSubChat({
|
||||
dismissNotice,
|
||||
retryConnect,
|
||||
openRecharge: () => setNotice('余额不足,请充值后继续使用'),
|
||||
newSession,
|
||||
close,
|
||||
};
|
||||
}
|
||||
|
||||
+19
-32
@@ -507,43 +507,30 @@ export function useTKMindChat(
|
||||
setChatState('loading');
|
||||
setError(null);
|
||||
|
||||
let sessionId: string | null = null;
|
||||
let sessionId = readStoredSessionId(userRef.current?.id);
|
||||
let staleSession = false;
|
||||
let freshSession: Session | null = null;
|
||||
|
||||
setSessionsLoading(true);
|
||||
try {
|
||||
const items = sortAndTrim(await listSessions());
|
||||
setSessions(items);
|
||||
sessionId = items[0]?.id ?? null;
|
||||
} catch {
|
||||
// Fall back to stored session or create a new one when the list is unavailable.
|
||||
} finally {
|
||||
setSessionsLoading(false);
|
||||
if (sessionId) {
|
||||
try {
|
||||
await getSession(sessionId);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && (err.status === 403 || err.status === 404 || err.status === 400)) {
|
||||
clearStoredSessionId(userRef.current?.id);
|
||||
sessionId = null;
|
||||
staleSession = true;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sessionId) {
|
||||
let staleSession = false;
|
||||
sessionId = readStoredSessionId(userRef.current?.id);
|
||||
if (sessionId) {
|
||||
try {
|
||||
await getSession(sessionId);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && (err.status === 403 || err.status === 404 || err.status === 400)) {
|
||||
clearStoredSessionId(userRef.current?.id);
|
||||
sessionId = null;
|
||||
staleSession = true;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sessionId) {
|
||||
freshSession = await startSession();
|
||||
sessionId = freshSession.id;
|
||||
if (staleSession) {
|
||||
setNotice('上次会话已失效,已为你新建对话');
|
||||
}
|
||||
freshSession = await startSession();
|
||||
sessionId = freshSession.id;
|
||||
writeStoredSessionId(userRef.current?.id, sessionId);
|
||||
if (staleSession) {
|
||||
setNotice('上次会话已失效,已为你新建对话');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user