Skip to content

Commit d60102b

Browse files
Added `/thinking` slash command to toggle thinking blocks visibility in OpenTUI. (#4424) Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
1 parent 066a876 commit d60102b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ export function Autocomplete(props: {
245245
description: "jump to message",
246246
onSelect: () => command.trigger("session.timeline"),
247247
},
248+
{
249+
display: "/thinking",
250+
description: "toggle thinking blocks",
251+
onSelect: () => command.trigger("session.toggle.thinking"),
252+
},
248253
)
249254
if (sync.data.config.share !== "disabled") {
250255
results.push({

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class CustomSpeedScroll implements ScrollAcceleration {
8282
const context = createContext<{
8383
width: number
8484
conceal: () => boolean
85+
showThinking: () => boolean
8586
}>()
8687

8788
function use() {
@@ -112,6 +113,7 @@ export function Session() {
112113
const dimensions = useTerminalDimensions()
113114
const [sidebar, setSidebar] = createSignal<"show" | "hide" | "auto">(kv.get("sidebar", "auto"))
114115
const [conceal, setConceal] = createSignal(true)
116+
const [showThinking, setShowThinking] = createSignal(true)
115117

116118
const wide = createMemo(() => dimensions().width > 120)
117119
const sidebarVisible = createMemo(() => sidebar() === "show" || (sidebar() === "auto" && wide()))
@@ -385,6 +387,15 @@ export function Session() {
385387
dialog.clear()
386388
},
387389
},
390+
{
391+
title: "Toggle thinking blocks",
392+
value: "session.toggle.thinking",
393+
category: "Session",
394+
onSelect: (dialog) => {
395+
setShowThinking((prev) => !prev)
396+
dialog.clear()
397+
},
398+
},
388399
{
389400
title: "Page up",
390401
value: "session.page.up",
@@ -674,6 +685,7 @@ export function Session() {
674685
return contentWidth()
675686
},
676687
conceal,
688+
showThinking,
677689
}}
678690
>
679691
<box flexDirection="row" paddingBottom={1} paddingTop={1} paddingLeft={2} paddingRight={2} gap={2}>
@@ -1030,7 +1042,7 @@ function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: Ass
10301042
const ctx = use()
10311043
const content = createMemo(() => props.part.text.trim())
10321044
return (
1033-
<Show when={content()}>
1045+
<Show when={content() && ctx.showThinking()}>
10341046
<box
10351047
id={"text-" + props.part.id}
10361048
paddingLeft={2}

0 commit comments

Comments
 (0)