Normalize active session ids in frontend
This commit is contained in:
@@ -209,13 +209,15 @@ function SessionFilesPanel({
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
async function loadFiles() {
|
||||
const activeSessionId =
|
||||
sessionId ?? window.localStorage.getItem("claw.activeSessionId");
|
||||
const activeSessionId = normalizeSessionId(
|
||||
sessionId ?? window.localStorage.getItem("claw.activeSessionId"),
|
||||
);
|
||||
if (!activeSessionId) {
|
||||
setPayload({ input: [], output: [] });
|
||||
setStatus("当前还没有可用会话。");
|
||||
return;
|
||||
}
|
||||
window.localStorage.setItem("claw.activeSessionId", activeSessionId);
|
||||
setStatus("正在读取聊天中的文件...");
|
||||
try {
|
||||
const url = new URL("/api/claw/files", window.location.origin);
|
||||
@@ -280,6 +282,12 @@ function SessionFilesPanel({
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeSessionId(value: unknown) {
|
||||
if (typeof value !== "string") return null;
|
||||
const trimmed = value.trim();
|
||||
return trimmed || null;
|
||||
}
|
||||
|
||||
function FileSection({
|
||||
title,
|
||||
files,
|
||||
|
||||
Reference in New Issue
Block a user