Skip to content

Commit 119bd10

Browse files
refactor
1 parent 4eee49f commit 119bd10

File tree

2 files changed

+71
-27
lines changed

2 files changed

+71
-27
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ export function DialogStatus() {
1111

1212
const enabledFormatters = createMemo(() => sync.data.formatter.filter((f) => f.enabled))
1313

14+
const plugins = createMemo(() => {
15+
const pluginList = sync.data.config.plugin ?? []
16+
return pluginList.map((plugin) => {
17+
if (plugin.startsWith("file://")) {
18+
const path = plugin.replace("file://", "")
19+
const parts = path.split("/")
20+
const filename = parts.pop() || path
21+
22+
// If it's a file with extension (like index.ts or workflow.ts)
23+
if (filename.includes(".")) {
24+
const basename = filename.split(".")[0]
25+
// If the basename is generic (like "index"), use the parent directory name
26+
if (basename === "index") {
27+
const dirname = parts.pop()
28+
const name = dirname || basename
29+
return { raw: plugin, name, type: "local" as const }
30+
}
31+
// Otherwise use the basename without extension (like "workflow" from "workflow.ts")
32+
return { raw: plugin, name: basename, type: "local" as const }
33+
}
34+
35+
return { raw: plugin, name: filename, type: "local" as const }
36+
}
37+
const lastAtIndex = plugin.lastIndexOf("@")
38+
const name = lastAtIndex > 0 ? plugin.substring(0, lastAtIndex) : plugin
39+
const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest"
40+
return { raw: plugin, name, version, type: "npm" as const }
41+
})
42+
})
43+
1444
return (
1545
<box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
1646
<box flexDirection="row" justifyContent="space-between">
@@ -99,6 +129,31 @@ export function DialogStatus() {
99129
</For>
100130
</box>
101131
</Show>
132+
<Show when={plugins().length > 0} fallback={<text fg={theme.text}>No Plugins</text>}>
133+
<box>
134+
<text fg={theme.text}>{plugins().length} Plugins</text>
135+
<For each={plugins()}>
136+
{(item) => (
137+
<box flexDirection="row" gap={1}>
138+
<text
139+
flexShrink={0}
140+
style={{
141+
fg: theme.success,
142+
}}
143+
>
144+
145+
</text>
146+
<text wrapMode="word" fg={theme.text}>
147+
<b>{item.name}</b>
148+
<Show when={item.type === "npm" && item.version}>
149+
<span style={{ fg: theme.textMuted }}> @{item.version}</span>
150+
</Show>
151+
</text>
152+
</box>
153+
)}
154+
</For>
155+
</box>
156+
</Show>
102157
</box>
103158
)
104159
}

packages/opencode/src/cli/cmd/tui/routes/home.tsx

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,23 @@ export function Home() {
1919
return Object.values(sync.data.mcp).some((x) => x.status === "failed")
2020
})
2121

22-
const plugins = createMemo(() => (sync.data.config.plugin ?? []).length)
23-
2422
const Hint = (
25-
<box flexShrink={0} flexDirection="column" gap={0}>
26-
<Show when={Object.keys(sync.data.mcp).length > 0}>
27-
<box flexDirection="row" gap={1}>
28-
<text fg={theme.text}>
29-
<Switch>
30-
<Match when={mcpError()}>
31-
<span style={{ fg: theme.error }}></span> mcp errors{" "}
32-
<span style={{ fg: theme.textMuted }}>ctrl+x s</span>
33-
</Match>
34-
<Match when={true}>
35-
<span style={{ fg: theme.success }}></span>{" "}
36-
{Locale.pluralize(Object.values(sync.data.mcp).length, "{} mcp server", "{} mcp servers")}
37-
</Match>
38-
</Switch>
39-
</text>
40-
</box>
41-
</Show>
42-
<Show when={plugins() > 0}>
43-
<box flexDirection="row" gap={1}>
44-
<text fg={theme.text}>
45-
<span style={{ fg: theme.success }}></span> {Locale.pluralize(plugins(), "{} plugin", "{} plugins")}
46-
</text>
47-
</box>
48-
</Show>
49-
</box>
23+
<Show when={Object.keys(sync.data.mcp).length > 0}>
24+
<box flexShrink={0} flexDirection="row" gap={1}>
25+
<text fg={theme.text}>
26+
<Switch>
27+
<Match when={mcpError()}>
28+
<span style={{ fg: theme.error }}></span> mcp errors{" "}
29+
<span style={{ fg: theme.textMuted }}>ctrl+x s</span>
30+
</Match>
31+
<Match when={true}>
32+
<span style={{ fg: theme.success }}></span>{" "}
33+
{Locale.pluralize(Object.values(sync.data.mcp).length, "{} mcp server", "{} mcp servers")}
34+
</Match>
35+
</Switch>
36+
</text>
37+
</box>
38+
</Show>
5039
)
5140

5241
let prompt: PromptRef

0 commit comments

Comments
 (0)