Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 22a34d7

Browse files
authored
feat: tui: Port /exit command and all command aliases (anomalyco#3665)
1 parent cb4401e commit 22a34d7

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Session } from "@tui/routes/session"
2323
import { PromptHistoryProvider } from "./component/prompt/history"
2424
import { DialogAlert } from "./ui/dialog-alert"
2525
import { ToastProvider, useToast } from "./ui/toast"
26-
import { ExitProvider } from "./context/exit"
26+
import { ExitProvider, useExit } from "./context/exit"
2727
import type { SessionRoute } from "./context/route"
2828
import { Session as SessionApi } from "@/session"
2929
import { TuiEvent } from "./event"
@@ -110,6 +110,7 @@ function App() {
110110
const toast = useToast()
111111
const [sessionExists, setSessionExists] = createSignal(false)
112112
const { theme } = useTheme()
113+
const exit = useExit()
113114

114115
useKeyboard(async (evt) => {
115116
if (evt.meta && evt.name === "t") {
@@ -245,6 +246,12 @@ function App() {
245246
},
246247
category: "System",
247248
},
249+
{
250+
title: "Exit the app",
251+
value: "app.exit",
252+
onSelect: exit,
253+
category: "System",
254+
}
248255
])
249256

250257
createEffect(() => {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type AutocompleteRef = {
1818

1919
export type AutocompleteOption = {
2020
display: string
21+
aliases?: string[]
2122
disabled?: boolean
2223
description?: string
2324
onSelect?: () => void
@@ -207,6 +208,7 @@ export function Autocomplete(props: {
207208
},
208209
{
209210
display: "/compact",
211+
aliases: ["/summarize"],
210212
description: "compact the session",
211213
onSelect: () => command.trigger("session.compact"),
212214
},
@@ -232,6 +234,7 @@ export function Autocomplete(props: {
232234
results.push(
233235
{
234236
display: "/new",
237+
aliases: ["/clear"],
235238
description: "create a new session",
236239
onSelect: () => command.trigger("session.new"),
237240
},
@@ -247,6 +250,7 @@ export function Autocomplete(props: {
247250
},
248251
{
249252
display: "/session",
253+
aliases: ["/resume", "/continue"],
250254
description: "list sessions",
251255
onSelect: () => command.trigger("session.list"),
252256
},
@@ -275,6 +279,12 @@ export function Autocomplete(props: {
275279
description: "show all commands",
276280
onSelect: () => command.show(),
277281
},
282+
{
283+
display: "/exit",
284+
aliases: ["/quit", "/q"],
285+
description: "exit the app",
286+
onSelect: () => command.trigger("app.exit"),
287+
},
278288
)
279289
const max = firstBy(results, [(x) => x.display.length, "desc"])?.display.length
280290
if (!max) return results
@@ -293,7 +303,7 @@ export function Autocomplete(props: {
293303
const currentFilter = filter()
294304
if (!currentFilter) return mixed.slice(0, 10)
295305
const result = fuzzysort.go(currentFilter, mixed, {
296-
keys: ["display", "description"],
306+
keys: ["display", "description", (obj) => obj.aliases?.join(" ") ?? ""],
297307
limit: 10,
298308
})
299309
return result.map((arr) => arr.obj)

0 commit comments

Comments
 (0)