2
0
Эх сурвалжийг харах

tweak: only show dropdown for 3+ items (#4345)

Aiden Cline 3 сар өмнө
parent
commit
35c737ac68

+ 36 - 12
packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx

@@ -60,13 +60,19 @@ export function Sidebar(props: { sessionID: string }) {
           </box>
           </box>
           <Show when={Object.keys(sync.data.mcp).length > 0}>
           <Show when={Object.keys(sync.data.mcp).length > 0}>
             <box>
             <box>
-              <box flexDirection="row" gap={1} onMouseDown={() => setMcpExpanded(!mcpExpanded())}>
-                <text fg={theme.text}>{mcpExpanded() ? "▼" : "▶"}</text>
+              <box
+                flexDirection="row"
+                gap={1}
+                onMouseDown={() => Object.keys(sync.data.mcp).length > 2 && setMcpExpanded(!mcpExpanded())}
+              >
+                <Show when={Object.keys(sync.data.mcp).length > 2}>
+                  <text fg={theme.text}>{mcpExpanded() ? "▼" : "▶"}</text>
+                </Show>
                 <text fg={theme.text}>
                 <text fg={theme.text}>
                   <b>MCP</b>
                   <b>MCP</b>
                 </text>
                 </text>
               </box>
               </box>
-              <Show when={mcpExpanded()}>
+              <Show when={Object.keys(sync.data.mcp).length <= 2 || mcpExpanded()}>
                 <For each={Object.entries(sync.data.mcp)}>
                 <For each={Object.entries(sync.data.mcp)}>
                   {([key, item]) => (
                   {([key, item]) => (
                     <box flexDirection="row" gap={1}>
                     <box flexDirection="row" gap={1}>
@@ -100,13 +106,19 @@ export function Sidebar(props: { sessionID: string }) {
           </Show>
           </Show>
           <Show when={sync.data.lsp.length > 0}>
           <Show when={sync.data.lsp.length > 0}>
             <box>
             <box>
-              <box flexDirection="row" gap={1} onMouseDown={() => setLspExpanded(!lspExpanded())}>
-                <text fg={theme.text}>{lspExpanded() ? "▼" : "▶"}</text>
+              <box
+                flexDirection="row"
+                gap={1}
+                onMouseDown={() => sync.data.lsp.length > 2 && setLspExpanded(!lspExpanded())}
+              >
+                <Show when={sync.data.lsp.length > 2}>
+                  <text fg={theme.text}>{lspExpanded() ? "▼" : "▶"}</text>
+                </Show>
                 <text fg={theme.text}>
                 <text fg={theme.text}>
                   <b>LSP</b>
                   <b>LSP</b>
                 </text>
                 </text>
               </box>
               </box>
-              <Show when={lspExpanded()}>
+              <Show when={sync.data.lsp.length <= 2 || lspExpanded()}>
                 <For each={sync.data.lsp}>
                 <For each={sync.data.lsp}>
                   {(item) => (
                   {(item) => (
                     <box flexDirection="row" gap={1}>
                     <box flexDirection="row" gap={1}>
@@ -132,13 +144,19 @@ export function Sidebar(props: { sessionID: string }) {
           </Show>
           </Show>
           <Show when={todo().length > 0}>
           <Show when={todo().length > 0}>
             <box>
             <box>
-              <box flexDirection="row" gap={1} onMouseDown={() => setTodoExpanded(!todoExpanded())}>
-                <text fg={theme.text}>{todoExpanded() ? "▼" : "▶"}</text>
+              <box
+                flexDirection="row"
+                gap={1}
+                onMouseDown={() => todo().length > 2 && setTodoExpanded(!todoExpanded())}
+              >
+                <Show when={todo().length > 2}>
+                  <text fg={theme.text}>{todoExpanded() ? "▼" : "▶"}</text>
+                </Show>
                 <text fg={theme.text}>
                 <text fg={theme.text}>
                   <b>Todo</b>
                   <b>Todo</b>
                 </text>
                 </text>
               </box>
               </box>
-              <Show when={todoExpanded()}>
+              <Show when={todo().length <= 2 || todoExpanded()}>
                 <For each={todo()}>
                 <For each={todo()}>
                   {(todo) => (
                   {(todo) => (
                     <text style={{ fg: todo.status === "in_progress" ? theme.success : theme.textMuted }}>
                     <text style={{ fg: todo.status === "in_progress" ? theme.success : theme.textMuted }}>
@@ -151,13 +169,19 @@ export function Sidebar(props: { sessionID: string }) {
           </Show>
           </Show>
           <Show when={diff().length > 0}>
           <Show when={diff().length > 0}>
             <box>
             <box>
-              <box flexDirection="row" gap={1} onMouseDown={() => setDiffExpanded(!diffExpanded())}>
-                <text fg={theme.text}>{diffExpanded() ? "▼" : "▶"}</text>
+              <box
+                flexDirection="row"
+                gap={1}
+                onMouseDown={() => diff().length > 2 && setDiffExpanded(!diffExpanded())}
+              >
+                <Show when={diff().length > 2}>
+                  <text fg={theme.text}>{diffExpanded() ? "▼" : "▶"}</text>
+                </Show>
                 <text fg={theme.text}>
                 <text fg={theme.text}>
                   <b>Modified Files</b>
                   <b>Modified Files</b>
                 </text>
                 </text>
               </box>
               </box>
-              <Show when={diffExpanded()}>
+              <Show when={diff().length <= 2 || diffExpanded()}>
                 <For each={diff() || []}>
                 <For each={diff() || []}>
                   {(item) => {
                   {(item) => {
                     const file = createMemo(() => {
                     const file = createMemo(() => {