mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
Fetch OpenCode Go's catalog as the settings window opens
Codex already refreshes its boxes from the source at open, so the built-in list is never the whole truth for longer than a window takes to build. OpenCode Go now gets the same courtesy: one request to /models on a background thread, both of its boxes refilled with the picked model kept, skipped entirely when there is no key to send.
This commit is contained in:
+21
-1
@@ -135,6 +135,8 @@ class Settings(DikteTest):
|
||||
"_load_transcribe_models"))
|
||||
self.enterContext(mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_codex_models"))
|
||||
self.enterContext(mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_opencode_models"))
|
||||
# The local model boxes fetch their own list the moment they are shown,
|
||||
# from a thread, which is nobody's test failing but a real request.
|
||||
self.enterContext(mock.patch.object(settings_ui.LocalModelBox,
|
||||
@@ -285,6 +287,20 @@ class Settings(DikteTest):
|
||||
self.assertEqual(window.cleanup_codex_model.currentText(),
|
||||
"my-own-model")
|
||||
|
||||
def test_opencode_answering_refills_both_of_its_boxes(self):
|
||||
"""The catalog fetched at open replaces the built-in list in the
|
||||
cleanup and agent boxes alike, and neither loses what was picked."""
|
||||
conf = self.config(cleanup_opencode_model="my-own-model")
|
||||
window = self.window(conf)
|
||||
window._on_opencode_models_loaded(["glm-9", "kimi-k9"])
|
||||
for combo in (window.cleanup_opencode_model,
|
||||
window.assistant_opencode_model):
|
||||
with self.subTest(combo=combo.objectName() or "combo"):
|
||||
offered = [combo.itemText(i) for i in range(combo.count())]
|
||||
self.assertEqual(offered, ["glm-9", "kimi-k9"])
|
||||
self.assertEqual(window.cleanup_opencode_model.currentText(),
|
||||
"my-own-model")
|
||||
|
||||
def test_a_fetched_opencode_list_lands_in_opencode_s_own_box(self):
|
||||
"""The OpenRouter and meeting boxes are not refilled by another
|
||||
provider's catalog, and the picked model survives the refill."""
|
||||
@@ -1026,7 +1042,9 @@ class MeetingSources(DikteTest):
|
||||
mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_transcribe_models"), \
|
||||
mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_codex_models"):
|
||||
"_load_codex_models"), \
|
||||
mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_opencode_models"):
|
||||
window = settings_ui.SettingsWindow(cfg.Config())
|
||||
self.addCleanup(window.deleteLater)
|
||||
self.addCleanup(window.close)
|
||||
@@ -1058,6 +1076,8 @@ class LocalModels(DikteTest):
|
||||
# And one with Codex on it would ask it for its model list.
|
||||
self.enterContext(mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_codex_models"))
|
||||
self.enterContext(mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_opencode_models"))
|
||||
|
||||
def window(self, conf):
|
||||
window = settings_ui.SettingsWindow(conf)
|
||||
|
||||
Reference in New Issue
Block a user