tui: truncate sidebar file paths (#30531)

This commit is contained in:
Simon Klee 2026-06-03 11:54:24 +02:00 committed by GitHub
parent b6f76e29c5
commit 06eecc5a6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,9 +1,16 @@
import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui"
import type { InternalTuiPlugin } from "../../plugin/internal"
import { createMemo, For, Show, createSignal } from "solid-js"
import { Locale } from "@/util/locale"
const id = "internal:sidebar-files"
function changeCountWidth(item: { additions: number; deletions: number }) {
return [item.additions ? `+${item.additions}` : "", item.deletions ? `-${item.deletions}` : ""]
.filter(Boolean)
.join(" ").length
}
function View(props: { api: TuiPluginApi; session_id: string }) {
const [open, setOpen] = createSignal(true)
const theme = () => props.api.theme.current
@ -25,7 +32,7 @@ function View(props: { api: TuiPluginApi; session_id: string }) {
{(item) => (
<box flexDirection="row" gap={1} justifyContent="space-between">
<text fg={theme().textMuted} wrapMode="none">
{item.file}
{Locale.truncateLeft(item.file, Math.max(2, 36 - changeCountWidth(item)))}
</text>
<box flexDirection="row" gap={1} flexShrink={0}>
<Show when={item.additions}>