Files
dbx/apps/desktop/src/lib
chenow9andt8y2 d08189ba7d feat(ai): add Grok CLI as a Desktop no-API-key provider
* feat(ai): add Grok CLI as a Desktop no-API-key provider

Add grok-cli alongside Codex/Claude Code/Pi, with path/env settings,
isolated MCP-scoped headless runs, model listing, and connection test.

* feat(ai): expose Grok CLI reasoning effort like Codex

Attach low/medium/high effort capabilities to Grok models for the
assistant effort menu, wire resolve_model_effort for grok-cli, and
use the monochrome Grok mark icon.

* i18n: add Grok CLI error messages for remaining locales

Fill grokCli* cliErrors strings in es, it, ja, ko, pt-BR, and zh-TW
to match en/zh-CN and satisfy i18n autofill CI.

* fix(ai): align Grok CLI headless with official Build flags

Address review feedback on PR #5494:
- Use streaming-json + CliAgentJsonlDialect::GrokStreamingJson
- Switch permission to --always-approve and MCPTool(dbx__*) rules
- Prefer --effort over --reasoning-effort; keep --prompt-file

Verified with unit tests and a local headless e2e against grok 1.0.

* style(ai): fix rustfmt for Grok CLI provider files

* test(ai): fix Grok CLI entry in provider ordering spec

* fix(ai): harden grok CLI error wording and config schema

Add 'not signed in' to classify_grok_run_error and test_grok_connection
auth detection — real @xai-official/grok 1.0.0 emits this exact wording
on headless auth failure (verified against the shipped binary).

Remove invalid config.toml fields: permission_mode='always-approve'
(not a valid enum; auto-approve is driven by --always-approve flag) and
startup_timeout_sec/tool_timeout_sec/enabled_tools (not mcp_servers
schema fields per 'grok mcp add').

---------

Co-authored-by: t8y2 <1156263951@qq.com>
2026-08-10 10:54:27 +08:00
..

Desktop Library Layout

src/lib is organized by product/runtime domain. Keep implementation modules inside a domain folder instead of adding new files at the root.

  • backend: Tauri, HTTP, platform, storage, and transport bridges.
  • common: generic helpers with no DBX feature ownership.
  • app, tabs, sidebar, connection: shell, navigation, and connection UI state helpers.
  • database, metadata, schema, table: relational database metadata, capabilities, DDL, and table-object helpers.
  • sql, sql/semantic, editor, query, history, savedSql: SQL editing, execution, diagnostics, history, and saved SQL behavior. Keep fixed SQL completion statements and their database-specific variants in sql/sqlSnippetTemplates.ts; cross-check row-limiting families against crates/dbx-core/src/sql_dialect/capabilities.rs and authoritative dialect documentation, and never replace a user-customized built-in body with a generated default.
  • dataGrid: result/grid rendering, editing, previews, pagination, and export helpers tied to the grid.
  • ai, mcp: AI assistant and MCP configuration helpers.
  • redis, mongo, elasticsearch, etcd, kv, mq, nacos, zookeeper, webdav: non-relational or service-specific helpers.
  • diagram, document, export, imports: feature-specific utilities that are shared by more than one component.

Tests under src/lib/__tests__ mirror the same domain folders. When moving a module, update both runtime imports and colocated tests so stale root-level aliases do not return.

Schema Diff Metadata Guardrails

Schema comparison must filter disabled object types before loading metadata. Tables load columns and the relational metadata enabled by the compare options; views load DDL only.

Do not call column, index, foreign-key, or trigger metadata APIs for views. MySQL 5.7 can validate a SQL SECURITY DEFINER view during column discovery and return error 1143 when its definer account no longer exists, even though SHOW CREATE VIEW still succeeds. Keep view detection centralized in schema/schemaDiffTableFilter.ts and preserve the DDL-only plan in schema/schemaDiffMetadataLoad.ts.

Regression coverage belongs in:

  • src/lib/__tests__/schema/schemaDiffTableFilter.spec.ts
  • src/lib/__tests__/schema/schemaDiffMetadataLoad.spec.ts