Skip to content

Latest commit

 

History

History
221 lines (131 loc) · 16.5 KB

web-interface-guide.md

File metadata and controls

221 lines (131 loc) · 16.5 KB

Web Interface Guide

This document describes the complete workflow of the SQL Coder web interface: model service configuration, database connection configuration, semantic file generation, workspace creation, conversational interaction, SQL validation, and keyboard shortcuts. All screenshots are taken from a running instance with the interface set to English; the Chinese edition is web-interface-guide.zh-CN.md.

0. Terminology and prerequisites

A data subject in the interface corresponds to one source_id under databases in the runtime configuration. A workspace is bound to exactly one data subject at creation time and does not switch databases afterwards. The semantic file is the sole description of the schema available to the model, and its semantic_model.name must equal that source_id; when the file is produced through the interface, the value is written automatically and requires no manual editing.

The interface requires:

  1. Python dependencies and Node.js 18 or later installed locally;
  2. a running local bridge process; no configuration file has to be prepared — the first start writes an empty skeleton, and the model, connections, semantic files and memory switch are set in the interface;
  3. the frontend served either by the bridge (after a build) or by the development server.

Startup commands and the two deployment modes are documented in the Web interface section of the README. The rest of this document assumes the interface is open in a browser.

1. Configuring the model service

The model service is the first card on the Settings page, reachable from the left navigation rail.

Figure 1 Model service card

The card has four elements: Provider, Model, Base URL (custom providers only) and API Key. Test and Save in the upper-right corner verify endpoint availability and persist the configuration, respectively.

1.1 Provider

Provider is a drop-down whose values are the English vendor names; the selection determines the default endpoint and the candidate models. The supported values are:

Value Displayed as Default base URL
deepseek DeepSeek https://api.deepseek.com
openai OpenAI https://api.openai.com/v1
qwen Qwen https://dashscope.aliyuncs.com/compatible-mode/v1
kimi Kimi https://api.moonshot.cn/v1
glm GLM https://open.bigmodel.cn/api/paas/v4
doubao Doubao https://ark.cn-beijing.volces.com/api/v3
minimax MiniMax https://api.minimaxi.com/v1
hunyuan Hunyuan https://api.hunyuan.cloud.tencent.com/v1
xiaomi Xiaomi MiMo https://api.xiaomimimo.com/v1
generic Custom (OpenAI-compatible) supplied by the user

Figure 2 Provider drop-down

For a preset provider the base URL is fixed by the preset and applied in the background, so the field is not displayed. For generic, the card adds a Base URL row, which must not be empty. When the provider is switched, the model field falls back to the first candidate of the new provider if the current model does not belong to that provider's candidate set; generic has no candidate set, so a typed model name is preserved.

1.2 Model and key

Model is an editable drop-down rather than a closed list: the options list the provider's common models, and a new model name can be typed directly, so releases newer than the interface remain usable. API Key is a password field; a stored key is shown only by its last four characters (for example ••••6882). Submitting the form with this field empty keeps the stored key instead of clearing it.

Validate the configuration in two steps:

  1. Select Test. On success the card shows Connected · {latency}ms; on failure a dialog reports the error code and the original message.
  2. Select Save. The llm section of the runtime configuration file loaded by the bridge is rewritten; the key is stored in that file in clear text, and the interface subsequently returns only its last four characters.

Changes take effect for subsequent requests and do not alter SQL versions that have already been committed.

2. Configuring database connections

The second card on the Settings page, Database connections, lists every configured connection.

Figure 3 Database connection list

Each row has three parts: the connection identifier with database details (dialect, host and port, database name); the semantic file summary (file name, table count, generation time); and row actions (Edit, Delete). When no semantic file exists, the second line reads No semantic file.

2.1 Adding a connection

Select Add connection in the card header and fill in the dialog.

Figure 4 Add connection dialog

Field Meaning Notes
Name source_id Unique identifier of the connection and the data-subject identifier in workspaces; immutable after creation
Type SQL dialect MySQL in the current release
Host and port Endpoint An empty port lets the driver apply its default
Database Database name Must match a database visible to the account
User / Password Credentials The password is masked; only a placeholder is echoed on later edits

