app: prefer using useLocation instead of window.location (#15989)

This commit is contained in:
Brendan Allan
2026-03-05 14:41:12 +08:00
committed by GitHub
parent f363904feb
commit 7948de1612
8 changed files with 49 additions and 43 deletions

View File

@@ -52,6 +52,7 @@ import { TextShimmer } from "./text-shimmer"
import { AnimatedCountList } from "./tool-count-summary"
import { ToolStatusTitle } from "./tool-status-title"
import { animate } from "motion"
import { useLocation } from "@solidjs/router"
function ShellSubmessage(props: { text: string; animate?: boolean }) {
let widthRef: HTMLSpanElement | undefined
@@ -1471,6 +1472,7 @@ ToolRegistry.register({
render(props) {
const data = useData()
const i18n = useI18n()
const location = useLocation()
const childSessionId = () => props.metadata.sessionId as string | undefined
const title = createMemo(() => i18n.t("ui.tool.agent", { type: props.input.subagent_type || props.tool }))
const description = createMemo(() => {
@@ -1487,8 +1489,7 @@ ToolRegistry.register({
const direct = data.sessionHref?.(sessionId)
if (direct) return direct
if (typeof window === "undefined") return
const path = window.location.pathname
const path = location.pathname
const idx = path.indexOf("/session")
if (idx === -1) return
return `${path.slice(0, idx)}/session/${sessionId}`