Compare commits

...

2 Commits

Author SHA1 Message Date
Simon Klee 6d94287b99 dont change api 2026-06-02 23:10:13 +02:00
Simon Klee ce9f61014a tui: guard path formatting inputs
Issue #29895
2026-06-02 22:43:51 +02:00
3 changed files with 12 additions and 6 deletions
@@ -24,7 +24,7 @@ export function usePathFormatter() {
}
function formatPath(input: string | undefined, base: string | undefined) {
if (!input) return ""
if (typeof input !== "string" || !input) return ""
const root = base || process.cwd()
const absolute = path.isAbsolute(input) ? input : path.resolve(root, input)
@@ -2478,7 +2478,7 @@ function Skill(props: ToolProps<typeof SkillTool>) {
function Diagnostics(props: { diagnostics?: Record<string, Record<string, any>[]>; filePath: string }) {
const { theme } = useTheme()
const errors = createMemo(() => {
const normalized = Filesystem.normalizePath(props.filePath)
const normalized = Filesystem.normalizePath(typeof props.filePath === "string" ? props.filePath : "")
const arr = props.diagnostics?.[normalized] ?? []
return arr.filter((x) => x.severity === 1).slice(0, 3)
})
@@ -2508,7 +2508,7 @@ function input(input: Record<string, any>, omit?: string[]): string {
}
function filetype(input?: string) {
if (!input) return "none"
if (typeof input !== "string" || !input) return "none"
const ext = path.extname(input)
const language = LANGUAGE_EXTENSIONS[ext]
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"
@@ -21,7 +21,7 @@ import { usePathFormatter } from "../../context/path-format"
type PermissionStage = "permission" | "always" | "reject"
function filetype(input?: string) {
if (!input) return "none"
if (typeof input !== "string" || !input) return "none"
const ext = path.extname(input)
const language = LANGUAGE_EXTENSIONS[ext]
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"
@@ -35,8 +35,14 @@ function EditBody(props: { request: PermissionRequest }) {
const config = useTuiConfig()
const dimensions = useTerminalDimensions()
const filepath = createMemo(() => (props.request.metadata?.filepath as string) ?? "")
const diff = createMemo(() => (props.request.metadata?.diff as string) ?? "")
const filepath = createMemo(() => {
const value = props.request.metadata?.filepath
return typeof value === "string" ? value : ""
})
const diff = createMemo(() => {
const value = props.request.metadata?.diff
return typeof value === "string" ? value : ""
})
const view = createMemo(() => {
const diffStyle = config.diff_style