فهرست منبع

toggle to hide username in TUI (#4750)

Co-authored-by: Aiden Cline <[email protected]>
Jaga Santagostino 2 ماه پیش
والد
کامیت
f17e1def32

+ 18 - 1
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

@@ -81,6 +81,7 @@ const context = createContext<{
   conceal: () => boolean
   showThinking: () => boolean
   showTimestamps: () => boolean
+  usernameVisible: () => boolean
   showDetails: () => boolean
   diffWrapMode: () => "word" | "none"
   sync: ReturnType<typeof useSync>
@@ -115,6 +116,7 @@ export function Session() {
   const [conceal, setConceal] = createSignal(true)
   const [showThinking, setShowThinking] = createSignal(kv.get("thinking_visibility", true))
   const [showTimestamps, setShowTimestamps] = createSignal(kv.get("timestamps", "hide") === "show")
+  const [usernameVisible, setUsernameVisible] = createSignal(kv.get("username_visible", true))
   const [showDetails, setShowDetails] = createSignal(kv.get("tool_details_visibility", true))
   const [diffWrapMode, setDiffWrapMode] = createSignal<"word" | "none">("word")
 
@@ -419,6 +421,20 @@ export function Session() {
         dialog.clear()
       },
     },
+    {
+      title: usernameVisible() ? "Hide username" : "Show username",
+      value: "session.username_visible.toggle",
+      keybind: "username_toggle",
+      category: "Session",
+      onSelect: (dialog) => {
+        setUsernameVisible((prev) => {
+          const next = !prev
+          kv.set("username_visible", next)
+          return next
+        })
+        dialog.clear()
+      },
+    },
     {
       title: "Toggle code concealment",
       value: "session.toggle.conceal",
@@ -776,6 +792,7 @@ export function Session() {
         conceal,
         showThinking,
         showTimestamps,
+        usernameVisible,
         showDetails,
         diffWrapMode,
         sync,
@@ -995,7 +1012,7 @@ function UserMessage(props: {
               </box>
             </Show>
             <text fg={theme.textMuted}>
-              {sync.data.config.username ?? "You"}{" "}
+              {ctx.usernameVisible() ? `${sync.data.config.username ?? "You"} ` : "You"}{" "}
               <Show
                 when={queued()}
                 fallback={

+ 1 - 0
packages/opencode/src/config/config.ts

@@ -398,6 +398,7 @@ export namespace Config {
       editor_open: z.string().optional().default("<leader>e").describe("Open external editor"),
       theme_list: z.string().optional().default("<leader>t").describe("List available themes"),
       sidebar_toggle: z.string().optional().default("<leader>b").describe("Toggle sidebar"),
+      username_toggle: z.string().optional().default("none").describe("Toggle username visibility"),
       status_view: z.string().optional().default("<leader>s").describe("View status"),
       session_export: z.string().optional().default("<leader>x").describe("Export session to editor"),
       session_new: z.string().optional().default("<leader>n").describe("Create a new session"),

+ 4 - 0
packages/sdk/js/src/gen/types.gen.ts

@@ -732,6 +732,10 @@ export type KeybindsConfig = {
    * Toggle sidebar
    */
   sidebar_toggle?: string
+  /**
+   * Toggle username visibility
+   */
+  username_toggle?: string
   /**
    * View status
    */

+ 1 - 0
packages/web/src/content/docs/keybinds.mdx

@@ -14,6 +14,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf
     "editor_open": "<leader>e",
     "theme_list": "<leader>t",
     "sidebar_toggle": "<leader>b",
+    "username_toggle": "none",
     "status_view": "<leader>s",
     "session_export": "<leader>x",
     "session_new": "<leader>n",

+ 13 - 0
packages/web/src/content/docs/tui.mdx

@@ -348,3 +348,16 @@ You can customize TUI behavior through your OpenCode config file.
 
 - `scroll_acceleration` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.**
 - `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (minimum: `1`). Defaults to `1` on Unix and `3` on Windows. **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.**
+
+---
+
+## View customization
+
+You can customize various aspects of the TUI view using the command palette (`ctrl+x h` or `/help`). These settings persist across restarts.
+
+### Username display
+
+Toggle whether your username appears in chat messages. Access this through:
+
+- Command palette: Search for "username" or "hide username"
+- The setting persists automatically and will be remembered across TUI sessions