diff --git a/packages/tui/src/feature-plugins/sidebar/footer.tsx b/packages/tui/src/feature-plugins/sidebar/footer.tsx index c90281550985..a4fe2d0200a9 100644 --- a/packages/tui/src/feature-plugins/sidebar/footer.tsx +++ b/packages/tui/src/feature-plugins/sidebar/footer.tsx @@ -21,11 +21,10 @@ function View(props: { api: TuiPluginApi; sessionID: string }) { const dir = session?.directory || props.api.state.path.directory || paths.cwd const out = abbreviateHome(dir, paths.home) const branch = session?.directory === props.api.state.path.directory ? props.api.state.vcs?.branch : undefined - const text = branch ? out + ":" + branch : out - const list = text.split("/") + const list = out.split("/") return { parent: list.slice(0, -1).join("/"), - name: list.at(-1) ?? "", + name: (list.at(-1) ?? "") + (branch ? ":" + branch : ""), } }) @@ -65,7 +64,7 @@ function View(props: { api: TuiPluginApi; sessionID: string }) { - {path().parent}/ + {path().parent}{path().parent ? "/" : ""} {path().name} diff --git a/packages/tui/src/feature-plugins/system/diff-viewer-file-tree.tsx b/packages/tui/src/feature-plugins/system/diff-viewer-file-tree.tsx index cb15eaa5034a..291612b86f35 100644 --- a/packages/tui/src/feature-plugins/system/diff-viewer-file-tree.tsx +++ b/packages/tui/src/feature-plugins/system/diff-viewer-file-tree.tsx @@ -85,14 +85,14 @@ export function DiffViewerFileTree(props: DiffViewerFileTreeProps) { backgroundColor={highlighted() ? props.theme.primary : undefined} onMouseUp={() => props.onRowClick?.(row)} > - + {prefix()} diff --git a/packages/tui/src/routes/session/index.tsx b/packages/tui/src/routes/session/index.tsx index c3bedf98ca15..d9d0a0576473 100644 --- a/packages/tui/src/routes/session/index.tsx +++ b/packages/tui/src/routes/session/index.tsx @@ -1460,7 +1460,7 @@ function UserMessage(props: { const directory = file.mime === "application/x-directory" return ( - + {directory ? " Directory " : " File "} {file.filename} diff --git a/packages/tui/src/theme/index.ts b/packages/tui/src/theme/index.ts index 3a50d737fece..260863668948 100644 --- a/packages/tui/src/theme/index.ts +++ b/packages/tui/src/theme/index.ts @@ -101,16 +101,18 @@ export function selectedForeground(theme: Theme, bg?: RGBA): RGBA { // For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary) if (theme.background.a === 0) { - const targetColor = bg ?? theme.primary - const { r, g, b } = targetColor - const luminance = 0.299 * r + 0.587 * g + 0.114 * b - return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255) + return contrastForeground(bg ?? theme.primary) } // Fall back to background color return theme.background } +function contrastForeground(bg: RGBA): RGBA { + const luminance = 0.299 * bg.r + 0.587 * bg.g + 0.114 * bg.b + return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255) +} + type HexColor = `#${string}` type RefName = string type Variant = { @@ -277,6 +279,8 @@ export function resolveTheme(theme: ThemeJson, mode: "dark" | "light") { const hasSelectedListItemText = theme.theme.selectedListItemText !== undefined if (hasSelectedListItemText) { resolved.selectedListItemText = resolveColor(theme.theme.selectedListItemText!) + } else if (resolved.background?.a === 0) { + resolved.selectedListItemText = contrastForeground(resolved.primary ?? RGBA.fromInts(0, 0, 0)) } else { // Backward compatibility: if selectedListItemText is not defined, use background color // This preserves the current behavior for all existing themes