mirror of
https://github.com/anomalyco/opencode.git
synced 2026-09-07 04:04:41 +00:00
feat(tui): enable session terminal panes by default (#46797)
This commit is contained in:
parent
d57e210f84
commit
fe4ea1d693
7 changed files with 7 additions and 34 deletions
|
|
@ -55,7 +55,7 @@ export const settings: Setting[] = [
|
|||
title: "Terminal",
|
||||
category: "Session",
|
||||
path: ["session", "terminal"],
|
||||
default: false,
|
||||
default: true,
|
||||
values: [false, true],
|
||||
labels: ["off", "on"],
|
||||
keywords: ["pty", "shell", "terminal pane"],
|
||||
|
|
|
|||
|
|
@ -265,12 +265,6 @@ export type Resolved = Omit<Info, "attention" | "cursor" | "keybinds" | "leader"
|
|||
|
||||
export function resolve(input: Info, options: { terminalSuspend: boolean }): Resolved {
|
||||
const keybinds: TuiKeybind.KeybindOverrides = { ...input.keybinds }
|
||||
if (input.session?.terminal) {
|
||||
if (input.keybinds?.["terminal.toggle"] === undefined && input.keybinds?.["theme.switch"] === undefined) {
|
||||
keybinds["terminal.toggle"] = "<leader>t"
|
||||
keybinds["theme.switch"] = "none"
|
||||
}
|
||||
}
|
||||
if (!options.terminalSuspend) {
|
||||
keybinds["terminal.suspend"] = "none"
|
||||
if (keybinds["input.undo"] === undefined) {
|
||||
|
|
@ -305,6 +299,7 @@ export function resolve(input: Info, options: { terminalSuspend: boolean }): Res
|
|||
session: {
|
||||
...input.session,
|
||||
new_location: input.session?.new_location ?? "launch",
|
||||
terminal: input.session?.terminal ?? true,
|
||||
tps: input.session?.tps ?? true,
|
||||
},
|
||||
tabs: {
|
||||
|
|
|
|||
|
|
@ -88,14 +88,14 @@ export const Definitions = {
|
|||
"diff.help": keybind("?,shift+?,shift+/", "Show more diff viewer shortcuts"),
|
||||
|
||||
"prompt.editor": keybind("<leader>e", "Open external editor"),
|
||||
"theme.switch": keybind("<leader>t", "List available themes"),
|
||||
"theme.switch": keybind("none", "List available themes"),
|
||||
"theme.switch_mode": keybind("none", "Switch between light and dark theme mode"),
|
||||
"theme.mode.lock": keybind("none", "Lock or unlock theme mode"),
|
||||
"session.sidebar.toggle": keybind("<leader>b", "Toggle sidebar"),
|
||||
"pane.focus.left": keybind("<leader>left", "Focus session pane"),
|
||||
"pane.focus.right": keybind("<leader>right", "Focus terminal pane"),
|
||||
"terminal.select": keybind("<leader>down", "Select terminal"),
|
||||
"terminal.toggle": keybind("none", "Toggle terminal pane"),
|
||||
"terminal.toggle": keybind("<leader>t", "Toggle terminal pane"),
|
||||
"terminal.close": keybind("<leader>up", "Close terminal pane"),
|
||||
"session.toggle.scrollbar": keybind("none", "Toggle session scrollbar"),
|
||||
"opencode.status": keybind("<leader>s", "View status"),
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ async function renderComposer(
|
|||
const app = await testRender(
|
||||
() => (
|
||||
<TestTuiContexts directory={directory}>
|
||||
<ConfigProvider config={createTuiResolvedConfig({ keybinds })}>
|
||||
<ConfigProvider config={createTuiResolvedConfig({ keybinds, session: { terminal: false } })}>
|
||||
<Keymap.Provider>
|
||||
<ClientProvider api={createApi(calls.fetch)}>
|
||||
<DataProvider directory={process.cwd()}>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function emitEvent(events: ReturnType<typeof createEventStream>, event: OpenCode
|
|||
events.emit({ ...event, location: { directory } })
|
||||
}
|
||||
|
||||
const config = createTuiResolvedConfig()
|
||||
const config = createTuiResolvedConfig({ session: { terminal: false } })
|
||||
|
||||
function DataProvider(props: ParentProps) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -106,29 +106,6 @@ test("validates terminal copy behavior", () => {
|
|||
expect(setting?.default).toBe(process.platform === "win32" ? "manual" : "select")
|
||||
})
|
||||
|
||||
test("keeps persistent terminals disabled until explicitly enabled", () => {
|
||||
const disabled = resolve({}, { terminalSuspend: true })
|
||||
expect(disabled.session.terminal ?? false).toBe(false)
|
||||
expect(disabled.keybinds.get("theme.switch")).toMatchObject([{ key: "<leader>t" }])
|
||||
expect(disabled.keybinds.get("terminal.toggle")).toEqual([])
|
||||
expect(settings.find((setting) => setting.path.join(".") === "session.terminal")?.default).toBe(false)
|
||||
expect(settings.filter((setting) => setting.category === "Terminal").map((setting) => setting.title)).toEqual([
|
||||
"Window title",
|
||||
"Copy behavior",
|
||||
])
|
||||
|
||||
const enabled = resolve({ session: { terminal: true } }, { terminalSuspend: true })
|
||||
expect(enabled.keybinds.get("terminal.toggle")).toMatchObject([{ key: "<leader>t" }])
|
||||
expect(enabled.keybinds.get("theme.switch")).toEqual([])
|
||||
|
||||
const customized = resolve(
|
||||
{ session: { terminal: true }, keybinds: { "theme.switch": "<leader>t", "terminal.toggle": "<leader>p" } },
|
||||
{ terminalSuspend: true },
|
||||
)
|
||||
expect(customized.keybinds.get("theme.switch")).toMatchObject([{ key: "<leader>t" }])
|
||||
expect(customized.keybinds.get("terminal.toggle")).toMatchObject([{ key: "<leader>p" }])
|
||||
})
|
||||
|
||||
test("uses command IDs as keybind keys", () => {
|
||||
const config = resolve({ keybinds: { "session.list": "ctrl+l" } }, { terminalSuspend: true })
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ export function createFetch(override?: FetchHandler, events?: ReturnType<typeof
|
|||
if (url.pathname === "/api/form/request")
|
||||
return json({ location: { directory, project: { id: "proj_test", directory: worktree } }, data: [] })
|
||||
if (/^\/api\/session\/[^/]+\/form$/.test(url.pathname)) return json({ data: [] })
|
||||
if (/^\/api\/experimental\/session\/[^/]+\/terminal$/.test(url.pathname)) return json({ data: [] })
|
||||
if (
|
||||
["/api/agent", "/api/model", "/api/provider", "/api/integration", "/api/command", "/api/skill"].includes(
|
||||
url.pathname,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue