Skip to content

Commit ae614d9

Browse files
fix(tui): simplify console org display (#21339)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
1 parent 65cde7f commit ae614d9

File tree

6 files changed

+40
-53
lines changed

6 files changed

+40
-53
lines changed

packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
88
import { DialogVariant } from "./dialog-variant"
99
import { useKeybind } from "../context/keybind"
1010
import * as fuzzysort from "fuzzysort"
11-
import { consoleManagedProviderLabel } from "@tui/util/provider-origin"
1211

1312
export function useConnected() {
1413
const sync = useSync()
@@ -47,11 +46,7 @@ export function DialogModel(props: { providerID?: string }) {
4746
key: item,
4847
value: { providerID: provider.id, modelID: model.id },
4948
title: model.name ?? item.modelID,
50-
description: consoleManagedProviderLabel(
51-
sync.data.console_state.consoleManagedProviders,
52-
provider.id,
53-
provider.name,
54-
),
49+
description: provider.name,
5550
category,
5651
disabled: provider.id === "opencode" && model.id.includes("-nano"),
5752
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
@@ -89,9 +84,7 @@ export function DialogModel(props: { providerID?: string }) {
8984
description: favorites.some((item) => item.providerID === provider.id && item.modelID === model)
9085
? "(Favorite)"
9186
: undefined,
92-
category: connected()
93-
? consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, provider.id, provider.name)
94-
: undefined,
87+
category: connected() ? provider.name : undefined,
9588
disabled: provider.id === "opencode" && model.includes("-nano"),
9689
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
9790
onSelect() {
@@ -142,7 +135,7 @@ export function DialogModel(props: { providerID?: string }) {
142135
const title = createMemo(() => {
143136
const value = provider()
144137
if (!value) return "Select model"
145-
return consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, value.id, value.name)
138+
return value.name
146139
})
147140

148141
function onSelect(providerID: string, modelID: string) {

packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DialogModel } from "./dialog-model"
1313
import { useKeyboard } from "@opentui/solid"
1414
import { Clipboard } from "@tui/util/clipboard"
1515
import { useToast } from "../ui/toast"
16-
import { CONSOLE_MANAGED_ICON, isConsoleManagedProvider } from "@tui/util/provider-origin"
16+
import { isConsoleManagedProvider } from "@tui/util/provider-origin"
1717

1818
const PROVIDER_PRIORITY: Record<string, number> = {
1919
opencode: 0,
@@ -49,11 +49,7 @@ export function createDialogProviderOptions() {
4949
}[provider.id],
5050
footer: consoleManaged ? sync.data.console_state.activeOrgName : undefined,
5151
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
52-
gutter: consoleManaged ? (
53-
<text fg={theme.textMuted}>{CONSOLE_MANAGED_ICON}</text>
54-
) : connected ? (
55-
<text fg={theme.success}></text>
56-
) : undefined,
52+
gutter: connected ? <text fg={theme.success}></text> : undefined,
5753
async onSelect() {
5854
if (consoleManaged) return
5955

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { useToast } from "../../ui/toast"
3636
import { useKV } from "../../context/kv"
3737
import { useTextareaKeybindings } from "../textarea-keybindings"
3838
import { DialogSkill } from "../dialog-skill"
39-
import { CONSOLE_MANAGED_ICON, consoleManagedProviderLabel } from "@tui/util/provider-origin"
4039

4140
export type PromptProps = {
4241
sessionID?: string
@@ -96,15 +95,8 @@ export function Prompt(props: PromptProps) {
9695
const list = createMemo(() => props.placeholders?.normal ?? [])
9796
const shell = createMemo(() => props.placeholders?.shell ?? [])
9897
const [auto, setAuto] = createSignal<AutocompleteRef>()
99-
const activeOrgName = createMemo(() => sync.data.console_state.activeOrgName)
100-
const canSwitchOrgs = createMemo(() => sync.data.console_state.switchableOrgCount > 1)
101-
const currentProviderLabel = createMemo(() => {
102-
const current = local.model.current()
103-
const provider = local.model.parsed().provider
104-
if (!current) return provider
105-
return consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, current.providerID, provider)
106-
})
107-
const hasRightContent = createMemo(() => Boolean(props.right || activeOrgName()))
98+
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
99+
const hasRightContent = createMemo(() => Boolean(props.right))
108100

109101
function promptModelWarning() {
110102
toast.show({
@@ -1120,17 +1112,6 @@ export function Prompt(props: PromptProps) {
11201112
<Show when={hasRightContent()}>
11211113
<box flexDirection="row" gap={1} alignItems="center">
11221114
{props.right}
1123-
<Show when={activeOrgName()}>
1124-
<text
1125-
fg={theme.textMuted}
1126-
onMouseUp={() => {
1127-
if (!canSwitchOrgs()) return
1128-
command.trigger("console.org.switch")
1129-
}}
1130-
>
1131-
{`${CONSOLE_MANAGED_ICON} ${activeOrgName()}`}
1132-
</text>
1133-
</Show>
11341115
</box>
11351116
</Show>
11361117
</box>
@@ -1162,7 +1143,7 @@ export function Prompt(props: PromptProps) {
11621143
}
11631144
/>
11641145
</box>
1165-
<box flexDirection="row" justifyContent="space-between">
1146+
<box width="100%" flexDirection="row" justifyContent="space-between">
11661147
<Show when={status().type !== "idle"} fallback={props.hint ?? <text />}>
11671148
<box
11681149
flexDirection="row"
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
export const CONSOLE_MANAGED_ICON = "⌂"
2-
31
const contains = (consoleManagedProviders: string[] | ReadonlySet<string>, providerID: string) =>
42
Array.isArray(consoleManagedProviders)
53
? consoleManagedProviders.includes(providerID)
64
: consoleManagedProviders.has(providerID)
75

86
export const isConsoleManagedProvider = (consoleManagedProviders: string[] | ReadonlySet<string>, providerID: string) =>
97
contains(consoleManagedProviders, providerID)
10-
11-
export const consoleManagedProviderSuffix = (
12-
consoleManagedProviders: string[] | ReadonlySet<string>,
13-
providerID: string,
14-
) => (contains(consoleManagedProviders, providerID) ? ` ${CONSOLE_MANAGED_ICON}` : "")
15-
16-
export const consoleManagedProviderLabel = (
17-
consoleManagedProviders: string[] | ReadonlySet<string>,
18-
providerID: string,
19-
providerName: string,
20-
) => `${providerName}${consoleManagedProviderSuffix(consoleManagedProviders, providerID)}`

packages/opencode/test/tool/registry.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,37 @@ describe("tool.registry", () => {
9898
}),
9999
)
100100

101+
await Bun.write(
102+
path.join(opencodeDir, "package-lock.json"),
103+
JSON.stringify({
104+
name: "custom-tools",
105+
lockfileVersion: 3,
106+
packages: {
107+
"": {
108+
dependencies: {
109+
"@opencode-ai/plugin": "^0.0.0",
110+
cowsay: "^1.6.0",
111+
},
112+
},
113+
},
114+
}),
115+
)
116+
117+
const cowsayDir = path.join(opencodeDir, "node_modules", "cowsay")
118+
await fs.mkdir(cowsayDir, { recursive: true })
119+
await Bun.write(
120+
path.join(cowsayDir, "package.json"),
121+
JSON.stringify({
122+
name: "cowsay",
123+
type: "module",
124+
exports: "./index.js",
125+
}),
126+
)
127+
await Bun.write(
128+
path.join(cowsayDir, "index.js"),
129+
["export function say({ text }) {", " return `moo ${text}`", "}", ""].join("\n"),
130+
)
131+
101132
await Bun.write(
102133
path.join(toolsDir, "cowsay.ts"),
103134
[

packages/opencode/test/tool/webfetch.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ describe("tool.webfetch", () => {
147147
)
148148

149149
expect(ids).toHaveLength(1)
150-
expect(cleared).toHaveLength(1)
151-
expect(cleared[0]).toBe(ids[0])
150+
expect(cleared).toContain(ids[0])
152151
})
153152
})
154153
})

0 commit comments

Comments
 (0)