Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

fix: gate missing models only on actions

wytb61c8ee6e8f1
diff --git a/src/renderer/locales/en.json b/src/renderer/locales/en.json
index 8beb95ff..43d95b55 100644
--- a/src/renderer/locales/en.json
+++ b/src/renderer/locales/en.json
@@ -1897,8 +1897,6 @@
"search.no_results": "No results for \"{query}\"",
"search.role.user": "Me",
"search.role.ai": "AI",
- "model_guard.banner": "No model has been added. AI features are currently unavailable. Add a model account in Settings.",
- "model_guard.cta": "Open Settings",
"model_guard.modal": "No model has been added, so this feature is currently unavailable.\n\nAdd a model account in Settings.",
"marketplace.title": "Marketplace",
"marketplace.tab_agent": "Agents",
diff --git a/src/renderer/locales/ja.json b/src/renderer/locales/ja.json
index 5d4b75ef..0db15e01 100644
--- a/src/renderer/locales/ja.json
+++ b/src/renderer/locales/ja.json
@@ -1897,8 +1897,6 @@
"search.no_results": "「{query}」の結果はありません",
"search.role.user": "自分",
"search.role.ai": "AI",
- "model_guard.banner": "モデルが追加されていないため、AI 機能は現在利用できません。設定でモデルアカウントを追加してください。",
- "model_guard.cta": "設定を開く",
"model_guard.modal": "モデルが追加されていないため、この機能は現在利用できません。\n\n設定でモデルアカウントを追加してください。",
"marketplace.title": "マーケットプレイス",
"marketplace.tab_agent": "エージェント",
diff --git a/src/renderer/locales/pt.json b/src/renderer/locales/pt.json
index 02cd82c0..faacd6cc 100644
--- a/src/renderer/locales/pt.json
+++ b/src/renderer/locales/pt.json
@@ -1886,8 +1886,6 @@
"search.no_results": "Nenhum resultado para \"{query}\"",
"search.role.user": "Eu",
"search.role.ai": "IA",
- "model_guard.banner": "Nenhum modelo foi adicionado. Os recursos de IA estão indisponíveis no momento. Adicione uma conta de modelo nas Configurações.",
- "model_guard.cta": "Abra Configurações",
"model_guard.modal": "Nenhum modelo foi adicionado, portanto este recurso está indisponível no momento.\n\nAdicione uma conta de modelo nas Configurações.",
"marketplace.title": "Marketplace",
"marketplace.tab_agent": "Agentes",
diff --git a/src/renderer/locales/zh.json b/src/renderer/locales/zh.json
index 91c9f757..236738d9 100644
--- a/src/renderer/locales/zh.json
+++ b/src/renderer/locales/zh.json
@@ -1897,8 +1897,6 @@
"search.no_results": "未找到「{query}」相关内容",
"search.role.user": "我",
"search.role.ai": "AI",
- "model_guard.banner": "尚未添加模型,AI 功能暂不可用。请先在设置中添加模型账号。",
- "model_guard.cta": "前往设置",
"model_guard.modal": "尚未添加模型,暂时无法使用此功能。\n\n请先在设置中添加模型账号。",
"marketplace.title": "官方平台",
"marketplace.tab_agent": "智能体",
diff --git a/src/renderer/modules/model-guard.js b/src/renderer/modules/model-guard.js
index f3ae63c5..c77188a1 100644
--- a/src/renderer/modules/model-guard.js
+++ b/src/renderer/modules/model-guard.js
@@ -1,12 +1,10 @@
// ─── Model config guard ──────────────────────────────────────────────────
-// Central gate that keeps LLM-dependent features disabled until the user
-// has at least one (provider, model, credential) entry. Two surfaces:
-// 1) a persistent banner pinned above the main content area that links
-// to the settings page (hidden on settings itself);
-// 2) `ensureModelConfigured()`, a synchronous check that action handlers
-// call before firing an LLM-backed request — it short-circuits with
-// an alert + settings redirect when the user hasn't configured a
-// model yet, so every action path fails the same way.
+// Central gate that keeps LLM-dependent actions disabled until the user has
+// at least one (provider, model, credential) entry. `ensureModelConfigured()`
+// is the synchronous action boundary: it short-circuits with an alert and a
+// Settings redirect when no model is available. There is intentionally no
+// persistent page-level warning; the user only needs guidance when starting
+// an action that requires a model.
// Refreshed at boot and after Settings reloads following a successful
// credential/entry transaction, OAuth entry creation, repair, or deletion.
@@ -17,64 +15,9 @@ function _modelGuardErrorType(error) {
}
let _hasConfiguredModel = true; // optimistic — flipped to false after refresh if empty
-let _guardBannerEl = null;
-let _guardChecked = false;
let _modelGuardRefreshSequence = 0;
let _modelConfigSnapshotSignature = '';
-function _ensureGuardBanner() {
- if (_guardBannerEl) return _guardBannerEl;
- const main = document.querySelector('.main-content');
- if (!main) return null;
- const el = document.createElement('div');
- el.className = 'model-guard-banner';
- el.id = 'model-guard-banner';
- el.style.display = 'none';
- const dotIcon = (typeof window !== 'undefined' && typeof window.uiIconHtml === 'function')
- ? window.uiIconHtml('dot', 'ui-icon')
- : '';
- el.innerHTML = `
- <span class="model-guard-icon" aria-hidden="true">${dotIcon}</span>
- <span class="model-guard-text">${escapeHtml(t('model_guard.banner'))}</span>
- <button type="button" class="btn btn-sm btn-primary model-guard-cta">${escapeHtml(t('model_guard.cta'))}</button>
- `;
- el.querySelector('.model-guard-cta').addEventListener('click', () => {
- if (typeof setView === 'function') {
- setView('settings', null, { entryPoint: 'model_guard_banner' });
- }
- // Drop the user straight on the 配置 (Credentials) tab — that's where
- // the model-auth UI lives now (Phase 4 4-tab restructure).
- _activateModelCredentialsTab();
- });
- // Keep this one in sync when user toggles language.
- window.addEventListener('i18n-change', () => {
- if (!_guardBannerEl) return;
- const txt = _guardBannerEl.querySelector('.model-guard-text');
- const cta = _guardBannerEl.querySelector('.model-guard-cta');
- if (txt) txt.textContent = t('model_guard.banner');
- if (cta) cta.textContent = t('model_guard.cta');
- });
- // Pin to the top of the main content area so it's visible on every view
- // except settings (see CSS: `.panel-settings-active .model-guard-banner`).
- main.insertBefore(el, main.firstChild);
- _guardBannerEl = el;
- return el;
-}
-
-function _applyGuardVisuals() {
- const banner = _ensureGuardBanner();
- if (banner) banner.style.display = _hasConfiguredModel ? 'none' : '';
- document.body.classList.toggle('model-not-configured', !_hasConfiguredModel);
- syncModelGuardBannerTelemetry();
-}
-
-/** Called after both model-state refreshes and logical view changes. The CSS
- * hides this banner on Settings, so only count an impression on a view where
- * the user can actually see it. */
-function syncModelGuardBannerTelemetry() {
- // Commercial telemetry is intentionally absent from the open build.
-}
-
async function refreshModelGuard() {
const refreshSequence = ++_modelGuardRefreshSequence;
try {
@@ -89,7 +32,6 @@ async function refreshModelGuard() {
await refreshModelConfigSnapshot();
if (refreshSequence !== _modelGuardRefreshSequence) return _hasConfiguredModel;
_hasConfiguredModel = configured;
- _guardChecked = true;
} else {
_guardLog.warn('refresh ipc not-ok', { error: res && res.error });
}
@@ -97,7 +39,6 @@ async function refreshModelGuard() {
_guardLog.warn('refresh failed', { error: (e && e.message) || String(e) });
}
if (refreshSequence !== _modelGuardRefreshSequence) return _hasConfiguredModel;
- _applyGuardVisuals();
return _hasConfiguredModel;
}
diff --git a/src/renderer/style.css b/src/renderer/style.css
index bf253f0c..5844d0d7 100644
--- a/src/renderer/style.css
+++ b/src/renderer/style.css
@@ -2670,38 +2670,6 @@ body.is-sidebar-resizing iframe { pointer-events: none; }
overflow: hidden;
}
-/* When the model-guard banner is visible we switch main-content to a
- vertical stack so the banner sits above the active panel instead of
- fighting it for horizontal space. */
-body.model-not-configured .main-content { flex-direction: column; }
-
-/* Top-of-main warning banner: shown on every view except settings when
- no (provider, model, credential) entry has been configured. CTA jumps
- the user straight into the settings page. */
-.model-guard-banner {
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px 20px;
- background: #fff7e6;
- border-bottom: 1px solid #f0c66b;
- color: #7a4d00;
- font-size: 13px;
- line-height: 1.5;
- flex: 0 0 auto;
-}
-.model-guard-banner .model-guard-icon {
- color: #d97706;
- font-size: 14px;
- line-height: 1;
-}
-.model-guard-banner .model-guard-text { flex: 1; }
-.model-guard-banner .model-guard-cta { flex: 0 0 auto; }
-
-/* Hide the banner when the user is already on the settings page (they're
- at the fix spot anyway). Uses :has() — Electron's Chromium supports it. */
-.main-content:has(#panel-settings.active) .model-guard-banner { display: none !important; }
-
.panel {
display: none;
flex: 1;
diff --git a/test/e2e/app_e2e_smoke.spec.ts b/test/e2e/app_e2e_smoke.spec.ts
index 536f0ecc..920b13bb 100644
--- a/test/e2e/app_e2e_smoke.spec.ts
+++ b/test/e2e/app_e2e_smoke.spec.ts
@@ -84,7 +84,7 @@ test.describe('desktop shell', () => {
))).toBe(true);
const model = await orkas.invoke<{ configured: boolean }>('auth.hasConfiguredModel');
expect(model.configured).toBe(true);
- await expect(appPage.locator('#model-guard-banner')).toBeHidden();
+ await expect(appPage.locator('#model-guard-banner')).toHaveCount(0);
const openBuildEnvironment = await appPage.evaluate(async () => {
const env = await (window as any).orkas.env();
diff --git a/test/e2e/fixtures/orkas.ts b/test/e2e/fixtures/orkas.ts
index d1d3bf6c..73f9c474 100644
--- a/test/e2e/fixtures/orkas.ts
+++ b/test/e2e/fixtures/orkas.ts
@@ -1054,7 +1054,7 @@ export class OrkasTestApp {
await (window as any).refreshModelGuard();
}
});
- await expect(page.locator('#model-guard-banner')).toBeHidden();
+ await expect(page.locator('#model-guard-banner')).toHaveCount(0);
}
// Builtin Marketplace installation is intentionally deferred from the
// renderer-ready signal. Open-build E2E cases exercise shipped agents
diff --git a/test/e2e/settings_e2e_modules.spec.ts b/test/e2e/settings_e2e_modules.spec.ts
index 7657b410..5d63f0f2 100644
--- a/test/e2e/settings_e2e_modules.spec.ts
+++ b/test/e2e/settings_e2e_modules.spec.ts
@@ -147,4 +147,32 @@ test.describe('settings modules and model guard', () => {
await expect(row).toHaveCount(0);
});
+ test('keeps an empty model state quiet until an LLM action needs configuration', async ({ appPage, orkas }) => {
+ const listed = await orkas.invoke<{
+ entries: Array<{ entryId: string }>;
+ }>('auth.listEntries');
+ for (const entry of listed.entries) {
+ const removed = await orkas.invoke<{ ok: boolean; removed: boolean }>('auth.removeEntry', {
+ entryId: entry.entryId,
+ });
+ expect(removed).toMatchObject({ ok: true, removed: true });
+ }
+
+ const silentResult = await appPage.evaluate(async () => {
+ await (window as any).refreshModelGuard();
+ return (window as any).ensureModelConfigured({ silent: true });
+ });
+ expect(silentResult).toBe(false);
+ await expect(appPage.locator('#model-guard-banner')).toHaveCount(0);
+ await expect(appPage.locator('#panel-new-chat')).toHaveClass(/\bactive\b/);
+
+ await appPage.locator('#new-chat-input').fill('This request needs a configured model.');
+ await appPage.locator('#new-chat-send-btn').click();
+
+ await expect(appPage.locator('#panel-settings')).toHaveClass(/\bactive\b/);
+ await expect(appPage.locator('.settings-tab[data-settings-tab="credentials"]')).toHaveClass(/\bis-active\b/);
+ await expect(appPage.locator('.ui-dialog-overlay:visible .ui-dialog')).toBeVisible();
+ await expect(appPage.locator('#conversation-list .conv-item')).toHaveCount(0);
+ });
+
});