fix session routing and subagent visibility

This commit is contained in:
wuyang6
2026-06-12 11:06:04 +08:00
parent a6e7d2260b
commit 40d7c92a1d
9 changed files with 447 additions and 45 deletions
@@ -92,8 +92,9 @@ import {
writePendingWorkspaceSessionId,
} from "@/lib/claw-active-session";
import { useClawSessionReplay } from "@/lib/claw-session-replay";
import { cn } from "@/lib/utils";
import { readSessionIdFromUrl } from "@/lib/claw-session-url";
import { dispatchSkillToggled } from "@/lib/use-training-mode";
import { cn } from "@/lib/utils";
type ComposerInsertEvent = CustomEvent<{ text: string }>;
@@ -396,21 +397,25 @@ function usePendingWorkspaceSessionId() {
function useActiveSessionId() {
const [sessionId, setSessionId] = useState<string | null>(() =>
typeof window !== "undefined"
? normalizeSessionId(readActiveSessionId())
? normalizeSessionId(readSessionIdFromUrl() ?? readActiveSessionId())
: null,
);
useEffect(() => {
const refresh = () => {
setSessionId(normalizeSessionId(readActiveSessionId()));
setSessionId(
normalizeSessionId(readSessionIdFromUrl() ?? readActiveSessionId()),
);
};
window.addEventListener(ACTIVE_SESSION_CHANGED_EVENT, refresh);
window.addEventListener("storage", refresh);
window.addEventListener("focus", refresh);
window.addEventListener("popstate", refresh);
return () => {
window.removeEventListener(ACTIVE_SESSION_CHANGED_EVENT, refresh);
window.removeEventListener("storage", refresh);
window.removeEventListener("focus", refresh);
window.removeEventListener("popstate", refresh);
};
}, []);
@@ -1349,7 +1354,9 @@ function useComposerContextStatus() {
const statePayload = stateResponse.ok
? ((await stateResponse.json()) as ClawState)
: {};
const activeSessionId = normalizeSessionId(readActiveSessionId());
const activeSessionId = normalizeSessionId(
readSessionIdFromUrl() ?? readActiveSessionId(),
);
const latestMessageSessionId = normalizeSessionId(latestSessionId);
let sessionId = normalizeSessionId(
isRunning
@@ -2088,7 +2095,10 @@ const ActivityChainSummary: FC<{
liveStartedAtRef.current = authoritativeStartedAt;
} else if (liveStartedAtRef.current === null && storedElapsedMs !== null) {
liveStartedAtRef.current = Date.now() - storedElapsedMs;
} else if (liveStartedAtRef.current === null && messageCreatedAtMs !== null) {
} else if (
liveStartedAtRef.current === null &&
messageCreatedAtMs !== null
) {
liveStartedAtRef.current = messageCreatedAtMs;
}
const startedAt = liveStartedAtRef.current;