The dialog provides three actions. Test verifies connectivity and credentials without writing the configuration. Cancel discards the edit. Save & generate semantic file writes the connection and immediately starts semantic file generation (Section 3).

2.2 Editing and deleting

Edit opens the same dialog with the name read-only. If the dialect, host, port, database or user changes, saving regenerates the semantic file; when only fields that cannot affect the schema (for example the password) change, the existing file is reused.

Delete requires confirmation. If any workspace still references the connection, its data is retained and the connection is marked disabled instead of removed: it disappears from the data-subject candidates for new workspaces, while existing workspaces remain usable. The interface reports Still used by {count} workspaces, so it was disabled.

2.3 Memory

The Memory switch at the bottom of the settings page governs business memory. When on, the system summarises the business definitions and query constraints that appear in a conversation — including the result conclusions confirmed in that round — stores them locally, and injects them as context into later sessions; when off, nothing is read or written.

It is off by default. With it off the system still keeps sessions, versions and debug evidence — it simply does not accumulate cross-session definitions. A change is written to the runtime configuration immediately (memory.enabled) and needs no bridge restart; open sessions apply it from their next request.

3. Generating the semantic file

The semantic file is the schema view presented to the model and determines which tables, columns and descriptions the model may reference when generating SQL. Generation is triggered by Save & generate semantic file and proceeds in four stages, with progress reported inside the dialog:

  1. Connecting — establish the connection and verify credentials;
  2. Reading tables — enumerate the tables in the database;
  3. Reading columns — read column names, types and available comments table by table;
  4. Writing file — write content/semantic/<source_id>.yaml.

On completion the dialog closes and the row displays the file name, table count and generation time (Figure 3). On failure an error dialog appears, the connection record is retained and the semantic file remains absent; saving again retries the scan.

3.1 Inspecting the generated file

After generation, open the Data structure window from the navigation rail to inspect exactly what the model reads.

Figure 5 Data structure window

The window provides a semantic-file selector at the top, the list of tables with column counts on the left, the columns and types of the selected table in the middle, and the first ten rows of that table at the bottom. The preview queries the database directly and exists for verification only; it is not part of the model call. If the connection behind the file has been deleted, the preview is unavailable while the column metadata remains readable.

Note that the model answers from the semantic file alone and does not read database metadata directly. Columns whose business meaning is not evident from their names should be documented in the semantic file and the file regenerated, otherwise the model can only infer meaning from identifiers.

4. Creating a workspace

A workspace is the container of one conversation; it binds a data subject and stores the conversation, SQL versions and execution evidence.

From Workspaces (the home page), select New in the upper-right corner.

Figure 6 Workspace list

The list is ordered by update time and shows name, data subject, SQL dialect, version, update time and actions. The search box filters by name. Deletion requires confirmation and removes the entire conversation with its records.

Figure 7 New workspace dialog

Provide a Name and select a Data subject. Candidates include only connections that own a semantic file; SQL dialect is filled from the selected subject and is not editable. Names must be unique across all workspaces; a duplicate name is rejected with an error message.

Selecting Create opens the workspace. Neither the name nor the subject can be changed on this page afterwards; use a new workspace to change either.

5. Conversational interaction

The workspace is split into two panes: the current SQL and its actions on the left, the Coder conversation on the right.

Figure 8 Workspace and conversation

5.1 Layout

The left pane contains, from top to bottom, a toolbar (Copy SQL, Format, Validate query, current target range), the SQL editor, and a save hint. The editor accepts direct edits; while uncommitted changes exist the toolbar marks Unsaved edits, and the SQL is saved automatically before a message is sent or a validation is started.

The right pane contains the conversation, the composer, and the mode and command hints. The heading shows the current phase, for example Writing SQL, Awaiting clarification or Awaiting review.

5.2 Sending a request

Describe the requirement in natural language (tables, aggregation rules, filters, ordering) and submit with Send or Enter. The system then reads the semantic file, samples data when needed, generates SQL, and writes the result to the left pane. The editor is read-only during generation; Stop terminates the run, and committed SQL versions and pending checkpoints survive termination.

Normal mode produces SQL directly. Plan mode first produces a query plan that must be approved before SQL is generated. Normal mode suits well-specified requests; plan mode reduces rework when joins or metric definitions need agreement in advance.

