From dfbdc36f90c39ca21bcfe6661182642ec4fa61c4 Mon Sep 17 00:00:00 2001 From: Callie Peden Date: Fri, 6 Nov 2026 16:53:43 -0500 Subject: [PATCH] web: show the extensions view in settings, with an optional session picker Settings > extensions renders the chat window's ExtensionsView without a session; a session drop-down under the search adds the per-session column. Removes the separate global-only ExtensionsSettings page and its tree helper. --- robot-docs/web.md | 2 +- test/manual/ux/extensions_check.py | 70 ++++----- web/scripts/extension-tree.test.mjs | 48 ------- web/src/lib/Settings.svelte | 61 +++++++- web/src/lib/api.ts | 51 +++++-- .../lib/settings/ExtensionsSettings.svelte | 134 ------------------ web/src/lib/settings/extension-tree.ts | 63 -------- web/src/lib/views/ExtensionsView.svelte | 80 +++++++---- 8 files changed, 186 insertions(+), 323 deletions(-) delete mode 100644 web/scripts/extension-tree.test.mjs delete mode 100644 web/src/lib/settings/ExtensionsSettings.svelte delete mode 100644 web/src/lib/settings/extension-tree.ts diff --git a/robot-docs/web.md b/robot-docs/web.md index f403bacfc..1a6a50a43 100644 --- a/robot-docs/web.md +++ b/robot-docs/web.md @@ -131,7 +131,7 @@ The **web search** section (`settings/WebSearchSettings.svelte`) is the TUI's `/ Extension config (`settings/ConfigurationSettings.svelte`) renders the daemon’s declared `extension_settings` fields, with search across sections and fields; clearing a field resets it to inheritance. A sticky category outline on the right follows the visible groups in page order, highlights the category at the scroll position, and scrolls only the editor when clicked (including on a zoomed canvas). On narrow windows it becomes a compact horizontal strip; jump targets stay below it, and reduced-motion preferences disable smooth scrolling. The editor owns the scroll container and passes it to the configuration form; a cleaned-up listener batches measurements of at most five category headings into one animation frame. These sections load lazily and retain drafts when changing sections. Both explicitly save only changed fields using the group’s observed ETag and `application/merge-patch+json`; 412 retains edits and offers an explicit discard/reload, never retries a stale write. Save errors, warnings and success remain visible, and in-flight saves disable the fields and defer closing until the save settles. MCP sign-ins reuse `McpServers.svelte`. Provider creation and credentials still belong to the CLI. `test/manual/ux/settings_check.py` drives singleton opening/focus, category jumps and scroll tracking, board switching with drafts, saves, resets, conflicts, browser persistence, window closing and the phone fallback through a private daemon and browser. -The **extensions** tab (`settings/ExtensionsSettings.svelte`) is global-only: a searchable dependency thread with one on/off control per extension (`settings/extension-tree.ts`: each extension sits below its deepest installed requirement, so files, which needs python and run, threads under run under python; a requirement the thread above does not show is named in a note). A toggle the daemon would refuse for a dependency is stopped before saving and says what to do first (`files is dependent on run. Disable files first in order to disable run.`, and the enabling counterpart); the daemon still validates. A toggle flips at once and only it shows as saving; the list then refreshes in place without dimming or a success banner (warnings and errors still show), and a refused save puts the toggle back, confirmation, and quarantine diagnostics. There is no session picker, override, follow-global or reload action. `GET /server?include=extensions` returns the installed global inventory, including disabled extensions, without creating or preparing any session; `http_catalog.global_extensions` encodes the runtime-owned facts. Global choices still use the `extensions` settings group and its observed ETag; stale writes refresh without retrying. Read the validator before the inventory so an intervening global change cannot be overwritten. Older daemons without the inventory field use a read-only catalog solely for global metadata, never for session overrides or mutations. The daemon owns dependency and compaction validation. New sessions use global defaults; existing sessions apply them on reload. Settings cannot close during a mutation. `test/manual/ux/extensions_check.py` exercises global-only controls, cancellation, stale writes and dependency refusal through a private daemon with no sessions. +The **extensions** tab is the same `views/ExtensionsView.svelte` the chat's extensions window shows (above), opened without a session, so by default it is global-only. A session dropdown under the search (`ExtensionsView`'s `below` snippet, passed only by settings, never by the chat window; `none` by default) picks a session, which gives the view that `sessionId` and with it the "this session" column, own-choice tints, follow-all-sessions and the reload; changing the pick reads the choices again and keeps the search and folds, and is disabled while a save runs. With none picked: the shelves, folding, search, memory radios and detail panel are shared, the "this session" column, own-choice tints, follow-all-sessions and the reload are not rendered, and a change is confirmed, then saved to the `extensions` settings group at its observed ETag (a stale write refreshes without retrying; the daemon still refuses a toggle another extension needs, and its reason shows above the list). The view takes an optional `sessionId`; without one `extensionChoices` builds its rows from the global inventory instead of a session catalog. `GET /server?include=extensions` returns the installed global inventory, including disabled extensions, without creating or preparing any session; `http_catalog.global_extensions` encodes the runtime-owned facts. The inventory carries no shelf, summary or tools, so the view borrows that metadata (read-only; it describes the extension, not the session) from the first session's catalog; with no session every row sits on the builtins shelf. Read the validator before the inventory so an intervening global change cannot be overwritten. Older daemons without the inventory field use a read-only catalog solely for global metadata, never for session overrides or mutations. New sessions use global defaults; existing sessions apply them on reload. Settings cannot close during a save (`onbusy`). While this tab is open the section fills the window and the list scrolls inside it, so its shelf headings can stick. `test/manual/ux/extensions_check.py` exercises global-only controls, stale writes and dependency refusal through a private daemon with no sessions. The chat view (`chat/`) reads `GET /sessions/{id}/history` (newest page, then `before=` as the reader scrolls up, and `after=` when the stream says something committed) and sends with `PUT /sessions/{id}/inputs/{uuidv7}`; a page's references are read in one walk of `history/content?entries=` (`hydrateAll`), and the work groups that come into view together expand through one such read. Blocks equal to the ones already drawn keep their objects (`Transcript.#keep`), so a page or a streamed delta redraws only rows that changed, and rows off screen skip layout and paint (`content-visibility: auto`); while the session works, a stop button beside send (or Escape in an empty field) reads the session's `run_id` and `input_order` fresh and posts `/sessions/{id}/interrupt`, so a stop never reaches a later run, `{kind: "message", text}`; images attach by paste, drop or the composer's picture button (`chat/attachments.ts`, the terminal client's scheme: each image leaves an `[Image #n]` marker at the cursor, deleting the marker drops the image, sending renumbers the marked images 1..n in reading order and sends them base64 as `images`, at most 10); a user entry's images show above its bubble from their history references (`/api/sessions/{id}/history/{entry}/image-n`). a send stays on screen as pending until its `input_id` appears in history, and a failed one offers retry with the same id. A turn that failed ends in a quiet row under it, the error's own words (the provider's message out of its JSON body; a click shows all of it): the stream's `error` event says so as it happens, and a chat opened later reads the session's request records since its oldest loaded entry (`context?view=requests`, again whenever the session rests, and for each earlier page it reads), a turn whose last model call failed (`Transcript.failures`); a later call that succeeded clears only a failure a call reported, never one the stream did. There is no retry for a failed turn yet; the daemon has none to call. A stop cancels the messages still queued behind the turn (the daemon never commits them); the interrupt answer's `cancelled_input_ids` name them, and the chat takes those pending bubbles back out of the transcript and appends their text and images to the composer's draft (`Draft.restore`: blank-line separated, in send order, images renumbered after the draft's, focus untouched), so a stop loses no words. Your newest message carries a receipt until a reply follows it, drawn as Signal's (`chat/Receipt.svelte`): a dashed ring while sending, a ring with a check once the daemon has accepted it (sent), two filled ones once its entry is in history (seen), which the daemon commits in the same transaction that takes it into the conversation, so the model has it (a message sent while albedo works stays `sent` until the loop takes it at its next step). Until it is seen the bubble stays faded. A waiting input is not listed anywhere, so after a reload it shows nothing until it commits. `transcript.svelte.ts` turns entries into blocks: user bubbles, assistant markdown, and each run of thinking and tool calls between messages folded into one "Worked" line (open while it is the live run or a thought inside it is expanded). Referenced message text is fetched with the page; tool arguments and output only when their run is opened. Markdown is rendered by `marked` with raw HTML escaped and only http(s)/mailto links (`markdown.ts`), because transcripts carry model and tool text into a page that can reach the daemon. The session list (`sessions.svelte.ts`) follows the collection's stream (`GET /sessions?scope=roots` as server-sent events, `followSessions` in `stream.ts`): each `activity` event patches that session's status and activity in place, so the sidebar, window titles and faces change as the daemon does, and `reset`, `overflow` or `invalidate` reads the list again (once for a burst). While that stream is up the list is also read once a minute in case; while it is down, every 4 s. Both stop while the tab is hidden. Each user message shows its timestamp under the bubble (with the receipt on the newest), and a turn's sign-off row shows its timestamp right before its actions, trace and copy as icons, which appear while the pointer is anywhere over the turn's reply or on the row itself (found from the page when the pointer moves, `hover` in `Chat.svelte`), or always on a screen with no hover. What is typed in a composer is a draft kept by session (`chat/drafts.ts`), outside the composer, which goes with its window when another board is shown, so the draft is there when the board comes back. The text is also written to localStorage (`albedo.draft.v1:`) once typing pauses for 300 ms, and on `pagehide`, so a reload keeps it; sending or emptying the field removes it, and one untouched for 30 days is dropped at the next load. The images it marks are not kept (they are too big for storage), so a reload drops them and their `[Image #n]` markers; switching boards keeps them. diff --git a/test/manual/ux/extensions_check.py b/test/manual/ux/extensions_check.py index 3a8d4e71c..20b0430c1 100644 --- a/test/manual/ux/extensions_check.py +++ b/test/manual/ux/extensions_check.py @@ -1,7 +1,7 @@ """Opt-in global Extensions UI checks against a disposable kit daemon. Run after settings_check has installed its no-credential settings-test profile. -The HTTP suite cannot catch accidental session controls or dependency-thread structure. +The HTTP suite cannot catch accidental session controls in the global view. """ from __future__ import annotations @@ -45,40 +45,28 @@ async def check(ui: kit.Review) -> None: original = await api("GET", "/settings?group=extensions") await ui.key(",", kit.CTRL) await click("extensions") - await node("button", "Disable skills globally") + await node("switch", "skills for all sessions") assert not await ui.js( - "!!document.querySelector('[aria-label=\"Extension selection\"] select')" + "!!document.querySelector('[aria-label=\"Extension selection\"] .segments')" ) assert not await ui.js( - "!!document.querySelector('[aria-label=\"Extension selection\"] details')" + "[...document.querySelectorAll('[aria-label=\"Extension selection\"] .column')].some(el => el.textContent.includes('this session'))" ) assert await api("GET", "/sessions?scope=roots&limit=200") == before - assert await ui.js("""() => { - const rows = [...document.querySelectorAll('.threads article')]; - const ids = rows.map(row => row.getAttribute('aria-label')); - const skills = rows.find(row => row.getAttribute('aria-label') === 'Extension skills'); - const parent = skills.closest('li').parentElement.closest('li')?.querySelector(':scope > article'); - return new Set(ids).size === ids.length && parent?.getAttribute('aria-label') === 'Extension python'; - }""") - print( - "PASS global inventory loads once per extension with dependency thread ancestry, without sessions" - ) + print("PASS global inventory loads without session columns or sessions") view = await ui.js( "document.querySelector('.svelte-flow__viewport').style.transform" ) wheel = await ui.js("""() => { - const content = document.querySelector('.settings .content'); - content.scrollTop = 0; - const r = content.getBoundingClientRect(); + const list = document.querySelector('.extensions .scroll'); + list.scrollTop = 0; + const r = list.getBoundingClientRect(); return [r.x + r.width / 2, r.y + r.height / 2]; }""") - await ui.wheel(wheel[0], wheel[1], 0, -180) - await ui.js("document.querySelector('.settings .content').scrollTop = 100") - await ui.wheel(wheel[0], wheel[1], 2, 180) - await node("button", "Disable skills globally") - assert await ui.js("document.querySelector('.settings .content').scrollTop") > 100 + await ui.wheel(wheel[0], wheel[1], 0, 180) + assert await ui.js("document.querySelector('.extensions .scroll').scrollTop") > 0 await ui.js( - "const c = document.querySelector('.settings .content'); c.scrollTop = c.scrollHeight" + "const c = document.querySelector('.extensions .scroll'); c.scrollTop = c.scrollHeight" ) await ui.wheel(wheel[0], wheel[1], 0, 180) assert ( @@ -93,16 +81,20 @@ async def check(ui: kit.Review) -> None: await ui.js("document.activeElement.blur()") await ui.key("0", kit.SHIFT) print( - "PASS settings scrolls without panning the canvas, including at edges; pinch still zooms" + "PASS the list scrolls without panning the canvas, including at edges; pinch still zooms" ) - await ui.page.fill(await node("searchbox", "Filter extensions"), "skills") - try: - await click("Disable skills globally") - await node("button", "Enable skills globally") - assert not await ui.js( - "[...document.querySelectorAll('button')].some(b => b.textContent.includes('Confirm'))" + async def feedback(text: str) -> bool: + return await ui.js( + "(text) => [...document.querySelectorAll('.extensions .feedback p')].some(el => el.textContent.includes(text))", + text, ) + + await ui.page.fill(await node("searchbox", "search extensions"), "skills") + try: + await click("skills for all sessions") + await click("confirm") + await node("switch", "skills for all sessions") assert (await api("GET", "/settings?group=extensions"))["defaults"][ "skills" ] is False @@ -110,21 +102,21 @@ async def check(ui: kit.Review) -> None: print("PASS toggles change only global defaults") await api("PATCH", "/settings?group=extensions", {"defaults": {"skills": True}}) - await click("Enable skills globally") - await node("button", "Disable skills globally") - assert await ui.js( - "[...document.querySelectorAll('[role=alert]')].some(el => el.textContent.includes('choices changed elsewhere'))" - ) + await click("skills for all sessions") + await click("confirm") + await node("switch", "skills for all sessions") + assert await feedback("configuration changed") assert (await api("GET", "/settings?group=extensions"))["defaults"][ "skills" ] is True print("PASS stale writes refresh rather than overwrite global choices") - await ui.page.fill(await node("searchbox", "Filter extensions"), "python") - await click("Disable python globally") - await node("alert", "") + await ui.page.fill(await node("searchbox", "search extensions"), "python") + await click("python for all sessions") + await click("confirm") + await node("switch", "python for all sessions") assert await ui.js( - "[...document.querySelectorAll('[role=alert]')].some(el => /requir|depend/i.test(el.textContent))" + "[...document.querySelectorAll('.extensions .error')].some(el => /requir|depend/i.test(el.textContent))" ) assert ( "python" not in (await api("GET", "/settings?group=extensions"))["defaults"] diff --git a/web/scripts/extension-tree.test.mjs b/web/scripts/extension-tree.test.mjs deleted file mode 100644 index 43bb8c95a..000000000 --- a/web/scripts/extension-tree.test.mjs +++ /dev/null @@ -1,48 +0,0 @@ -// Browser-only thread layout: the daemon cannot see duplicate rows or filtered -// ancestor context. Cyclic/multi-parent graphs cannot be installed via its API. -import assert from 'node:assert/strict'; -import { readFile } from 'node:fs/promises'; -import { stripTypeScriptTypes } from 'node:module'; -import test from 'node:test'; -const source = stripTypeScriptTypes(await readFile(new URL('../src/lib/settings/extension-tree.ts', import.meta.url), 'utf8')); -const { extensionTree } = await import(`data:text/javascript;base64,${Buffer.from(source).toString('base64')}`); -const item = (id, requires = []) => ({ id, requires, description: id, enabled: true, quarantined: false, diagnostic: null }); -const flatten = (branches) => branches.flatMap(branch => [branch, ...flatten(branch.children)]); - -test('shared dependencies retain every edge but render only one toggle per extension', () => { - const input = [item('a'), item('b'), item('c', ['a', 'b']), item('d', ['c'])]; - const tree = extensionTree(input, ''); - const rows = flatten(tree.roots); - assert.equal(rows.length, input.length); - assert.equal(new Set(rows.map(row => row.item.id)).size, input.length); - const edges = []; - for (const row of rows) { - edges.push(...row.children.map(child => `${child.item.id}:${row.item.id}`)); - edges.push(...row.additional.map(parent => `${row.item.id}:${parent}`)); - } - assert.deepEqual(edges.sort(), ['c:a', 'c:b', 'd:c']); -}); - -test('a requirement that needs another nests a level deeper instead of becoming a note', () => { - // The daemon's own shape: files needs python and run, and run needs python. - const input = [item('python'), item('files', ['python', 'run']), item('run', ['python']), item('view', ['python', 'run', 'files'])]; - const tree = extensionTree(input, ''); - const path = (branches, prefix = []) => branches.flatMap(branch => [[...prefix, branch.item.id].join('/'), ...path(branch.children, [...prefix, branch.item.id])]); - assert.deepEqual(path(tree.roots), ['python', 'python/run', 'python/run/files', 'python/run/files/view']); - assert(flatten(tree.roots).every(row => row.additional.length === 0)); -}); - -test('filtering a leaf keeps its ancestor chain and removes unrelated roots', () => { - const tree = extensionTree([item('a'), item('b', ['a']), item('leaf', ['b']), item('other')], 'leaf'); - assert.equal(tree.matches, 1); - assert.deepEqual(flatten(tree.roots).map(row => row.item.id), ['a', 'b', 'leaf']); - assert.deepEqual(flatten(tree.roots).map(row => row.context), [true, true, false]); -}); - -test('cyclic, self-referential and missing requirements never hide or duplicate rows', () => { - const input = [item('a', ['b']), item('b', ['a']), item('self', ['self']), item('missing', ['absent'])]; - const rows = flatten(extensionTree(input, '').roots); - assert.deepEqual(rows.map(row => row.item.id).sort(), input.map(row => row.id).sort()); - assert(rows.find(row => row.item.id === 'self').additional.includes('self')); - assert(rows.find(row => row.item.id === 'missing').additional.includes('absent')); -}); diff --git a/web/src/lib/Settings.svelte b/web/src/lib/Settings.svelte index 7dab29284..2b706ec52 100644 --- a/web/src/lib/Settings.svelte +++ b/web/src/lib/Settings.svelte @@ -3,7 +3,8 @@ import ProvidersSettings from './settings/ProvidersSettings.svelte'; import ConfigurationSettings from './settings/ConfigurationSettings.svelte'; import McpServers from './McpServers.svelte'; - import ExtensionsSettings from './settings/ExtensionsSettings.svelte'; + import ExtensionsView from './views/ExtensionsView.svelte'; + import { sessions } from './sessions.svelte'; import WebSearchSettings from './settings/WebSearchSettings.svelte'; import WebhooksSettings from './settings/WebhooksSettings.svelte'; import DiscordSettings from './settings/DiscordSettings.svelte'; @@ -27,6 +28,9 @@ let content = $state(); let configurationSaving = $state(false); let extensionsSaving = $state(false); + /** The session whose own extension choices the extensions tab shows too; none shows the global defaults alone. */ + let extensionsSession = $state(''); + const pickedSession = $derived(sessions.byId.has(extensionsSession) ? extensionsSession : undefined); const saving = $derived(configurationSaving || extensionsSaving); let configurationDirty = $state(false); let confirming = $state(false); @@ -68,6 +72,16 @@ } +{#snippet sessionPicker()} + +{/snippet} +
@@ -86,7 +100,7 @@ {/each} -
+
{current.scope}

{current.label}

@@ -105,7 +119,9 @@ {/if} {#if visited.includes('extensions')} - + {/if} {#if visited.includes('providers')}