Skip to content

Commit eada824

Browse files
authored
1 parent 650e9e2 commit eada824

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/opencode/src/cli/cmd/tui/context/path-format.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function usePathFormatter() {
2424
}
2525

2626
function formatPath(input: string | undefined, base: string | undefined) {
27-
if (!input) return ""
27+
if (typeof input !== "string" || !input) return ""
2828

2929
const root = base || process.cwd()
3030
const absolute = path.isAbsolute(input) ? input : path.resolve(root, input)

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,7 @@ function Skill(props: ToolProps<typeof SkillTool>) {
25342534
function Diagnostics(props: { diagnostics?: Record<string, Record<string, any>[]>; filePath: string }) {
25352535
const { theme } = useTheme()
25362536
const errors = createMemo(() => {
2537-
const normalized = Filesystem.normalizePath(props.filePath)
2537+
const normalized = Filesystem.normalizePath(typeof props.filePath === "string" ? props.filePath : "")
25382538
const arr = props.diagnostics?.[normalized] ?? []
25392539
return arr.filter((x) => x.severity === 1).slice(0, 3)
25402540
})
@@ -2564,7 +2564,7 @@ function input(input: Record<string, any>, omit?: string[]): string {
25642564
}
25652565

25662566
function filetype(input?: string) {
2567-
if (!input) return "none"
2567+
if (typeof input !== "string" || !input) return "none"
25682568
const ext = path.extname(input)
25692569
const language = LANGUAGE_EXTENSIONS[ext]
25702570
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"

packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { usePathFormatter } from "../../context/path-format"
2121
type PermissionStage = "permission" | "always" | "reject"
2222

2323
function filetype(input?: string) {
24-
if (!input) return "none"
24+
if (typeof input !== "string" || !input) return "none"
2525
const ext = path.extname(input)
2626
const language = LANGUAGE_EXTENSIONS[ext]
2727
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"
@@ -35,8 +35,14 @@ function EditBody(props: { request: PermissionRequest }) {
3535
const config = useTuiConfig()
3636
const dimensions = useTerminalDimensions()
3737

38-
const filepath = createMemo(() => (props.request.metadata?.filepath as string) ?? "")
39-
const diff = createMemo(() => (props.request.metadata?.diff as string) ?? "")
38+
const filepath = createMemo(() => {
39+
const value = props.request.metadata?.filepath
40+
return typeof value === "string" ? value : ""
41+
})
42+
const diff = createMemo(() => {
43+
const value = props.request.metadata?.diff
44+
return typeof value === "string" ? value : ""
45+
})
4046

4147
const view = createMemo(() => {
4248
const diffStyle = config.diff_style

0 commit comments

Comments
 (0)