5.3 Clarification and plan review

When a request admits several valid interpretations, a Confirm requirements card appears in the right pane, listing each question with candidate answers, a recommended option and an Other… free-text input. After all questions are answered, Confirm and continue resumes the run with those answers.

In plan mode the plan requires approval: Generate from this plan approves the current plan, while an instruction typed into the composer asks the model to revise it before another review.

5.4 Versions and history

Every committed change creates a new SQL version, shown next to the pane title (for example SQL v1). History lists each version with its kind, version number and summary; a selected version can be previewed and restored through the conversation.

Start over returns the window to the state before the first question: the conversation, the version history and the business-memory records produced in that window are removed, irreversibly. New session creates another workspace under the same data subject.

6. Debugging SQL

The editor also serves as a read-only debugger. Validate query executes the SQL against the real database and returns the result, which confirms syntax and semantics as well as locating the failing stage of a multi-part query. The scope follows the selection; the three granularities are shown in the three figures below.

6.1 The whole statement

With no selection, the entire SQL is executed.

Figure 9 Debug results for the whole statement

The panel has two tabs: Results lists the columns and rows returned for each target, and Executed SQL shows the statement actually issued. The figure above is a query without CTEs, returning 20 rows.

6.2 A single CTE

When the selection fully covers one or more CTE declarations, those CTEs are executed, with the CTEs they depend on materialised as a WITH prefix.

Figure 10 Debug results after selecting a complete CTE

Here british is selected (lines 1–10) and the panel returns driver_id and nationality, not the full_name and wins of the final statement. Different columns mean a different scope: that is the direct evidence that only the CTE ran, and the toolbar states both version and range as SQL v{n} · lines 1–10.

6.3 A SELECT fragment inside a CTE

When the selection covers only the SELECT body of a CTE, that fragment is executed with the CTEs visible above it materialised as a WITH prefix, so the fragment runs on its own.

Figure 11 Executed SQL for a SELECT fragment inside a CTE

The selection is the SELECT inside wins (lines 12–21), whose FROM british b reads an upstream CTE. The Executed SQL tab is the evidence: the statement issued begins with WITH british AS (…) and only then the selected fragment. A single JOIN or aggregate can therefore be isolated without stitching the upstream definitions by hand, and without touching the rest of the statement.

6.4 Shared constraints

  • Uncommitted edits are saved before execution; the verdict is bound to the SQL version, so after further edits it must be repeated.
  • At most data_access.max_rows rows are returned, each statement is subject to statement_timeout_seconds, and write operations are rejected.
  • The divider between editor and panel is draggable, and Hide result / View result toggle the panel.

7. Keyboard shortcuts

Action Shortcut Scope
Save current SQL Ctrl + S / ⌘ + S SQL editor
Undo / redo Ctrl + Z / Ctrl + Shift + Z (⌘ on macOS) SQL editor
Send message Enter Composer
Insert line break Shift + Enter Composer
Open command menu / Composer
Move within menu ↑ / ↓ Command menu
Select command Enter or Tab Command menu
Close menu Esc Command menu

Figure 12 Command menu

Commands are grouped by purpose: General contains /sql_explain (explain the current or selected SQL) and /sql_fix (repair SQL according to a requirement or a validation error); SQL authoring contains /sp (write a stored procedure with parameters and logic agreed in natural language). A command may be submitted on its own as a complete request, or followed by an instruction, for example /sql_fix handle nulls.

While a generation or validation is running the editor is read-only and Ctrl + S does not save; wait for the run to finish or stop it first.

8. Troubleshooting

Symptom Cause Remedy
Provider and model saved, but Test returns 404 Missing path prefix in the base URL, or the model is not available to the account Compare against the table in Section 1.1
Test returns 401 Wrong or truncated key, or a key that does not match the endpoint Paste the key again and confirm it belongs to the provider
No semantic file after saving a connection The account cannot read the schema, or the scan was interrupted Read the error code in the dialog, correct the cause and save again
The data-subject list is empty when creating a workspace No connection has a semantic file yet Complete Section 3 first
Validation fails with a permission error The database account is restricted beyond read-only, or the host is unreachable Use an account with read-only access to the database