From f17e1def32c36c7eb89d1a1e810c0de4ed71c424 Mon Sep 17 00:00:00 2001 From: Jaga Santagostino Date: Tue, 2 Dec 2025 22:11:03 +0100 Subject: [PATCH] toggle to hide username in TUI (#4750) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> --- .../src/cli/cmd/tui/routes/session/index.tsx | 19 ++++++++++++++++++- packages/opencode/src/config/config.ts | 1 + packages/sdk/js/src/gen/types.gen.ts | 4 ++++ packages/web/src/content/docs/keybinds.mdx | 1 + packages/web/src/content/docs/tui.mdx | 13 +++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 83f44c944..b0860c0b8 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/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 @@ -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: { - {sync.data.config.username ?? "You"}{" "} + {ctx.usernameVisible() ? `${sync.data.config.username ?? "You"} ` : "You"}{" "} e").describe("Open external editor"), theme_list: z.string().optional().default("t").describe("List available themes"), sidebar_toggle: z.string().optional().default("b").describe("Toggle sidebar"), + username_toggle: z.string().optional().default("none").describe("Toggle username visibility"), status_view: z.string().optional().default("s").describe("View status"), session_export: z.string().optional().default("x").describe("Export session to editor"), session_new: z.string().optional().default("n").describe("Create a new session"), diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index d81fda9f8..f8e1d34fb 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/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 */ diff --git a/packages/web/src/content/docs/keybinds.mdx b/packages/web/src/content/docs/keybinds.mdx index afcff3a0e..80a74c159 100644 --- a/packages/web/src/content/docs/keybinds.mdx +++ b/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": "e", "theme_list": "t", "sidebar_toggle": "b", + "username_toggle": "none", "status_view": "s", "session_export": "x", "session_new": "n", diff --git a/packages/web/src/content/docs/tui.mdx b/packages/web/src/content/docs/tui.mdx index a580a4ce8..2543df639 100644 --- a/packages/web/src/content/docs/tui.mdx +++ b/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