mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-20 15:13:27 +00:00
fix(tui): standardize compact terminology (#41141)
This commit is contained in:
parent
3776975d5c
commit
0b84e24e65
6 changed files with 12 additions and 7 deletions
|
|
@ -407,7 +407,7 @@ export function RunCommandMenuBody(props: {
|
|||
name: "compact",
|
||||
display: "Compact session",
|
||||
footer: "/compact",
|
||||
keywords: "compact summarize session context",
|
||||
keywords: "compact session context",
|
||||
},
|
||||
{
|
||||
action: "slash",
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ export function createPromptState(input: PromptInput): PromptState {
|
|||
kind: "slash",
|
||||
name: "compact",
|
||||
display: "/compact",
|
||||
description: "summarize the session to reduce context usage",
|
||||
description: "compact older session context to free space",
|
||||
} satisfies SlashOption,
|
||||
{ kind: "slash", name: "exit", display: "/exit", description: "close OpenCode" } satisfies SlashOption,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ export function isNewCommand(input: string): boolean {
|
|||
}
|
||||
|
||||
export function isCompactCommand(input: string): boolean {
|
||||
const text = input.trim().toLowerCase()
|
||||
return text === "/compact" || text === "/summarize"
|
||||
return input.trim().toLowerCase() === "/compact"
|
||||
}
|
||||
|
||||
export function createPromptHistory(items?: RunPrompt[]): PromptHistoryState {
|
||||
|
|
|
|||
|
|
@ -635,7 +635,6 @@ export function Session() {
|
|||
group: "Session",
|
||||
slash: {
|
||||
name: "compact",
|
||||
aliases: ["summarize"],
|
||||
},
|
||||
run: () => {
|
||||
void client.api.session.compact({ sessionID: route.sessionID })
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import {
|
||||
createPromptHistory,
|
||||
isCompactCommand,
|
||||
isExitCommand,
|
||||
isNewCommand,
|
||||
movePromptHistory,
|
||||
|
|
@ -98,4 +99,10 @@ describe("run prompt shared", () => {
|
|||
expect(isNewCommand(" /NEW ")).toBe(true)
|
||||
expect(isNewCommand("/new now")).toBe(false)
|
||||
})
|
||||
|
||||
test("recognizes only the compact command", () => {
|
||||
expect(isCompactCommand("/compact")).toBe(true)
|
||||
expect(isCompactCommand(" /COMPACT ")).toBe(true)
|
||||
expect(isCompactCommand("/summarize")).toBe(false)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ describe("run runtime queue", () => {
|
|||
])
|
||||
})
|
||||
|
||||
test.each(["/compact", "/summarize"])("treats %s as a local compaction command", async (command) => {
|
||||
test("treats /compact as a local compaction command", async () => {
|
||||
const ui = createFooterApiFixture()
|
||||
const seen: string[] = []
|
||||
let compacted = 0
|
||||
|
|
@ -96,7 +96,7 @@ describe("run runtime queue", () => {
|
|||
},
|
||||
})
|
||||
|
||||
ui.submit(command)
|
||||
ui.submit("/compact")
|
||||
ui.submit("hello")
|
||||
await task
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue