feat(app): choose each server's terminal shell from its menu (#63539)

This commit is contained in:
usrnk1
2026-11-12 15:37:30 +01:00
committed by GitHub
Unverified
parent 98def2f90e
commit 1c53e40a7f
3 changed files with 80 additions and 19 deletions
+52 -1
View File
@@ -1,15 +1,19 @@
import { Icon } from "@opencode/ui/icon"
import { IconButton } from "@opencode/ui/icon-button"
import { Menu } from "@opencode/ui/menu"
import { type Component, Show } from "solid-js"
import { type Component, createMemo, For, Show } from "solid-js"
import type { ServerActionsController } from "@/servers/registry/controller"
import { useLanguage } from "@/runtime/i18n/language"
import { ServerConnection } from "@/runtime/server/registry"
import { createShellOptions } from "@/settings/general/behavior"
import type { ShellSettingsController } from "@/settings/general/controllers"
export const ServerRowMenu: Component<{
server: ServerConnection.Any
domain: ServerActionsController
onEdit: (server: ServerConnection.Http) => void
shell?: ShellSettingsController
action?: string
open?: boolean
onOpenChange?: (open: boolean) => void
}> = (props) => {
@@ -23,6 +27,8 @@ export const ServerRowMenu: Component<{
canRemove={props.domain.connection.canRemove(key)}
canHide={props.domain.connection.canHide(key)}
hidden={props.domain.connection.isHidden(key)}
shell={props.shell}
action={props.action}
onEdit={props.onEdit}
onRemove={() => props.domain.connection.remove(key)}
onHide={() => props.domain.connection.setHidden(key, true)}
@@ -41,6 +47,9 @@ export function serverMenuLabels(language: ReturnType<typeof useLanguage>) {
remove: language.t("dialog.server.menu.remove"),
hide: language.t("dialog.server.menu.hide"),
show: language.t("dialog.server.menu.show"),
shell: language.t("settings.general.row.shell.title"),
shellAuto: language.t("settings.general.row.shell.autoDefault"),
shellTerminalOnly: language.t("settings.general.row.shell.terminalOnly"),
}
}
@@ -50,6 +59,8 @@ export const ServerRowMenuView: Component<{
canRemove: boolean
canHide?: boolean
hidden?: boolean
shell?: ShellSettingsController
action?: string
onEdit: (server: ServerConnection.Http) => void
onRemove: () => void
onHide?: () => void
@@ -68,6 +79,7 @@ export const ServerRowMenuView: Component<{
size="small"
icon={<Icon name="outline-dots" />}
aria-label={props.labels.more}
data-action={props.action}
/>
<Menu.Portal>
<Menu.Content>
@@ -83,6 +95,7 @@ export const ServerRowMenuView: Component<{
>
{props.labels.edit}
</Menu.Item>
<Show when={props.shell}>{(shell) => <ShellSubmenu shell={shell()} labels={props.labels} />}</Show>
<Show when={props.hidden}>
<Menu.Item onSelect={props.onShow}>{props.labels.show}</Menu.Item>
</Show>
@@ -99,3 +112,41 @@ export const ServerRowMenuView: Component<{
</Menu>
)
}
function ShellSubmenu(props: { shell: ShellSettingsController; labels: ReturnType<typeof serverMenuLabels> }) {
const options = createMemo(() =>
createShellOptions({ shells: props.shell.shells(), current: props.shell.current() }),
)
const current = () => options().find((option) => option.value === props.shell.current())?.id ?? "auto"
return (
<Menu.Sub gutter={4} overflowPadding={16} overlap>
<Menu.SubTrigger>{props.labels.shell}</Menu.SubTrigger>
<Menu.Portal>
<Menu.SubContent class="w-max min-w-[172px] max-w-[calc(100vw-32px)]" aria-label={props.labels.shell}>
<Menu.RadioGroup
value={current()}
onChange={(id) => {
const option = options().find((item) => item.id === id)
if (option) props.shell.select(option.value)
}}
>
<For each={options()}>
{(option) => (
<Menu.RadioItem value={option.id}>
{option.id === "auto"
? props.labels.shellAuto
: option.terminalOnly
? `${option.name} (${props.labels.shellTerminalOnly})`
: option.name}
</Menu.RadioItem>
)}
</For>
</Menu.RadioGroup>
</Menu.SubContent>
</Menu.Portal>
</Menu.Sub>
)
}
@@ -69,11 +69,7 @@ const WorkspaceDestinationSetting: Component = () => {
)
}
export const ShellSetting: Component<{
controller: ShellSettingsController
/** Search reveals the row with the default action; the Servers page names the other servers' rows apart. */
action?: string
}> = (props) => {
export const ShellSetting: Component<{ controller: ShellSettingsController }> = (props) => {
const language = useLanguage()
const options = createMemo(() =>
@@ -89,7 +85,7 @@ export const ShellSetting: Component<{
description={language.t("settings.general.row.shell.description")}
>
<Select
data-action={props.action ?? "settings-shell"}
data-action="settings-shell"
options={options()}
current={options().find((option) => option.value === props.controller.current()) ?? options()[0]}
placement="bottom-end"
+26 -12
View File
@@ -70,15 +70,12 @@ export const SettingsServerList: Component<{
aria-label={entry.name}
>
<SettingsList>
<ServerConnectionRow entry={entry} onServerChange={props.onServerChange} />
<Show when={serverPagesConnection(entry.availability)} keyed>
{(server) => (
<ServerShell
server={server}
action={entry.key === props.selected ? undefined : `settings-shell:${entry.key}`}
/>
)}
</Show>
<ServerConnectionRow
entry={entry}
onServerChange={props.onServerChange}
shellMenu
action={entry.key === props.selected ? undefined : `settings-shell:${entry.key}`}
/>
</SettingsList>
</section>
)}
@@ -109,6 +106,9 @@ function SettingsServersHeader(props: { title: string; onAddServer: () => void }
function ServerConnectionRow(props: {
entry: SettingsServer
onServerChange?: (server: ServerConnection.Any) => void
shellMenu?: boolean
/** Search reveals the row with the default action; the Servers page names the other servers' rows apart. */
action?: string
}) {
const dialog = useDialog()
const language = useLanguage()
@@ -145,7 +145,21 @@ function ServerConnectionRow(props: {
</Button>
)}
</Show>
<ServerRowMenu server={server()} domain={controller} onEdit={edit} />
<Show
when={props.shellMenu && serverPagesConnection(props.entry.availability)}
keyed
fallback={<ServerRowMenu server={server()} domain={controller} onEdit={edit} />}
>
{(ready) => (
<ServerRowMenu
server={server()}
domain={controller}
onEdit={edit}
shell={createServerShellController(() => ready)}
action={props.action ?? "settings-shell"}
/>
)}
</Show>
</div>
</div>
)}
@@ -157,8 +171,8 @@ function ServerConnectionRow(props: {
)
}
function ServerShell(props: { server: ServerConnection.Any; action?: string }) {
function ServerShell(props: { server: ServerConnection.Any }) {
const controller = createServerShellController(() => props.server)
return <ShellSetting controller={controller} action={props.action} />
return <ShellSetting controller={controller} />
}