From b87cfa15cef1dbb8b9b89708bec10ee2c835da18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Wed, 2 Dec 2026 19:26:31 +0000 Subject: [PATCH] VS Code: the panel written up; a refused change goes back; only a listed mode or model is passed on - README and CHANGELOG: the views, the rule for whole or beside the conversation, what stays outside the panel and why, how the settings' levels work. - A setting change the extension refused puts the field back to what is in force. - A session's mode and model from the page are passed on only when the session or the server listed them; "Choose the Mode" opens a session first so its list is there. - The Status view looks up who is signed in the first time it is asked for. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 39 +++++++ README.md | 14 ++- vscode/README.md | 207 ++++++++++++++++++++++++--------- vscode/extension.js | 11 +- vscode/media/chat.js | 7 +- vscode/tests/extension.test.js | 4 + vscode/tests/page.test.js | 10 +- vscode/tests/vsix.test.js | 2 +- 8 files changed, 225 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e748aab..d5f7916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,45 @@ ## Unreleased +### Changed (VS Code / VSCodium) + +- **Everything is in the one panel.** The LLeMbas side panel has a strip of tabs — Chat, Sessions, + Models, Autocomplete, Settings, Account, Status — over one frame, and nothing asks anywhere else: + no Quick Pick, no input box, no notification that wants an answer, no trip to the editor's + Settings page. Every command is still in the palette and on its key; each now opens the panel + where it belongs or does its work in the file. The view that is open, and what you were typing, + are there again after the panel is closed or the window reloaded. +- **Whole, or beside the conversation.** A tab opens its view in the whole frame. Anything reached + from the conversation — the model button, History, a note's button, *Resume a Previous Session*, + *Choose This Session's Model*, *Open File from Project Index* — opens beside it (below it in a + narrow panel, next to it from 640 px) and closes back with Esc, leaving the composer's text, the + scroll and the keyboard where they were. +- **Every setting has a field in the panel**, made from one table that follows the manifest. They + stay the editor's own settings: each field shows where its value comes from, is written to the + level you choose (User or Workspace) and can be reset there, and follows a change made elsewhere + at once. The *Tune* drawer is gone: its settings are the Autocomplete view. +- **Signing in and out is the Account view**: the address, the code to approve with a button for + the approval page (the browser is no longer opened by itself), the question whose sign-in is + replaced, and Cancel — all in the panel. +- **Models are three lists in the Models view**: this conversation's, the chat and rewrite model, + and the autocomplete model, each saved in the account or for this window only. +- **Rewrite and Generate ask for their instruction above the composer**, show the rewrite being + written with a way to stop it, and offer *Accept all* / *Reject all* there; the changes are still + answered one by one in the file. *Ask About the Selection* attaches the selection and puts the + keyboard in the composer. + +### Added (VS Code / VSCodium) + +- **Sessions view**: filter, resume, new, and delete (where the CLI can), asked again in the row. +- **Status view**: the agent's state, the program and its version, what this and the server need, + what went wrong lately, what the agent last wrote, and *Restart the agent*. Commands *LLeMbas: + Status of the Agent* and *LLeMbas: Settings (in the Panel)*. +- What the page sends is checked against a schema: a setting is written only when it is one of + LLeMbas's, with a value of its type and range; a server's address the program would read as an + option is refused. +- Controls are 28 px high, fields keep their label, control, hint and level on shared rows, nothing + scrolls sideways in a 240 px side bar, and high-contrast themes and reduced motion are respected. + ## [1.0.0-beta.6] — 2026-12-01 Both editors were checked method by method against the LLeMbas CLI (2.0.0-beta.17) and now run diff --git a/README.md b/README.md index a3084ed..345261b 100644 --- a/README.md +++ b/README.md @@ -109,11 +109,15 @@ scripts/package-vscode.sh # writes dist/llemba codium --install-extension dist/llembas-.vsix # or: code --install-extension … ``` -Includes a redesigned sidebar chat with interactive approval, question and plan cards, real GFM -tables, code-block Copy/Insert toolbars, collapsible thinking and tool output, session resume and -compaction, `@file` and `/command` popups, inline diff rewrites and generation, inline autocomplete -with a **Tune** drawer (max-tokens slider, length presets, and custom instructions), and shown -media. Commands, keys, and settings: [`vscode/README.md`](vscode/README.md). +Everything is in **one side panel**: a strip of tabs over one frame — Chat, Sessions, Models, +Autocomplete, Settings, Account, Status. The chat has interactive approval, question and plan +cards, real GFM tables, code-block Copy/Insert toolbars, collapsible thinking and tool output, +session resume and compaction, `@file` and `/command` popups and shown media; rewrites and +generation are inline diffs; autocomplete is inline. Every `llembas.*` setting has a field in the +panel (written to your User or Workspace settings, as you choose), signing in happens in the +Account view, and nothing asks through a Quick Pick, an input box or a notification. A view reached +from the conversation opens beside it and closes back to it. Commands, keys, and settings: +[`vscode/README.md`](vscode/README.md). ## Tests diff --git a/vscode/README.md b/vscode/README.md index 00e741f..be00222 100644 --- a/vscode/README.md +++ b/vscode/README.md @@ -1,8 +1,10 @@ # LLeMbas for VS Code and VSCodium -LLeMbas in the editor: an agentic chat beside your files, questions and plans as interactive cards, -rewriting and generating code as inline diffs, session resume, `@file` and `/command` completion, -and tunable inline autocomplete. +LLeMbas in the editor, **in one side panel**: an agentic chat beside your files, questions and plans +as interactive cards, rewriting and generating code as inline diffs, session resume, `@file` and +`/command` completion, tunable inline autocomplete — and, in the same frame, the sessions, the +models, every setting, the sign-in and the agent's status. Nothing sends you to a Quick Pick, an +input box, a notification that wants an answer, or the editor's Settings page. The extension is a client of the [LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI). The CLI is the agent: it holds the sign-in to your LLeMbas server, the models, the tools and the permissions. @@ -14,7 +16,7 @@ about a server or a model is set in the editor, only which command starts the CL - VS Code or VSCodium 1.85 or newer. - The LLeMbas CLI, 2.0.0-beta.16 or newer, on the same computer. An older one is said once, with how to update it (`lembas update`), and what it lacks is off. -- The CLI signed in to your LLeMbas server: **LLeMbas: Sign In** in the editor, or +- The CLI signed in to your LLeMbas server: the panel's **Account** view (*LLeMbas: Sign In*), or `lembas login
` in a terminal. It is the same sign-in — the CLI keeps **one for the whole computer**, which the terminal and the linked service use too. @@ -37,20 +39,58 @@ or in the editor: Extensions → `…` → *Install from VSIX…*. If the editor does not find `lembas` (an editor started from the desktop does not always have your shell's `PATH`) it also looks in `~/.local/bin`, where the CLI's installer puts it; anywhere else, -set **LLeMbas: Command** to the program's full path. +set the program's full path in the panel under **Settings → Program** (`llembas.command`). The extension is off in a folder you have not trusted (Restricted Mode): it starts an agent that works in that folder. ## What it does -**Chat.** The LLeMbas icon in the activity bar opens the chat. The header shows the connection -status, session title, mode (switchable live mid-turn), session model, **Tune** (autocomplete -settings drawer), **Compact**, **History** (resume previous sessions), and **New**. Enter sends -(or steers mid-run), Shift+Enter starts a new line, `@` searches project files and folders, and `/` -completes slash commands and skills. Approval cards open edited files in the diff view first; -question cards support single/multi-select, recommended markers, custom answers, and skip; plan -cards render formatted Markdown with Approve (Edit/Manual), Revise, and Dismiss actions. +**One panel.** The LLeMbas icon in the activity bar opens it. A strip of tabs runs along its top — +**Chat, Sessions, Models, Autocomplete, Settings, Account, Status** — icons in a narrow side bar +(each with its name as a tooltip and for a screen reader), icons with their names in a wide one. +The arrow keys walk the strip, `Home` and `End` go to its ends, and the view that is open is the +one you find again after closing the panel or reloading the window, with what you were typing. + +**Whole, or beside the conversation.** One rule decides how a view opens: + +- **A tab opens its view in the whole frame**, and so does a command that is about how LLeMbas is + set up (*Models*, *Settings*, *Sign In*, *Status*). The **Chat** tab is the way back. +- **Anything reached from the conversation opens beside it** — the model button and **History** in + the chat's header, a note's *Sign in* or *Status* button, and the commands that are about the + conversation in progress (*Resume a Previous Session*, *Choose This Session's Model*, *Open File + from Project Index*). The conversation stays where it is: the view takes the lower half of the + panel, or the right half when the panel is 640 px wide or more. **Esc** or **Close** puts it away + and gives the keyboard back to where it was; the composer's text and the place you had scrolled + to are untouched. + +Something in the conversation that waits for your answer while another view fills the frame marks +the **Chat** tab; it does not pull you away from what you are doing. + +**Chat.** The header shows the connection status, the session's title, the mode (switchable live +mid-turn), the session's model (a button: the models open beside the conversation), **Compact**, +**History** and **New**. Enter sends (or steers mid-run), Shift+Enter starts a new line, `@` +searches project files and folders, and `/` completes slash commands and skills. Approval cards +open edited files in the diff view first; question cards support single/multi-select, recommended +markers, custom answers, and skip; plan cards render formatted Markdown with Approve (Edit/Manual), +Revise, and Dismiss actions. + +**Sessions.** The earlier sessions of this folder, with a filter. A press resumes one; **Delete** +(where the CLI can delete a session) asks again in the row before anything goes. + +**Models.** Three lists from your server, the one in force marked: the model of **this +conversation**, the **chat and rewrite** model new sessions start with, and the **autocomplete** +model. The last two are kept *saved in your account* (every editor you sign in from uses it) or for +*this window only* (a quick switch, saved nowhere) — chosen next to each list. + +**Settings, in the panel.** Every `llembas.*` setting has a field in the panel: autocomplete's in +**Autocomplete**, the certificate file in **Account**, the rest in **Settings**. They are the +editor's own settings underneath, so `settings.json`, Settings Sync and policies work as ever. Each +field says where the value in force comes from (the default, your User settings, the Workspace, a +folder), lets you choose the level your change is written to (**User** or **Workspace**; what starts +a program is User only) and has a **Reset** for that level. A change made anywhere else — the +editor's Settings page, `settings.json` — shows in the panel at once. A small link at the foot of +**Settings** opens the editor's own Settings page; nothing needs it. What a model writes is drawn as text through the extension's own Markdown reader: paragraphs, headings, lists, task checklists, quotes, real GFM tables (in horizontally scrollable wrappers), @@ -60,19 +100,24 @@ references. HTML in a reply stays text, pictures in a reply are not loaded, and status, kind, duration, clickable changed files, and expandable output; thinking blocks collapse cleanly. -**Ask, Explain, Fix, Generate & Rewrite.** Ask about or explain a selection, fix reported warnings -and errors in the active file, generate code at the cursor, or rewrite selected lines as proposed -hunks with *Accept* / *Reject* CodeLenses and a side-by-side diff view. Nothing is written until you -accept, and hunks whose lines you edited meanwhile are dropped safely. +**Ask, Explain, Fix, Generate & Rewrite.** *Ask About the Selection* attaches the selection to your +next message and puts the keyboard in the composer. *Explain* and *Fix Problems* send at once. +*Generate* and *Rewrite* ask for their instruction in the panel, above the composer (Enter sends it, +Esc puts it away, and the keyboard goes back to your text); while the model writes, the same place +shows how far it is, with **Cancel**. The result is proposed hunks in the file, with *Accept* / +*Reject* CodeLenses and a side-by-side diff view — and, in the panel, **Accept all**, **Reject all** +and **Show as a diff**. Nothing is written until you accept, and hunks whose lines you edited +meanwhile are dropped safely. **Tunable Autocomplete.** Inline suggestions appear as you type and on `Alt+\` (Tab accepts, Escape -dismisses). Use the **Tune** drawer in the chat header (or Settings) to slide **Max Tokens** from a -few words up to a full file (`0`..`4096`), pick a prediction scope preset (`Auto`, `Few words`, -`Single line`, `Function / block`, `Large / file`), and add custom **Autocomplete instructions**. +dismisses). The panel's **Autocomplete** view holds all of it: on or off as you type, how much to +suggest (`Auto`, a few words, one line, a function or block, a large part of the file), the most +tokens (`0`..`4096`), the pause before asking, and your own instructions for suggestions. -**Two model settings.** *LLeMbas: Models (Autocomplete and Main)* — also the *LLeMbas* item in the -status bar — shows both the **autocomplete** model and the **main** model (chat and rewriting), saved -in your account or switched for this window only. +**In the status bar.** The *LLeMbas* item says which autocomplete model is in use and whether +suggestions are on, for when the panel is closed; a press opens the panel on **Models** (or, when +there are no suggestions because no model is chosen or nobody is signed in, where that is put +right). **Files the agent shows.** Pictures appear inline in the chat. Other files appear with *Open* (only for display-only kinds whose bytes match their filename) or *Show in folder* for anything else. Files @@ -82,63 +127,88 @@ over 64 MB are refused (`llembas.media.maxMegabytes`). open files back through the document so undo and disk stay in sync. A document keeps its own line ends (CRLF stays CRLF). -**Signing in.** *LLeMbas: Sign In* asks for your server's address (nothing is predefined), runs the -CLI's own sign-in, shows the code to approve and opens the approval page in your browser; the -notification's Cancel stops waiting. When it is approved the agent starts anew and the open chat -works at once. If the computer is signed in to another server already, the extension says which and +**Signing in.** The **Account** view says who this computer is signed in as. Type your server's +address (nothing is predefined) and press **Sign in**: the CLI's own sign-in runs, the view shows +the code to approve and where, with **Open the approval page** (your browser is opened when you +press it, never by itself) and **Cancel**. When it is approved the agent starts anew and the open +chat works at once. If the computer is signed in to another server already, the view says which and asks first: the new sign-in replaces it, for the terminal and the linked service too. For a server -with a private certificate authority set `llembas.login.caFile`; with it the CLI always makes a new -sign-in. *LLeMbas: Sign Out* signs the computer out, after asking. +with a private certificate authority, the certificate file is a field of the same view +(`llembas.login.caFile`); with it the CLI always makes a new sign-in. **Sign out** signs the +computer out, after asking in the view. **When something is wrong.** A CLI that is not found, is too old, is not signed in, stops or does -not answer is said in the chat in words, with what to do; a turn that failed says why. What the CLI -wrote on stderr is in the *LLeMbas* channel of the Output panel. *LLeMbas: Stop the Agent* ends a -stuck one; the next message starts it again. +not answer is said in the chat in words, with a button to where it is put right; a turn that failed +says why. The **Status** view has the agent's state, the program that is started and its version, +the oldest version this needs, what your server asks for, what went wrong lately, what the agent +last wrote on stderr (kept after it is gone), and **Restart the agent**. The same lines go to the +*LLeMbas* channel of the Output panel. + +## What stays outside the panel, and why + +- **Inline suggestions** (ghost text at the cursor) — they are about the text you are typing. +- **A rewrite's changes**: the marks in the file, the *Accept* / *Reject* CodeLenses above each + change, and the editor's own diff view — a change is judged where the code is. +- **The diff of an edit the agent asks about**, in the editor's diff view (the question itself is a + card in the chat). +- **The editor context menu, the keys and the command palette** — every command is still there, so + keys can be bound to them; each one opens the panel where it belongs or does its work in the file. +- **The status bar item** — one glance when the panel is closed; a press opens the panel. +- **A line of the editor's own** (a notification with no button) when a command could not start in + the editor: nothing selected, a rewrite already under way in that file. ## Commands and keys | Command | Key | | |---|---|---| -| LLeMbas: Open the Chat | `Ctrl+Alt+L` | | -| LLeMbas: Ask About the Selection | `Ctrl+Alt+K` | also in editor context menu | +| LLeMbas: Open the Chat | `Ctrl+Alt+L` | the panel on Chat, the keyboard in the composer | +| LLeMbas: Ask About the Selection | `Ctrl+Alt+K` | also in editor context menu; type the question in the composer | | LLeMbas: Explain the Selection | | editor context menu | | LLeMbas: Fix Problems in This File | | editor context menu | | LLeMbas: Generate Code at Cursor | | editor context menu | -| LLeMbas: Rewrite the Selection | `Ctrl+Alt+E` | also in editor context menu | +| LLeMbas: Rewrite the Selection | `Ctrl+Alt+E` | also in editor context menu; the instruction is typed in the panel | | LLeMbas: Suggest a Completion Here | `Alt+\` | | | LLeMbas: Toggle Autocomplete as You Type | | | | LLeMbas: Accept All Proposed Changes in This File | `Ctrl+Alt+Enter` | while changes are proposed | | LLeMbas: Reject All Proposed Changes in This File | `Ctrl+Alt+Backspace` | while changes are proposed | | LLeMbas: Accept / Reject the Proposed Change at the Cursor | | or CodeLenses above each change | | LLeMbas: Show the Proposed Changes as a Diff | | | -| LLeMbas: Open File from Project Index / Add File to Chat | | asks for part of the file's name | -| LLeMbas: New Session / Resume a Previous Session | | | +| LLeMbas: Open File from Project Index | | a search beside the conversation | +| LLeMbas: Add File to Chat | | an `@` in the composer, with the project's files listed under it | +| LLeMbas: New Session | | | +| LLeMbas: Resume a Previous Session | | the Sessions view, beside the conversation | | LLeMbas: Compact Session Context | | | | LLeMbas: Stop the Running Turn | | | -| LLeMbas: Choose the Mode / Choose This Session's Model | | | -| LLeMbas: Models (Autocomplete and Main) | | also status bar item | -| LLeMbas: Choose the Autocomplete Model / the Main Model | | | +| LLeMbas: Choose the Mode | | the keyboard on the mode list of the chat's header | +| LLeMbas: Choose This Session's Model | | the Models view, beside the conversation | +| LLeMbas: Models (Autocomplete and Main) | | the Models view; also the status bar item | +| LLeMbas: Choose the Autocomplete Model / the Main Model | | the Models view, on that list | +| LLeMbas: Settings (in the Panel) | | the Settings view | +| LLeMbas: Status of the Agent | | the Status view | | LLeMbas: Stop the Agent | | starts again when needed | -| LLeMbas: Sign In / Sign Out | | the CLI's one sign-in for this computer | +| LLeMbas: Sign In / Sign Out | | the Account view; the CLI's one sign-in for this computer | On macOS the keys use `Cmd` in place of `Ctrl`. ## Settings +Each has a field in the panel (the view is named in the last column), and is an ordinary setting of +the editor underneath. + | Setting | Default | | |---|---|---| -| `llembas.command` | `lembas` | the LLeMbas CLI, or its full path (machine-scoped) | -| `llembas.login.caFile` | | the CA file of a server with a private certificate authority, for *Sign In* (machine-scoped) | -| `llembas.chat.sendEditorContext` | on | send active file, cursor, selection, diagnostics and open files | -| `llembas.chat.showThinking` | off | show collapsible model thinking blocks | -| `llembas.chat.startMode` | | initial mode for a new session (machine-scoped) | -| `llembas.complete.auto` | on | suggest as you type; off: only on `Alt+\` | -| `llembas.complete.debounce` | 250 | pause in milliseconds before requesting a completion | -| `llembas.complete.maxTokens` | 0 | max tokens to predict (`0`: server default or preset; up to `4096`) | -| `llembas.complete.length` | `auto` | prediction scope preset (`auto`, `words`, `line`, `block`, `file`) | -| `llembas.complete.instructions` | `""` | custom instructions sent with autocomplete requests | -| `llembas.rewrite.openDiff` | on | open diff view beside the file when a rewrite is proposed | -| `llembas.media.maxMegabytes` | 64 | largest shown file accepted from the agent | +| `llembas.command` | `lembas` | the LLeMbas CLI, or its full path (User level only) — *Settings* | +| `llembas.login.caFile` | | the CA file of a server with a private certificate authority, for signing in (User level only) — *Account* | +| `llembas.chat.sendEditorContext` | on | send active file, cursor, selection, diagnostics and open files — *Settings* | +| `llembas.chat.showThinking` | off | show collapsible model thinking blocks — *Settings* | +| `llembas.chat.startMode` | | initial mode for a new session (User level only) — *Settings* | +| `llembas.complete.auto` | on | suggest as you type; off: only on `Alt+\` — *Autocomplete* | +| `llembas.complete.debounce` | 250 | pause in milliseconds before requesting a completion — *Autocomplete* | +| `llembas.complete.maxTokens` | 0 | max tokens to predict (`0`: server default or preset; up to `4096`) — *Autocomplete* | +| `llembas.complete.length` | `auto` | prediction scope preset (`auto`, `words`, `line`, `block`, `file`) — *Autocomplete* | +| `llembas.complete.instructions` | `""` | custom instructions sent with autocomplete requests — *Autocomplete* | +| `llembas.rewrite.openDiff` | on | open diff view beside the file when a rewrite is proposed — *Settings* | +| `llembas.media.maxMegabytes` | 64 | largest shown file accepted from the agent — *Settings* | ## Not there yet @@ -146,6 +216,13 @@ On macOS the keys use `Cmd` in place of `Ctrl`. - An edit the agent asks about in a chat is allowed or denied as a whole, not change by change. - No marketplace listing: install from the `.vsix`. - A question card has no "ask back" answer, and a plan card no editing of the plan in place. +- The effort of a conversation is shown (in **Models**) and cannot be changed from the editor: the + CLI does not tell an editor which levels a model has. +- A setting a folder of a multi-root workspace holds is shown as coming from that folder, and is + changed there: the panel writes the User and the Workspace level. +- In VS Code 1.85 itself, fields that stand side by side in a wide panel do not share their rows + (its browser has no `subgrid` yet); from 1.86 they do. In a narrow side bar fields are stacked + either way. - It has been tested against a stand-in for the editor and against the LLeMbas CLI itself, not yet in a release of VS Code by these tests: tell us what you see. @@ -153,11 +230,27 @@ On macOS the keys use `Cmd` in place of `Ctrl`. Plain JavaScript, no bundler, no dependencies, nothing fetched from the network, no telemetry. `extension.js` is the only file that talks to the editor; everything else is in `src/` and runs -without one. The chat page (`media/chat.js`) builds elements with `createElement` and `textContent` -only, under a strict Content-Security-Policy (no remote resource, no inline script or style); every -colour comes from VS Code's theme variables. What the page sends back is checked again by the -extension before anything is opened. The page says what happens to a screen reader (a turn began or -ended, something waits for your answer) and everything in it can be reached with the keyboard. +without one. The panel's page (`src/webview.js`, `media/chat.js`) builds elements with +`createElement` and `textContent` only, under a strict Content-Security-Policy (no remote resource, +no inline script or style); every colour comes from VS Code's theme variables, and high-contrast +themes and "reduce motion" are respected. + +- **The settings come from one table** (`src/settings.js`) made from the manifest: a setting that is + contributed cannot be missing from the panel, and a test fails when the table and the manifest + differ. +- **What the page sends is checked against a schema** (`src/messages.js`) — type, shapes, lengths, + enumerations — before anything is done. A setting is written only when it is one of the table, + with a value of its declared type and range, at a level it has; a model or a session only when + the server or the CLI listed it. A path typed in the panel is stored, never run: the CLI is + started as one list of arguments, and a server's address is refused when the program would read + it as an option. +- **Forms line up by construction**: a field is always its four parts — label, control, hint, level + — on the rows of the form it is in (`subgrid`), so two fields side by side keep their parts on + the same lines whatever the text does; a track gives up its minimum before a 240 px side bar + scrolls sideways; what is pressed is 28 px high. +- The page says what happens to a screen reader (a turn began or ended, something waits for your + answer, which view is in front), labels are tied to their controls, and everything in it can be + reached with the keyboard. ## Tests diff --git a/vscode/extension.js b/vscode/extension.js index cfa671a..10c28c9 100644 --- a/vscode/extension.js +++ b/vscode/extension.js @@ -515,9 +515,12 @@ class ChatView { } case 'detach': return this.attach(null); + // Only a mode the session has, only a model the server listed (or the one in force), whatever the page sends. case 'setMode': + if (this.chat.modes.length && !this.chat.modes.some((x) => String(x.id) === m.id)) return undefined; return a.guard(this.chat.setMode(m.id)); case 'setModel': + if (m.id !== this.chat.model && !this.chat.models.some((x) => x.id === m.id)) return undefined; return a.guard(this.chat.setModel(m.id)); case 'answer': return this.chat.answer(m.card, m.option); @@ -1137,6 +1140,8 @@ function activate(context) { if (what === 'models') return loadModels(); if (what === 'sessions') return loadSessions(); if (what === 'account') return account.refresh(); + // Status says who is signed in too: looked up once, the first time it is asked for. + if (!account.checked) account.refresh().then(postStatus, postStatus); return postStatus(); } @@ -1620,7 +1625,11 @@ function activate(context) { command('llembas.toggleAutocomplete', toggleAutocomplete); command('llembas.openFile', openIndexedFile); command('llembas.addFile', addFileToChat); - command('llembas.chooseMode', () => view.show('chat', { focus: 'mode' })); + command('llembas.chooseMode', async () => { + // The modes are the session's: one is opened first, so the list in the chat's header has them. + await chat.ensureSession(); + return view.show('chat', { focus: 'mode' }); + }); command('llembas.chooseModel', () => view.show('models', { beside: true, focus: 'm-session' })); command('llembas.modelSettings', () => view.show('models', { focus: 'm-main' })); command('llembas.chooseAutocompleteModel', () => view.show('models', { focus: 'm-autocomplete' })); diff --git a/vscode/media/chat.js b/vscode/media/chat.js index 392e207..ecfd16b 100644 --- a/vscode/media/chat.js +++ b/vscode/media/chat.js @@ -1368,14 +1368,15 @@ if (resetBtn) resetBtn.disabled = !(level === 'workspace' ? cfg.workspace : cfg.user); } - function showConfig() { + /** `force`: also the field that has the keyboard — a change that was refused goes back to what is in force. */ + function showConfig(force) { if (!data.config || !data.config.values) return; settingEls().forEach(function (elx) { var key = elx.getAttribute('data-setting'); var cfg = data.config.values[key]; if (!cfg) return; // What is being typed is not written over by its own echo. - if (doc.activeElement !== elx) { + if (force || doc.activeElement !== elx) { if (elx.type === 'checkbox') elx.checked = !!cfg.value; else elx.value = String(cfg.value === null || cfg.value === undefined ? '' : cfg.value); } @@ -1658,7 +1659,7 @@ } else if (m.type === 'refused' && typeof m.text === 'string') { // A write the extension did not take: said, and the field shows what is in force again. announce(m.text); - showConfig(); + showConfig(true); } else if (m.type === 'show') { // A command of the editor's: the panel opens where the command belongs. var view = String(m.view || 'chat'); diff --git a/vscode/tests/extension.test.js b/vscode/tests/extension.test.js index c6cbf1b..e6b816b 100644 --- a/vscode/tests/extension.test.js +++ b/vscode/tests/extension.test.js @@ -145,8 +145,12 @@ test('a message typed in the view is answered, and the reply reaches the page as assert.deepEqual(prompt.params._meta.lembas.editor, { path: path.join(dir, 'oven.py'), cursor: { line: 2 } }); assert.equal(sent().find((m) => m.method === 'session/new').params.cwd, dir); // The page's own controls. + view.say({ type: 'setModel', id: 'made/up' }); // not a model the server listed: not passed on + view.say({ type: 'setMode', id: 'root' }); view.say({ type: 'setModel', id: 'example/model-b' }); await until(() => state().model === 'example/model-b'); + assert.deepEqual(sent().filter((m) => m.method === '_lembas/configure').map((m) => m.params.model), ['example/model-b']); + assert.ok(!sent().some((m) => m.method === 'session/set_mode')); view.say({ type: 'setMode', id: 'edit' }); await until(() => state().mode === 'edit'); view.say({ type: 'new' }); diff --git a/vscode/tests/page.test.js b/vscode/tests/page.test.js index bbbe92d..66f77eb 100644 --- a/vscode/tests/page.test.js +++ b/vscode/tests/page.test.js @@ -503,8 +503,14 @@ test('settings: a field shows the value in force and where it comes from; a chan assert.equal(p.$('set-chat-showThinking-level').querySelector('option[value="workspace"]').disabled, true); assert.equal(p.$('set-complete-debounce-level').value, 'user'); // A write the extension refused is said. - p.tell({ type: 'refused', text: 'Pause before asking (milliseconds): from 0 to 5000' }); - assert.equal(p.$('announce').textContent, 'Pause before asking (milliseconds): from 0 to 5000'); + // The field goes back to what is in force, even with the keyboard still on it. + p.$('set-chat-showThinking').focus(); + p.$('set-chat-showThinking').checked = true; + p.fire(p.$('set-chat-showThinking'), 'change'); + p.tell({ type: 'refused', text: 'Open a folder to keep a setting for it.' }); + assert.equal(p.$('set-chat-showThinking').checked, false); + assert.equal(p.$('announce').textContent, 'Open a folder to keep a setting for it.'); + p.take(); // The way out, and the way across to the model. p.click('open-settings-ui'); assert.deepEqual(p.take(), [{ type: 'openSettingsUi' }]); diff --git a/vscode/tests/vsix.test.js b/vscode/tests/vsix.test.js index dde702d..71d613b 100644 --- a/vscode/tests/vsix.test.js +++ b/vscode/tests/vsix.test.js @@ -107,7 +107,7 @@ test('the package script builds a .vsix that is what an editor expects', (t) => assert.deepEqual({ ...packed, version: pkg.version }, pkg, 'otherwise the source manifest, unchanged'); assert.ok(names.includes('extension/' + packed.main.replace(/^\.\//, ''))); assert.ok(names.includes('extension/' + packed.contributes.viewsContainers.activitybar[0].icon)); - for (const need of ['extension/README.md', 'extension/LICENSE.txt', 'extension/media/chat.js', 'extension/media/chat.css', 'extension/src/rpc.js']) assert.ok(names.includes(need), need); + for (const need of ['extension/README.md', 'extension/LICENSE.txt', 'extension/media/chat.js', 'extension/media/chat.css', 'extension/src/rpc.js', 'extension/src/settings.js', 'extension/src/messages.js', 'extension/src/account.js', 'extension/src/webview.js']) assert.ok(names.includes(need), need); assert.equal(get('extension/LICENSE.txt'), fs.readFileSync(path.join(REPO, 'LICENSE'), 'utf8')); // Every module the code asks for is in the package, or is Node's or the editor's own.