Skip to content

Commit 659712c

Browse files
authored
Merge branch 'dev' into fix/session-messages-sort-by-time
2 parents 384c171 + a618fbe commit 659712c

File tree

4 files changed

+71
-68
lines changed

4 files changed

+71
-68
lines changed

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

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -33,76 +33,82 @@ export function DialogModel(props: { providerID?: string }) {
3333

3434
const options = createMemo(() => {
3535
const q = query()
36-
const favorites = showExtra() ? local.model.favorite() : []
36+
const needle = q.trim()
37+
const showSections = showExtra() && needle.length === 0
38+
const favorites = connected() ? local.model.favorite() : []
3739
const recents = local.model.recent()
3840

39-
const recentList = showExtra()
41+
const recentList = showSections
4042
? recents.filter(
4143
(item) => !favorites.some((fav) => fav.providerID === item.providerID && fav.modelID === item.modelID),
4244
)
4345
: []
4446

45-
const favoriteOptions = favorites.flatMap((item) => {
46-
const provider = sync.data.provider.find((x) => x.id === item.providerID)
47-
if (!provider) return []
48-
const model = provider.models[item.modelID]
49-
if (!model) return []
50-
return [
51-
{
52-
key: item,
53-
value: {
54-
providerID: provider.id,
55-
modelID: model.id,
56-
},
57-
title: model.name ?? item.modelID,
58-
description: provider.name,
59-
category: "Favorites",
60-
disabled: provider.id === "opencode" && model.id.includes("-nano"),
61-
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
62-
onSelect: () => {
63-
dialog.clear()
64-
local.model.set(
65-
{
47+
const favoriteOptions = showSections
48+
? favorites.flatMap((item) => {
49+
const provider = sync.data.provider.find((x) => x.id === item.providerID)
50+
if (!provider) return []
51+
const model = provider.models[item.modelID]
52+
if (!model) return []
53+
return [
54+
{
55+
key: item,
56+
value: {
6657
providerID: provider.id,
6758
modelID: model.id,
6859
},
69-
{ recent: true },
70-
)
71-
},
72-
},
73-
]
74-
})
60+
title: model.name ?? item.modelID,
61+
description: provider.name,
62+
category: "Favorites",
63+
disabled: provider.id === "opencode" && model.id.includes("-nano"),
64+
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
65+
onSelect: () => {
66+
dialog.clear()
67+
local.model.set(
68+
{
69+
providerID: provider.id,
70+
modelID: model.id,
71+
},
72+
{ recent: true },
73+
)
74+
},
75+
},
76+
]
77+
})
78+
: []
7579

76-
const recentOptions = recentList.flatMap((item) => {
77-
const provider = sync.data.provider.find((x) => x.id === item.providerID)
78-
if (!provider) return []
79-
const model = provider.models[item.modelID]
80-
if (!model) return []
81-
return [
82-
{
83-
key: item,
84-
value: {
85-
providerID: provider.id,
86-
modelID: model.id,
87-
},
88-
title: model.name ?? item.modelID,
89-
description: provider.name,
90-
category: "Recent",
91-
disabled: provider.id === "opencode" && model.id.includes("-nano"),
92-
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
93-
onSelect: () => {
94-
dialog.clear()
95-
local.model.set(
96-
{
80+
const recentOptions = showSections
81+
? recentList.flatMap((item) => {
82+
const provider = sync.data.provider.find((x) => x.id === item.providerID)
83+
if (!provider) return []
84+
const model = provider.models[item.modelID]
85+
if (!model) return []
86+
return [
87+
{
88+
key: item,
89+
value: {
9790
providerID: provider.id,
9891
modelID: model.id,
9992
},
100-
{ recent: true },
101-
)
102-
},
103-
},
104-
]
105-
})
93+
title: model.name ?? item.modelID,
94+
description: provider.name,
95+
category: "Recent",
96+
disabled: provider.id === "opencode" && model.id.includes("-nano"),
97+
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
98+
onSelect: () => {
99+
dialog.clear()
100+
local.model.set(
101+
{
102+
providerID: provider.id,
103+
modelID: model.id,
104+
},
105+
{ recent: true },
106+
)
107+
},
108+
},
109+
]
110+
})
111+
: []
106112

107113
const providerOptions = pipe(
108114
sync.data.provider,
@@ -145,6 +151,7 @@ export function DialogModel(props: { providerID?: string }) {
145151
}
146152
}),
147153
filter((x) => {
154+
if (!showSections) return true
148155
const value = x.value
149156
const inFavorites = favorites.some(
150157
(item) => item.providerID === value.providerID && item.modelID === value.modelID,
@@ -177,16 +184,11 @@ export function DialogModel(props: { providerID?: string }) {
177184
)
178185
: []
179186

180-
// Apply fuzzy filtering to each section separately, maintaining section order
181-
if (q) {
182-
const filteredFavorites = fuzzysort.go(q, favoriteOptions, { keys: ["title"] }).map((x) => x.obj)
183-
const filteredRecents = fuzzysort
184-
.go(q, recentOptions, { keys: ["title"] })
185-
.map((x) => x.obj)
186-
.slice(0, 5)
187-
const filteredProviders = fuzzysort.go(q, providerOptions, { keys: ["title", "category"] }).map((x) => x.obj)
188-
const filteredPopular = fuzzysort.go(q, popularProviders, { keys: ["title"] }).map((x) => x.obj)
189-
return [...filteredFavorites, ...filteredRecents, ...filteredProviders, ...filteredPopular]
187+
// Search shows a single merged list (favorites inline)
188+
if (needle) {
189+
const filteredProviders = fuzzysort.go(needle, providerOptions, { keys: ["title", "category"] }).map((x) => x.obj)
190+
const filteredPopular = fuzzysort.go(needle, popularProviders, { keys: ["title"] }).map((x) => x.obj)
191+
return [...filteredProviders, ...filteredPopular]
190192
}
191193

192194
return [...favoriteOptions, ...recentOptions, ...providerOptions, ...popularProviders]

packages/opencode/src/global/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ await Promise.all([
3333
fs.mkdir(Global.Path.bin, { recursive: true }),
3434
])
3535

36-
const CACHE_VERSION = "14"
36+
const CACHE_VERSION = "15"
3737

3838
const version = await Bun.file(path.join(Global.Path.cache, "version"))
3939
.text()

packages/opencode/src/plugin/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Flag } from "../flag/flag"
1111
export namespace Plugin {
1212
const log = Log.create({ service: "plugin" })
1313

14-
const BUILTIN = ["[email protected].9", "[email protected]"]
14+
const BUILTIN = ["[email protected].11", "[email protected]"]
1515

1616
const state = Instance.state(async () => {
1717
const client = createOpencodeClient({

packages/opencode/src/provider/provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ export namespace Provider {
852852
if (modelID === "gpt-5-chat-latest" || (providerID === "openrouter" && modelID === "openai/gpt-5-chat"))
853853
delete provider.models[modelID]
854854
if (model.status === "alpha" && !Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS) delete provider.models[modelID]
855+
if (model.status === "deprecated") delete provider.models[modelID]
855856
if (
856857
(configProvider?.blacklist && configProvider.blacklist.includes(modelID)) ||
857858
(configProvider?.whitelist && !configProvider.whitelist.includes(modelID))

0 commit comments

Comments
 (0)